// This is the validation for the new forms
// The forms are broken down into 4 steps with partial validation in the first two steps

function RefreshForm(myStep){

//		Fields that need valiadation after the first step 
	if (myStep == "Step2") {
		if("" == document.forms.myform.firstname.value)
			{
				alert("Please enter your first name.");
				document.forms.myform.firstname.focus();
				return false;
			}
		
		if("" == document.forms.myform.lastname.value)
			{
				alert("Please enter your last name.");
				document.forms.myform.lastname.focus();
				return false;
			}
		
		if("" == document.forms.myform.address.value)
			{
				alert("Please enter your address.");
				document.forms.myform.address.focus();
				return false;
			}
			
		if("" == document.forms.myform.city.value)
			{
				alert("Please enter your city.");
				document.forms.myform.city.focus();
				return false;
			}
				
		if("" == document.forms.myform.province.value)
			{
				alert("Please enter your province.");
				document.forms.myform.province.focus();
				return false;
			}
				
		if("" == document.forms.myform.postalcode.value)
			{
				alert("Please enter postal code.");
				document.forms.myform.postalcode.focus();
				return false;
			}				
				
		if("" == document.forms.myform.country.value)
			{
				alert("Please enter your country.");
				document.forms.myform.country.focus();
				return false;
			}



			
// 		Email validation

		if (!checkMail(document.forms.myform.email.value))
			{
   			alert("Please enter a valid email address");
			document.forms.myform.email.focus();
			return false;
		}
		
		if("" == document.forms.myform.AreaCode.value)
			{
				alert("Please enter your area code number.");
				document.forms.myform.AreaCode.focus();
				return false;
			}
			
		}
	
	
	
//		Fields that need validation after the second step

	if (myStep == "Step3") {
		if("" == document.forms.myform.from.value)
			{
				alert("Please enter the city to fly from.");
				document.forms.myform.from.focus();
				return false;
			}
		
		if("" == document.forms.myform.to.value)
			{
				alert("Please enter the city to fly to.");
				document.forms.myform.to.focus();
				return false;
			}
		
		if("" == document.forms.myform.departure.value)
			{
				alert("Please enter your date of departure.");
				document.forms.myform.departure.focus();
				return false;
			}
			
		if("" == document.forms.myform.return_date.value)
			{
				alert("Please enter your date of return.");
				document.forms.myform.return_date.focus();
				return false;
			}
	}

//		Hide/Show the div panels
	document.getElementById("Step1").style.visibility="hidden";
	document.getElementById("Step2").style.visibility="hidden";
	document.getElementById("Step3").style.visibility="hidden";
	document.getElementById("Step4").style.visibility="hidden";
	document.getElementById(myStep).style.visibility="visible";
}



function checkMail(email)
	{	
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;	

		if (filter.test(email)) 
			{		
				return true;	
			}	

	return false;
	}
