function IsBlank(theObj) {
	var re = /^\s{1,}$/g; //match any white space including space, tab, form-feed, etc. 
	if ((theObj.value.length==0) || (theObj.value==null) || ((theObj.value.search(re)) > -1)) {
		return true;
	}else {
		return false;
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


function canManipulateImages() {
	if (document.images)
		return true;
	else
		return false;
}

function loadPosterImage(imageURL) {
	if (gImageCapableBrowser) {
		document.imagePoster.src = imageURL;
		return false;
	}
	else {
		return true;
	}
}

function loadPosterImage1(imageURL) {
	if (gImageCapableBrowser) {
		document.imagePoster1.src = imageURL;
		return false;
	}
	else {
		return true;
	}
}

function loadPosterImage2(imageURL) {
	if (gImageCapableBrowser) {
		document.imagePoster2.src = imageURL;
		return false;
	}
	else {
		return true;
	}
}

gImageCapableBrowser = canManipulateImages();


function colorLinks(id){ 
	for (i=1; i<=3; i++) {
	document.getElementById('a'+i).style.color='#000000';
	}
	document.getElementById(id).style.color='#FD8C29';
}


function OpenWindow(theURL,winName,features){
	var myWindow = window.open(theURL,winName,features);
}


function validateForm(theForm){
	if(theForm.theDate.value != "" && theForm.lengthOfStay.value != ""){
		theDatefrm = theForm.theDate.value;
		lengthOfStay = parseInt(theForm.lengthOfStay.value);

		var theDate = new Date(theDatefrm);
		theMonth = paddZero(theDate.getMonth()+1);
		//theForm.arrivalDateMonth.value = theMonth;

		theDay = paddZero(theDate.getDate());
		//theForm.arrivalDateDay.value = theDay;
		
		theYear = theDate.getFullYear();
		//theForm.arrivalDateYear.value = theYear;
		
		arvDate = (theYear+"-"+theMonth+"-"+theDay);
		theForm.arrivalDate.value = arvDate;
		
		theDate.setDate(theDate.getDate() + lengthOfStay);
		
		theMonth = paddZero(theDate.getMonth()+1);
		//theForm.departureDateMonth.value = theMonth;

		theDay = paddZero(theDate.getDate());
		//theForm.departureDateDay.value = theDay;
		
		theYear = theDate.getFullYear();
		//theForm.departureDateYear.value = theYear;
		
		depDate = (theYear+"-"+theMonth+"-"+theDay);
		theForm.departureDate.value = depDate;

		theForm.lengthOfStay.value = paddZero(lengthOfStay);
	
		theForm.method = "get";
		//theForm.action = "bookit_result.php";
		theForm.action = "http://www.starwoodhotels.com/lemeridien/search/ratelist.html";
		theForm.submit();
	}else{
		alert ("Please indicate Check In Date and Nš of Nights");
	}
}

function validateFormTest(theForm){
	if(theForm.theDate.value != "" && theForm.lengthOfStay.value != ""){
		theDatefrm = theForm.theDate.value;
		lengthOfStay = parseInt(theForm.lengthOfStay.value);

		var theDate = new Date(theDatefrm);
		theMonth = paddZero(theDate.getMonth()+1);
		//theForm.arrivalDateMonth.value = theMonth;

		theDay = paddZero(theDate.getDate());
		//theForm.arrivalDateDay.value = theDay;
		
		theYear = theDate.getFullYear();
		//theForm.arrivalDateYear.value = theYear;
		
		arvDate = (theYear+"-"+theMonth+"-"+theDay);
		theForm.arrivalDate.value = arvDate;
		
		theDate.setDate(theDate.getDate() + lengthOfStay);
		
		theMonth = paddZero(theDate.getMonth()+1);
		//theForm.departureDateMonth.value = theMonth;

		theDay = paddZero(theDate.getDate());
		//theForm.departureDateDay.value = theDay;
		
		theYear = theDate.getFullYear();
		//theForm.departureDateYear.value = theYear;
		
		depDate = (theYear+"-"+theMonth+"-"+theDay);
		theForm.departureDate.value = depDate;

		theForm.lengthOfStay.value = paddZero(lengthOfStay);
	
		theForm.method = "get";
		theForm.action = "http://www.starwoodhotels.com/lemeridien/search/ratelist.html";
		theForm.submit();
	}else{
		alert ("Please indicate Check In Date and Nš of Nights");
	}
}


function paddZero(s){
	if(s >= 0 && s <= 9){
		s = '0' + s;
	}
	return s;
}

function validateRFPForm(theForm){
	if (theForm.name.value == ""){
		alert ("Please enter Your Name");
		theForm.name.focus();
	}else if (theForm.where.value == ""){
		alert ("Please enter Where you're at");
		theForm.where.focus();
	}else if (theForm.telephone.value == ""){
		alert ("Please enter Telephone");
		theForm.telephone.focus();
	}else if (theForm.fax.value == ""){
		alert ("Please enter Fax");
		theForm.fax.focus();
	}else if (theForm.email.value == ""){
		alert ("Please enter E-mail");
		theForm.email.focus();
	}else if(((theForm.email.value.indexOf ("@", 0) == -1) || (theForm.email.value.indexOf (".", 0) == -1))){
		alert("Please enter E-mail.");
		theForm.email.focus();
	}else if (theForm.traveling.value == ""){
		alert ("Please enter Traveling to New York City when?");
		theForm.traveling.focus();
	}else if (theForm.nights.value == ""){
		alert ("Please enter How many nights?");
		theForm.nights.focus();
	}else if (theForm.dates.value == ""){
		alert ("Please enter Second chance dates");
		theForm.dates.focus();
	}else if (theForm.rooms.value == ""){
		alert ("Please enter How many rooms?");
		theForm.rooms.focus();
	}else if (theForm.suites.value == ""){
		alert ("Please enter How many suites?");
		theForm.suites.focus();
	}else if (theForm.people.value == ""){
		alert ("Please enter How many people?");
		theForm.people.focus();
	}else if (theForm.meetings.value == ""){
		alert ("Please enter Are there meetings in your plans?");
		theForm.meetings.focus();
	}else{
		theForm.submit();
	}
}


function validateNYForm(theForm){
	if (theForm.in_txt.value == ""){
		alert ("Please enter In");
		theForm.in_txt.focus();
	}else if (theForm.out_txt.value == ""){
		alert ("Please enter Out");
		theForm.out_txt.focus();
	}else if (theForm.reservation.value == ""){
		alert ("Please enter reservation#");
		theForm.reservation.focus();
	}else if (theForm.email.value == ""){
		alert ("Please enter E-mail");
		theForm.email.focus();
	}else if(((theForm.email.value.indexOf ("@", 0) == -1) || (theForm.email.value.indexOf (".", 0) == -1))){
		alert("Please enter E-mail.");
		theForm.email.focus();
	}else{
		theForm.submit();
	}
}


function validateContactForm(theForm){
	if (IsBlank(theForm.question)){
		alert ("Please enter your Question.");
		theForm.question.focus();
	}else if (IsBlank(theForm.email)){
		alert ("Please enter your E-mail.");
		theForm.email.focus();
	}else if(((theForm.email.value.indexOf ("@", 0) == -1) || (theForm.email.value.indexOf (".", 0) == -1))){
		alert("Please enter your E-mail.");
		theForm.email.focus();
	}else if (IsBlank(theForm.name)){
		alert ("Please enter your Name.");
		theForm.name.focus();
	}else{
		theForm.submit();
	}
}

function validateBuyForm(theForm){
	if (theForm.name.value == ""){
		alert ("Please enter your Name");
		theForm.name.focus();
	}else if (theForm.address.value == ""){
		alert ("Please enter your Address");
		theForm.address.focus();
	}else if (theForm.city.value == ""){
		alert ("Please enter your City");
		theForm.city.focus();
	}else if (theForm.state.value == ""){
		alert ("Please enter your State");
		theForm.state.focus();
	}else if (theForm.zip.value == ""){
		alert ("Please enter your Zip");
		theForm.zip.focus();
	}else{
		theForm.submit();
	}
}
