	    // checks if date is mm/dd/yyyy
	    //after builds anew date with SS format : YYYY-MM-DD and puts it in hidden field
	    function ValidateDate(date)
	    {
		 	// check for format mm/dd/yyyy
            var filter  = /(0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])[-](19|20)\d\d/
		    
		    if (filter.test(date))
		    {
				var arr = date.split("-");
				var NewDate = arr[2] + "-" + arr[0]+ "-" + arr[1];
				document.getElementById("Birthdate").value = NewDate;
				return true;
		    }
		    else
		    { 
		       return false;
		    }
	    }
	    
	    function IsMailNotValid(emailName)
	    {
		    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		    if (!filter.test(emailName))
		    return true;
	    }
	    
	    //The validation functions 
	    function checkForm2(formRef)
	    {

		    if (formRef.First_Name__c.value.length<1){
			    alert("You must enter a first name");
			    formRef.First_Name__c.focus();
			    return false;
		    }
		    
		    
		    if (formRef.Last_Name__c.value.length<1){
			    alert("You must enter a last name");
			    formRef.Last_Name__c.focus();
			    return false;
		    }
			
	    	if (!ValidateDate(formRef.nsf_temp_Birthdate.value))
	    	{
			    alert("Please enter Birthdate in this format : MM-DD-YYYY");
			    formRef.nsf_temp_Birthdate.focus();
			    return false;
		    }
		    
			if (formRef.Birhtdate__c.value.length<1){
			    alert("You must pick a date.");
			    formRef.Birhtdate__c.focus();
			    return false;
		    }
			
			if(formRef.University_Currently_Attending__c.value.length<1){
				alert("You must enter the university where you are currently attending.");
			    formRef.University_Currently_Attending__c.focus();
			    return false;
		    }
			
		    if (formRef.Maimonides_Campus_wish_to_attend__c.selectedIndex==0)
		    {
			    alert("Please enter the Maimonides campus you wish to attend.");
			    formRef.Maimonides_Campus_wish_to_attend__c.focus();
			    return false;
		    }

		    if (formRef.Semester_for_Which_Applying__c.selectedIndex==0)
		    {
			    alert("Please enter the semester for which you are applying.");
			    formRef.Semester_for_Which_Applying__c.focus();
			    return false;
		    }
			
        	if (formRef.Cell_Phone__c.value.length<1){
			    alert("Please enter your Mobile Number.");
			    formRef.Cell_Phone__c.focus();
			    return false;
		    }

        	if (formRef.Email__c.value.length<1){
			    alert("Please enter your email address.");
			    formRef.Email__c.focus();
			    return false;
		    }

		    if (IsMailNotValid(formRef.Email__c.value) )
		    {
			    alert("The email you entered is not valid");
			    formRef.Email__c.focus();
			    return false;
		    }
			
			if (formRef.religion_born_into__c.value.length<1){
			    alert("Please enter the religion you were born into.");
			    formRef.religion_born_into__c.focus();
			    return false;
		    }
		
			if (formRef.Mother_s_religion__c.selectedIndex==0)
		    {
			    alert("Please select the religion your biological mother was born into.");
			    formRef.Mother_s_religion__c.focus();
			    return false;
		    }
			
			if (formRef.Father_s_religion__c.selectedIndex==0)
		    {
			    alert("Please select the religion your biological father was born into.");
			    formRef.Father_s_religion__c.focus();
			    return false;
		    }

			if (formRef.Maternal_grandparent_s_religion__c.selectedIndex==0)
		    {
			    alert("Please select the religion your maternal grandparents were born into.");
			    formRef.Maternal_grandparent_s_religion__c.focus();
			    return false;
		    }

			if (formRef.Paternal_grandparent_s_religion__c.selectedIndex==0)
		    {
			    alert("Please select the religion your paternal grandparents were born into.");
			    formRef.Paternal_grandparent_s_religion__c.focus();
			    return false;
		    }

        	if (formRef.Religion_Association__c.value.length<1){
			    alert("Please enter your religion association.");
			    formRef.Religion_Association__c.focus();
			    return false;
		    }

			if (formRef.Highest_Level_of_Jewish_Education__c.selectedIndex==0)
		    {
			    alert("Please select the highest level of Jewish education which you've completed.");
			    formRef.Highest_Level_of_Jewish_Education__c.focus();
			    return false;
		    }

        	if (formRef.Hope_to_gain_from_Program__c.value.length<1){
			    alert("Please explain what you hope to gain from the Maimonides Leaders Fellowship.");
			    formRef.Hope_to_gain_from_Program__c.focus();
			    return false;
		    }
			
			if (formRef.Referral__c.value.length<1){
			    alert("Please enter 'Who referred you to this program'.");
			    formRef.Referral__c.focus();
			    return false;
		    }

   }