function checkForm()
{
    var fname,lname,email,phone,abox,bbox,cbox,dbox,ebox,fbox,gbox,hbox,nbox,mbox,obox,pbox,qbox,rbox,prbox,hcbox,aperson,bperson,cperson,dperson,eperson,fperson,gperson,hperson,nperson,mperson,operson,pperson,qperson,rperson,prperson,hcperson,sbox,sperson;
      
    fname    = document.confirm.txt_fname;
    lname    = document.confirm.txt_lname;
    email    = document.confirm.txt_email;
   	phone	= document.confirm.txt_phone;
   	
   	abox	= document.confirm.abox;
   	bbox	= document.confirm.bbox;
   	cbox	= document.confirm.cbox;
   	dbox	= document.confirm.dbox;
   	ebox	= document.confirm.ebox;
   	fbox	= document.confirm.fbox;
   	gbox	= document.confirm.gbox;
   	hbox	= document.confirm.hbox;
   	nbox	= document.confirm.nbox;
   	mbox	= document.confirm.mbox;
   	obox	= document.confirm.obox;
   	pbox	= document.confirm.pbox;
   	qbox	= document.confirm.qbox;
   	rbox	= document.confirm.rbox;
   	prbox	= document.confirm.prbox;
   	hcbox	= document.confirm.hcbox;	
		sbox	= document.confirm.sbox;
   	
   	aperson	= document.confirm.aperson;
   	bperson	= document.confirm.bperson;
   	cperson	= document.confirm.cperson;
   	dperson	= document.confirm.dperson;
   	eperson	= document.confirm.eperson;
   	fperson	= document.confirm.fperson;
   	gperson	= document.confirm.gperson;
   	hperson	= document.confirm.hperson;
   	nperson	= document.confirm.nperson;
   	mperson	= document.confirm.mperson;
   	operson	= document.confirm.operson;
   	pperson	= document.confirm.pperson;
   	qperson	= document.confirm.qperson;
   	rperson	= document.confirm.rperson;
   	prperson	= document.confirm.prperson;
   	hcperson	= document.confirm.hcperson;
	sperson	= document.confirm.sperson;
   	
   	cname 	= document.confirm.txt_cname;
   	ccontact = document.confirm.txt_ccontact;
   	cemail	= document.confirm.txt_cemail;
   	gfname	= document.confirm.txt_gfname;
   	glname	= document.confirm.txt_glname;
   	   	
    
   	if ((!abox.checked) && (!bbox.checked) && (!cbox.checked) && (!dbox.checked) && (!ebox.checked) && (!gbox.checked)  && (!hbox.checked)  && (!nbox.checked)  && (!mbox.checked) && (!obox.checked) && (!pbox.checked) && (!qbox.checked) && (!rbox.checked) && (!fbox.checked) && (!prbox.checked) && (!hcbox.checked) && (!sbox.checked)){
   		alert('Please select a service type')
   		return false;
   	}
   	else if(!IsNumeric(trim(aperson.value)))
    {
        alert('No. of persons for Airport Transfer is not valid');
        aperson.focus();
        return false;
    }
    else if(!IsNumeric(trim(bperson.value)))
    {
        alert('No. of persons for Legend Golf Course is not valid');
        bperson.focus();
        return false;
    }
    else if(!IsNumeric(trim(cperson.value)))
    {
        alert('No. of persons for Links Golf Course is not valid');
        cperson.focus();
        return false;
    }
    else if(!IsNumeric(trim(dperson.value)))
    {
        alert('No. of persons for Babysitting Service is not valid');
        dperson.focus();
        return false;
    }
   	else if(!IsNumeric(trim(eperson.value)))
    {
        alert('No. of persons for Early Check-in is not valid');
        eperson.focus();
        return false;
    }	
    else if(!IsNumeric(trim(gperson.value)))
    {
        alert('No. of persons for Laptop Rental is not valid');
        gperson.focus();
        return false;
    }
    else if(!IsNumeric(trim(hperson.value)))
    {
        alert('No. of persons for Les Petits Princes is not valid');
        hperson.focus();
        return false;
    }
    else if(!IsNumeric(trim(nperson.value)))
    {
        alert('No. of persons for Guerlain is not valid');
        nperson.focus();
        return false;
    }
    else if(!IsNumeric(trim(mperson.value)))
    {
        alert('No. of persons for Golf Academy is not valid');
        mperson.focus();
        return false;
    }
    else if(!IsNumeric(trim(operson.value)))
    {
        alert('No. of persons for Kite Surf is not valid');
        operson.focus();
        return false;
    }
    else if(!IsNumeric(trim(pperson.value)))
    {
        alert('No. of persons for Newspaper Direct is not valid');
        pperson.focus();
        return false;
    }
    else if(!IsNumeric(trim(qperson.value)))
    {
        alert('No. of persons for Bodydoctor fitness is not valid');
        qperson.focus();
        return false;
    }
    else if(!IsNumeric(trim(rperson.value)))
    {
        alert('No. of persons for Restaurant Booking is not valid');
        rperson.focus();
        return false;
    }
    else if(!IsNumeric(trim(fperson.value)))
    {
        alert('No. of persons for Special Requests is not valid');
        fperson.focus();
        return false;
    }
	else if(!IsNumeric(trim(prperson.value)))
    {
        alert('No. of persons for Special Requests is not valid');
        fperson.focus();
        return false;
    }
	else if(!IsNumeric(trim(hcperson.value)))
    {
        alert('No. of persons for Special Requests is not valid');
        fperson.focus();
        return false;
    }
	else if(!IsNumeric(trim(sperson.value)))
    {
        alert('No. of persons for La Terasse VIP Lounge is not valid');
        fperson.focus();
        return false;
    }
    else if (!document.confirm.account[0].checked && !document.confirm.account[1].checked){
    	alert('Please select an account type: Guest or Travel Agent');
    	return false;
    }
    else if (document.confirm.account[0].checked){
    	if(trim(fname.value) == '')
	    {
	        alert('Please enter your first name');
	        fname.focus();
	        return false;
	    }
	    else if(trim(lname.value) == '')
	    {
	        alert('Please enter your last name');
	        lname.focus();
	        return false;
	    }
	      else if(trim(email.value) == '')
	    {
	        alert('Please enter your email address');
	        email.focus();
	        return false;
	    }
	    else if(!isEmail(trim(email.value)))
	    {
	        alert('Email address is not valid');
	        email.focus();
	        return false;
	    }
    }
    else if (document.confirm.account[1].checked){
    	if(trim(cname.value) == '')
	    {
	        alert('Please enter your company name');
	        cname.focus();
	        return false;
	    }
	    else if(trim(ccontact.value) == '')
	    {
	        alert('Please enter your company contact details');
	        ccontact.focus();
	        return false;
	    }
	    else if(trim(cemail.value) == '')
	    {
	        alert('Please enter your company email address');
	        cemail.focus();
	        return false;
	    }
	    else if(!isEmail(trim(cemail.value)))
	    {
	        alert('Email address is not valid');
	        cemail.focus();
	        return false;
	    }
	    else if(trim(gfname.value) == '')
	    {
	        alert('Please enter your guest first name');
	        gfname.focus();
	        return false;
	    }
	    else if(trim(glname.value) == '')
	    {
	        alert('Please enter your guest last name');
	        glname.focus();
	        return false;
	    }
	    
    }
   	    
        
    else
    {
        var answer=confirm('Are you sure you want to proceed?');
        if (!answer){
        	return false;}
        	else
        	{
    	fname.value = trim(fname.value);
        lname.value = trim(lname.value);
        email.value = trim(email.value);
        cname.value = trim(cname.value);
        ccontact.value = trim(ccontact.value);
        cemail.value = trim(cemail.value);
        gfname.value = trim(gfname.value);
        glname.value = trim(glname.value);
        return true;}
    }
    
    
}

/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
    return str.replace(/^\s+|\s+$/g,'');
}

/*
Check if a string is in valid email format. 
Returns true if valid, false otherwise.
*/
function isEmail(str)
{
    var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
    return regex.test(str);
}

function confirmReset(){
	var answer=confirm('Are you sure that you want to reset the form?');
	if(!answer){
		return false;}
		else{
			return true;}
}


function IsNumeric(sText)


{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
 
 }
 

   
 