/*
*  The Validator
*   The class that handles all validation related issues
*    
*   pass the name of the form while constructing.
*   methods:
*    addValidation(input_item_name,validation_descriptor,error_string)
*       call this method for each input item. Single input item can have 
*       many validations
*      
*    setAddnlValidationFunction(function_name)
*             call this function to set a custom validat function, which will
*						 be called after other validations are over.
*			       The function should return 'true' or 'false' 
*/

<!--SACHI COMMENT   Employee ID: 0017 Javascript validation for comparing two dates -->
var n;
var p;
var p1;
function ValidatePhone()
{
	p=p1.value
	if(p.length==3)
	{
		pp=p;
		d4=p.indexOf('-')
		if(d4==-1)
		{
			pp=pp+"-";
		}
		p1.value="";
		p1.value=pp;
	}
	if(p.length>4)
	{
	p11=p.substring(0,3);
	if(p11.length>3)
	{
		p12=p11;
		l12=p12.length;
		l15=p.length
		p13=p11.substring(0,3);
		p14=p11.substring(3,l12);
		p15=p.substring(d2+1,l15);
		p1.value="";
		pp="("+p13+")"+p14+p15;
		p1.value=pp;
	}
	l16=p.length;
	p16=p.substring(4,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1)
	{
		p17=p.substring(4,7);
		p18=p.substring(7,l16);
		p19=p.substring(0,4);
		pp=p19+p17+"-"+p18;
		p1.value="";
		p1.value=pp;
	}
}
setTimeout(ValidatePhone,100)
}
function getIt(m)
{
	n=m.name;
	p1=m
	ValidatePhone()
}
function onChange1()
{
	var v=window.document.addmenu;
	if(v.MenuLevel.value == 'root')
	{
		document.getElementById("banner").disabled=false;
		
	}
	else
	{
		

//document.addmenu.banner.disabled=false;
document.getElementById("banner").disabled=true;
	}
	
}

function onChange2()
{
	var v=window.document.addmenu;
	if(v.menulevel.value == 'root')
	{
		document.getElementById("banner").disabled=false;
		
	}
	else
	{
		

//document.addmenu.banner.disabled=false;
document.getElementById("banner").disabled=true;
	}
	
}


function onChange3()
{
	var v=window.document.studentapplication;
	if(v.KsResident.value == 'Yes')
	{
		document.getElementById("KsMoveDate").disabled=false;
		
	}
	else
	{
		

//document.addmenu.banner.disabled=false;
document.getElementById("KsMoveDate").disabled=true;
	}
	
}


function onChange4()
{
	var v=window.document.studentapplication;
	if(v.ParentKsResident.value == 'Yes')
	{
		document.getElementById("ParentKsYears").disabled=false;
		
	}
	else
	{
		

//document.addmenu.banner.disabled=false;
document.getElementById("ParentKsYears").disabled=true;
	}
	
}


function onChange5()
{
	var v=window.document.studentapplication;
	if(v.ActiveMilitary.value == 'Yes')
	{
		document.getElementById("StationedKs").disabled=false;
		
	}
	else
	{
		

//document.addmenu.banner.disabled=false;
document.getElementById("StationedKs").disabled=true;
	}
	
}


function enableField()
{
document.addmenu.banner.disabled=false;
}
 





function addannouncementcompareDates()
{ // alert("hi");
//alert();
var comp=document.addannouncement;
if(comp.expdate.value != '');
		{ 
			//alert("jagadeesh");
			var entry = comp.firstdate.value.split('/');//splits input value;
			
			m=entry[0]*1; //alert(m);
			d=entry[1]*1-1;//alert(d);//sets months to default values i.e Jan = 0; Feb = 1; etc.
			y=entry[2]*1;//alert(y);
			var entry1 = comp.expdate.value.split('/');//splits input value;
			m1=entry1[0]*1;
			d1=entry1[1]*1-1;// alert(d1);//sets months to default values i.e Jan = 0; Feb = 1; etc.
			y1=entry1[2]*1;//alert(y1);
			//var (entry1);
			//var (entry1);
			var newDate = new Date(m,d,y);//sets the new date
			//alert(newDate);
			//var today = new Date(m1-1,d1-1,y1-1);
			 var today = new Date(m1,d1,y1);
			//alert(today);
		 
		  // alert(today);
		   dif = newDate-today;//difference in milliseconds
		   dif =today-newDate;
		   //alert(dif);
		   dif = Math.ceil(dif/1000/60/60/24);//difference in days
		   //alert(dif);
		   if(dif < 0)
			{//if the date is in the future
					alert('You should select greater than Current Date!');
					comp.expdate.value="";
					comp.expdate.focus();
					return false;
			}
			
	}
   }

<!--SACHI COMMENT   Employee ID: 0017 Javascript validation for the form -->
function addannouncementvalidate()
{
	var com =document.addannouncement;
	if(com.firstdate.value == '')
	{
		alert ("Please enter firstdate")
		com.firstdate.focus();
		return false;
	}
	if(com.expdate.value == '')
	{
		alert ("Please enter enddate")
		com.expdate.focus();
		return false;
	}
	if(com.comments.value == '')
	{
		alert ("Please enter description")
		com.comments.focus();
		return false;
	}
}

		

function addeventsvalidate()
{
	 var v=document.addevents;
	 
	 var isError = false;
	 var errorMessage = "";
	
	 if(v.eventtitle.value=="")
	 {
		  alert("Please Enter Event Title");
		  v.eventtitle.focus();
		  return false;
	 }
	 if(v.eventdate.value=="")
	 {
		  alert("Please Enter Event Date");
		 
		  v.eventdate.focus();
		  return false;
	 }
/*	 else if(v.eventdate.value!=Date())
	 {
		alert("Date entered is not a current date");
		v.eventdate.focus();
		return false;
	 }
	 */
	 if(v.hours.selectedIndex == 0 )
	 {
		  alert("Please Enter Hours");
		  v.hours.focus();
		  return false;
	 }
	 
	 if(v.mins.selectedIndex == 0 )
	 {
		  alert("Please Enter Mins");
		  v.mins.focus();
		  return false;
	 }
	 
					 
	 if(v.time.selectedIndex == 0 )
	 {
		  alert("Please Enter Time");
		  v.time.focus();
		  return false;
	 }
	 
	 
	 
	 if(v.location.value=="")
	 {
		alert("Please Enter Event location");
		v.location.focus();
		return false;
	 }
	 if(v.comments.value=="")
	 {
		  alert("Please Enter Event Description");
		  v.comments.focus();
		  return false;
	 }
	if(v.location.value=="")
	 {
		  alert("Please Enter Event Location");
		  v.location.focus();
		  return false;
	 }
		
} 
function Validator(frmname)
{
  this.formobj=document.forms[frmname];
	if(!this.formobj)
	{
	  alert("BUG: couldnot get Form object "+frmname);
		return;
	}
	if(this.formobj.onsubmit)
	{
	 this.formobj.old_onsubmit = this.formobj.onsubmit;
	 this.formobj.onsubmit=null;
	}
	else
	{
	 this.formobj.old_onsubmit = null;
	}
	this.formobj.onsubmit=form_submit_handler;
	this.addValidation = add_validation;
	this.setAddnlValidationFunction=set_addnl_vfunction;
	this.clearAllValidations = clear_all_validations;
}

function set_addnl_vfunction(functionname)
{
  this.formobj.addnlvalidation = functionname;
}
function clear_all_validations()
{
	for(var itr=0;itr < this.formobj.elements.length;itr++)
	{
		this.formobj.elements[itr].validationset = null;
	}
}
function form_submit_handler()
{
	for(var itr=0;itr < this.elements.length;itr++)
	{
		if(this.elements[itr].validationset &&
	   !this.elements[itr].validationset.validate())
		{
		  return false;
		}
	}
	if(this.addnlvalidation)
	{
	  str =" var ret = "+this.addnlvalidation+"()";
	  eval(str);
    if(!ret) return ret;
	}
	return true;
}

