
function retrieveCookie( cookieName ) {
/* retrieved in the format
cookieName4=value; cookieName3=value; cookieName2=value; cookieName1=value
only cookies for this domain and path will be retrieved */
var cookieJar = document.cookie.split( "; " );
for( var x = 0; x < cookieJar.length; x++ ) {
var oneCookie = cookieJar[x].split( "=" );
if( oneCookie[0] == escape( cookieName ) ) { return unescape( oneCookie[1] ); }
}
return null;
}

function setCookie( cookieName, cookieValue, lifeTime, path, domain, isSecure ) {
if( !cookieName ) { return false; }
if( lifeTime == "delete" ) { lifeTime = -10; } //this is in the past. Expires immediately.
/* This next line sets the cookie but does not overwrite other cookies.
syntax: cookieName=cookieValue[;expires=dataAsString[;path=pathAsString[;domain=domainAsString[;secure]]]]
Because of the way that document.cookie behaves, writing this here is equivalent to writing
document.cookie = whatIAmWritingNow + "; " + document.cookie; */
document.cookie = escape( cookieName ) + "=" + escape( cookieValue ) +
( lifeTime ? ";expires=" + ( new Date( ( new Date() ).getTime() + ( 1000 * lifeTime ) ) ).toGMTString() : "" ) +
( path ? ";path=" + path : "") + ( domain ? ";domain=" + domain : "") + 
( isSecure ? ";secure" : "");
//check if the cookie has been set/deleted as required
if( lifeTime < 0 ) { if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return false; } return true; }
if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return true; } return false;
}


// JavaScript Document

function validateForm()
{
	var testresult=true;
	
	
	checkMeta();
	if(document.quotForm.arrdate.value=='')
	{
		document.getElementById('quat-name').style.backgroundColor = '#FF0000';
		testresult=false;
	}
	else
		document.getElementById('quat-name').style.backgroundColor = '#FFFFFF';
}



function validate()
{
	var testresult=true;
	
	
	checkMeta();
	if(document.Query.arrdate.value=='')
	{
		document.getElementById('arrdate').style.backgroundColor = '#FF0000';
		testresult=false;
	}
	else
		document.getElementById('arrdate').style.backgroundColor = '#FFFFFF';
	if(document.Query.depdate.value=='')
	{	document.getElementById('depdate').style.backgroundColor = '#FF0000';
		testresult=false;
	}

	else
		document.getElementById('depdate').style.backgroundColor = '#FFFFFF';

	if(document.Query.arrdate.value > document.Query.depdate.value)
	{
		alert('Arrival Date Should not be Greater then Departure date')
		document.Query.depdate.focus;
		testresult=false;
	}

	if(!checkemail())
	{	document.getElementById('email').style.backgroundColor = '#FF0000';
			testresult=false;
	}

	else
		document.getElementById('email').style.backgroundColor = '#FFFFFF';

	if(document.Query.fname.value=='')
{		document.getElementById('fname').style.backgroundColor = '#FF0000';
		testresult=false;
	}

	else
		document.getElementById('fname').style.backgroundColor = '#FFFFFF';
	if(document.Query.city.value=='')
{		document.getElementById('city').style.backgroundColor = '#FF0000';
		testresult=false;
	}

	else
		document.getElementById('city').style.backgroundColor = '#FFFFFF';
	if(!ValidatePhone())
{		document.getElementById('phone').style.backgroundColor = '#FF0000';
		testresult=false;
	}

	else
		document.getElementById('phone').style.backgroundColor = '#FFFFFF';
		
	if(testresult==true)
	{
	
		document.getElementById('tableform').style.visibility="hidden";
		document.getElementById('whenSlowMessage').style.visibility = "visible";
	    document.getElementById('whenSlowMessage').style.display = "block";
		document.Query.action="http://www.visitorissa.in/thanks.php";
		document.Query.submit();
		}
		
}

function checkemail(){
 var str=document.Query.email.value
 var filter=/^.+@.+\..{2,3}$/

 if (filter.test(str))
    testresults=true
 else {
    //alert("Please input a valid email address!")
    testresults=false
}
 return (testresults)

}

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 = 10;

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;
}