// FORM VALIDATION Starts


// ZUROSMAK.com

function check()
{
//alert('Please enter your Name');
//return false;
if (document.booknow_form.txt_name.value == '') {
alert('Please enter your Name');
document.booknow_form.txt_name.focus();
	return false;
}
if (document.booknow_form.txt_surname.value == '') {
alert('Please enter your Surname');
document.booknow_form.txt_surname.focus();
	return false;
}

if (document.booknow_form.txt_adress.value == '') {
alert('Please enter your Address');
document.booknow_form.txt_adress.focus();

	return false;
}

if (document.booknow_form.sl_city.options[document.booknow_form.sl_city.selectedIndex].text=="Select")
{
    
    alert('Please select your City');
    document.booknow_form.sl_city.focus();
	return false;
}
if (document.booknow_form.sl_country.options[document.booknow_form.sl_country.selectedIndex].text=="Select")
{
    
    alert('Please select your Country');
    document.booknow_form.sl_country.focus();
	return false;
}

if (document.booknow_form.txt_phone_code.value == '') {
alert('Please enter your Phone Code');
document.booknow_form.txt_phone_code.focus();

	return false;
}
var pcodeNumber = document.booknow_form.txt_phone_code.value

for(i=0 ; i<pcodeNumber.length ; i++)
		{
			var c = pcodeNumber.charAt(i);
			if((c <'0' || c>'9'))
			{
				alert("Phone number can only be numeric");
				document.booknow_form.txt_phone_code.value="";
				document.booknow_form.txt_phone_code.focus();
				return false;
			}
		}


if (document.booknow_form.txt_phone.value == '') {
alert('Please enter your Phone');
document.booknow_form.txt_phone.focus();

	return false;
}
var mobileNumber = document.booknow_form.txt_phone.value

for(i=0 ; i<mobileNumber.length ; i++)
		{
			var c = mobileNumber.charAt(i);
			if((c <'0' || c>'9'))
			{
				alert("Phone number can only be numeric");
				document.booknow_form.txt_phone.value="";
				document.booknow_form.txt_phone.focus();
				return false;
			}
		}

if (document.booknow_form.txt_email.value == '') {
alert('Please enter your Email');
document.booknow_form.txt_email.focus();

	return false;
}
if (!emailCheck(document.booknow_form.txt_email.value))
{
document.booknow_form.txt_email.value="";
document.booknow_form.txt_email.focus();
return false ;
}

if (document.booknow_form.txt_datetobook.value == '') {
alert('Please enter Date');
document.booknow_form.txt_datetobook.focus();

	return false;
}
return true;
}
//mail
function emailCheck (emailStr) 
{
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null) {
alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}


if (user.match(userPat)==null) {


alert("The Email ID doesn't seem to be valid.");
return false;
}

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {


for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}

 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}



if (len<2) {
alert("This address is missing a hostname!");
return false;
}


return true;
}
// FORM VALIDATION ENDS

//visibility scripts


                        function showState(chosen)
                        {
                            
                            if (chosen.value == 'United States')
                            {
                                
                                document.booknow_form.state_select.style.visibility  = 'visible';
                                document.booknow_form.state.style.visibility  = 'hidden';
                                document.booknow_form.state.value  = '';
                              
                            } 
                            else
                            {
                                document.booknow_form.state_select.style.visibility  = 'hidden';
                                document.booknow_form.state.style.visibility  = 'visible';
                                document.booknow_form.state.value  = '';
                            }
                        }
                        function setState(chosenst)
                        {
                            
                           document.booknow_form.state.value=chosenst.value;
                           
                        }
                        function disablePjmethod(chosenpj)
                        {//.options[document.booknow_form.country.selectedIndex].text=="Select"
                           if(chosenpj.options[chosenpj.selectedIndex].text=="Market Research")
                           {
                            document.booknow_form.pjct_method.disabled=false;
                           }
                           else
                           {
                            document.booknow_form.pjct_method.disabled=true;
                           }
                           
                        }
                        