function add_validation(itemname,descriptor,errstr)
{
  if(!this.formobj)
	{
	  alert("BUG: the form object is not set properly");
		return;
	}//if
	var itemobj = this.formobj[itemname];
  if(!itemobj)
	{
	  alert("BUG: Couldnot get the input object named: "+itemname);
		return;
	}
		
	if(!itemobj.validationset)
	{
	  itemobj.validationset = new ValidationSet(itemobj);
	}
  itemobj.validationset.add(descriptor,errstr);
}
function ValidationDesc(inputitem,desc,error)
{
  this.desc=desc;
	this.error=error;
	this.itemobj = inputitem;
	this.validate=vdesc_validate;
}
function vdesc_validate()
{
 if(!V2validateData(this.desc,this.itemobj,this.error))
 {
    this.itemobj.focus();
		return false;
 }
 return true;
}


function ValidationSet(inputitem)
{
  this.vSet=new Array();
	this.add= add_validationdesc;
	this.validate= vset_validate;
	this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
  this.vSet[this.vSet.length]= 
	  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
	 {
	   if(!this.vSet[itr].validate())
		 {
		   return false;
		 }
	 }
	 return true;
}

//---------------------------------EMail Check ------------------------------------ 

/*  checks the validity of an email address entered 
*   returns true or false 
*   
*/ 

function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}

