var t_user_name_rewiev_cleared_flag = 0;
var p_psw_rewiev_cleared_flag 			= 0;
var t_user_name_grant_cleared_flag 	= 0;
var p_psw_grant_cleared_flag 				= 0;

function CatchEnter(ActionToDo,e)
	{
		var keyCode = (e.keyCode) ? e.keyCode : e.which; // match the keyCode in IE to which in mozilla
		if ((keyCode==13)&&(ActionToDo=='Review'))
		{FormWindowReview()}
		if ((keyCode==13)&&(ActionToDo=='Grant'))
		{FormWindowGrant()}
		if ((keyCode==13)&&(ActionToDo=='FinancialReport'))
		{FormWindowFinancialReport()}
	}

function OpeningFormWindow()
	{
	/*
		//Set variables, version is IE version number
		var ua = window.navigator.appVersion;
		var msie = ua.indexOf ( "MSIE " );
		var version = ua.substring(msie+5,msie+6);
			
		//if ((msie>0)&&(version >= "7")) //client is using IE and IE if 7 ar higher
		//	{alert("You are using Internet Explorer version 7. In order to use the ISF online system you must do the following:\n    1.       add the www.isf.org.il to the trusted sites list\n    2.       allow pop ups on www.isf.org.il\nPlease see the user guide for instructions\n(to be downloaded from – Applications --> Guidelines and forms\nThis message will continue to appear after performing the above, but it will not prevent any action, please ignore it.")}
		
		var page 	= RelativePath + 'Agreement.html';
		if(awindow) awindow.close();
		var awindow = window.open(page, 'AgreementWindow', 'width=600, height=350, status=0, resizable=0, scrollbars=0,toolbar=0,menubar=0,location=0');
		var Swidth	=	screen.width;
		var Sheight	=	screen.height;
		Sheight			=	Sheight-100;
		SMwidth			=	Swidth/2;
		SMheight		=	Sheight/2;
		MTwidth			=	SMwidth-(600/2)
		MTheight		=	SMheight-(400/2)
		awindow.moveTo(MTwidth,MTheight);
		awindow.focus();
	*/	
	
		if(typeof alertLanguage!="undefined")
			{
				if (alertLanguage=='Heb')
					alert("הקרן משדרגת את מערכות המידע שלה ולכן לא ניתן לגשת אליהן\nהמערכות יפתחו מחדש בספטמבר 2010\nאנו מתנצלים על אי הנוחות הזמנית  צוות הקרן")
				else
					alert("The ISF online system is now close. It will be reopen for new submissions on September 2010.")
			}
			else
					alert("The ISF online system is now close. It will be reopen for new submissions on September 2010.")
	
	}
	
function FormWindowReview()
	{
		//if ((document.getElementById('MainForm').t_user_name_review.value.length==0)||(document.getElementById('MainForm').p_psw_review.value.length==0))
		//	{	
		//		if (alertLanguage=='Heb')
		//			alert('.יש להזין מספר משתמש וסיסמא וללחוץ שוב על כפתור זה. תודה')
		//		else
		//			alert('Please fill in user ID and password and click this button again. Thank you.')	
		//	}
		//else
		//	{	
	  //  	document.getElementById('MainForm').action='http://192.168.10.133/IsfForms/Reviewers/ReviewerGrantsList.aspx';
		//		document.getElementById('MainForm').UserName.value = document.getElementById('MainForm').t_user_name_review.value;
		//		document.getElementById('MainForm').Psw.value = document.getElementById('MainForm').p_psw_review.value;			
				/*if ((!isNumObj(document.forms[0].UserName,''))||(!isNumObj(document.forms[0].Psw,'')))
				{
					if (alertLanguage=='Heb')
						alert('.הוזן תו לא חוקי לשם משתמש או סיסמה')
					else
						alert('An illegal character was filled in.  Please try again or contact us for assistance.  Thank you.')
				}
				else
				{*/
		//			var Sheight	=	screen.height;
		//			var Swidth	=	screen.width;
		//			var page		=	'';
		//			if(awindow) awindow.close();
		//			var awindow = window.open(page, 'FormWindowReview', 'width=800, height=' + eval(Sheight-110) + ', status=0, resizable=1, scrollbars=1,toolbar=1,menubar=0,location=0');
		//			document.getElementById('MainForm').target='FormWindowReview';
		//			document.getElementById('MainForm').submit();
		//			SMwidth			=	Swidth/2;
		//			SMheight		=	Sheight/2;
		//			MTwidth			=	SMwidth-(700/2)
		//			MTheight		=	SMheight-(eval(Sheight-30)/2)
		//			awindow.moveTo(MTwidth,MTheight);
		//			awindow.focus();
		//			document.getElementById('MainForm').target='_self';
				//}			
		//	}
					
				
		if(typeof alertLanguage!="undefined")
			{
				if (alertLanguage=='Heb')
					alert("webmaster@isf.org.il :המערכת המקוונת סגורה כעת. נשמח לקבל את חוות דעתך בדואר אלקטרוני אל")
				else
					alert("The ISFonline evaluation system is now close. Please send your review via email to: webmaster@isf.org.il")
			}
			else
					alert("The ISFonline evaluation system is now close. Please send your review via email to: webmaster@isf.org.il")
	}	

