﻿function WinResize(x,y){
	try{
		top.resizeTo(x,y);
	}catch(e){}
}

/*****************************************************************
   						Registration Page
*****************************************************************/
function checkIfNumber(pEvent)
{
	if ((pEvent.keyCode < 48 || pEvent.keyCode > 57)  && (pEvent.keyCode!=45))
		pEvent.returnValue = false;
}
	
function ChkChars(str)
{
	var arr;
	arr="%^&*()][{};:'.,/?\|#$@!-" + String.fromCharCode(34);
	for (x=0;x<str.length;x++)
		for (y=0;y<arr.length;y++)
			if(arr.substring(y,y+1)==str.substring(x,x+1))
			{
				
				return true ;
			}
	return false;   
}
	
function validate()
{			
		try{
			if (isNaN(document.frmSendPassword.txtPhoneNumber.value))
	    	{
				document.all.sendForm.style.display='inline'
				document.all.WsendForm.style.display='none'
				alert("בשדה זה ניתן להזין ספרות בלבד")
		      	document.frmSendPassword.txtPhoneNumber.focus()
				
				return false;
			}
			
			
			/*
			if(String(document.frmSendPassword.txtPhoneNumber.value).length < 7)
			{
				alert("נא להזין 7 ספרות");
				document.frmSendPassword.txtPhoneNumber.focus();
				return false;
			}
			*/
			if (ChkChars(document.frmSendPassword.txtPhoneNumber.value))
			{
				alert("תו אינו חוקי. נא להזין ספרות בלבד");
				document.frmSendPassword.txtPhoneNumber.focus();
				return false;
			}
			else
			{	
				document.all.sendForm.style.display='none'
				document.all.WsendForm.style.display='inline'
				return true;
			}
		}catch(e){}	
}						

function IfEnter()
{

	if (event.keyCode==13)
		{
			if  (validate() == true )
				frmSendPassword.submit(); 
			
		}	
}
		
function checkanswer()
{
	if(document.frmSendPassword.txtPassword.value=="")
	{
		alert("SMS אנא הזן את הסיסמה הזמנית שהגיעה אליך ב");
		document.frmSendPassword.txtPassword.focus();
		return false
	}
	else
	{
		document.all.sendForm.style.display='none'
		document.all.WsendForm.style.display='inline'
		frmSendPassword.submit(); 
	}
}

function IfEnter2()
{
	if (event.keyCode==13)
		{
			
			if(checkanswer() == true)
				frmSendPassword.submit(); 
			
		}	
}
		
function contact()
{
opener.location.href='http://www.icellcom.co.il/contactUS/default.asp'
window.close()
}

function isWithSpaces(str) // returns string without spacing 
{
	if (str.indexOf(" ") != -1) 
		return true;
	else
		return false;
}
	
function IsHebrewChar(c){
	return (((c.charAt(0) >= "א") && (c.charAt(0) <= "ת")) || ((escape(c.charAt(0)) >= "%u05D0") && (escape(c.charAt(0)) <= "%u05EA")))
}

function isNotHebrew(field_value){
	for (i=0;i< field_value.length;i++){
		var c = field_value.charAt(i);
		if (IsHebrewChar(c)) {
			return true
		}
	}
	return false;
}
	
function check()
{
	try{
		UName=document.frmLogin.txtUserName.value;
		pass=document.frmLogin.txtPassword.value;
		if(pass=="")
		{
			alert("נא להזין סיסמה")
			document.frmLogin.txtPassword.focus();
			return false;
		}
		if(UName=="")
		{
			alert("נא להזין שם משתמש")
			document.frmLogin.txtUserName.focus();
			return false;
		}		
		else if (isWithSpaces(UName))
		{
			alert("נא להזין שדה זה ללא רווחים");
			document.frmLogin.txtUserName.focus();
			return false;
		}
		else if (isWithSpaces(pass))
		{
			alert("נא להזין שדה זה ללא רווחים");
			document.frmLogin.txtPassword.focus();
			return false;
		}
		else if (isNotHebrew(UName))
		{
			alert("לא ניתן להקליד שמות בעברית");
			document.frmLogin.txtUserName.focus();
			return false;
		}
		else if (isNotHebrew(pass))
		{
			alert("לא ניתן להקליד שמות בעברית");
			document.frmLogin.txtPassword.focus();
			return false;
		}
	}catch(e){}
}