//Ajax request 

var createRequest=function() {
 
    try 
	 {
       request = new XMLHttpRequest();
     } 
	 catch (trymicrosoft) 
	 {
       try 
	   {
         request = new ActiveXObject("Msxml2.XMLHTTP");
       } 
	   catch (othermicrosoft) 
	   {
         try 
		 {
           request = new ActiveXObject("Microsoft.XMLHTTP");
         }
		 catch (failed) 
		 {
           request = null;
         }
       }
	   
     }

     if (request == null)
       alert("Error creating request object!");
   }


  //Check empty and white spaces

   var whitespace = " \t\n\r";
	function isEmpty(s)
	{
	   return ((s == null) || (s.length == 0))
	}
function isWhitespace(s)
	{  
			var i;
		// Is s empty?
		if (isEmpty(s)) return true;

		 // Search through string's characters one by one
		 // until we find a non-whitespace character.
		 // When we do, return false; if we don't, return true.
		 for (i = 0; i < s.length; i++)
		 {   
			 // Check that current character isn't whitespace.
			 var c = s.charAt(i);
	 
			 if (whitespace.indexOf(c) == -1) return false;
		 }
	 
		 // All characters are whitespace.
		 return true;
	}


	//Check mail

var testresults
function checkemail(strEmail){
//var str=document.validation.emailcheck.value;
var str= strEmail;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if (filter.test(str))
testresults=true;
else{
alert("Please input a valid email address!");
testresults=false;
}
return (testresults);
}


/***********Phone number validation*/

// Declaring required variables
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;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}



/*date format*/

function getMonth(val) {
var monthArray = new Array("JAN","FEB","MAR","APR","MAY","JUN",
"JUL","AUG","SEP","OCT","NOV","DEC");
for (var i=0; i<monthArray.length; i++) {
if (monthArray[i] == val) {
return(i);
} 
}
return(-1);
}


function checkDate(fld) { 
var success = true; 
var mo, day, yy, testDate; 
var val = fld.value; 

var re = new RegExp("[0-9]{1,2}[/-][A-Z]{3}[/-][0-9]{4}", "g");
if (re.test(val)) { 
var delimChar = (val.indexOf("-") != -1) ? "-" : "-"; 
var delim1 = val.indexOf(delimChar); 
var delim2 = val.lastIndexOf(delimChar); 
day = parseInt(val.substring(0,delim1),10); 
mo = getMonth(val.substring(delim1+1,delim2),10); 
yy = parseInt(val.substring(delim2+1),10); 
testDate = new Date(yy,mo,day); 
if (testDate.getDate() == day) { 
if (testDate.getMonth() == mo) { 
if (!testDate.getFullYear() == yy) { 
alert("Invalid year entry."); 
success = false; 
} 
} 
else { 
alert("Invalid month entry."); 
success = false; 
} 
} 
else { 
alert("Invalid day entry."); 
success = false; 
} 
} 
else { 
alert("Incorrect date format. Enter as DD-MON-YYYY."); 
success = false; 
} 


return success;
//return(success); 

} 



// Declaring valid date character, minimum year and maximum year

var dtCh= "/";
var minYear=00;
var maxYear=99;



