﻿function doSubmit()
{
form2.reset();
fName=document.form1.fnm.value;
if (fName=='')
	{ msg="נא למלא שם";
	  document.form1.fnm.value = msg;
	  window.setTimeout("document.form1.fnm.value='';document.form1.fnm.focus();",1500);
	  return;}
lName=document.form1.lnm.value;
if (lName=='')
	{ msg="נא למלא משפחה";
	  document.form1.lnm.value = msg;
	  window.setTimeout("document.form1.lnm.value='';document.form1.lnm.focus();",1500);
	  return;}
pw=document.form1.pw.value;
if (pw=='')
	{ document.form1.pw.dir= "rtl";
	  msg="נא למלא סיסמה";	  
	  document.form1.pw.value = msg;
	  window.setTimeout("document.form1.pw.value='';document.form1.pw.dir= 'ltr';document.form1.pw.focus();",1500);
	  return;}
address=document.form1.address.value;
if (address=='')
	{ msg="נא למלא כתובת";
	  document.form1.address.value = msg;
	  window.setTimeout("document.form1.address.value='';document.form1.address.focus();",1500);
	  return;}

Email=document.form1.eml.value;
if (Email=='')
	{ msg="נא למלא מייל";
	  document.form1.eml.dir= "rtl";
	  document.form1.eml.value = msg;
	  window.setTimeout("document.form1.eml.value='';document.form1.eml.dir='ltr';document.form1.eml.focus();",1500);
	  
	  return;}
if ((Email.indexOf("@")<2) || (Email.lastIndexOf(".")<=(Email.indexOf("@")+2) || ((Email.length<8)) || (Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "@" || Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "."))) 
	  	{msg="נא למלא מייל תקין";
		 document.form1.eml.dir= "rtl";
		 document.form1.eml.value = msg;
		 window.setTimeout("document.form1.eml.value='';document.form1.eml.dir='ltr';document.form1.eml.focus();",1500);
		
		 return;}	  	 
pn=document.form1.pn.value;
if (pn=='')
	{ msg="נא למלא טלפון";
	  document.form1.pn.dir= "rtl";
	  document.form1.pn.value = msg;
	  window.setTimeout("document.form1.pn.value='';document.form1.pn.dir='ltr';document.form1.pn.focus();",1500);
	  
	  return;}
dage=document.form1.dage.value;
mage=document.form1.mage.value;
yage=document.form1.yage.value;
if (ValidateDate(dage,mage,yage)==false)
	return;
/*if ((dage=='')||(dage=='dd'))&&((dage=='')||(dage=='dd'))&&((dage=='')||(dage=='dd')))
	{ msg="נא למלא ת. לידה";
	  document.form1.age.dir= "rtl";
	  document.form1.age.value = msg;
	  window.setTimeout("document.form1.age.value='';document.form1.age.dir='ltr';document.form1.age.focus();",1500);	  
	  return;}*/
form1.submit();
}
function showAge(msg1)
{document.form1.dage.className= "inputDH";
 document.form1.mage.className= "inputMH";
 document.form1.yage.className= "inputYH";
 document.form1.age.className = "inputA";
 document.form1.age.value = msg1;}
 function hideAge()
 {document.form1.age.value='';
  document.form1.age.className = "inputAH";
  document.form1.dage.className= "inputD";
  document.form1.mage.className= "inputM";
  document.form1.yage.className= "inputY";  
  //document.form1.dage.focus();
  }
  
function ValidateDate(day1, month1, year1) {
            var monthLength = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
            var x = document.forms[0].elements;
            var day = parseInt(day1);
            var month = parseInt(month1);
            var year = parseInt(year1);
            //trace("opa")
            if (!day || !month || !year) {
				msg="נא למלא תאריך לידה";
				showAge(msg);
				window.setTimeout("hideAge();",1500);	  
				return false;}

            if (year%4 == 0) {
               monthLength[1] = 29;}
			//alert(day+' '+month+' '+monthLength[month-1]);
			//alert(1);
            if (day>monthLength[month-1]) {
              	msg="נא למלא תאריך לידה תקין";
				showAge(msg);
				window.setTimeout("hideAge();",1500);	  
				return false;}
				monthLength[1] = 28;
	            now = new Date();
	            currentyear = now.getYear();+1900;
            //NN3
			//alert(currentyear);
			if (month>12) {
				msg="נא למלא תאריך לידה תקין";
				showAge(msg);
				window.setTimeout("hideAge();",1500);	  
				return false;}
			
            if (year>currentyear || year<1900) {
				msg="נא למלא תאריך לידה תקין";
				showAge(msg);
				window.setTimeout("hideAge();",1500);	  
				return false;}
			
            if (year == currentyear) {
               currentmonth = now.getMonth()+1;
               alert(currentmonth);
               if (currentmonth<month) {
	                msg="נא למלא תאריך לידה תקין";
					showAge(msg);
					window.setTimeout("hideAge();",1500);	  
					return false;} 
				else if (currentmonth == month) {
				alert(4);
                    currentday = now.getDate();
                    if (currentday<day) {
						msg="נא למלא תאריך לידה תקין";
						showAge(msg);
						window.setTimeout("hideAge();",1500);	  
						return false;
	                       }
                   }
            }
            return true;

}