/* function V2validateData 
*  Checks each field in a form 

*/ 
function V2validateData(strValidateStr,objValue,strError) 
{ 
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    } 

    switch(command) 
    { 
        case "req": 
        case "required": 
         { 
           if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : Required Field"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : "+cmdvalue+" characters maximum "; 
               }//if 
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false; 
             }//if 
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : " + cmdvalue + " characters minimum  "; 
               }//if               
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false;                 
             }//if 
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alpha-numeric characters allowed "; 
                }//if 
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//case alphanumeric 
        case "num": 
        case "numeric": 
           { 
              var charpos = objValue.value.search("[^0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only digits allowed "; 
                }//if               
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break;               
           }//numeric 
        case "numericdesc": 
           { 
              var charpos = objValue.value.search("[^0-9.0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only digits allowed "; 
                }//if               
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break;               
           }//numeric 

        case "alphabetic": 
        case "alpha": 
           { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alphabetic characters allowed "; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//alpha 
		case "alphaperiodspace":
			{
              var charpos = objValue.value.search("[^A-Za-z\. ]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": characters allowed are A-Z,a-z, period and space"; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 			
			break;
			}
	case "alnumscore":
				{
				  var charpos = objValue.value.search("[^A-Za-z0-9\_]"); 
				  if(objValue.value.length > 0 &&  charpos >= 0) 
				  { 
					  if(!strError || strError.length ==0) 
					{ 
					  strError = objValue.name+": characters allowed are A-Z,a-z,0-9 and _"; 
					}//if                             
					alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
					return false; 
				  }//if 			
				break;
				}

case "tele":
				{
				  var charpos = objValue.value.search("[^0-9\ + - ( )]"); 
				  if(objValue.value.length > 0 &&  charpos >= 0) 
				  { 
					  if(!strError || strError.length ==0) 
					{ 
					  strError = objValue.name+": characters allowed are 0-9,+,-,()and "; 
					}//if                             
					alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
					return false; 
				  }//if 			
				break;
				}



        case "email": 
          { 
               if(!validateEmailv2(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Enter a valid Email address "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email 
        case "lt": 
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : value should be less than "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : value should be greater than "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
            if(!objValue.value.match(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name+": Invalid characters found "; 
              }//if                                                               
              alert(strError); 
              return false;                   
            }//if 
           break; 
         }//case regexp 
        case "dontselect": 
         { 
            if(objValue.selectedIndex == null) 
            { 
              alert("BUG: dontselect command for non-select Item"); 
              return false; 
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError = objValue.name+": Please Select One Option "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
             break; 
         }//case dontselect 
    }//switch 
    return true; 
}



	
	function Validate(form) { 
    var v = new RegExp(); 
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"); 
    if (!v.test(form["url"].value)) { 
        alert("You must supply a valid URL starting with http://."); 
        return false; 
    } 
} 

	
	function surveyValidate(form) { 
    var v = new RegExp(); 
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"); 
    if (!v.test(form["url"].value)) { 
        alert("You must supply a valid URL starting with http://."); 
        return false; 
    } 
} 
	
	

 



 
	/*Employee ID: 0036   validations for all the forms */
	
	/* Social Security Number Validation for Dietary Manager,Student Record Change and Student application form */

function SSNValidation(ssn) {
var matchArr = ssn.match(/^(\d{3})-\d{2}-\d{4}$/);
var numDashes = ssn.split('-').length - 1;
if (matchArr == null || numDashes == 1) {
alert('Invalid SSN. Must be 9 digits or in the form ###-##-####.');
msg = "does not appear to be valid";
return false;
}
else 
if (parseInt(matchArr[1],10)==0) {
alert("Invalid SSN: SSN's can't start with 000.");
msg = "does not appear to be valid";
alert(ssn + "\r\n\r\n" + msg + " Social Security Number.");
return false;
}
}
		



function confirmDelete()
{
	if(confirm("Are you sure you want to delete this record ?"))
		return true;
	else
		return false;
}

/* Student Record Change Validation */

function studentrecordchangevalidate()

{
	 
	
	 
	 if(document.StudChng.SSN2.value =='' )
				 {
					  alert("Please Enter SSN");
					  document.StudChng.SSN2.focus();
					    return false;
				 }
	
	    
			if(document.StudChng.DOB2.value =='' )
				 {
					  alert("Please Select Date of Birth");
					  document.StudChng.DOB2.focus();
					   return false;
				 }
				 
				 if(document.StudChng.LastName2.value =='' )
				 {
					  alert("Please Enter Last Name");
					  document.StudChng.LastName2.focus();
					   return false;
				 }
				 
				  
				 if(document.StudChng.FirstName2.value =='' )
				 {
					  alert("Please Enter First Name");
					  document.StudChng.FirstName2.focus();
					   return false;
				 }
				 
				 
				  if(document.StudChng.MiddleName2.value =='' )
				 {
					  alert("Please Enter Middle Name");
					  document.StudChng.MiddleName2.focus();
					  return false;
				 }
				 
				  if(document.StudChng.Street2.value =='' )
				 {
					  alert("Please Enter Address");
					  document.StudChng.Street2.focus();
					   return false;
				 }
				 
				   
				 
				   if(document.StudChng.City2.value =='' )
				 {
					  alert("Please Enter City ");
					  document.StudChng.City2.focus();
					   return false;
				 }
				 
				 
				  		 
				 
				  if(document.StudChng.State2.selectedIndex == 0 )
				 {
					  alert("Please Select State ");
					  document.StudChng.State2.focus();
					  return false;
				 }
				 
				 
				 
				 if(document.StudChng.County2.value =='' )
				 {
					  alert("Please Enter Country ");
					  document.StudChng.County2.focus();
					   return false;
				 }
				 
				   if(document.StudChng.ZipCode2.value =='' )
				 {
					  alert("Please Enter Zip Code ");
					  document.StudChng.ZipCode2.focus();
					   return false;
				 }
				 
				 if(document.StudChng.HomeTelephone2.value =='' )
				 {
					  alert("Please Enter Home Telephone ");
					  document.StudChng.HomeTelephone2.focus();
					   return false;
				 }
				 
				  if(document.StudChng.AltTelephone2.value =='' )
				 {
					  alert("Please Enter Evening Telephone ");
					  document.StudChng.AltTelephone2.focus();
					   return false;
				 }
				 
				 
				 
				  if(document.StudChng.CurrentProgram2.value =='' )
				 {
					  alert("Please Enter Current Program ");
					  document.StudChng.CurrentProgram2.focus();
					  return false;
				 }
				  
				 
				   if(document.StudChng.NewProgram2.value =='' )
				 {
					  alert("Please Enter New Program ");
					  document.StudChng.NewProgram2.focus();
					  return false;
				 }
				  
				 
				  
				   if(document.StudChng.GraduationDate2.value =='' )
				 {
					  alert("Please Select  Graduation Date ");
					  document.StudChng.GraduationDate2.focus();
					   return false;
				 }
				 
	              
				if(document.StudChng.LastName3.value =='' )
				 {
					  alert("Please Enter Last Name");
					  document.StudChng.LastName3.focus();
					   return false;
				 }
				 
				  
				 if(document.StudChng.FirstName3.value =='' )
				 {
					  alert("Please Enter First Name");
					  document.StudChng.FirstName3.focus();
					   return false;
				 }
				 
				 
				  if(document.StudChng.MiddleName3.value =='' )
				 {
					  alert("Please Enter Middle Name");
					  document.StudChng.MiddleName3.focus();
					   return false;
				 }
				 

	               if(document.StudChng.Street3.value =='' )
				 {
					  alert("Please Enter Address ");
					  document.StudChng.Street3.focus();
					  return false;
				 }
				 
				     
				 
				   if(document.StudChng.City3.value =='' )
				 {
					  alert("Please Enter City ");
					  document.StudChng.City3.focus();
					  return false;
				 }
				 
				 
				 if(document.StudChng.State3.selectedIndex == 0 )
				 {
					  alert("Please Select State ");
					  document.StudChng.State3.focus();
					  return false;
				 }
				 
								 
				 if(document.StudChng.County3.value =='' )
				 {
					  alert("Please Enter Country ");
					  document.StudChng.County3.focus();
					   return false;
				 }
				 
				 
				   if(document.StudChng.ZipCode3.value =='' )
				 {
					  alert("Please Enter Zip Code ");
					  document.StudChng.ZipCode3.focus();
					   return false;
				 }
				 
				 if(document.StudChng.HomeTelephone3.value =='' )
				 {
					  alert("Please Enter Home Telephone ");
					  document.StudChng.HomeTelephone3.focus();
					  return false;
				 }
				 
				  if(document.StudChng.AltTelephone3.value =='' )
				 {
					  alert("Please Enter Evening Telephone ");
					  document.StudChng.AltTelephone3.focus();
					   return false;
				 }
				
				
	           if(document.StudChng.CurrentProgram3.value =='' )
				 {
					  alert("Please Enter Current Program ");
					  document.StudChng.CurrentProgram3.focus();
					   return false;
				 }
				  
				 
				   if(document.StudChng.NewProgram3.value =='' )
				 {
					  alert("Please Enter New Program ");
					  document.StudChng.NewProgram3.focus();
					  return false;
				 }
				  
				 
				  
				   if(document.StudChng.GraduatoinDate2.value =='' )
				 {
					  alert("Please Select  Graduation Date ");
					  document.StudChng.GraduatoinDate2.focus();
					   return false;
				 }
				 
				  /* here it checks the Social Security Number ie valid or not  if valid only it will submit the form */
				  return SSNValidation(document.StudChng.SSN2.value);
				 
				 
				
}


/* to accept Numbers  only in all forms */
function numbersonly(){
if (event.keyCode<48||event.keyCode>57)
return false
}
/* to accept alphabets  only in all forms   */
function alphaonly(){
if (event.keyCode<65||event.keyCode>=122)
return false
}

/*function onKeyPressBlockNumbers(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=32){ //if the key isn't the backspace key (which we should allow)
if (unicode<65||unicode>122) //if not a number
return false //disable key press
}
}
*/
/* to accept  Alphabets with Spaces in all forms  */
function onKeyPressBlockNumbers(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=32){ //if the key isn't the backspace key (which we should allow)(space)
if (unicode<65||unicode>90)//if not a number
//if not a number
if (unicode<97||unicode>122)
return false //disable key press
}
}

function formatPhone()
{
     var theCount = 0;
     var theString = document.dm_application.ssn.value;
     var newString = "";
     var myString = theString;
     var theLen = myString.length;
     for ( var i = 0 ; i < theLen ; i++ )
     {
     // Character codes for ints 1 - 9 are 48 - 57
          if ( (myString.charCodeAt(i) >= 48 ) && (myString.charCodeAt(i) <= 57) )
          newString = newString + myString.charAt(i);   
     }
// Now the validation to determine that the remaining string is 9 characters.
     if (newString.length ==9)
     {
// Now the string has been stripped of other chars it can be reformatted to ###-##-#### 
          var newLen = newString.length;
          var newPhone = "";
          for ( var i = 0 ; i < newLen ; i++ )
          {
               if ( ( i == 2 ) || ( i == 4 ) )
               {
                    newPhone = newPhone + newString.charAt(i) + "-";
               }else{
                    newPhone = newPhone + newString.charAt(i);
               }
          }
          document.dm_application.ssn.value = newPhone;
          return true;
     }else{
          alert("The SSN number you entered "+newString+" does not contain the correct number of digits");
          document.dm_application.ssn.focus();
          return false;
     }
}


function formatPhone1()
{
     var theCount = 0;
     var theString = document.StudChng.SSN2.value;
     var newString = "";
     var myString = theString;
     var theLen = myString.length;
     for ( var i = 0 ; i < theLen ; i++ )
     {
     // Character codes for ints 1 - 9 are 48 - 57
          if ( (myString.charCodeAt(i) >= 48 ) && (myString.charCodeAt(i) <= 57) )
          newString = newString + myString.charAt(i);   
     }
// Now the validation to determine that the remaining string is 9 characters.
     if (newString.length ==9)
     {
// Now the string has been stripped of other chars it can be reformatted to ###-##-#### 
          var newLen = newString.length;
          var newPhone = "";
          for ( var i = 0 ; i < newLen ; i++ )
          {
               if ( ( i == 2 ) || ( i == 4 ) )
               {
                    newPhone = newPhone + newString.charAt(i) + "-";
               }else{
                    newPhone = newPhone + newString.charAt(i);
               }
          }
          document.StudChng.SSN2.value = newPhone;
          return true;
     }else{
          alert("The SSN number you entered "+newString+" does not contain the correct number of digits");
          document.StudChng.SSN2.focus();
          return false;
     }
}


function formatPhone2()
{
     var theCount = 0;
     var theString = document.studentapplication.SSN.value;
     var newString = "";
     var myString = theString;
     var theLen = myString.length;
     for ( var i = 0 ; i < theLen ; i++ )
     {
     // Character codes for ints 1 - 9 are 48 - 57
          if ( (myString.charCodeAt(i) >= 48 ) && (myString.charCodeAt(i) <= 57) )
          newString = newString + myString.charAt(i);   
     }
// Now the validation to determine that the remaining string is 9 characters.
     if (newString.length ==9)
     {
// Now the string has been stripped of other chars it can be reformatted to ###-##-#### 
          var newLen = newString.length;
          var newPhone = "";
          for ( var i = 0 ; i < newLen ; i++ )
          {
               if ( ( i == 2 ) || ( i == 4 ) )
               {
                    newPhone = newPhone + newString.charAt(i) + "-";
               }else{
                    newPhone = newPhone + newString.charAt(i);
               }
          }
         document.studentapplication.SSN.value = newPhone;
          return true;
     }else{
          alert("The SSN number you entered "+newString+" does not contain the correct number of digits");
          document.studentapplication.SSN.focus();
          return false;
     }
}



/* Request form Validation */

function requestinfovalidate()

{	
 			if(document.requestinfo.firstname.value =='' )
				 {
					  alert("Please Enter First Name");
					  document.requestinfo.firstname.focus();
					   return false;
				 }
			
			
			    if(document.requestinfo.lastname.value =='' )
				 {
					  alert("Please Enter Last Name");
					  document.requestinfo.lastname.focus();
					   return false;
				 }
			
					
			   if(document.requestinfo.address.value =='' )
				 {
					  alert("Please Enter Address");
					  document.requestinfo.address.focus();
					   return false;
				 }
					
			   if(document.requestinfo.aptpobox.value =='' )
				 {
					  alert("Please Enter Apartments");
					  document.requestinfo.aptpobox.focus();
					   return false;
				 }
			
			   if(document.requestinfo.city.value =='' )
				 {
					  alert("Please Enter City");
					  document.requestinfo.city.focus();
					   return false;
				 }
				 
				 		
			
			  if(document.requestinfo.state.selectedIndex == 0 )
				 {
					  alert("Please Select State");
					  document.requestinfo.state.focus();
					  return false;
				 }
			
			    if(document.requestinfo.zip.value =='' )
				 {
					  alert("Please Enter Zip Code");
					  document.requestinfo.zip.focus();
					   return false;
				 }
			
			
			if(document.requestinfo.DOB.value =='' )
				 {
					  alert("Please Select Date of Birth");
					  document.requestinfo.DOB.focus();
					   return false;
				 }
				 
				 
				  if(document.requestinfo.gender.selectedIndex == 0 )
				 {
					  alert("Please Select Gender");
					  document.requestinfo.gender.focus();
					  return false;
				 }
				 
				 if(document.requestinfo.startsemester.selectedIndex == 0 )
				 {
					  alert("Please Select Start Semester");
					  document.requestinfo.startsemester.focus();
					  return false;
				 }			 
				 
				 if(document.requestinfo.startyear.selectedIndex == 0 )
				 {
					  alert("Please Select Start Year");
					  document.requestinfo.startyear.focus();
					  return false;
				 }
				 
				 if(document.requestinfo.dayphone.value =='' )
				 {
					  alert("Please Enter Day Telephone ");
					  document.requestinfo.dayphone.focus();
					   return false;
				 }
				 
				 			 
				 
				  if(document.requestinfo.eveningphone.value =='' )
				 {
					  alert("Please Enter Evening Telephone ");
					  document.requestinfo.eveningphone.focus();
					   return false;
				 }
				 
				   if(document.requestinfo.email.value =='' )
				 {
					  alert("Please Enter Email");
					  document.requestinfo.email.focus();
					   return false;
				 }
				 /* E-mail id Validation */
				 
				  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.requestinfo.email.value)){
alert("Please Enter  Valid E-mail id ");
document.requestinfo.email.focus();
return false;
}
				 
				 if(document.requestinfo.PresentHS.value =='' )
				 {
					  alert("Please Enter Present High School ");
					  document.requestinfo.PresentHS.focus();
					   return false;
				 }
				 
				 
				 if(document.requestinfo.PresentHSgrade.selectedIndex == 0 )
				 {
					  alert("Please Select  Present High School Grade");
					  document.requestinfo.PresentHSgrade.focus();
					  return false;
				 }
				 
				/*  if(document.requestinfo.OtherProgram.value =='' )
				 {
					  alert("Please Enter Other Program");
					  document.requestinfo.OtherProgram.focus();
					  return false;
				 }
				 */
				  if(document.requestinfo.media.selectedIndex == 0 )
				 {
					  alert("Please Select Media");
					  document.requestinfo.media.focus();
					  return false;
				 }
				 
				 /* if media is Radio,TV,Newspaper   enter the media name */
				   var v=window.document.requestinfo;
				 
				 	 if((v.media.value == 'Radio') || (v.media.value == 'TV') || (v.media.value == 'Newspaper'))
	{
				 
				 
				 if(document.requestinfo.medianame.value =='' )
				 {
					  alert("Please Enter Media name ");
					  document.requestinfo.medianame.focus();
					   return false;
				 }
				 
	}
				 
				 
				 
				 
				 
				/*  if(document.requestinfo.medianame.value =='' )
				 {
					  alert("Please Enter Media name ");
					  document.requestinfo.medianame.focus();
					   return false;
				 }
				 */
				 			   
				 if(document.requestinfo.WordOfMouth.selectedIndex == 0 )
				 {
					  alert("Please Select Word Of Mouth");
					  document.requestinfo.WordOfMouth.focus();
					  return false;
				 }
				if(document.requestinfo.RequestInfo.value =='' )
				 {
					  alert("Please Enter Request Info ");
					  document.requestinfo.RequestInfo.focus();
					   return false;
				 }
				if(document.requestinfo.OtherInfo.value == 0)
				 {
					  alert("Please Enter Other Info");
					  document.requestinfo.OtherInfo.focus();
					  return false;
				 }
				 
				 if(document.requestinfo.SpecialNeeds.value == 0)
				 {
					  alert("Please Enter Special Needs");
					  document.requestinfo.SpecialNeeds.focus();
					  return false;
				 }
				 
				 if(document.requestinfo.Comments.value == 0)
				 {
					  alert("Please Enter Comments");
					  document.requestinfo.Comments.focus();
					  return false;
				 }
				 
				 
				 if(document.requestinfo.security_code.value =='' )
				 {
					  alert("Please Enter Security Code ");
					  document.requestinfo.security_code.focus();
					   return false;
				 }
		
				 
}





