<!-- LANSA CODE - put in central scripts folder and call from there -->
	<!--                                         -->
<!--     LANSA for the Web                   -->
<!--     Default Scripts                     -->
<!--     Last Modified: 10.0  2002-04-15     -->


//<![CDATA[
//  ALL OF THIS SCRIPT GOES IN lansa-code.js


function gotoRESNET()
{   
    // make sure valid date
    if (isDate(document.LANSA.date1.value,"M/d/yyyy") == false)
    {
        alert("Please provide a valid Check-in date in the following format:  mm/dd/yyyy; or pick a date from the calendar.");
        return;
    }

    // make sure date is between today and 3 months from now
    var currentDate = new Date();

    //var threeMonths;
    threeMonths = formatDate(maxDate(8),"M/d/yyyy");//dateAdd("m",8,currentDate,true);

    var todayformatted  = formatDate(currentDate,"M/dd/yyyy");
    var result=0;
    var result2=0;

    result = compareDates(document.LANSA.date1.value,"M/d/yyyy",threeMonths,"M/d/yyyy") // want 0 returned
    result2 = compareDates( todayformatted,"M/d/yyyy",document.LANSA.date1.value,"M/d/yyyy")// want 0 returned 

    if ((result != 0) || (result2 != 0))
    {
        var message;
        message = 'Date must be between ' +  todayformatted + ' and ' + threeMonths;
        alert(message);
        return;    
    }   
	
    // first make sure that they have chosen a property
    if (document.LANSA.Property.value == "Select") 
    {
        alert("Please select a Property to continue.");
        return;
    }

    // the rest of the function builds the URL for ResNet.  
	// Change the domain name and the partition and the offer below to match your needs 
	// the %3B in the URL is the semiColon.
	
	var partition = "il1";	// From ResNet. Usually a 3 character code that was given to you during ResNet setup
	//var offer = "web01"; 	// From ResNet. If using the default blank offer just leave the two quote marks

	//var offer = "web01";
    var offer = "";
	
    if (document.LANSA.AOFFERSC.value == "Promo Code") {
		document.LANSA.AOFFERSC.value = "";
    } else {
		offer = document.LANSA.AOFFERSC.value;
	}


	var roomType = "010";   // change this to the first room type sequence in the offer used above.
    var domain = "reservations.isleta-casino.com";	// Example: res.greathotel.com  DO NOT include the https//

  
    partition = document.LANSA.Property.value;
    //alert(String(partition));
   
    // set roomtype based on property
    switch ( partition ) {
        case "BOU": 
            roomType = "010"; break;
        case "RRS": 
            roomType = "010";  break;
        case "SUN":
            roomType = "010";  break;
        case "TEX":
            roomType = "010";  break;
        case "WIL":
            roomType = "010";  break;
        case "SAN":
            roomType = "010";  break;
        case "PAL":
            roomType = "010";  break;
        case "GRE":
            roomType = "010";  break;
        case "FIE":
            roomType = "010";  break;
        case "RES":
            roomType = "010"; break;
    }
    
   // take the date picked from calendar control and parse it into separate day,month,year that
   // RESNET is looking for
   //alert(document.LANSA.date1.value);
   
   var tempDate = new Array();
   tempDate = document.LANSA.date1.value.split('/');
   //alert(String(tempDate.length));
  
   var month; 
   var day; 
   var year;
        
   switch(tempDate.length){
    case 3:
        //alert('correct date');
        month = tempDate[0];
        day = tempDate[1];
        year = tempDate[2];
        // if it is an invalid date, a message will be displayed on the resnet page that gets called
        break;
    default:
       //alert('incorrect date');
        var currentTime = new Date();
        month = currentTime.getMonth();
        day = currentTime.getDate() ;
        year = currentTime.getFullYear();
    } 
     
    // get nbr nights and nbr adults from the form	
	var nights = document.LANSA.LRESNNC.value;
	var adults = document.LANSA.LRESNAC.value;
	// default
	var children = 0;
	// RESNET needs only 2 chars for year
	var myyear = year.substring(2,4);
	
	// all is good - goto RESNET page	
	//document.location.href =
	window.open (   "https://"+domain+"/cgi-bin/lansaweb?procfun+rn+resnet+"+partition+"+funcparms+UP(A2560)%3A%3B"+offer+"%3B"+month+day+myyear+"%3B"+nights+"%3B"+adults+"%3B"+children+"%3B"+roomType+"%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3F");
        
}

