<!--

//prints messages
function PrintMesg(ctrlvar,mesg)
{ alert(mesg); ctrlvar.focus(); return false }

// function to check spaces
function SpaceChk(ctrlvar)
{
   chkstr     = ctrlvar.value
   stlength   = chkstr.length
   spacecount = 0
   if (stlength >0)  {
    for(i=0;i<=stlength;i++)
     if ( chkstr.charAt(i)==" ") { spacecount=spacecount+1  }
    if (stlength == spacecount) { return false }
   return true }
}
//-->
function Validate()
{
	 // Declaring required variables
	var digits = "0123456789";
	// non-digit characters which are allowed in phone numbers
	var phoneNumberDelimiters = "()- ";
	// characters which are allowed in international phone numbers
	// (a leading + is OK)
	var validWorldPhoneChars = phoneNumberDelimiters + "+";
	// Minimum no of digits in an international phone no.
	var minDigitsInIPhoneNumber = 8;
	
	function isInteger(s)
	{
		var i;
		for (i = 0; i < s.length; i++)
		{   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		// All characters are numbers.
		return true;
	}
	
	function stripCharsInBag(s, bag)
	{
		var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < s.length; i++){   
			var c = s.charAt(i);
			if (bag.indexOf(c) == -1) returnString += c;
		}
		return returnString;
	}
	
	function checkInternationalPhone(strPhone)
	{
		s=stripCharsInBag(strPhone,validWorldPhoneChars);
		return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
	}	
	
	//------------------- Sender firstname -------------------
	if ( document.frmEmail.firstname.value == ""  )
	   {if (!(PrintMesg(document.frmEmail.firstname,"Please enter First Name.")))
	   {return false;}}
	 else  { 
	   if (!SpaceChk(document.frmEmail.firstname))
		{if (!(PrintMesg(document.frmEmail.firstname,"Please enter First Name other than space")))
		{return false;}}
	}
	//------------------- Sender lastname -------------------
	if ( document.frmEmail.lastname.value == ""  )
	   {if (!(PrintMesg(document.frmEmail.lastname,"Please enter Last Name.")))
	   {return false;}}
	 else  { 
	   if (!SpaceChk(document.frmEmail.lastname))
		{if (!(PrintMesg(document.frmEmail.lastname,"Please enter the Last Name other than space")))
		{return false;}}
	}


	//-------------------- phone1----------
	phone1 = document.frmEmail.phone1.value
 	if (phone1  == "")
    {if (!(PrintMesg(document.frmEmail.phone1,"Please enter The Phone No (business hour)")))
	{return false;}}
		
	if (checkInternationalPhone(phone1)==false)
	{
		alert("Please Enter a Valid Phone Number (business hour). Eg. 0242223333");
		phone1="";
		document.frmEmail.phone1.focus();
		return false;
	}
	
	//-------------------- phone2----------
	/*phone2 = document.frmEmail.phone2.value
 	if (phone2  == "")
    {if (!(PrintMesg(document.frmEmail.phone2,"Please enter The Phone No (after hour)")))
	{return false;}}
		
	if (checkInternationalPhone(phone2)==false)
	{
		alert("Please Enter a Valid Phone Number (after hour)");
		phone2="";
		document.frmEmail.phone2.focus();
		return false;
	}
	*/
	//-------------------- email----------
	mail = document.frmEmail.email.value
	if (mail  == "")
	{
		if (!(PrintMesg(document.frmEmail.email,"Please enter From Email address")))
		{	return false;	}
	}
	else { 
		n = mail.indexOf("@")
	   	if (n >= 0)
	   	{ 
			newstr = mail.substring(n)
		 	n= newstr.indexOf(".")
		 	if (n<0)
			{
				if (!(PrintMesg(document.frmEmail.email,"Enter a valid E-mail Address")))
				{	return false;	}
			}
	   	} 
	   	else
		{
			if (!(PrintMesg(document.frmEmail.email,"Enter a valid E-mail Address")))
			{	return false;	}
		}
	}
	
	//---------Address
	/*if ( document.frmEmail.address.value == ""  )
	   {if (!(PrintMesg(document.frmEmail.address,"Please enter Address.")))
	   {return false;}}
	 else  { 
	   if (!SpaceChk(document.frmEmail.address))
		{if (!(PrintMesg(document.frmEmail.address,"Please enter the Address other than space")))
		{return false;}}
	}*/

	//------------------Message -------------------
	if ( document.frmEmail.message.value == ""  )
	   {if (!(PrintMesg(document.frmEmail.message,"Please enter  Message.")))
	   {return false;}}
	 else  { 
	   if (!SpaceChk(document.frmEmail.message))
		{if (!(PrintMesg(document.frmEmail.message,"Please enter the  Message other than space")))
		{return false;}}
	}

		//-------------------- verification image----------
	secretCode = document.frmEmail.secretCode.value
	ValidateCode = document.frmEmail.ValidateCode.value
    ValidateCode = ValidateCode.toUpperCase( ); 
 	if (secretCode!= ValidateCode)
    {if (!(PrintMesg(document.frmEmail.ValidateCode,"Please enter The right verification code")))
	{return false;}}
	//--------------------------------------
	return true;
}