/* To  accept numbers only */
function numbers1only(){
if (event.keyCode<45||event.keyCode>57)
return false
}

/* code used for copying permananent address ie(same as address for Kansas) in student application form */  
var PermanentStreet = "";
var PermanentApt = "";
var PermanentCountry = "";
var PermanentCity = "";
var PermanentState = "";
var PermanentZipCode = "";

/* initial saving the variables  for permanent street,apt,country,city,state,zipcode */
function InitSaveVariables(form) {
PermanentStreet = form.PermanentStreet.value;
PermanentApt = form.PermanentApt.value;
PermanentCountry = form.PermanentCountry.value;
PermanentCity= form. PermanentCity.value;
PermanentState = form.PermanentState.value;
PermanentZipCode = form.PermanentZipCode.value;
}

/* copying the permanent address to Current addres */
function ShipToBillPerson(form) {
if (form.SameAddr.checked) {
InitSaveVariables(form);
form.PermanentStreet.value = form.CurrentStreet.value;
form.PermanentApt.value = form.CurrentApt.value;
form.PermanentCountry.value = form.CurrentCounty.value;
form.PermanentCity.value = form.CurrentCity.value;
form.PermanentState.value = form.CurrentState.value;
form.PermanentZipCode.value = form.CurrentZipCode.value;
}
else {
form.CurrentStreet.value = CurrentStreet;
form.CurrentApt.value = CurrentApt;
form.CurrentCounty.value = CurrentCounty;
form.CurrentCity.value = CurrentCity;
form.CurrentState.value = CurrentState;
form.CurrentZipCode.value = CurrentZipCode;
 }
}






/* Student Application Form  Validation */


function studentapplicationvalidate()

