﻿
var blnDebugMode = true;
var blnSavedData = false;
var EMPTY_VAULE = "";
var NULL_VALUE = -1;
var DEFAULT_PARAM_CMD = -1;
var SUB_MENU = "SubMenu";
var FRM_APP = "FrmApp";
var MENU = "Menu"



function OpenHomepageFiles()
{
	window.open("images/Invitation.pdf")
}

function OpenWindow(strURL){
	
	window.open(strURL);
}

function CommitSearching(){
	
	if ((document.all.search.value != "") && (document.all.search.value != "חפש")){
		
		strLocation = VIRTUAL_DIRECTORY + "General/frmSearchResults.asp?strValue="+document.all.search.value
		self.location = VIRTUAL_DIRECTORY + "General/InternalPageFullScreen.asp?strLocation="+strLocation
																			+"&strValue="+document.all.search.value
																			+"&LanguageSiteID=1";	
		
	}else{
		
		var strError = "עליך להזין ערך לחיפוש";
		OpenMessageWindow(VIRTUAL_DIRECTORY + "Main/confirmWin.asp",strError,0,355,120); 
		document.all.search.focus();
	}	
}


function SetImage(MagazinImage){
	
	if (MagazinImage != ""){
		top.window.document.all.divImage.style.display = "block"; 
		top.window.document.all.txtPicture.src = MAGAZINE_IMAGES_PATH + MagazinImage
	}else{
		top.window.divImage.style.display = "none"; 
	}	
	
}

/*******************************************************
 porpuse: reset the document fields
 inputs : 
 return:  
 comments:
*******************************************************/
function ResetFields(){
	for(ItemIndex = 0; ItemIndex < document.all.length; ItemIndex++){				
		
		if ((document.all(ItemIndex).tagName.toLowerCase() == "input") && (document.all(ItemIndex).type.toLowerCase() != "button") && (document.all(ItemIndex).type.toLowerCase() != "hidden")) {
			//if (!document.all(ItemIndex).disabled){
				if (document.all(ItemIndex).type.toLowerCase() != "checkbox" )		
					document.all(ItemIndex).value = "" ;
				else	
					document.all(ItemIndex).checked = false ;
			//}	
		}else if (document.all(ItemIndex).tagName.toLowerCase() == "select") {
				document.all(ItemIndex).value = '' ;
		}else if (document.all(ItemIndex).tagName.toLowerCase() == "textarea") {
				document.all(ItemIndex).value = '' ;
		}
				
	}
}

/*********************************************************************************************
 porpuse: reset the fields and change the document to the AddNew mode in the details window
 inputs :
 return:
 comments:
**********************************************************************************************/
function AddNewInDetailsWindow(){
	confirm = true;
	if (document.body.innerHTML != strBodyBuffer){ // if the changes have been saved
		
		var confirm = window.showModalDialog(VIRTUAL_DIRECTORY +"Main/confirmWin.asp?str="+NotSaveData+"&blnOkCancel=1",null,"dialogWidth:380px;dialogHeight:120px;center=yes;status=0;help=0");
	}	
	
	if (confirm){
		
		ResetFields()
		Action = "AddNew";
	
		// save the current body innerHTML
		strBodyBuffer = document.body.innerHTML
	
	}	
}

/***********************************************
 porpuse: perform the main action when the enter key pressed
 inputs :
 return:
 comments:
***********************************************/
function OnEnterKeyPress(FunctionName) {
	
   if (window.event.keyCode == 13){
	   if (document.activeElement.type){
			if (document.activeElement.type.toLowerCase() != "button"){
				window.event.returnValue = false 
				 eval(FunctionName + "()");
			}	
	   }else{
		    eval(FunctionName + "()");
	   }	
						    						
   }   
}
/**************************************************************
 porpuse: get the login user id
 inputs : 
 return:  
 comments:
***************************************************************/
function GetUserID(){
	
	var UserID = top.frames["Menu"].document.all.txtUserID.value;
	return UserID;
	
}
/**************************************************************
 porpuse: get the login user group id
 inputs : 
 return:  
 comments:
***************************************************************/
function GetUserGroupID(){
	
	var UserGroupID = top.frames["Menu"].document.all.txtUserGroupID.value;
	return UserGroupID;
	
}
/*******************************************************************************
porpuse: closing the modal details window and check if the data have been saved
inputs : 
return:  
comments: 
*******************************************************************************/
function CloseDetailsWindow(){	
	var confirm = true
	
	if (document.body.innerHTML != strBodyBuffer){ // if the changes have been saved
		
		var confirm = window.showModalDialog(VIRTUAL_DIRECTORY + "Main/confirmWin.asp?str="+NotSaveData+"&blnOkCancel=1",null,"dialogWidth:380px;dialogHeight:120px;center=yes;status=0;help=0");
	}	
	
	
	if (confirm){
		if ((strDefaultBodyBuffer != strBodyBuffer) || (IsChange)){ // if we made changes
			window.returnValue = true;
		}else{
			window.returnValue = false;
		}
	
		top.window.close()				
	}
}
/******************************************************
porpuse: closing the modal window
inputs : 
return:  
comments: 
******************************************************/
function CloseWindow(){	
	
	top.window.close()	
}
/******************************************************
porpuse: xml error message
inputs : 
return:  
comments: 
******************************************************/
function ErrorHandlingRaise(ErrorVal){

	//alert(" :התרחשה שגיאה \n" + ErrorVal)
	var strError = " :התרחשה שגיאה \n" + ErrorVal
	OpenMessageWindow(VIRTUAL_DIRECTORY + "Main/confirmWin.asp",strError,0,325,120)
}
/******************************************************
porpuse: cancel the last changes in the form
inputs : 
return:  
comments: 
******************************************************/
function Undo() {
	
	document.body.innerHTML = strBodyBuffer;
	
	
}