function FormWindowGrant()
	{
		/*
		if ((document.getElementById('MainForm').t_user_name_grant.value.length==0)||(document.getElementById('MainForm').p_psw_grant.value.length==0))
			{	
				if (alertLanguage=='Heb')
					alert('.יש להזין מספר משתמש וסיסמא וללחוץ שוב על כפתור זה. תודה')
				else
					alert('Please fill in user ID and password and click this button again. Thank you.')	
			}
		else
			{	
			  document.getElementById('MainForm').action='http://192.168.10.133/IsfForms/ActionForms/OpenGrant.aspx';
				document.getElementById('MainForm').UserName.value = document.getElementById('MainForm').t_user_name_grant.value;
				document.getElementById('MainForm').Psw.value = document.getElementById('MainForm').p_psw_grant.value;
				if (!isNumObj(document.forms[0].UserName,'שם משתמש'))
					{
						if (alertLanguage=='Heb')
							alert('.הוזן תו לא חוקי לשם משתמש')
						else
							alert('An illegal character was filled in.  Please try again or contact us for assistance.  Thank you.')	
					}
				else
				{								
					var Sheight	=	screen.height;
					var Swidth	=	screen.width;
					var page		=	'';
					if(awindow) awindow.close();
					var awindow = window.open(page, 'FormWindow2', 'width=880, height=' + eval(Sheight-100) + ', status=0, resizable=1, scrollbars=1,toolbar=0,menubar=0,location=0');
					document.getElementById('MainForm').target='FormWindow2';
					document.getElementById('MainForm').submit();
					SMwidth			=	Swidth/2;
					SMheight		=	Sheight/2;
					MTwidth			=	SMwidth-(850/2)
					MTheight		=	SMheight-(eval(Sheight-50)/2)
					awindow.moveTo(MTwidth,MTheight);
					awindow.focus();
					document.getElementById('MainForm').target='_self';
				}
			}
			*/
			
			if(typeof alertLanguage!="undefined")
				{
					if (alertLanguage=='Heb')
						alert("הקרן משדרגת את מערכות המידע שלה ולכן לא ניתן לגשת אליהן\nהמערכות יפתחו מחדש בספטמבר 2010\nאנו מתנצלים על אי הנוחות הזמנית  צוות הקרן")
					else
						alert("The ISF online system is now close. It will be reopen for new submissions on September 2010.")
				}
			else
					alert("The ISF online system is now close. It will be reopen for new submissions on September 2010.")
						
	}		

function FormWindowFinancialReport()
{
	/*if ((document.getElementById('MainForm').t_user_name_financial_report.value.length==0)||(document.getElementById('MainForm').p_psw_financial_report.value.length==0))
		{	
			if (alertLanguage=='Heb')
				alert('.יש להזין מספר משתמש וסיסמא וללחוץ שוב על כפתור זה. תודה')
			else
				alert('Please fill in user ID and password and click this button again. Thank you.')	
		}
	else
		{	
			document.getElementById('MainForm').UserName.value = document.getElementById('MainForm').t_user_name_financial_report.value;
			document.getElementById('MainForm').Psw.value = document.getElementById('MainForm').p_psw_financial_report.value;			
			if (!isNumObj(document.forms[0].UserName,''))
			{
				if (alertLanguage=='Heb')
					alert('.הוזן תו לא חוקי לשם משתמש')
				else
					alert('An illegal character was filled in.  Please try again or contact us for assistance.  Thank you.')
			}
			else
			{document.getElementById('MainForm').submit();}			
		}*/
		
		
		if(typeof alertLanguage!="undefined")
				{
					if (alertLanguage=='Heb')
						alert("הקרן משדרגת את מערכות המידע שלה ולכן לא ניתן לגשת אליהן\nהמערכות יפתחו מחדש בספטמבר 2010\nאנו מתנצלים על אי הנוחות הזמנית  צוות הקרן")
					else
						alert("The ISF online system is now close. It will be reopen for new submissions on September 2010.")
				}
			else
					alert("The ISF online system is now close. It will be reopen for new submissions on September 2010.")
						
}