{
    	 
	 if(document.studentapplication.SSN.value =='' )
				 {
					  alert("Please Enter SSN Number");
					  document.studentapplication.SSN.focus();
					    return false;
				 }
	
	    
			  if(document.studentapplication.gender.selectedIndex == 0 )
				 {
					  alert("Please Select Gender ");
					  document.studentapplication.gender.focus();
					  return false;
				 }
			
						 
				 if(document.studentapplication.LastName.value =='' )
				 {
					  alert("Please Enter Legal Last Name");
					  document.studentapplication.LastName.focus();
					   return false;
				 }
				 
				  
				 if(document.studentapplication.FirstName.value =='' )
				 {
					  alert("Please Enter First Name");
					  document.studentapplication.FirstName.focus();
					   return false;
				 }
				 
				 
				  if(document.studentapplication.MiddleName.value =='' )
				 {
					  alert("Please Enter Middle Name");
					  document.studentapplication.MiddleName.focus();
					  return false;
				 }
				 
				 
				   if(document.studentapplication.OtherLastNames.value =='' )
				 {
					  alert("Please Enter Other Last Name");
					  document.studentapplication.OtherLastNames.focus();
					  return false;
				 }
				 
				 
				  if(document.studentapplication.DOB.value =='' )
				 {
					  alert("Please Select Date of Birth");
					  document.studentapplication.DOB.focus();
					  return false;
				 }
				 
				 
				   if(document.studentapplication.city_born.value =='' )
				 {
					  alert("Please Enter City Of Birth");
					  document.studentapplication.city_born.focus();
					   return false;
				 }
				 
				 
				 if(document.studentapplication.state_born.selectedIndex == 0 )
				 {
					  alert("Please Select State of Birth ");
					   document.studentapplication.state_born.focus();
					  return false;
				 }
				 
				 
				 
				  if(document.studentapplication.county_born.value =='' )
				 {
					  alert("Please Enter Country of Birth ");
					   document.studentapplication.county_born.focus();
					   return false;
				 }
				 
				   if(document.studentapplication.select.selectedIndex == 0 )
				 {
					  alert("Please Select Ethnic Status ");
					  document.studentapplication.select.focus();
					  return false;
				 }
				 
				 if(document.studentapplication.maritalstatus.selectedIndex == 0 )
				 {
					  alert("Please Select Marital Status ");
					  document.studentapplication.maritalstatus.focus();
					  return false;
				 }
				 
				 
				  if(document.studentapplication.finaid.selectedIndex == 0 )
				 {
					  alert("Please Select Financial Aid either Yes or No");
					  document.studentapplication.finaid.focus();
					  return false;
				 }
				 
				 
				 
				  if(document.studentapplication.CurrentStreet.value =='' )
				 {
					  alert("Please Enter Current Address");
					  document.studentapplication.CurrentStreet.focus();
					   return false;
				 }
				 
				   if(document.studentapplication.CurrentApt.value =='' )
				 {
					  alert("Please Enter Current Apartment");
					  document.studentapplication.CurrentApt.focus();
					   return false;
				 }
				 
				 
				 
				 
				  if(document.studentapplication.CurrentCounty.value =='' )
				 {
					  alert("Please Enter Current Country");
					  document.studentapplication.CurrentCounty.focus();
					   return false;
				 }
				 
				   
				   
				   if(document.studentapplication.CurrentCity.value =='' )
				 {
					  alert("Please Enter Current City");
					  document.studentapplication.CurrentCity.focus();
					   return false;
				 }
				 
				 
				 
				  if(document.studentapplication.CurrentState.selectedIndex == 0 )
				 {
					  alert("Please Select Current State");
					  document.studentapplication.CurrentState.focus();
					  return false;
				 }
				 
				 
				 		 
				   if(document.studentapplication.CurrentZipCode.value =='' )
				 {
					  alert("Please Enter Current Zip Code ");
					  document.studentapplication.CurrentZipCode.focus();
					   return false;
				 }
				 
				 
			/*	 if (document.studentapplication.SameAddr.checked == false)
{
alert ('Please click the checkbox!');
document.studentapplication.SameAddr.focus();
return false;
}
*/

				 
				 
				  if(document.studentapplication.PermanentStreet.value =='' )
				 {
					  alert("Please Enter Permanent Street");
					  document.studentapplication.PermanentStreet.focus();
					   return false;
				 }
				 
				 
				 if(document.studentapplication.PermanentApt.value =='' )
				 {
					  alert("Please Enter Permanent Apartment");
					  document.studentapplication.PermanentApt.focus();
					   return false;
				 }
				 
				 
				 
				 if(document.studentapplication.PermanentCountry.value =='' )
				 {
					  alert("Please Enter Permanent Country");
					  document.studentapplication.PermanentCountry.focus();
					   return false;
				 }
				 
				 
				  if(document.studentapplication.PermanentCity.value =='' )
				 {
					  alert("Please Enter Permanent City");
					  document.studentapplication.PermanentCity.focus();
					   return false;
				 }
				 
				 if(document.studentapplication.PermanentState.selectedIndex == 0 )
				 {
					  alert("Please Select Permanent State");
					  document.studentapplication.PermanentState.focus();
					  return false;
				 }
				 
				 
				   if(document.studentapplication.PermanentZipCode.value =='' )
				 {
					  alert("Please Enter Permanent Zip Code");
					  document.studentapplication.PermanentZipCode.focus();
					   return false;
				 }
				 			 
				 
				 
				 if(document.studentapplication.CurrentTelephone.value =='' )
				 {
					  alert("Please Enter Current Telephone ");
					  document.studentapplication.CurrentTelephone.focus();
					   return false;
				 }
				 
				if(document.studentapplication.AlternateTelephone.value =='' )
				 {
					  alert("Please Enter Evening Telephone ");
					  document.studentapplication.AlternateTelephone.focus();
					   return false;
				 }
				 
				 
				    if(document.studentapplication.EmailAddress.value =='' )
				 {
					  alert("Please Enter Email ");
					  document.studentapplication.EmailAddress.focus();
					   return false;
				 }
				 
				 /* E-mail id Validation */
				  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.studentapplication.EmailAddress.value)){
alert("Please Enter  Valid E-mail id ");
document.studentapplication.EmailAddress.focus();
return false;
}
				 
				  if(document.studentapplication.UScitizen.selectedIndex == 0 )
				 {
					  alert("Please Select US citizen");
					  document.studentapplication.UScitizen.focus();
					  return false;
				 }
				 
				 
				 if(document.studentapplication.PermResident.selectedIndex == 0 )
				 {
					  alert("Please Select Permanenent Resident either Yes or No");
					  document.studentapplication.PermResident.focus();
					  return false;
				 }
				 
				 
				 
				  if(document.studentapplication.CountryBorn.value =='' )
				 {
					  alert("Please Enter Country of Birth");
					   document.studentapplication.CountryBorn.focus();
					   return false;
				 }
				 
				  if(document.studentapplication.ResidencyStatus.selectedIndex == 0 )
				 {
					  alert("Please Select Residency Status");
					  document.studentapplication.ResidencyStatus.focus();
					  return false;
				 }
				 
				 
				   if(document.studentapplication.alienreg.value =='' )
				 {
					  alert("Please Enter Alien Registration");
					   document.studentapplication.alienreg.focus();
					   return false;
				 }
				 
				 
				    if(document.studentapplication.CountryCitizenship.value =='' )
				 {
					  alert("Please Enter Country Citizenship");
					  document.studentapplication.CountryCitizenship.focus();
					   return false;
				 }
				 var v=window.document.studentapplication;
				 			 
	            
				  if(document.studentapplication.KsResident.selectedIndex == 0 )
				 {
					  alert("Please Select Kansas resident either Yes or No");
					  document.studentapplication.KsResident.focus();
					  return false;
				 }
				 
				 /* If you select Kansas Resident either yes means you need to select date for Living continuously  in kansas  else  select Relocation State*/
				 var v=window.document.studentapplication;
				 
				 	 if(v.KsResident.value == 'Yes')
	{
						 
				     if(document.studentapplication.KsMoveDate.value =='' )
				 {
					  alert("Please Select Date for Living Continuously in Kansas");
					   document.studentapplication.KsMoveDate.focus();
					   return false;
				 }
				 
	}
				  if(document.studentapplication.RelocationState.selectedIndex == 0 )
				 {
					  alert("Please Select Relocation State");
					  document.studentapplication.RelocationState.focus();
					  return false;
				 }
				 
				 
				  if(document.studentapplication.ParentKsResident.selectedIndex == 0 )
				 {
					  alert(" Are Your parents or guardians a Kansas resident? Please select either Yes or No");
					  document.studentapplication.ParentKsResident.focus();
					  return false;
				 }
				 /*  if you select the parents or guardians  if it is yes you need to enter the years  else select active military */
				 
				  var v=window.document.studentapplication;
				 
				 	 if(v.ParentKsResident.value == 'Yes')
	{
				 
				 if(document.studentapplication.ParentKsYears.value =='' )
				 {
					  alert("Please Enter Years");
					   document.studentapplication.ParentKsYears.focus();
					   return false;
				 }

	}
				 
				 
				  if(document.studentapplication.ActiveMilitary.selectedIndex == 0 )
				 {
					  alert("Are you on active military duty? Please Select Either Yes or No");
					  document.studentapplication.ActiveMilitary.focus();
					  return false;
				 }
				 
				 
				  /*  if Active military is Yes  it will execute this loop */
				  var v=window.document.studentapplication;
				 
				 	 if(v.ActiveMilitary.value == 'Yes')
	{
				 
				 
				  if(document.studentapplication.StationedKs.selectedIndex == 0 )
				 {
					  alert("Is duty station in Kansas? Please Select Either Yes or NO");
					  document.studentapplication.StationedKs.focus();
					  return false;
				 }
				 
	}
				   if(document.studentapplication.veteran.selectedIndex == 0 )
				 {
					  alert("Are you a veteran? Please Select Either Yes or NO");
					  document.studentapplication.veteran.focus();
					  return false;
				 }
				 
				  if(document.studentapplication.enrollsemester.selectedIndex == 0 )
				 {
					  alert("When do you plan to attend WATC Please Select Enroll Semester ");
					  document.studentapplication.enrollsemester.focus();
					  return false;
				 }
				 
				   if(document.studentapplication.enrollyear.selectedIndex == 0 )
				 {
					  alert("Please Select Enroll Year");
					  document.studentapplication.enrollyear.focus();
					  return false;
				 }
				 
				   if(document.studentapplication.gradwatcmoyr.selectedIndex == 0 )
				 {
					  alert("Please Select Anticipated Graduation Date");
					  document.studentapplication.gradwatcmoyr.focus();
					  return false;
				 }
				 
				   if(document.studentapplication.seeking.selectedIndex == 0 )
				 {
					  alert("Please Check the Category in Which You Plan to Register");
					  document.studentapplication.seeking.focus();
					  return false;
				 }
				 
			     
				  if(document.studentapplication.proginterest.value =='' )
				 {
					  alert("Please Enter Program Title");
					   document.studentapplication.proginterest.focus();
					   return false;
				 }
				 
				 
				 
				 if(document.studentapplication.progcode.value =='' )
				 {
					  alert("Please Enter Code");
					   document.studentapplication.progcode.focus();
					   return false;
				 }
				 
				 
				 
				   if(document.studentapplication.graduatedhs.selectedIndex == 0 )
				 {
					  alert("Please Select High school");
					  document.studentapplication.graduatedhs.focus();
					  return false;
				 }
				 
				  if(document.studentapplication.hsgraduatedfrom.value =='' )
				 {
					  alert("Please Enter High school graduated from");
					   document.studentapplication.hsgraduatedfrom.focus();
					   return false;
				 }
				 
				 if(document.studentapplication.hsgradcity.value =='' )
				 {
					  alert("Please Enter High school graduated City");
					   document.studentapplication.hsgradcity.focus();
					   return false;
				 }
				 
				 
				  if(document.studentapplication.hsgradstate.selectedIndex == 0 )
				 {
					  alert("Please Select High school graduated State");
					  document.studentapplication.hsgradstate.focus();
					  return false;
				 }
				 
				/* if(document.studentapplication.yrgradhs.value =='' )
				 {
					  alert("Please Enter Year of Completion for graduation");
					   document.studentapplication.yrgradhs.focus();
					   return false;
				 }
				 */
				  if(document.studentapplication.yrgradhs.selectedIndex == 0 )
				 {
					   alert("Please Select Year of Completion");
					   document.studentapplication.yrgradhs.focus();
					   return false;
				 }
				    if(document.studentapplication.educationlevel.selectedIndex == 0 )
				 {
					  alert("Please Select  Highest Education Level");
					  document.studentapplication.educationlevel.focus();
					  return false;
				 }
				 
				 
				   if(document.studentapplication.othercolleges.selectedIndex == 0 )
				 {
					  alert("Please Select Previous Attendance Either Yes or No");
					  document.studentapplication.othercolleges.focus();
					  return false;
				 }
				 
				 
				 /*  If previous attendance is yes  means it will check the following the loop else go to last2nd Validation */
				 
				  var v=window.document.studentapplication;
				 
			 if(v.othercolleges.value=='Yes')
	          {
				 
				 
				  if(document.studentapplication.college1name.value =='' )
				 {
					  alert("Please Enter First School");
					   document.studentapplication.college1name.focus();
					   return false;
				 }
				 
				  if(document.studentapplication.college1city.value =='' )
				 {
					  alert("Please Enter First School -City");
					   document.studentapplication.college1city.focus();
					   return false;
				 }
				 
				 
				  if(document.studentapplication.college1state.selectedIndex == 0 )
				 {
					  alert("Please Select First School -State");
					  document.studentapplication.college1state.focus();
					  return false;
				 }
				 
				 
				    if(document.studentapplication.college1hrs.selectedIndex == 0 )
				 {
					  alert("Please Select First School-Credit Hours");
					  document.studentapplication.college1hrs.focus();
					  return false;
				 }
				 
				 
				  if(document.studentapplication.college1degree.selectedIndex == 0 )
				 {
					  alert("Please Select First School-Award ");
					  document.studentapplication.college1degree.focus();
					  return false;
				 }
				 
				   if(document.studentapplication.college1month.selectedIndex == 0 )
				 {
					  alert("Please Select First School-Month");
					  document.studentapplication.college1month.focus();
					  return false;
				 }
				 
				 
				    if(document.studentapplication.college1year.selectedIndex == 0 )
				 {
					  alert("Please Select First School-Year");
					  document.studentapplication.college1year.focus();
					  return false;
				 }
				 
				 
				   if(document.studentapplication.college2name.value =='' )
				 {
					  alert("Please Enter Second School");
					   document.studentapplication.college2name.focus();
					   return false;
				 }
				 
				   if(document.studentapplication.college2city.value =='' )
				 {
					  alert("Please Enter Second School -City");
					   document.studentapplication.college2city.focus();
					   return false;
				 }
				 
				  if(document.studentapplication.college2state.selectedIndex == 0 )
				 {
					  alert("Please Select Second School -State");
					  document.studentapplication.college2state.focus();
					  return false;
				 }
				 
				 
				 
				    if(document.studentapplication.college2hrs.selectedIndex == 0 )
				 {
					  alert("Please Select Second School -Credit Hours");
					  document.studentapplication.college2hrs.focus();
					  return false;
				 }
				 
				 
				  if(document.studentapplication.college2degree.selectedIndex == 0 )
				 {
					  alert("Please Select Second School -Award ");
					  document.studentapplication.college2degree.focus();
					  return false;
				 }
				 
				 
				  if(document.studentapplication.college2month.selectedIndex == 0 )
				 {
					  alert("Please Select Second School -Month");
					  document.studentapplication.college2month.focus();
					  return false;
				 }
				 
				 
				    if(document.studentapplication.college2year.selectedIndex == 0 )
				 {
					  alert("Please Select Second School -Year");
					  document.studentapplication.college2year.focus();
					  return false;
				 }
				 
				 
				    if(document.studentapplication.college3name.value =='' )
				 {
					  alert("Please Enter Third School");
					   document.studentapplication.college3name.focus();
					   return false;
				 }
				 
				   if(document.studentapplication.college3city.value =='' )
				 {
					  alert("Please Enter Third School-City");
					   document.studentapplication.college3city.focus();
					   return false;
				 }
				 
				   if(document.studentapplication.college3state.selectedIndex == 0 )
				 {
					  alert("Please Select Third School-State");
					  document.studentapplication.college3state.focus();
					  return false;
				 }
				 
				 
				    if(document.studentapplication.college3hrs.selectedIndex == 0 )
				 {
					  alert("Please Select Third School-Credit Hours");
					  document.studentapplication.college3hrs.focus();
					  return false;
				 }
				 
				 
				  if(document.studentapplication.college3degree.selectedIndex == 0 )
				 {
					  alert("Please Select Third School-Award ");
					  document.studentapplication.college3degree.focus();
					  return false;
				 }
				 
				 
				  if(document.studentapplication.college3month.selectedIndex == 0 )
				 {
					  alert("Please Select Third School-Month");
					  document.studentapplication.college3month.focus();
					  return false;
				 }
				 
				 
				    if(document.studentapplication.college3year.selectedIndex == 0 )
				 {
					  alert("Please Select Third School-Year");
					  document.studentapplication.college3year.focus();
					  return false;
				 }
				 
			  }
				    if(document.studentapplication.media.selectedIndex == 0 )
				 {
					  alert("How did you learn about WATC");
					  document.studentapplication.media.focus();
					  return false;
				 }
		   if (document.studentapplication.certifyinfo.checked == false){
alert ("Please Click on Radio button to certify that all the answers given in this application are accurate to the best of my knowledge");
return false;
}             /* here it checks the Social Security Number ie valid or not  if valid only it will submit the form */
	 return SSNValidation(document.studentapplication.SSN.value);
}