function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDatechk(dtStr){

	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	//if (strYear.length != 2 || year==0 || year<=minYear || year>maxYear)
	if (strYear.length != 2  || year < minYear || year>maxYear){
		alert("Please enter a valid 2 digit year between "+minYear+" and "+maxYear)
		//alert("Please enter a valid 2 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}


function checkStrtDateEndDate(strSdate,strEdate)
{
  var start_date1 =strSdate;  //document.frmcal.todays_date.value; 
  var end_date1=strEdate;
  
  
// Break up the start date - using the delimiter "/" - into an array of strings  

start_date = start_date1.split("/");

end_date=end_date1.split("/");
  
// Access each element in the array  
year = start_date[2];  
month = start_date[0];  
day = start_date[1];  
 
year1 = end_date[2];  
month1 = end_date[0];  
day1 = end_date[1];  

   
/// Some basic date validation /// 
// did they enter number?  
if (isNaN(day) || isNaN(month) || isNaN(year)) { 
   alert("Invalid number. Please ensure the day, month and    year are valid numbers.");  
   return false;  
} 
  
// check month range 
if (month < 1 || month > 12) {  
   alert("Invalid Month. Please ensure that the month is    between 1 and 12 inclusive.");  
   return false;  
} 
  
// check day range 
if (day < 1 || day > 31) {  
   alert("Invalid Day. Please ensure that the day is between    1 and 31 inclusive.");  
   return false;  
} 
  
// check day/month combination 
if ((month==4 || month==6 || month==9 || month==11) && day==31) { 
   alert("Invalid Day/Month combination. Please ensure that    you have a valid day/month combination."); 
   return false; 
}
   
// check for february 29th 
if (month == 2) {  
   var isleap = (year % 4 == 0 && (year % 100 != 0 || year %    400 == 0)); 
   if (day>29 || (day==29 && !isleap)) {  
      alert("Invalid Day. This year is not a leap year.       Please enter a value less than 29 for the day."); 
      return false; 
   } 
} 
  
// Set the start date using the Date object and pass it our date parameters. 
// NOTE: when passing the month as a number, remember that the array starts at 0. // So Jan = 0, Feb = 1 ... Dec = 11 
var sDate = new Date(year,month-1,day);  
var pdate=new Date(year1,month1-1,day1);  
// get the current date based on client's computer clock 

//var today = new Date();  
  
// what is the difference between the start date and today's date 
//diff = sDate-today; 

diff = pdate-sDate; 
  
// get the difference in days 
diff = Math.ceil(diff/1000/60/60/24); 
	if (diff <= 0) 
	{
		
		return false; 
	} 
	else
	{
	return true;
	}
	
}



function checkEmbStrtDateEndDate(strSdate,strEdate)
{
  var start_date1 =strSdate;  //document.frmcal.todays_date.value; 
  var end_date1=strEdate;
  
  
// Break up the start date - using the delimiter "/" - into an array of strings  

start_date = start_date1.split("/");

end_date=end_date1.split("/");
  
// Access each element in the array  
year = start_date[2];  
month = start_date[0];  
day = start_date[1];  

 
 year1 = end_date[2];  
 month1 = end_date[0];  
 day1 = end_date[1];  


   
/// Some basic date validation /// 
// did they enter number?  
if (isNaN(day) || isNaN(month) || isNaN(year)) { 
   alert("Invalid number. Please ensure the day, month and    year are valid numbers.");  
   return false;  
} 
  
// check month range 
if (month < 1 || month > 12) {  
   alert("Invalid Month. Please ensure that the month is    between 1 and 12 inclusive.");  
   return false;  
} 
  
// check day range 
if (day < 1 || day > 31) {  
   alert("Invalid Day. Please ensure that the day is between    1 and 31 inclusive.");  
   return false;  
} 
  
// check day/month combination 
if ((month==4 || month==6 || month==9 || month==11) && day==31) { 
   alert("Invalid Day/Month combination. Please ensure that    you have a valid day/month combination."); 
   return false; 
}
   
// check for february 29th 
if (month == 2) {  
   var isleap = (year % 4 == 0 && (year % 100 != 0 || year %    400 == 0)); 
   if (day>29 || (day==29 && !isleap)) {  
      alert("Invalid Day. This year is not a leap year.       Please enter a value less than 29 for the day."); 
      return false; 
   } 
} 
  
// Set the start date using the Date object and pass it our date parameters. 
// NOTE: when passing the month as a number, remember that the array starts at 0. // So Jan = 0, Feb = 1 ... Dec = 11 
var sDate = new Date(year,month-1,day);  
var pdate=new Date(year1,month1-1,day1);  
// get the current date based on client's computer clock 

//var today = new Date();  
  
// what is the difference between the start date and today's date 
//diff = sDate-today; 

diff = pdate-sDate; 
  
// get the difference in days 
diff = Math.ceil(diff/1000/60/60/24); 
	if (diff < 0) 
	{
		
		return false; 
	} 
	else
	{
		return true;

	}
	
}


//Check for past date should not be less then todays date

function checkpastDate(strdata)
{
		var start_date =strdata;  

		// Break up the start date - using the delimiter "/" - into an array of strings  
		start_date = start_date.split("/");

		var addyear="2000"
		// Access each element in the array  
		year = parseFloat(start_date[2]) + parseFloat(addyear);
		month = start_date[0];  
		day = start_date[1];  
		
		// Set the start date using the Date object and pass it our date parameters. 
		// NOTE: when passing the month as a number, remember that the array starts at 0. // So Jan = 0, Feb = 1 ... Dec = 11 
		var sDate = new Date(year,month-1,day);  
		//var pdate=new Date(year1,month2-1,day3);  
		// get the current date based on client's computer clock 

		var today = new Date();  
        // what is the difference between the start date and today's date 
		diff = sDate-today; 
		// get the difference in days 
		diff = Math.ceil(diff/1000/60/60/24); 
        if (diff < 0) { 
		return false; 
		} 
}



function hidestatus(){
window.status='myexcursions.com'
return true
}

if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT )
document.onmouseover=hidestatus
document.onmouseout=hidestatus







   


   