function popUpNews(id)
{	
	if(awindow) awindow.close();
	var awindow = window.open('news_in.asp?message_id='+id, 'news', 'width=600, height=400, status=no, resizable=1, scrollbars=1,toolbar=0,menubar=0,location=0');
	var Swidth=screen.width;
	var Sheight=screen.height;
	SMwidth		=	Swidth/2;
	SMheight	=	Sheight/2;
	MTwidth		=	SMwidth-(600/2)
	MTheight	=	SMheight-(400/2)
	awindow.moveTo(MTwidth,MTheight);
	awindow.focus();
}

function PassAlert()
{
	//if(awindow) awindow.close();
	var awindow = window.open('asp/psw/psw_alert.asp', 'PswAlert', 'width=400, height=250, status=no, resizable=1, scrollbars=1,toolbar=0,menubar=0,location=0');
	var Swidth	=	screen.width;
	var Sheight	=	screen.height;
	SMwidth			=	Swidth/2;
	SMheight		=	Sheight/2;
	MTwidth			=	SMwidth-(400/2)
	MTheight		=	SMheight-(250/2)
	awindow.moveTo(MTwidth,MTheight);
	awindow.focus();
}

function PassChange()
{
	if(awindow) awindow.close();
	var awindow = window.open('asp/psw/psw_change.asp', 'PswChange', 'width=400, height=400, status=no, resizable=1, scrollbars=1,toolbar=0,menubar=0,location=0');
	var Swidth	=	screen.width;
	var Sheight	=	screen.height;
	SMwidth			=	Swidth/2;
	SMheight		=	Sheight/2;
	MTwidth			=	SMwidth-(400/2)
	MTheight		=	SMheight-(400/2)
	awindow.moveTo(MTwidth,MTheight);
	awindow.focus();
}

function ForgotPassword(subSubject)
{	
	if(awindow) awindow.close();
	var awindow = window.open('ForgotPassword.asp?subSubject=' + subSubject, 'ForgotPassword', 'width=670, height=400, status=no, resizable=0, scrollbars=1,toolbar=0,menubar=0,location=0');
	var Swidth	=	screen.width;
	var Sheight	=	screen.height;
	SMwidth			=	Swidth/2;
	SMheight		=	Sheight/2;
	MTwidth			=	SMwidth-(670/2)
	MTheight		=	SMheight-(400/2)
	awindow.moveTo(MTwidth,MTheight);
	awindow.focus();
}

function FinancialReport()
{
	var Sheight=screen.height;
	var Swidth=screen.width;
	var page= RelativePath + 'asp/FinancialReports/psw/psw_form.asp';
	if(awindow) awindow.close();
	var awindow = window.open(page, 'FinancialReport', 'width=350, height=300, status=0, resizable=0, scrollbars=0,toolbar=0,menubar=0,location=0');
	SMwidth		=	Swidth/2;
	SMheight	=	Sheight/2;
	MTwidth		=	SMwidth-(350/2)
	MTheight	=	SMheight-(300/2)
	awindow.moveTo(MTwidth,MTheight);
	awindow.focus();
}	

function isNum(passedVal)
{
	var strValidChars = "0123456789.-";
	var strChar;
	
	if (passedVal.length == 0) return false;
	
	//  test strString consists of valid characters listed above
	for (i = 0; i < passedVal.length; i++)
	   {
	   	strChar = passedVal.charAt(i);
	   	if (strValidChars.indexOf(strChar) == -1)
	      {return false;}
			if ((strChar=="-")&&(i>0))
			 	{return false;}
	   }
	return true;
}

function isNumObj(tmpobj,txt)
{
	if(! isNum(tmpobj.value)) 
		{
			return false;
		}else{
			return true;}
}

function ClearMe(objToHide, objToShow)
{
	objToHide.style.display='none';
	objToShow.style.display='';
	objToShow.focus();
}

function swapImg(element,folder,name,action)
{
	if (action == 'over')
	{
		element.src =  folder + '/' + name + '_over.jpg'
	}else{
		element.src =  folder + '/' + name + '.jpg'
	}
}

var ShowHideGrantSearchFlag='';
function ShowHideGrantSearch(obj)
{
	if (obj.style.display=='')
		{
			obj.style.display='none';
			ShowHideGrantSearchFlag = 'hide';		
		}
	else
		{
			obj.style.display='';
			ShowHideGrantSearchFlag = 'show';
		}	
}

function PagingLink(page_name,NAV,sort_str,search_text_persons,search_text_title,grant_type,broad_field,general_field,year_num,menu_to_open)
{document.location.href = page_name+ '?NAV=' + NAV + '&sort_str=' + sort_str+ '&search_text_persons=' + search_text_persons+ '&search_text_title=' + search_text_title+ '&grant_type=' + grant_type+ '&broad_field=' + broad_field+ '&general_field=' + general_field+ '&year_num=' + year_num+ '&menu_to_open=' +  menu_to_open + '&ShowHideGrantSearchFlag=' + ShowHideGrantSearchFlag;}