/* contact us validation */
function contactvalidate()
{	
 			if(document.contact.name.value =='' )
				 {
					  alert("Please enter name");
					  document.contact.name.focus();
					   return false;
				 }
			
			
			   
				 
				   if(document.contact.email.value =='' )
				 {
					  alert("Please enter email");
					  document.contact.email.focus();
					   return false;
				 }
				 /* E-mail id Validation */
				 
				  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.contact.email.value)){
alert("Please enter  valid e-mail id ");
document.contact.email.focus();
return false;
}
}

/* volunteer sign up validation */
function volunteersignupvalidate()
{	
	
 			if(document.volunteer.groupName.value =='' )
			 {
				  alert("Please enter your name or the name of your group");
				  document.volunteer.groupName.focus();
				   return false;
			 }
			 
			 if(document.volunteer.contactName.value =='' )
			 {
				  alert("Please enter your name or the name of your groups contact person");
				  document.volunteer.contactName.focus();
				   return false;
			 }
			 
			 if(document.volunteer.phone.value =='' )
			 {
				  alert("Please enter your phone number");
				  document.volunteer.phone.focus();
				   return false;
			 }
			 
			if(document.volunteer.email.value =='' )
			{
			  alert("Please enter your email address");
			  document.volunteer.email.focus();
			   return false;
			}
			
				 /* E-mail id Validation */
				 if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.volunteer.email.value)){
				alert("Please enter a valid email address ");
				document.volunteer.email.focus();
				return false;
			}
			
			if(document.volunteer.interestsAndSkills.value =='' )
			 {
				  alert("Please enter your interests and skills");
				  document.volunteer.interestsAndSkills.focus();
				   return false;
			 }
			 
			 if(document.getElementById('volsOver21_yes').checked == false && document.getElementById('volsOver21_no').checked == false)
			 {
				 alert("Please indicate if the volunteer(s) are over 21 years old or not");
				 document.getElementById('volsOver21_yes').focus();
				 return false;
			 }
			 
			/* if(document.volunteer.preferredLocation[0].checked == false &&  document.volunteer.preferredLocation[1].checked == false)
			 {
				  alert("Please select a location you are interested in");
				  return false;
			 }*/
}