function GetTodaysDate()
{
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate(); 
var year = currentTime.getFullYear();
document.LANSA.date1.value= month + "/" + day + "/" + year;
}

// -------------------------------------------------------------------

// compareDates(date1,date1format,date2,date2format)

//   Compare two date strings to see which is greater.

//   Returns:

//   1 if date1 is greater than date2

//   0 if date2 is greater than date1 of if they are the same

//  -1 if either of the dates is in an invalid format

// -------------------------------------------------------------------

function compareDates(date1,dateformat1,date2,dateformat2) {

      var d1=getDateFromFormat(date1,dateformat1);

      var d2=getDateFromFormat(date2,dateformat2);

      if (d1==0 || d2==0) {

            return -1;

            }

      else if (d1 > d2) {

            return 1;

            }

      return 0;

      }

 

function dateAdd(p_Interval, p_Number, p_Date, myformat){

      

      p_Number = new Number(p_Number);

      var dt = new Date(p_Date);

      switch(p_Interval.toLowerCase()){

            case "yyyy": {// year

                  dt.setFullYear(dt.getFullYear() + p_Number);

                  break;

            }

            case "q": {       // quarter

                  dt.setMonth(dt.getMonth() + (p_Number*3));

                  break;

            }

            case "m": {       // month

                  dt.setMonth(dt.getMonth() + p_Number);

                  break;

            }

            case "y":         // day of year

            case "d":         // day

            case "w": {       // weekday

                  dt.setDate(dt.getDate() + p_Number);

                  break;

            }

            case "ww": {      // week of year

                  dt.setDate(dt.getDate() + (p_Number*7));

                  break;

            }

            case "h": {       // hour

                  dt.setHours(dt.getHours() + p_Number);

                  break;

            }

            case "n": {       // minute

                  dt.setMinutes(dt.getMinutes() + p_Number);

                  break;

            }

            case "s": {       // second

                  dt.setSeconds(dt.getSeconds() + p_Number);

                  break;

            }

            case "ms": {            // second

                  dt.setMilliseconds(dt.getMilliseconds() + p_Number);

                  break;

            }

            default: {

                  return "invalid interval: '" + p_Interval + "'";

            }

      }

      if (myformat)

      {

          // return date in format "MM/dd/YYYY"

          var dtNew;

          var month = dt.getMonth() + 1;

        var day = dt.getDate(); 

        var year = dt.getFullYear();

        dtNew = month + "/" + day + "/" + year;

        return dtNew;

      }

      else

          {

          alert(dt);

          return dt;

          }

      

}

 

 

// ------------------------------------------------------------------

// isDate ( date_string, format_string )

// Returns true if date string matches format of format string and

// is a valid date. Else returns false.

// It is recommended that you trim whitespace around the value before

// passing it to this function, as whitespace is NOT ignored!

// ------------------------------------------------------------------

function isDate(val,format) {

      var date=getDateFromFormat(val,format);

      if (date==0) { return false; }

      return true;

      }

 

// ------------------------------------------------------------------

// getDateFromFormat( date_string , format_string )

//

// This function takes a date string and a format string. It matches

// If the date string matches the format string, it returns the 

// getTime() of the date. If it does not match, it returns 0.

// ------------------------------------------------------------------

// These functions use the same 'format' strings as the 

// java.text.SimpleDateFormat class, with minor exceptions.

// The format string consists of the following abbreviations:

// 

// Field        | Full Form          | Short Form

// -------------+--------------------+-----------------------

// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)

// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)

//              | NNN (abbr.)        |

// Day of Month | dd (2 digits)      | d (1 or 2 digits)

// Day of Week  | EE (name)          | E (abbr)

// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)

// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)

// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)

// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)

// Minute       | mm (2 digits)      | m (1 or 2 digits)

// Second       | ss (2 digits)      | s (1 or 2 digits)

// AM/PM        | a                  |

//

// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!

// Examples:

//  "MMM d, y" matches: January 01, 2000

//                      Dec 1, 1900

//                      Nov 20, 00

//  "M/d/yy"   matches: 01/20/00

//                      9/2/00

//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"

// ------------------------------------------------------------------

 