function Validatefb()
{
	 // Declaring required variables
	var digits = "0123456789";
	// non-digit characters which are allowed in phone numbers
	var phoneNumberDelimiters = "()- ";
	// characters which are allowed in international phone numbers
	// (a leading + is OK)
	var validWorldPhoneChars = phoneNumberDelimiters + "+";
	// Minimum no of digits in an international phone no.
	var minDigitsInIPhoneNumber = 8;
	
	function isInteger(s)
	{
		var i;
		for (i = 0; i < s.length; i++)
		{   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		// All characters are numbers.
		return true;
	}
	
	function stripCharsInBag(s, bag)
	{
		var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < s.length; i++){   
			var c = s.charAt(i);
			if (bag.indexOf(c) == -1) returnString += c;
		}
		return returnString;
	}
	
	function checkInternationalPhone(strPhone)
	{
		s=stripCharsInBag(strPhone,validWorldPhoneChars);
		return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
	}	
	
	//------------------- Sender firstname -------------------
	if ( document.frmEmail.firstname.value == ""  )
	   {if (!(PrintMesg(document.frmEmail.firstname,"Please enter First Name.")))
	   {return false;}}
	 else  { 
	   if (!SpaceChk(document.frmEmail.firstname))
		{if (!(PrintMesg(document.frmEmail.firstname,"Please enter First Name other than space")))
		{return false;}}
	}
	//------------------- Sender lastname -------------------
	 if ( document.frmEmail.lastname.value == ""  )
	   {if (!(PrintMesg(document.frmEmail.lastname,"Please enter Last Name.")))
	   {return false;}}
	 else  { 
	   if (!SpaceChk(document.frmEmail.lastname))
		{if (!(PrintMesg(document.frmEmail.lastname,"Please enter the Last Name other than space")))
		{return false;}}
	}


	//-------------------- phone1----------
	phone1 = document.frmEmail.phone1.value
 	if (phone1  == "")
    {if (!(PrintMesg(document.frmEmail.phone1,"Please enter The Phone No")))
	{return false;}}
		
	if (checkInternationalPhone(phone1)==false)
	{
		alert("Please Enter a Valid Phone Number (business hour). Eg. 0242223333");
		phone1="";
		document.frmEmail.phone1.focus();
		return false;
	}
	

	//-------------------- email----------
 	mail = document.frmEmail.email.value
	if (mail  == "")
	{
		if (!(PrintMesg(document.frmEmail.email,"Please enter From Email address")))
		{	return false;	}
	}
	else { 
		n = mail.indexOf("@")
	   	if (n >= 0)
	   	{ 
			newstr = mail.substring(n)
		 	n= newstr.indexOf(".")
		 	if (n<0)
			{
				if (!(PrintMesg(document.frmEmail.email,"Enter a valid E-mail Address")))
				{	return false;	}
			}
	   	} 
	   	else
		{
			if (!(PrintMesg(document.frmEmail.email,"Enter a valid E-mail Address")))
			{	return false;	}
		}
	}
	

	
	//------------------Host Family Address -------------------
 if ( document.frmEmail.hostFamilyAddress.value == ""  )
	   {if (!(PrintMesg(document.frmEmail.hostFamilyAddress,"Please enter  Host Family Address.")))
	   {return false;}}
	 else  { 
	   if (!SpaceChk(document.frmEmail.hostFamilyAddress))
		{if (!(PrintMesg(document.frmEmail.hostFamilyAddress,"Please enter the  Host Family Address other than space")))
		{return false;}}
	}

	//------------------feedback -------------------
/*	if ( document.frmEmail.feedback.value == ""  )
	   {if (!(PrintMesg(document.frmEmail.feedback,"Please select a feedback type.")))
	   {return false;}}

	}*/
	//------------------details -------------------
	if ( document.frmEmail.details.value == ""  )
	   {if (!(PrintMesg(document.frmEmail.details,"Please enter  feedback details.")))
	   {return false;}}
	 else  { 
	   if (!SpaceChk(document.frmEmail.details))
		{if (!(PrintMesg(document.frmEmail.details,"Please enter the  feedback details other than space")))
		{return false;}}
	}

		//-------------------- verification image----------
	secretCode = document.frmEmail.secretCode.value
	ValidateCode = document.frmEmail.ValidateCode.value
    ValidateCode = ValidateCode.toUpperCase( ); 
 	if (secretCode!= ValidateCode)
    {if (!(PrintMesg(document.frmEmail.ValidateCode,"Please enter The right verification code")))
	{return false;}}
	//--------------------------------------
	return true;
} 