function sitevalidate()

{	
 			if(document.submit.name.value =='' )
				 {
					  alert("Please enter name");
					  document.submit.name.focus();
					   return false;
				 }
			
			 
				 
				   if(document.submit.email.value =='' )
				 {
					  alert("Please enter email");
					  document.submit.email.focus();
					   return false;
				 }
				 /* E-mail id Validation */
				 
				  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.submit.email.value)){
alert("Please enter  valid e-mail id ");
document.submit.email.focus();
return false;
}
            if(document.submit.url.value =='' )
				 {
					  alert("Please enter url");
					  document.submit.url.focus();
					   return false;
		
				 }
				 
				 
		 
    var v = new RegExp(); 
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"); 
    if (!v.test(document.submit.url.value)) { 
        alert("You must supply a valid url starting with http://."); 
		document.submit.url.focus();
        return false; 
    } 

      
 var v=document.submit;
	 
	 var isError = false;
	 var errorMessage = "";
	
	if (v.logo.value == "") 
	 {
		isError = true;
		alert("Please upload image");
		v.logo.focus();
		return false;
	}
	
		 
	  if (v.logo.value != "") 
	 {
		
		 var strextn=v.logo.value.substring(v.logo.value.lastIndexOf(".")).toUpperCase();
		

		if(strextn !=".JPG" && strextn !=".GIF")
		{
			isError = true;
		 	errorMessage += "\r\nNot a valid file";
			
			
		}
		
		if (isError == true) 
		{
			alert(errorMessage + " \n Only JPG or GIF  images allowed");
			return false;
		}
		
	}
	
	if(document.submit.services.value =='' )
	 {
					  alert("Please enter services");
					  document.submit.services.focus();
					   return false;
     }
				  				 		
				 
}


function ordervalidate()

{	
 			if(document.order.name.value =='' )
				 {
					  alert("Please enter name");
					  document.order.name.focus();
					   return false;
				 }
			
			
			if(document.order.address.value =='' )
				 {
					  alert("Please enter name and address");
					  document.order.address.focus();
					   return false;
				 }
				 
				 if(document.order.yourname.value =='' )
				 {
					  alert("Please enter your name");
					  document.order.yourname.focus();
					   return false;
				 }
				 
				  if(document.order.email.value =='' )
				 {
					  alert("Please enter email");
					  document.order.email.focus();
					   return false;
				 }
				 /* E-mail id Validation */
				 
				  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.order.email.value)){
alert("Please enter  valid e-mail id ");
document.order.email.focus();
return false;
}

        if(document.order.phone.value =='' )
				 {
					  alert("Please enter phone number");
					  document.order.phone.focus();
					   return false;
				 }
			 
			    if(document.order.address1.value =='' )
				 {
					  alert("Please enter address");
					  document.order.address1.focus();
					   return false;
				 }
				 
				 
				 
				   if(document.order.city.value =='' )
				 {
					  alert("Please enter city");
					  document.order.city.focus();
					   return false;
				 }
				 
				    if(document.order.state.selectedIndex == 0 )
				 {
					  alert("Please select state");
					  document.order.state.focus();
					  return false;
				 }
				 
				 
				 
				   if(document.order.zip.value =='' )
				 {
					  alert("Please enter zip");
					  document.order.zip.focus();
					   return false;
				 }
				  

         
              if(document.order.gift.value =='' )
				 {
					  alert("Please enter gift");
					  document.order.gift.focus();
					   return false;
				 }
				 
								 
				
  /*if (!document.order.creditcard[0].checked && !document.order.creditcard[1].checked){

alert("Please Select Visa or Master Card");
return false;
	  }

         if(document.order.cardnumber.value =='' )
				 {
					  alert("Please Enter Card Number");
					  document.order.cardnumber.focus();
					   return false;
				 }
				 

   if(document.order.expire.value =='' )
				 {
					  alert("Please Select Expire Date");
					  document.order.expire.focus();
					   return false;
				 }
				
*/

              if(document.order.services.value =='' )
				 {
					  alert("Please enter services");
					  document.order.services.focus();
					   return false;
				 }
       
			
				
								
				
				 
}


function checkAll(checkname, exby) {
  for (i = 0; i < checkname.length; i++)
  checkname[i].checked = exby.checked? true:false
}

function Check(chk)
{
if(document.order.Check_ctr.checked==true){
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}else{

for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}
}
function chkDate(input)
{
	var validformat=/^\d{2}\/\d{2}\/\d{4}$/
	var returnval=false
	if (!validformat.test(input.value))
		alert("Please check date formate")
	else
	{
		var monthfield=input.value.split("/")[0]
		var dayfield=input.value.split("/")[1]
		var yearfield=input.value.split("/")[2]
		var dayobj = new Date(yearfield, monthfield-1, dayfield)
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
			alert("Invalid Day, Month, or Year range detected. Please check")
		else
			returnval=true
	}
	if (returnval==false) 
		input.focus()
	return returnval
}


function volunteervalidate()