function getDateFromFormat(val,format) {

      val=val+"";

      format=format+"";

      var i_val=0;

      var i_format=0;

      var c="";

      var token="";

      var token2="";

      var x,y;

      var now=new Date();

      var year=now.getYear();

      var month=now.getMonth()+1;

      var date=1;

      var hh=now.getHours();

      var mm=now.getMinutes();

      var ss=now.getSeconds();

      var ampm="";

      

      while (i_format < format.length) {

            // Get next token from format string

            c=format.charAt(i_format);

            token="";

            while ((format.charAt(i_format)==c) && (i_format < format.length)) {

                  token += format.charAt(i_format++);

                  }

            // Extract contents of value based on format token

            if (token=="yyyy" || token=="yy" || token=="y") {

                  if (token=="yyyy") { x=4;y=4; }

                  if (token=="yy")   { x=2;y=2; }

                  if (token=="y")    { x=2;y=4; }

                  year=_getInt(val,i_val,x,y);

                  if (year==null) { return 0; }

                  i_val += year.length;

                  if (year.length==2) {

                        if (year > 70) { year=1900+(year-0); }

                        else { year=2000+(year-0); }


                        }

                  }

            else if (token=="MMM"||token=="NNN"){

                  month=0;

                  for (var i=0; i<MONTH_NAMES.length; i++) {

                        var month_name=MONTH_NAMES[i];

                        if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {

                              if (token=="MMM"||(token=="NNN"&&i>11)) {

                                    month=i+1;

                                    if (month>12) { month -= 12; }

                                    i_val += month_name.length;

                                    break;

                                    }

                              }

                        }

                  if ((month < 1)||(month>12)){return 0;}

                  }

            else if (token=="EE"||token=="E"){

                  for (var i=0; i<DAY_NAMES.length; i++) {

                        var day_name=DAY_NAMES[i];

                        if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {

                              i_val += day_name.length;

                              break;

                              }

                        }

                  }

            else if (token=="MM"||token=="M") {

                  month=_getInt(val,i_val,token.length,2);

                  if(month==null||(month<1)||(month>12)){return 0;}

                  i_val+=month.length;}

            else if (token=="dd"||token=="d") {

                  date=_getInt(val,i_val,token.length,2);

                  if(date==null||(date<1)||(date>31)){return 0;}

                  i_val+=date.length;}

            else if (token=="hh"||token=="h") {

                  hh=_getInt(val,i_val,token.length,2);

                  if(hh==null||(hh<1)||(hh>12)){return 0;}

                  i_val+=hh.length;}

            else if (token=="HH"||token=="H") {

                  hh=_getInt(val,i_val,token.length,2);

                  if(hh==null||(hh<0)||(hh>23)){return 0;}

                  i_val+=hh.length;}

            else if (token=="KK"||token=="K") {

                  hh=_getInt(val,i_val,token.length,2);

                  if(hh==null||(hh<0)||(hh>11)){return 0;}

                  i_val+=hh.length;}

            else if (token=="kk"||token=="k") {

                  hh=_getInt(val,i_val,token.length,2);

                  if(hh==null||(hh<1)||(hh>24)){return 0;}

                  i_val+=hh.length;hh--;}

            else if (token=="mm"||token=="m") {

                  mm=_getInt(val,i_val,token.length,2);

                  if(mm==null||(mm<0)||(mm>59)){return 0;}

                  i_val+=mm.length;}

            else if (token=="ss"||token=="s") {

                  ss=_getInt(val,i_val,token.length,2);

                  if(ss==null||(ss<0)||(ss>59)){return 0;}

                  i_val+=ss.length;}

            else if (token=="a") {

                  if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}

                  else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}

                  else {return 0;}

                  i_val+=2;}

            else {

                  if (val.substring(i_val,i_val+token.length)!=token) {return 0;}

                  else {i_val+=token.length;}

                  }

            }

      // If there are any trailing characters left in the value, it doesn't match

      if (i_val != val.length) { return 0; }

      // Is date valid for month?

      if (month==2) {

            // Check for leap year

            if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year

                  if (date > 29){ return 0; }

                  }

            else { if (date > 28) { return 0; } }

            }

      if ((month==4)||(month==6)||(month==9)||(month==11)) {

            if (date > 30) { return 0; }

            }

      // Correct hours value

      if (hh<12 && ampm=="PM") { hh=hh-0+12; }

      else if (hh>11 && ampm=="AM") { hh-=12; }

      var newdate=new Date(year,month-1,date,hh,mm,ss);

      return newdate.getTime();

      }

// END LANSA CODE 



//]]>

<!-- END LANSA CODE -->

