<!-- LANSA CODE-->
	<!--                                         -->
<!--     LANSA for the Web                   -->
<!--     Default Scripts                     -->
<!--     Last Modified: 10.0  2002-04-15     -->


//<![CDATA[
function SetSelect(HTMLName, Name,Row,Column,Select)
{
   document.LANSA._SELECT.value=Select;
   SetNameLocation(Name,Row,Column);
   document.LANSA._CALFLD.value=HTMLName;
}
function SetNameLocation(Name,Row,Column)
{
   document.LANSA._NAME.value=Name;
   document.LANSA._ROW.value=Row;
   document.LANSA._COLUMN.value=Column;
   document.LANSA._CALFLD.value=Name;
}

function HandleEvent(Proc,Func)
{
   document.LANSA._PROCESS.value=Proc;
   document.LANSA._FUNCTION.value=Func;

   // The following code takes a date entered on a form from a calendar control and parses it into 
   // the variables that RESNET needs JEN 6/13/2006
   var partition;
   partition = document.LANSA.Property.value;
   //alert(String(partition));
   // set hidden field - partition (partition = property)
   document.LANSA._PARTITION.value=partition;
   // take the date picked from calendar control and parse it into hidden date fields that RESNET is looking for
   var resDate = document.LANSA.date1.value;
   //alert(String(resDate));
  
   var tempDate = new Array();
   tempDate = resDate.split('/');
   //alert(String(tempDate.length));
  
   var month; 
   var day; 
   var year;
        
   switch(tempDate.length){
    case 3:
        //alert('correct date');
        month = tempDate[0]-1;
        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();
    } //end switch
    
    // set RESNET hidden fields with date entered on form     
    document.LANSA.date1.value= (month + 1) + "/" + day + "/" + year;
    document.LANSA.LRESDDX.value = day;
    // RESNET needs month and year concatenated as String
    var strMonth;
    switch (month) {
            case 0: strMonth = 'January'; break;
            case 1: strMonth = 'February'; break;
            case 2: strMonth = 'March'; break;
            case 3: strMonth = 'April'; break;
            case 4: strMonth = 'May'; break;
            case 5: strMonth = 'June'; break;
            case 6: strMonth = 'July'; break;
            case 7: strMonth = 'August'; break;
            case 8: strMonth = 'September'; break;
            case 9: strMonth = 'October'; break;
            case 10: strMonth = 'November'; break;
            default: strMonth = 'December';
            }
    var monthYear;
    monthYear = year + ' ' + strMonth;
    //alert('final date ' + monthYear);
    // set RESNET hidden field
    document.LANSA.LRESYRMTH.value = monthYear;
    // set ACTION, call RESNET page     
    document.LANSA.action = 'https://rooms.stationcasinos.com/CGI-BIN/LANSAWEB?WEBEVENT+R1B8069112EB0040004A9095+' + partition + '+ENG';   
    //alert(document.LANSA.action);
    document.LANSA.submit();
   
}


function SetFocus()
{
   var NumElements=document.LANSA.elements.length;

   for (i=0; i<NumElements;i++)
   {
      if (document.LANSA.elements[i].type=="checkbox" ||
          document.LANSA.elements[i].type=="password" ||
          document.LANSA.elements[i].type=="radio" ||
          document.LANSA.elements[i].type=="text" ||
          document.LANSA.elements[i].type=="textarea")
      {
         if (document.LANSA.elements[i].value!="")
            document.LANSA.elements[i].select();
         document.LANSA.elements[i].focus();
         break;
      }
   }
}
function preload(imgObj,imgSrc)
{
   if (document.images)
   {
      eval(imgObj+' = new Image()');
      eval(imgObj+'.src = "'+imgSrc+'"');
   }
}