function doSubmit1()
{
form2.reset();
Email=document.form1.eml1.value;
if (Email=='')
	{ msg="נא למלא מייל";
	  document.form1.eml1.dir= "rtl";
	  document.form1.eml1.value = msg;
	  window.setTimeout("document.form1.eml1.value='';document.form1.eml1.dir='ltr';document.form1.eml1.focus();",1500);
return;}
if ((Email.indexOf("@")<2) || (Email.lastIndexOf(".")<=(Email.indexOf("@")+2) || ((Email.length<8)) || (Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "@" || Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "."))) 
	  	{msg="נא למלא מייל תקין";
		 document.form1.eml1.dir= "rtl";
		 document.form1.eml1.value = msg;
		 window.setTimeout("document.form1.eml1.value='';document.form1.eml1.dir='ltr';document.form1.eml1.focus();",1500);
return;}
document.form2.eml1.value=document.form1.eml1.value;	  	 
pw=document.form1.pw1.value;
if (pw=='')
	{ document.form1.pw1.dir= "rtl";
	  msg="נא למלא סיסמה";	  
	  document.form1.pw1.value = msg;
	  window.setTimeout("document.form1.pw1.value='';document.form1.pw1.dir= 'ltr';document.form1.pw1.focus();",1500);
return;}
document.form2.pw1.value=document.form1.pw1.value;	  	 
form2.submit();
}
function doSubmit2()
{
form2.reset();
Email=document.form1.eml1.value;
if (Email=='')
	{ msg="נא למלא מייל";
	  document.form1.eml1.dir= "rtl";
	  document.form1.eml1.value = msg;
	  window.setTimeout("document.form1.eml1.value='';document.form1.eml1.dir='ltr';document.form1.eml1.focus();",1500);
return;}
if ((Email.indexOf("@")<2) || (Email.lastIndexOf(".")<=(Email.indexOf("@")+2) || ((Email.length<8)) || (Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "@" || Email.charAt(0) == "-" || Email.charAt(0) == "_" || Email.charAt(0) == "."))) 
	  	{msg="נא למלא מייל תקין";
		 document.form1.eml1.dir= "rtl";
		 document.form1.eml1.value = msg;
		 window.setTimeout("document.form1.eml1.value='';document.form1.eml1.dir='ltr';document.form1.eml1.focus();",1500);
return;}
document.form3.eml1.value=document.form1.eml1.value;	  	 
form3.submit();
}
function doChallengeSubmit()
{

FormKind=document.MyForm.FormKind.value;
if (FormKind=='1')
	{
	comment=document.MyForm.comment.value;
	if (comment=='')
	{ msg="נא למלא את שדה הטקסט";	
	  document.MyForm.comment.value = msg;
	  window.setTimeout("document.MyForm.comment.value='';document.MyForm.comment.focus();",1500);
	  return;}	 
	} 
else if (FormKind=='2')
	{
	IMGFileNameAfterStr=document.MyForm.IMGFileNameAfterStr.value;
	if(IMGFileNameAfterStr=='')
	{ msg="נא להעלות תמונה";	
	  document.MyForm.IMGFileNameAfterStr.value = msg;
	  window.setTimeout("document.MyForm.IMGFileNameAfterStr.value='';document.MyForm.IMGFileNameAfterStr.focus();",1500);
	  return;}
	  }
MyForm.submit();
}