{	
				
             
				    if(document.order.volunteer.selectedIndex == 0 )
				 {
					  alert("Please select how did u hear about crisis control");
					  document.order.volunteer.focus();
					  return false;
				 }
				 
				  var v=window.document.order;
				 
				 	 if(v.volunteer.value == 'others')
	{
				 
				 
				 if(document.order.others.value =='' )
				 {
					  alert("Please enter others ");
					  document.order.others.focus();
					   return false;
				 }
				 
	}
				 
				 
				  
				if (!document.order.places[0].checked && !document.order.places[1].checked){

alert("Please click in which place would you like to become volunteer");
return false;
}

   if (!document.order.ccm[0].checked && !document.order.ccm[1].checked){

alert("Please click either yes or no Have you ever been a ccm client");
return false;
}
         
		 if (document.order.ccm[0].checked){

           
 			if(document.order.yes.value =='' )
				 {
					  alert("Please enter if it is yes");
					  document.order.yes.focus();
					   return false;
				 }
}
		  
		  if (!document.order.volunteerdir[0].checked && !document.order.volunteerdir[1].checked){

alert("Please click either yes or no Would you like to be included in our volunteer directory ");
return false;
}
      
		  if (!document.order.ccmweekly[0].checked && !document.order.ccmweekly[1].checked){

alert("Please click either yes or no Would you like to recieve ccm's weekly e-mail newsletter  ");
return false;
}
		  
		   if(document.order.salutation.selectedIndex == 0 )
				 {
					  alert("Please select salutation");
					  document.order.salutation.focus();
					  return false;
				 }
		  
 			if(document.order.name.value =='' )
				 {
					  alert("Please enter name");
					  document.order.name.focus();
					   return false;
				 }
			
			if(document.order.email.value =='' )
				 {
					  alert("Please enter email");
					  document.order.email.focus();
					   return false;
				 }
				 /* E-mail id Validation */
				 
				  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.order.email.value)){
alert("Please enter  valid e-mail id ");
document.order.email.focus();
return false;
}

    if(document.order.phone.value =='' )
				 {
					  alert("Please enter phone");
					  document.order.phone.focus();
					   return false;
				 }
				 
				   if(document.order.work.value =='' )
				 {
					  alert("Please enter work phone");
					  document.order.work.focus();
					   return false;
				 }
			if(document.order.address.value =='' )
				 {
					  alert("Please enter address");
					  document.order.address.focus();
					   return false;
				 }
				 
				 
				 
				   if(document.order.city.value =='' )
				 {
					  alert("Please enter city");
					  document.order.city.focus();
					   return false;
				 }
				 
				  				 
				 if(document.order.state.selectedIndex == 0 )
				 {
					  alert("Please select state");
					  document.order.state.focus();
					  return false;
				 }
				 
				 
				   if(document.order.zip.value =='' )
				 {
					  alert("Please enter zip");
					  document.order.zip.focus();
					   return false;
				 }
				 
				 if(document.order.DOB.value =='' )
				 {
					  alert("Please enter birth date");
					  document.order.DOB.focus();
					   return false;
				 }
				else
				{
						if(!chkDate(document.order.DOB))
							return false
				}
				 
				 
				 
				 /* if(document.order.presentoccupation.value =='' )
				 {
					  alert("Please Enter Present Occupation  ");
					  document.order.presentoccupation.focus();
					   return false;
				 }
				 */
				
				 
				 	 
				 if(document.order.emergencyname.value =='' )
				 {
					  alert("Please enter emergency name");
					  document.order.emergencyname.focus();
					   return false;
				 }
			 
			 
			     if(document.order.emergencyphone.value =='' )
				 {
					  alert("Please enter emergency phone");
					  document.order.emergencyphone.focus();
					   return false;
				 }
			 
			 
			       if(document.order.emergencyrelation.value =='' )
				 {
					  alert("Please enter emergency relation");
					  document.order.emergencyrelation.focus();
					   return false;
				 }
				 
				  
			 
			 
			   
				 
			 
			     if(document.order.preferedhospital.value =='' )
				 {
					  alert("Please enter prefered hospital");
					  document.order.preferedhospital.focus();
					   return false;
				 }
			 
			 
			   /* if(document.order.physicianphone.value =='' )
				 {
					  alert("Please Enter Physician Phone Number");
					  document.order.physicianphone.focus();
					   return false;
				 }
			 */
   			    if(document.order.medical.value =='' )
				 {
					  alert("Please enter If you have any medical conditions,medications,allergies");
					  document.order.medical.focus();
					   return false;
				 }
				 
				 
		 /* if (!document.order.veteran[0].checked && !document.order.veteran[1].checked){

alert("Please click either Yes or No whether your a Veteran");
return false;
}
			
			 if (!document.order.secondlanguage[0].checked && !document.order.secondlanguage[1].checked){

alert("Please click either Yes or No whether you have Second Language");
return false;
}*/
				
				if(document.order.secondlanguage[0].checked){

           
 			if(document.order.yes12.value =='' )
				 {
					  alert("Please enter second language");
					  document.order.yes12.focus();
					   return false;
				 }
}
				
			 if (!document.order.computerskills[0].checked && !document.order.computerskills[1].checked){

alert("Please click either yes or no whether you have computer skills");
return false;
}
						 
             
				
				 
				 
				  if(document.order.aboutyou.value =='' )
				 {
					  alert("Please enter if you have special interests,hobbies,talent");
					  document.order.aboutyou.focus();
					   return false;
				 }
				 
				 
				 
				 if(document.order.referencesname1.value =='' )
				 {
					  alert("Please enter reference name1");
					  document.order.referencesname1.focus();
					   return false;
				 }
				 
				    if(document.order.referencesemail1.value =='' )
				 {
					  alert("Please enter references email1");
					  document.order.referencesemail1.focus();
					   return false;
				 }
				 /* E-mail id Validation */
				 
				  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.order.referencesemail1.value)){
alert("Please enter  valid e-mail id for reference1 ");
document.order.referencesemail1.focus();
return false;
}
				 
				 
				 
				 if(document.order.referencesphone1.value =='' )
				 {
					  alert("Please enter reference phone1");
					  document.order.referencesphone1.focus();
					   return false;
				 }
				 
				 
				 
               if(document.order.referencesname2.value =='' )
				 {
					  alert("Please enter reference name2");
					  document.order.referencesname2.focus();
					   return false;
				 }
				 
				    if(document.order.referencesemail2.value =='' )
				 {
					  alert("Please enter references email2");
					  document.order.referencesemail2.focus();
					   return false;
				 }
				 /* E-mail id Validation */
				 
				  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.order.referencesemail2.value)){
alert("Please enter  valid e-mail id for reference2 ");
document.order.referencesemail2.focus();
return false;
}
				 
				 
				 if(document.order.referencesphone2.value =='' )
				 {
					  alert("Please enter reference phone2");
					  document.order.referencesphone2.focus();
					   return false;
				 }
				 
				 
				 

 if (document.order.certifyinfo.checked == false){
alert ("By clicking here, i certify that i have read,understand and agree to abide by the statements above");
return false;
}      				 
			 
}


 function codename() {

if(document.order.money[1].checked)
{
document.order.cardnumber.disabled=false;
document.order.expire.disabled=false;
document.order.creditcard[0].disabled=false;
document.order.creditcard[1].disabled=false;
}

}

function codename1() {

if(document.order.money[0].checked)
{
document.order.cardnumber.enabled=true;
document.order.expire.enabled=true;
document.order.creditcard[0].enabled=true;
document.order.creditcard[1].enabled=true;
}

}


function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}

function enableField()
{
if (document.order.money[1].checked == true){
document.order.cardnumber.disabled=false;
document.order.expire.disabled=false;
document.order.creditcard[0].disabled=false;
document.order.creditcard[1].disabled=false;
}else {
document.order.cardnumber.disabled=true;
document.order.expire.disabled=true;
document.order.creditcard[0].disabled=true;
document.order.creditcard[1].disabled=true;
}
} 



function cropvalidate()

{	
 			if(document.cropwalk.congregationgroup.value =='' )
				 {
					  alert("Please enter congregation group");
					  document.cropwalk.congregationgroup.focus();
					   return false;
				 }
			
			if(document.cropwalk.recruiterName.value =='' )
				 {
					  alert("Please enter recruiter name");
					  document.cropwalk.recruiterName.focus();
					   return false;
				 }
				 
				  if(document.cropwalk.emailid.value =='' )
				 {
					  alert("Please enter email");
					  document.cropwalk.emailid.focus();
					   return false;
				 }
				 /* E-mail id Validation */
				 
				  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.cropwalk.emailid.value)){
alert("Please enter  valid e-mail id ");
document.cropwalk.emailid.focus();
return false;
}
			
         if(document.cropwalk.recruiterPhonenumber.value =='' )
				 {
					  alert("Please enter recruiter phone number");
					  document.cropwalk.recruiterPhonenumber.focus();
					   return false;
				 }
             
			   
			
			if(document.cropwalk.address.value =='' )
				 {
					  alert("Please enter address");
					  document.cropwalk.address.focus();
					   return false;
				 }
				 
						 
				 
				 
				   if(document.cropwalk.city.value =='' )
				 {
					  alert("Please enter city");
					  document.cropwalk.city.focus();
					   return false;
				 }
				 
				    if(document.cropwalk.state.selectedIndex == 0 )
				 {
					  alert("Please select state");
					  document.cropwalk.state.focus();
					  return false;
				 }
				 
				 
				 
				   if(document.cropwalk.zip.value =='' )
				 {
					  alert("Please enter zip");
					  document.cropwalk.zip.focus();
					   return false;
				 }
				

         
			 
}



function rvspvalidate()

{	
 			if(document.rvsp.name.value =='' )
				 {
					  alert("Please enter name");
					  document.rvsp.name.focus();
					   return false;
				 }
			
			
			   
				 
				   if(document.rvsp.email.value =='' )
				 {
					  alert("Please enter email");
					  document.rvsp.email.focus();
					   return false;
				 }
				 /* E-mail id Validation */
				 
				  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.rvsp.email.value)){
alert("Please enter  valid e-mail id ");
document.rvsp.email.focus();
return false;
}
				 
				
				 
}
function valid()
{
	var v = document.form1
	if(v.amount.value=="")
	 {
		  alert("Please Enter Amount");
		  v.amount.focus();
		  return false;
	 }
}