function validate(_form){
	if (trim(_form.fullName.value) == "")
	{
		alert("Please complete your name");
		_form.fullName.focus();
		return false;
	}
	
	if (trim(_form.eventContest.value) == "")
	{
		alert("Please complete the Event/Contest Name");
		_form.eventContest.focus();
		return false;
	}
	if (trim(_form.division.value) == "")
	{
		alert("Please complete your division");
		_form.division.focus();
		return false;
	}
	if (trim(_form.class.value) == "")
	{
		alert("Please complete your class");
		_form.class.focus();
		return false;
	}
	if (trim(_form.contactNumber.value) == "")
	{
		alert("Please complete your contact number");
		_form.contactNumber.focus();
		return false;
	}
	if (trim(_form.contactEmail.value) == "")
	{
		alert("Please complete your contact email");
		_form.contactEmail.focus();
		return false;
	}
	if (!validateEmail(trim(_form.contactEmail.value)))
	{
		alert("Your contact email is invalid");
		_form.contactEmail.focus();
		return false;
	}
	if (trim(_form.hotelInformation.value) == "")
	{
		alert("Please complete the hotel information");
		_form.hotelInformation.focus();
		return false;
	}
	if (trim(_form.numberOfApps.value) == "")
	{
		alert("Please complete the number of applications");
		_form.numberOfApps.focus();
		return false;
	}
	if (trim(_form.appTimesThu.value) == "")
	{
		alert("Please complete the requested appointment times (Thurs.)");
		_form.appTimesThu.focus();
		return false;
	}
	if (trim(_form.appTimesFri.value) == "")
	{
		alert("Please complete the requested appointment times (Fri.)");
		_form.appTimesFri.focus();
		return false;
	}
	if (!_form.satTouchUpYes.checked && !_form.satTouchUpNo.checked)
	{
		alert("Please complete the field Saturday Touch-Up (Yes/No)");
		_form.satTouchUpYes.focus();
		return false;
	}
	if (!_form.makeupYes.checked && !_form.makeupNo.checked)
	{
		alert("Please complete the question Make-Up/Hair (Yes/No)");
		_form.makeupYes.focus();
		return false;
	}
	if (_form.makeupNo.checked && trim(_form.makeupNoText.value) == "")
	{
		alert("Please input the service of Make-Up/Hair");
		_form.makeupNoText.focus();
		return false;
	}
	
	 if (_form.txtCaptcha.value == "")
	{
		alert("Please enter the code for the verify field!");
		_form.txtCaptcha.focus();
		return false;
	}
	
	 if (_form.v.value == "n")
	{
		alert("Please enter the code for the verify field!");
		_form.txtCaptcha.focus();
		return false;
	}
			
	
	
	return true;
};

function trim(instring)
{
    var start = 0;
    var length = instring.length;
    var end = length;
    var stopstart = false;
    var stopend = false;

    for(i = 0; i <= (length + 1)/ 2 ; i++ )
    {
            if (!(stopstart) && (" " == instring.charAt(i)))
                start++;
            else
                stopstart = true;

            if (!(stopend) && (" " == instring.charAt(length - i - 1)))
                 end--;
            else
                stopend = true;
        
            if (stopstart && stopend) break;
    }
    if (start > end) 
        return "";
    else
        return instring.substring(start,end);
}

function validateEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