function doAlert(m)
	{
	/*if (m=='0')
		{msg="הרשומה נקלטה בהצלחה";		
		 document.form1.fnm.value = msg;
		 window.setTimeout("document.form1.fnm.value='';document.form1.fnm.focus();",3800);}
	else if (m=='1')
		{msg="הרשומה לא נקלטה";
		 document.form1.fnm.value = msg;
		 window.setTimeout("document.form1.fnm.value='';document.form1.fnm.focus();",3800);}
	else if (m=='2')
		{msg="הרשומה קיימת";
		 document.form1.fnm1.value = msg;
		 window.setTimeout("document.form1.fnm1.value='';document.form1.fnm1.focus();",3800);}
	else */
	if (m=='3')
		{msg="הרשומה לא קיימת";
		document.form1.eml1.dir= "rtl";
		document.form1.eml1.value = msg;
		window.setTimeout("document.form1.eml1.value='';document.form1.eml1.dir='ltr';document.form1.eml1.focus();",3800);}
	else if (m=='4')
		{msg="מייל התזכורת נשלח אליך";
		document.form1.eml1.dir= "rtl";
		document.form1.eml1.value = msg;
		window.setTimeout("document.form1.eml1.value='';document.form1.eml1.dir='ltr';document.form1.eml1.focus();",3800);}
	else if (m=='5')
		{msg="מייל זה לא קיים";
		document.form1.eml1.dir= "rtl";
		document.form1.eml1.value = msg;
		window.setTimeout("document.form1.eml1.value='';document.form1.eml1.dir='ltr';document.form1.eml1.focus();",3800);}
	//form1.reset();
	//form2.reset();
	//location.href='list.asp';
			
	}
	
function showAlert(prm)
	{  if (prm=='err0')
		 { str ='הקובץ גדול מ-10 MB';
		   showAlert1();}
	   else if (prm=='err1')
		  {str ='שגיאה בהעלאת הקובץ ';
		   showAlert1();}
	   else if (prm=='err2')
		  {str =' הרשומה לא נקלטה';
		   showAlert1();}
	   else if (prm=='dbl')	
		  {document.getElementById("div3").className = "pop3";
		   document.getElementById("div3").style.display = "block";
		   MyForm.reset();}	   
	   else if (prm=='scss')	
		  {document.getElementById("div3").className = "pop1";
		   document.getElementById("div3").style.display = "block";
		   MyForm.reset();}
	} 
function showAlert1()
	{document.MyForm.IMGFileNameAfterStr.value = str;
	 window.setTimeout("document.MyForm.IMGFileNameAfterStr.value='';document.MyForm.IMGFileNameAfterStr.focus();",1500);}
function doAlert1(m)
	{if (m=='4')
		{msg="מייל וסיסמה זו כבר קיימים.";		 
		 document.form1.eml.dir= "rtl";
		 document.form1.eml.value = msg;		
		 window.setTimeout("document.form1.eml.value='';document.form1.eml.focus();",1500);}
	}	 
var myWindow;
function newWindow(winWidth,winHeight,imgName){
 if   (myWindow)
	  myWindow.close();
  myWindow=window.open(imgName,'mama','resizable=no,scrollbars=no,width='+winWidth+',height ='+winHeight+',left='+(screen.width/2-winWidth/2)+',top='+(screen.height/2-winHeight/2)+'');
  myWindow.focus();
}
function isHeb(e){	
	var strCheck = 'אבגדהוזחטיכלמנסעפצקרשתךףץםן- ';
	var whichCode = (window.Event) ? e.which : e.keyCode;		
	if (whichCode != 0){
		// return true;
		if (whichCode == 13)
			document.getElementById('divNames').style.display="none";
		key = String.fromCharCode(whichCode);
		if (strCheck.indexOf(key) == -1 ) return false;
		else return true;
	}
}

function isMail(e){	
	var strCheck = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.@';
	var whichCode = (window.Event) ? e.which : e.keyCode;		
	if (whichCode != 0){
		if (whichCode == 13) return true;
		key = String.fromCharCode(whichCode);
		if (strCheck.indexOf(key) == -1 ) return false;
		else return true;
	}
}
function isPhone(e){	
	var strCheck = '0123456789-';
	var whichCode = (window.Event) ? e.which : e.keyCode;	
	if (whichCode != 0){
		if (whichCode == 13) return true;
		key = String.fromCharCode(whichCode);
		if (strCheck.indexOf(key) >-1 ) return  true;
		else return false;
	}
}
function isAge(e){	
	var strCheck = '0123456789/';
	var whichCode = (window.Event) ? e.which : e.keyCode;	
	if (whichCode != 0){
		if (whichCode == 13) return true;
		key = String.fromCharCode(whichCode);
		if (strCheck.indexOf(key) >-1 ) return  true;
		else return false;
	}
}
function isPw(e){	
	var strCheck = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
	var whichCode = (window.Event) ? e.which : e.keyCode;	
	if (whichCode != 0){
		if (whichCode == 13) return true;
		key = String.fromCharCode(whichCode);
		if (strCheck.indexOf(key) >-1 ) return  true;
		else return false;
	}
}

function showDiv(prm)
{document.getElementById('div3').className='pop'+prm+'';
document.getElementById('div3').style.display='block';}