function Validate_Step1()
{
	
	//------------------- from field -------------------
	if ( document.form1.familyName.value == ""  )
	   {if (!(PrintMesg(document.form1.familyName,"Please enter your Family Name.")))
	   {return false;}}
	//------------------- from field -------------------
	if ( document.form1.otherName.value == ""  )
	   {if (!(PrintMesg(document.form1.otherName,"Please enter your Given Name.")))
	   {return false;}}

	    //------------------- from field -------------------
 	var sex;
	sex=0;
      for(i=0;i<document.form1.sex.length;i++)
       {
	   if ( document.form1.sex[i].checked)
	   {sex=1;}
	   }
	  if (sex==0)
	   {alert("Please select Gender.")
	    return false;} 
		
			    //------------------- from field -------------------
 	var marital;
	marital=0;
      for(i=0;i<document.form1.marital.length;i++)
       {
	   if ( document.form1.marital[i].checked)
	   {marital=1;}
	   }
	  if (marital==0)
	   {alert("Please select Marital Status.")
	    return false;} 
			//------------------- from field -------------------
	if ( document.form1.nationality.value == ""  )
	   {if (!(PrintMesg(document.form1.nationality,"Please enter your Nationality.")))
	   {return false;}}
	     //------------------- from field -------------------
 	var dobDay;
	dobDay=0;
      for(i=1;i<document.form1.dobDay.length;i++)
       {
	   if ( document.form1.dobDay[i].selected)
	   {dobDay=1; }
	   }
	  if (dobDay==0)
	   {alert("Please select the Day of your birth.")
	    return false;} 
				     //------------------- from field -------------------
 	var dobMonth;
	dobMonth=0;
      for(i=1;i<document.form1.dobMonth.length;i++)
       {
	   if ( document.form1.dobMonth[i].selected)
	   {dobMonth=1; }
	   }
	  if (dobMonth==0)
	   {alert("Please select the Month of your birth.")
	    return false;} 
		   //------------------- from field -------------------
 	var dobYear;
	dobYear=0;
      for(i=1;i<document.form1.dobYear.length;i++)
       {
	   if ( document.form1.dobYear[i].selected)
	   {dobYear=1; }
	   }
	  if (dobYear==0)
	   {alert("Please select the Year of your birth.")
	    return false;} 
		
		//------------------- from field -------------------
	if ( document.form1.firstLang.value == ""  )
	   {if (!(PrintMesg(document.form1.firstLang,"Please enter your First Language.")))
	   {return false;}}
	    //------------------- from field -------------------
/* 	var whereToStudy;
	whereToStudy=0;
      for(i=1;i<document.form1.whereToStudy.length;i++)
       {
	   if ( document.form1.whereToStudy[i].selected)
	   {whereToStudy=1; }
	   }
	  if (whereToStudy==0)
	   {alert("Please select Where do you intend to study.")
	    return false;} */
	//--------------------------------------
	return true;
}

function Validate_Step2()
{
	
			//------------------- from field -------------------
	if ( document.form1.email.value == ""  )
	   {if (!(PrintMesg(document.form1.email,"Please enter your Email.")))
	   {return false;}}
		//------------------- from field -------------------
	if ( document.form1.phone.value == ""  )
	   {if (!(PrintMesg(document.form1.phone,"Please enter your Telephone Number.")))
	   {return false;}}
	   	//------------------- from field -------------------
	if ( document.form1.name2.value == ""  )
	   {if (!(PrintMesg(document.form1.name2,"Please enter your Emergency Contact Name.")))
	   {return false;}}
	   //------------------- from field -------------------
	if ( document.form1.email2.value == ""  )
	   {if (!(PrintMesg(document.form1.phone2,"Please enter your Emergency Contact Email.")))
	   {return false;}}
	   	//------------------- from field -------------------
	if ( document.form1.phone2.value == ""  )
	   {if (!(PrintMesg(document.form1.phone2,"Please enter your Emergency Contact Telephone.")))
	   {return false;}}


	//--------------------------------------
	return true;
}
function Validate_Step3()
{
	
	
	       //------------------- from field -------------------
	var liveWithOther;
	liveWithOther=0;
      for(i=0;i<document.form1.liveWithOther.length;i++)
       {
	   if ( document.form1.liveWithOther[i].checked)
	   {liveWithOther=1;}
	   }
	  if (liveWithOther==0)
	 
	   {alert("Are you prepared to live in a household with another student from your country? Please select.")
	   return false;}
	
	       //------------------- from field -------------------
	var liveWithChildren;
	liveWithChildren=0;
      for(i=0;i<document.form1.liveWithChildren.length;i++)
       {
	   if ( document.form1.liveWithChildren[i].checked)
	   {liveWithChildren=1;}
	   }
	  if (liveWithChildren==0)
	 
	   {alert("Are you prepared to live in a household with children? Please select.")
	   return false;}
	    //------------------- from field -------------------
	var liveWithPets;
	liveWithPets=0;
      for(i=0;i<document.form1.liveWithPets.length;i++)
       {
	   if ( document.form1.liveWithPets[i].checked)
	   {liveWithPets=1;}
	   }
	  if (liveWithPets==0)
	 
	   {alert("Are you prepared to live in a household with pets? Please select.")
	   return false;}


	//--------------------------------------
	return true;
}

