// JavaScript Document


function goroomratepage() {
   var now         = new Date();
   var monthnumber = now.getMonth() + 1;
   var monthday    = now.getDate();	
	
	var onseason    = 0;
	<!-- alert (monthnumber +" "+monthday); -->
	<!-- If the date is between May and September it's on season -->
	if (monthnumber > 4 && monthnumber < 10) { onseason = 1};
	<!-- If the date is between Dec 23 and Jan 2 it's on season -->
	if ((monthnumber == 12 && (monthday > 22)) || (monthnumber == 1 && (monthday < 3))) { onseason = 2};
	 // alert ("onseason = "+onseason); 
	
	if (onseason == 0) {window.location = "rates_off_season.htm"} 
	if (onseason == 1) {window.location = "rates_on_season.htm"}
	if (onseason == 2) {window.location = "rates_xmas_season.htm"}

}

function goroomratepagetour() {
   var now         = new Date();
   var monthnumber = now.getMonth() + 1;
   var monthday    = now.getDate();	
	
	var onseason    = 0;
	<!-- alert (monthnumber +" "+monthday); -->
	<!-- If the date is between May and September it's on season -->
	if (monthnumber > 4 && monthnumber < 10) { onseason = 1};
	<!-- If the date is between Dec 23 and Jan 2 it's on season -->
	if ((monthnumber == 12 && (monthday > 22)) || (monthnumber == 1 && (monthday < 3))) { onseason = 2};
	 // alert ("onseason = "+onseason); 
	
	if (onseason == 0) {window.location = "../english/rates_off_season.htm"} 
	if (onseason == 1) {window.location = "../english/rates_on_season.htm"}
	if (onseason == 2) {window.location = "../english/rates_xmas_season.htm"}

}

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_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_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_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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openmap() {
window.open("","map",'toolbar=0,location=0,scrollbars=0,width=730,height=475,resizable=0, left=0, top=0');
}


function floatCam() {
window.open("","floatCam",'toolbar=0,location=0,scrollbars=0,width=400,height=375,resizable=0, left=0, top=0');
}

function getValue(varname)
{
  // First, we load the URL into a variable
  var url = window.location.href;

  // Next, split the url by the ?
  var qparts = url.split("?");

  // Check that there is a querystring, return "" if not
  if (qparts.length == 0) {
	  return false;
	  
	}

  // Then find the querystring, everything after the ?
  var query = qparts[1];

  // Split the query string into variables (separates by &s)
  var vars = query.split("&");

  // Initialize the value with "" as default
  var value = "";

  // Iterate through vars, checking each one for varname
  for (i=0;i<vars.length;i++)
  {
    // Split the variable by =, which splits name and value
    var parts = vars[i].split("=");
    
    // Check if the correct variable
    if (parts[0] == varname)
    {
      // Load value into variable
      value = parts[1];

      // End the loop
      break;
    }
  }
  
  // Convert escape code
  value = unescape(value);

  // Convert "+"s to " "s
  value.replace(/\+/g," ");

  // Return the value
  return value;
}


function setTheRoom( ) {
	x = getValue("room");
	if (x) {
    	y = x-1;
    	document.NewReservation.roomid[y].checked = true;
	}
  }

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}



function cc_validate(f) {
			//alert("Validating card...");
     var RegExPattern;
     RegExPattern = /^((4\d{3}|5[1-5]\d{2}|6011)[ -]*(\d{4}[ -]*\d{4}[ -]*\d{4}))|((34\d{2}|37\d{2})[ -]*(\d{6}[ -]*\d{5}))$/;
     
     if ((f.value.match(RegExPattern)) && (f.value!='')) {
          if (cc_luhn(f.value)) {
               return true;
          }
     }
     <!--- f.focus(); --->
     <!--- alert('Sorry. The card number you entered is invalid.  Please check and enter it again.'); --->
     return false;   
}



function cc_luhn(num) {
     // MOD 10 Validation of Credit Card Numbers
     var numberProduct;
     var numberProductDigitIndex;
     var checkSumTotal = 0;
     var cardNumbersOnly = num;
     var isValid = false;
     
     while (cardNumbersOnly.indexOf(' ') > 0) {
          cardNumbersOnly = cardNumbersOnly.replace(' ','');
     }
     while (cardNumbersOnly.indexOf('-') > -1) {
          cardNumbersOnly = cardNumbersOnly.replace('-','');
     }

     for (digitCounter = cardNumbersOnly.length - 1;     digitCounter >= 0; digitCounter--) {
          checkSumTotal += parseInt(cardNumbersOnly.charAt(digitCounter));
          if (digitCounter > 0) {
               digitCounter--;
               numberProduct = String((cardNumbersOnly.charAt(digitCounter) * 2));
               for (var productDigitCounter = 0; productDigitCounter < numberProduct.length; productDigitCounter++) {
                    checkSumTotal += parseInt(numberProduct.charAt(productDigitCounter));
               }
          }
     }

     isValid = (checkSumTotal % 10 == 0);
     return isValid;
}


function MM_validateForm() { //v4.0 modified to check for Credit card info and date
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;   
<!--  alert("validating...");-->
   var now         = new Date();
   var monthnumber = now.getMonth() + 1;
   var monthday    = now.getDate();	
	 var months 		 = new Array("January","February","March","April","May","June","July","August","September","October","November","December")

   
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; 
	 if ((val=val.value)!=0) {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is REQUIRED!\n';
				}
  } 
  
  

	switch (document.NewReservation.creditcard.value.charAt(0)) {
		case '4': {
			document.NewReservation.cardtype.value='Visa';
			break;
		}
		case '5': {
			document.NewReservation.cardtype.value='MasterCard';
			break;
		}
		default: {
			document.NewReservation.creditcard.focus();
		
		}     
	}
 <!--	 alert("checking credit card number..."); -->

 <!-- Check the credit card expiration date -->  
   
	n = monthnumber - 1;
  if (months[n] == document.NewReservation.Arrival_Month.value && monthday == document.NewReservation.Arrival_Day.value) {
		errors += "- invalid reservation date. You cannot select the current date for your reservation.\n";
  }

if ( document.NewReservation.Number_Males.value == -1 ) 
{
errors += '- Number of Males is REQUIRED!\n';

}

if ( document.NewReservation.Number_Females.value == -1 ) 
{
errors += '- Number of Females is REQUIRED!\n';

}

	if (errors) alert('The following error(s) in the form were found:\n'+errors);
	  
	document.MM_returnValue = (errors == '');
}

function openPictureWindow_Fever(imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
	newWindow = window.open("","newWindow","toolbar=0,location=0,scrollbars=0,width="+imageWidth+",height="+imageHeight+"resizable=0, left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#000000" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write("<div align=center><img src='../english/"+imageName+"' alt="+alt+"></div>"); 
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function openmap1() {
window.open("","map1",'toolbar=0,location=0,scrollbars=0,width=730,height=475,resizable=0, left=0, top=0');
}