function checkDateRange(userDate) {  var firstPos  var intMonth  var intDay  var intYear  var timeDiff    //Check for date string with 8 chars (m/d/yyyy)  if (userDate.length == 8) {	  intMonth = userDate.substring(0,1)	  intDay = userDate.substring(2,3)	  intYear = userDate.substring(4,8)	  	  now = new Date;	  user = new Date(intYear,(intMonth-1),intDay,23,00,00);	  	  //check to see if date is less then current	  if (user.getTime() < now.getTime()) {         document.freestyle.P_ARRIVEDATE.style.backgroundColor = "#ffcccc"         Message1.innerText = "Your arrival date cannot be less then today's date."		 return false;	  } else {	     //check to see if date entered is past the 10 month cutoff.		 //26006400000: this is the number of Milliseconds in 301 days		 //formula to get Milliseconds in a day (((1000*60)*60)*24)		 timeDiff = (user.getTime() - now.getTime())    		 if (timeDiff > 26006400000) {           document.freestyle.P_ARRIVEDATE.style.backgroundColor = "#ffcccc"           Message1.innerText = "You are not allowed to book rooms that far in advance."		   return false;		 } else {		   return true; 		 }//if	  }//if  }//if   //Check for date string with 10 chars (mm/dd/yyyy)  if (userDate.length == 10) {	  intMonth = userDate.substring(0,2)	  intDay = userDate.substring(3,5)	  intYear = userDate.substring(6,10)	  	  now = new Date;	  user = new Date(intYear,(intMonth-1),intDay,23,00,00);	  	  //check to see if date is less then current	  if (user.getTime() < now.getTime()) {         document.freestyle.P_ARRIVEDATE.style.backgroundColor = "#ffcccc"         Message1.innerText = "Your arrival date cannot be less then today's date."		 return false;	  } else {	     //check to see if date entered is past the 10 month cutoff.		 //26006400000: this is the number of Milliseconds in 301 days		 //formula to get Milliseconds in a day (((1000*60)*60)*24)		 timeDiff = (user.getTime() - now.getTime())    		 if (timeDiff > 26006400000) {           document.freestyle.P_ARRIVEDATE.style.backgroundColor = "#ffcccc"           Message1.innerText = "You are not allowed to book rooms that far in advance."		   return false;		 } else {		   return true; 		 }//if	  }//if  }//if  //Check for date string with 9 chars (mm/d/yyyy or m/dd/yyyy)  if (userDate.length == 9) {      firstPos = userDate.indexOf('/');	  	  //Check pos of 1st slash to determine exact positions of date values	  //POS = 2 is format (mm/d/yyyy)	  if (firstPos==2) {	     intMonth = userDate.substring(0,2)	     intDay = userDate.substring(3,4)	     intYear = userDate.substring(5,9)	  }//if	  //Check pos of 1st slash to determine exact positions of date values	  //POS = 1 is format (m/dd/yyyy)	  if (firstPos==1) {	     intMonth = userDate.substring(0,1)	     intDay = userDate.substring(2,4)	     intYear = userDate.substring(5,9)	  }//if	  	  now = new Date;	  user = new Date(intYear,(intMonth-1),intDay,23,00,00);	  	  //check to see if date is less then current	  if (user.getTime() < now.getTime()) {         document.freestyle.P_ARRIVEDATE.style.backgroundColor = "#ffcccc"         Message1.innerText = "Your arrival date cannot be less then today's date."		 return false;	  } else {	     //check to see if date entered is past the 10 month cutoff.		 //26006400000: this is the number of Milliseconds in 301 days		 //formula to get Milliseconds in a day (((1000*60)*60)*24)		 timeDiff = (user.getTime() - now.getTime())    		 if (timeDiff > 26006400000) {           document.freestyle.P_ARRIVEDATE.style.backgroundColor = "#ffcccc"           Message1.innerText = "You are not allowed to book rooms that far in advance."		   return false;		 } else {		   return true; 		 }//if	  }//if  }//if}function validateForm(form) {  if ( (dateCheck(form.P_ARRIVEDATE.value,'%m/%d/%yyyy')) ) {       form.P_ARRIVEDATE.style.backgroundColor = "#ffffff"       Message1.innerText = " "     	   if (checkDateRange(form.P_ARRIVEDATE.value)==false) {	      return false;	   } else {		  return true;	   }//if	  } else {       form.P_ARRIVEDATE.style.backgroundColor = "#ffcccc"       Message1.innerText = "Invalid Date Format.  Please use (m/d/yyyy)."       form.P_ARRIVEDATE.focus()       form.P_ARRIVEDATE.select()       return false;  }//if   }