function changeImage(layer,imgObj, imgName)
{
   if (document.images)
   {
      if (document.layers && layer!=null)
         eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
      else
         document.images[imgName].src = eval(imgObj+".src");
   }
}
function CheckNUpdate(Fld, Value)
{
   var NumElements=document.LANSA.elements.length;

   for (i=0; i<NumElements;i++)
   {
      if (document.LANSA.elements[i].name==Fld)
      {
         document.LANSA.elements[i].value=Value;
         break;
      }
   }
}
function FieldExists(Fld)
{
   var NumElements=document.LANSA.elements.length;

   for (i=0; i<NumElements;i++)
   {
      if (document.LANSA.elements[i].name==Fld)
         return true;
   }
  return false;
}
function SetState(obj, RFld, chkValue, unchkValue)
{
  var NumElements=document.LANSA.elements.length;

  for (i=0; i<NumElements;i++)
  {
    if (document.LANSA.elements[i].name==RFld)
    {
      if (obj.checked)
         document.LANSA.elements[i].value=chkValue;
      else
         document.LANSA.elements[i].value=unchkValue;
      break;
    }
  }
}
function GetFieldValue(RFld)
{
  var NumElements=document.LANSA.elements.length;

  for (i=0; i<NumElements;i++)
  {
    if (document.LANSA.elements[i].name==RFld)
         return document.LANSA.elements[i].value;
  }
  return null;
}
function CallLink(Process, Function, Partition, NewWindow)
{
  var URL="/CGI-BIN/LANSAWEB?PROCFUN+";

  URL+=Process;
  URL+="+";
  URL+=Function;
  URL+="+";
  URL+=Partition;	



  if (FieldExists('ASTDTABFLR'))
  {
      URL+="+FUNCPARMS+STDTABFLR(A004):";
      URL+=document.LANSA.ASTDTABFLR.value;
  }

   if (NewWindow == 'N')
      window.location=URL;
   else
       StartFunction(URL);
}

function SetCBState(obj, RFld, CY, CN)
{
   var NumElements=document.LANSA.elements.length;

   for (i=0; i<NumElements;i++)
   {
      if (document.LANSA.elements[i].name==RFld)
      {
         if (obj.checked)
            document.LANSA.elements[i].value=CY;
         else
            document.LANSA.elements[i].value=CN;
         break;
      }
   }
}
function StartFunction(URL)
{
  var win;
  win=window.open("","TESTFNC");
  if (win != null)
    win.location=URL;
  win.focus();
}
function ECSelect(proc,fun,ECparm)
{
  document.LANSA.action += '+FUNCPARMS+ECPARM(A0500):' + ECparm;
  HandleEvent(proc, fun);
}

function OpenNewWindow(url,name,featurelist) {window.open(url,name,featurelist); }

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;
}

function CallResNet()

{

   

    // 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 false;

    }

    // make sure date is between today and 3 months from now

    var currentDate = new Date();

    

    var threeMonths;

    threeMonths = dateAdd("m",5,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 false;    

    }   
	
	 // first make sure that they have chosen a property

    if (document.LANSA.Property.value == "Select") 

    {

        alert("Please select a Property to continue.");

        return false;

    }

    // jen added 9/1/06 need a room type for every property for new 3 panel display 


       
   switch ( document.LANSA.Property.value ) {
        case "BOU": 
            document.LANSA.LWRK_ROOM.value='Deluxe King Bed Smoking'; break;
        case "RRS": 
            document.LANSA.LWRK_ROOM.value='Strip View - One King Bed'; break;
        case "SUN":
            document.LANSA.LWRK_ROOM.value='Deluxe King Smoking'; break;
        case "TEX":
            document.LANSA.LWRK_ROOM.value='2 Queen Beds Smoking'; break;
        case "WIL":
            document.LANSA.LWRK_ROOM.value='2 Double Beds Smoking'; break;
        case "SAN":
            document.LANSA.LWRK_ROOM.value='2 Queen Beds Smoking'; break;
        case "PAL":
             document.LANSA.LWRK_ROOM.value='Courtyard Room-non smk'; break;
        case "GRE":
            document.LANSA.LWRK_ROOM.value='Deluxe King West Tower'; break;
        case "FIE":
            document.LANSA.LWRK_ROOM.value='2 Double Beds Smoking'; break;
        case "RES":
            document.LANSA.LWRK_ROOM.value='2 Queen Beds Smoking'; break;
    }


    document.LANSA.ASTDRENTRY.value='Y';

    HandleEvent('RN', 'RA19');

    return true;

    

}

 

// -------------------------------------------------------------------

// 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 -->