function Validate_Step4()
{
	
	
	       //------------------- from field -------------------
	var smoke;
	smoke=0;
      for(i=0;i<document.form1.smoke.length;i++)
       {
	   if ( document.form1.smoke[i].checked)
	   {smoke=1;}
	   }
	  if (smoke==0)
	 
	   {alert("Do you smoke? Please select.")
	   return false;}
	   
	          //------------------- from field -------------------
	var requireTransport;
	requireTransport=0;
      for(i=0;i<document.form1.requireTransport.length;i++)
       {
	   if ( document.form1.requireTransport[i].checked)
	   {requireTransport=1;}
	   }
	  if (requireTransport==0)
	 
	   {alert("On your arrival, do you require transport from Sydney Airport? Please select.")
	   return false;}
	


	//--------------------------------------
	return true;
}


function Validate_Step5()
{
	
	
	       //------------------- from field -------------------
	var terms;
	terms=0;
   
	   if ( document.form1.terms.checked)
	   {terms=1;}
	  if (terms==0)
	 
	   {alert("You have to agree our Terms & Conditions.")
	   return false;}
	
	//--------------------------------------
	return true;
}

function Validate_host()
{
	
		//------------------- from field -------------------
	if ( document.form1.lastName.value == ""  )
	   {if (!(PrintMesg(document.form1.lastName,"Please enter your Family Name.")))
	   {return false;}}
	   	//------------------- from field -------------------
	if ( document.form1.firstName.value == ""  )
	   {if (!(PrintMesg(document.form1.firstName,"Please enter your Given Name.")))
	   {return false;}}
	   

	   

	         	//-------------------- email----------
	mail = document.form1.email.value
	if (mail  == "")
	{
		if (!(PrintMesg(document.form1.email,"Please enter From Email address")))
		{	return false;	}
	}
	else { 
		n = mail.indexOf("@")
	   	if (n >= 0)
	   	{ 
			newstr = mail.substring(n)
		 	n= newstr.indexOf(".")
		 	if (n<0)
			{
				if (!(PrintMesg(document.form1.email,"Enter a valid E-mail Address")))
				{	return false;	}
			}
	   	} 
	   	else
		{
			if (!(PrintMesg(document.frmEmail.email,"Enter a valid E-mail Address")))
			{	return false;	}
		}
	}
	
	  	//------------------- from field -------------------
	if ( document.form1.phone.value == ""  )
	   {if (!(PrintMesg(document.form1.phone,"Please enter your Phone Number.")))
	   {return false;}}
	
	//------------------- from field -------------------
	if ( document.form1.addressLine1.value == ""  )
	   {if (!(PrintMesg(document.form1.addressLine1,"Please enter your Address.")))
	   {return false;}}
	
		//------------------- from field -------------------
	if ( document.form1.city.value == ""  )
	   {if (!(PrintMesg(document.form1.city,"Please enter your City.")))
	   {return false;}}
	   
	   //------------------- from field -------------------
	if ( document.form1.postcode.value == ""  )
	   {if (!(PrintMesg(document.form1.postcode,"Please enter your Postcode.")))
	   {return false;}}
	//--------------------------------------
	return true;
}


function isNumeric(s){if(isNaN(parseFloat(s))) return false; else return true;}

function   IsAlpha(cCheck){               
    return   ((('a'<=cCheck)   &&   (cCheck<='z'))   ||   (('A'<=cCheck)   &&   (cCheck<='Z')))               
  }                                                               
    
function   IsValid(strCheck){   
    for(i=0;i<strCheck.length;i++){   
      cCheck=strCheck.charAt(i);   
      if   (!IsAlpha(cCheck))   return   false;   
    }   
    return   true;   
  }   

