/**
 * FlashObject v1.3c: Flash detection and embed - http://blog.deconcept.com/flashobject/
 *
 * FlashObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof com == "undefined") var com = new Object();
if(typeof com.deconcept == "undefined") com.deconcept = new Object();
if(typeof com.deconcept.util == "undefined") com.deconcept.util = new Object();
if(typeof com.deconcept.FlashObjectUtil == "undefined") com.deconcept.FlashObjectUtil = new Object();
com.deconcept.FlashObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
  if (!document.createElement || !document.getElementById) return;
  this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
  this.skipDetect = com.deconcept.util.getRequestParameter(this.DETECT_KEY);
  this.params = new Object();
  this.variables = new Object();
  this.attributes = new Array();
  this.useExpressInstall = useExpressInstall;

  if(swf) this.setAttribute('swf', swf);
  if(id) this.setAttribute('id', id);
  if(w) this.setAttribute('width', w);
  if(h) this.setAttribute('height', h);
  if(ver) this.setAttribute('version', new com.deconcept.PlayerVersion(ver.toString().split(".")));
  this.installedVer = com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute('version'), useExpressInstall);
  if(c) this.addParam('bgcolor', c);
  var q = quality ? quality : 'high';
  this.addParam('quality', q);
  var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
  this.setAttribute('xiRedirectUrl', xir);
  this.setAttribute('redirectUrl', '');
  if(redirectUrl) this.setAttribute('redirectUrl', redirectUrl);
}
com.deconcept.FlashObject.prototype = {
  setAttribute: function(name, value){
    this.attributes[name] = value;
  },
  getAttribute: function(name){
    return this.attributes[name];
  },
  addParam: function(name, value){
    this.params[name] = value;
  },
  getParams: function(){
    return this.params;
  },
  addVariable: function(name, value){
    this.variables[name] = value;
  },
  getVariable: function(name){
    return this.variables[name];
  },
  getVariables: function(){
    return this.variables;
  },
  createParamTag: function(n, v){
    var p = document.createElement('param');
    p.setAttribute('name', n);
    p.setAttribute('value', v);
    return p;
  },
  getVariablePairs: function(){
    var variablePairs = new Array();
    var key;
    var variables = this.getVariables();
    for(key in variables){
      variablePairs.push(key +"="+ variables[key]);
    }
    return variablePairs;
  },
  getFlashHTML: function() {
    var flashNode = "";
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
      if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "PlugIn");
      flashNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
      flashNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
      var params = this.getParams();
       for(var key in params){ flashNode += [key] +'="'+ params[key] +'" '; }
      var pairs = this.getVariablePairs().join("&");
       if (pairs.length > 0){ flashNode += 'flashvars="'+ pairs +'"'; }
      flashNode += '/>';
    } else { // PC IE
      if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX");
      flashNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
      flashNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
      var params = this.getParams();
      for(var key in params) {
       flashNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
      }
      var pairs = this.getVariablePairs().join("&");
      if(pairs.length > 0) {flashNode += '<param name="flashvars" value="'+ pairs +'" />';}
      flashNode += "</object>";
    }
    return flashNode;
  },
  write: function(elementId){
    if(this.useExpressInstall) {
      // check to see if we need to do an express install
      var expressInstallReqVer = new com.deconcept.PlayerVersion([6,0,65]);
      if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
        this.setAttribute('doExpressInstall', true);
        this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
        document.title = document.title.slice(0, 47) + " - Flash Player Installation";
        this.addVariable("MMdoctitle", document.title);
      }
    } else {
      this.setAttribute('doExpressInstall', false);
    }
    if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
      var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
      n.innerHTML = this.getFlashHTML();
    }else{
      if(this.getAttribute('redirectUrl') != "") {
        document.location.replace(this.getAttribute('redirectUrl'));
      }
    }
  }
}

/* ---- detection functions ---- */
com.deconcept.FlashObjectUtil.getPlayerVersion = function(reqVer, xiInstall){
  var PlayerVersion = new com.deconcept.PlayerVersion(0,0,0);
  if(navigator.plugins && navigator.mimeTypes.length){
    var x = navigator.plugins["Shockwave Flash"];
    if(x && x.description) {
      PlayerVersion = new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
    }
  }else{
    try{
      var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
      for (var i=3; axo!=null; i++) {
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
        PlayerVersion = new com.deconcept.PlayerVersion([i,0,0]);
      }
    }catch(e){}
    if (reqVer && PlayerVersion.major > reqVer.major) return PlayerVersion; // version is ok, skip minor detection
    // this only does the minor rev lookup if the user's major version 
    // is not 6 or we are checking for a specific minor or revision number
    // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
    if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major != 6 || xiInstall) {
      try{
        PlayerVersion = new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
      }catch(e){}
    }
  }
  return PlayerVersion;
}
com.deconcept.PlayerVersion = function(arrVersion){
  this.major = parseInt(arrVersion[0]) || 0;
  this.minor = parseInt(arrVersion[1]) || 0;
  this.rev = parseInt(arrVersion[2]) || 0;
}
com.deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
  if(this.major < fv.major) return false;
  if(this.major > fv.major) return true;
  if(this.minor < fv.minor) return false;
  if(this.minor > fv.minor) return true;
  if(this.rev < fv.rev) return false;
  return true;
}
/* ---- get value of query string param ---- */
com.deconcept.util = {
  getRequestParameter: function(param){
    var q = document.location.search || document.location.hash;
    if(q){
      var startIndex = q.indexOf(param +"=");
      var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
      if (q.length > 1 && startIndex > -1) {
        return q.substring(q.indexOf("=", startIndex)+1, endIndex);
      }
    }
    return "";
  }
}

/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = com.deconcept.util.getRequestParameter;
var FlashObject = com.deconcept.FlashObject;

    //Extended Search for flexible dates.
    var win;

    

function setValidNoOfNights() {
  var form = document.propertyForm;

  if ((form.arriveDate.value == form.departDate.value) && (form
          .arriveMonth.value == form.departMonth.value) && (form
          .arriveYear.value == form.departYear.value)) {
    form.numberOfNights.value = "0";
  }
}

function setDefaultDate() {
  var currentDate = new Date();

  currentDate.setDate(currentDate.getDate() + 0);
  setArrivalDate(currentDate, '', '', '');
}

<!-- Valtech-NB4 Defect Fix [Defect Number - 30032]- START -->
function showMap() {
  closeWindow();

  var form = document.propertyForm;

  form.showHF.value = "no";
  form.operation.value = "DisplayMap";
  form.height.value = "220";
  form.width.value = "320";
  win = window.open("", "map", 
          "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, left=300, top=250, copyhistory=no, width=320, height=220"
          );

  if (window.focus) {
    win.focus();
  }

  form.target = "map";

  form.submit();

  form.showHF.value = "yes";
}

<!-- Valtech-NB4 Defect Fix [Defect Number - 30032]- END -->
function closeWindow() {
  if (win != null) {
    win.close();
  }
}

<!--
	  var currentDate = new Date();
	  var currentMonth= eval(currentDate.getMonth()+1);
	  var currentDay = currentDate.getDate();
	  var currentYear = currentDate.getFullYear();
	  var InventoryMonth= 12;

	  var InventoryDate = new Date(currentYear, (currentMonth + InventoryMonth -1), currentDay);
//-->

var Labels = new Array();


Labels[0]	= "Next Year";

Labels[1]	= "Previous Year";

Labels[2]	= "Previous Month";

Labels[3]	= "Next Month";

Labels[4]	= "Sun";

Labels[5]	= "Mon";

Labels[6]	= "Tue";

Labels[7]	= "Wed";

Labels[8]	= "Thu";

Labels[9]	= "Fri";

Labels[10]	= "Sat";

Labels[11]	= "January";

Labels[12]	= "February";

Labels[13]	= "March";

Labels[14]	= "April";

Labels[15]	= "May";

Labels[16]	= "June";

Labels[17]	= "July";

Labels[18]	= "August";

Labels[19]	= "September";

Labels[20]	= "October";

Labels[21]	= "November";

Labels[22]	= "December";

Labels[23]	= "S";

Labels[24]	= "M";

Labels[25]	= "T";

Labels[26]	= "W";

Labels[27]	= "T";

Labels[28]	= "F";

Labels[29]	= "S";

Labels[30]	= "";

Labels[31]	= "Close";

Labels[32]	= "Jan";

Labels[33]	= "Feb";

Labels[34]	= "Mar";

Labels[35]	= "Apr";

Labels[36]	= "May";

Labels[37]	= "Jun";

Labels[38]	= "Jul";

Labels[39]	= "Aug";

Labels[40]	= "Sep";

Labels[41]	= "Oct";

Labels[42]	= "Nov";

Labels[43]	= "Dec";

Labels[44]	= "Sunday";

Labels[45]	= "Monday";

Labels[46]	= "Tuesday";

Labels[47]	= "Wednesday";

Labels[48]	= "Thursday";

Labels[49]	= "Friday";

Labels[50]	= "Saturday";


<!--
  var monthName = new Array (Labels[11], Labels[12], Labels[13], Labels[14],Labels[15], Labels[16], Labels[17],Labels[18], Labels[19], Labels[20], Labels[21], Labels[22]);
  var dayName = new Array (Labels[44], Labels[45], Labels[46], Labels[47], Labels[48], Labels[49], Labels[50]);
  var calendarCtrlStrings = new Array ("","",Labels[31]);
//-->


<!--
         //************************************************************************
         // Global variables
         //************************************************************************

         var calendarWindow;

         //************************************************************************
      // Function:  getCalendarCtrlString
      // Purpose:   Return the appropriate localized calendar control string.
      //            (eg: prev, cancel, next).
      // Input:     stringID - Control string to return.
      //            language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      // Output:    String containing the Calendar Control string.
         //************************************************************************

         var CALCTRLSTR_NEXT = 0;
         var CALCTRLSTR_PREV = 1;
         var CALCTRLSTR_CNCL = 2;
		var dateSelectedYear;
		var InventoryDate ;


         function getCalendarCtrlString (stringID, language, locale)
         {
//          var enCalendarCtrlStrings = new Array ("Next", "Prev", "Close");
//          var esCalendarCtrlStrings = new Array ("Despu&#233s", "Anterior", "Cancelan");

            return (calendarCtrlStrings [stringID]);
         }

      //************************************************************************
      // Function:  parseYear
      // Purpose:   Find the index of the year in a HTML SELECT control.
      // Input:     year - year to locate in the control.
      //            inY - the control to search.
      // Output:    Index into the SELECT control.
         //************************************************************************

         function parseYear(year, yearCtrlStr)
         {
            var retval=0;
            var i=0;
            var formyear=0;
            for (i=0; i<=5; i++)
            {
               eval ("formyear = document.getElementById('" + yearCtrlStr + "').options[" + i + "].text;");
               if (year == formyear)
               {
                  retval=i;
                  break;
               }
         }
            return retval;
         }

         //************************************************************************
      // Function:  nextMonth
      // Purpose:   Increment the month.
      // Input:     month
      // Output:    month + 1
         //************************************************************************

         function nextMonth (month)
         {
            if (month==12)
            {
               return 1;
            }
            else
            {
               return (month+1);
            }
         }

         //************************************************************************
      // Function:  prevMonth
      // Purpose:   Previous month.
      // Input:     month
      // Output:    month - 1
         //************************************************************************

         function prevMonth (month)
         {
            var prevMonth = (month - 1)
            if (month==1)
            {
               prevMonth = 12;
            }
            return prevMonth
         }

         //************************************************************************
      // Function:  changeYear
      // Purpose:   Updates the year if incrementing or decrementing into the
      //            previous or following year.
      // Input:     direction - incrementing or decrementing
      //            month - month that is being updated.
      //            year - current year value.
      // Output:    Updated year.
         //************************************************************************

         function changeYear (direction, month, year)
         {
            // increments or decrements month when it goes past Jan or Dec
            var theYear = year
            if (direction=='next')
            {
              if (month == 12)
               {
                  theYear = (year + 1)
               }
            }
            if (direction=='prev')
            {
			   if (month == 1)
               {
				  theYear = (year - 1)
               }
            }
            return theYear
         }


         //************************************************************************
      // Function:  createCalendar
      // Purpose:   Create the calendar popup.
      // Input:     formStr - HTML name of the form that contains the date controls.
      //            dayCtrlStr - HTML name of the day drop down.
      //            monthCtrlStr - HTML name of the month drop down.
      //            yearCtrlStr - HTML name of the year drop down.
      //            dowCtrlStr - HTML name of the day of week control.
      //            language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      //            callBackFn - JavaScript function to call when closing the calendar.
      // Output:    none
         //************************************************************************

         function createCalendar (val,formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr, language, locale, callBackFn)
         {
			InventoryDate = val;
            calendarWindow = window.open ('', 'Calendar', 'width=320,height=295,resizable=yes,scrollbars=no');

            var mthVal = eval ("parseInt(document.getElementById('" + monthCtrlStr + "').options [document.getElementById('" + monthCtrlStr + "').selectedIndex].value, 10)");
            var yearVal = eval ("document.getElementById('" + yearCtrlStr + "').options [document.getElementById('" + yearCtrlStr + "').selectedIndex].value");
			generateCalendar (calendarWindow, mthVal, yearVal, formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr, language, locale, callBackFn)
         }


         //************************************************************************
      // Function:  generateCalendar
      // Purpose:   Emit the HTML into the calendar popup window.
      // Input:     target - Target browser window for the calendar.
      //            month - Month of the calendar top create.
      //            year - Year of the calendar to create.
      //            formStr - HTML name of the form that contains the date controls.
      //            dayCtrlStr - HTML name of the day drop down.
      //            monthCtrlStr - HTML name of the month drop down.
      //            yearCtrlStr - HTML name of the year drop down.
      //            dowCtrlStr - HTML name of the day of week control.
      //            language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      //            callBackFn - JavaScript function to call when closing the calendar.
      // Output:    none
         //************************************************************************
		 //
/*<body bgcolor="#FEFEFE" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="90%" border="0" cellspacing="5" cellpadding="3" align="center">
        <tr bgcolor="FEFBF0">
          <td>
            <div align="center"><b><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="A06000">Previous
              Year </font></b></div>
          </td>
          <td>
            <div align="center"><b><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="A06000">Previous
              Month </font></b></div>
          </td>
          <td>
            <div align="center"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="A06000">Next
              Month </font></b></div>
          </td>
          <td>
            <div align="center"><b><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="A06000">Next
              Year</font></b></div>
          </td>
        </tr>
      </table>*/

		 //

         function generateCalendar(target, month, year, formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr, language, locale, callBackFn)
         {
            var currentYearLabel= new Date().getFullYear();
			var nextYearLabel=eval(currentYear+1);
			var nextYearLabel2=eval(currentYear+2);
			var nextYearLabel3=eval(currentYear+3);
			var nextYearLabel4=eval(currentYear+4);
			var nextYearLabel5=eval(currentYear+5);
			target.document.open()
			calendar = "<html><head><title>Calendar </title>"
            calendar +="<STYLE><!-- \n"
            calendar +="body { font-family: Verdana, Arial, Helvetica, sans; font-size: 10px; color: #828282; font-weight: normal; }\n"
            calendar +=".monthtitle { font-family: Verdana, Arial, Helvetica; font-size: 14px; color: #828282; LETTER-SPACING: 0px; font-weight: bold; BACKGROUND-COLOR: #dcd7cb } \n"
            calendar +=".wedaytitle { font-family: Verdana,Arial,Helvetica; font-size: 12px; color: black; } \n"
            calendar +=".daytitle { font-family: Verdana,Arial,Helvetica; font-size: 12px; color: #828282; } \n"
            calendar +=".day  { font-family: Verdana,Arial,Helvetica; font-size: 10px; color: #828282; } \n"
            calendar +=".nxtprev { font-family: Verdana,Arial,Helvetica; font-size: 10px; color: #828282; } \n"
            calendar +="A:link {color:#8C8C8C} A:visited {color:#8C8C8C} A:hover {color:#003300} \n"

			

            calendar +="--></STYLE>\n"
            calendar +="</head><body>\n"
			calendar += "<table width='300' border='0' cellspacing='0' cellpadding='0'>" // table1
			//

			calendar +="<tr>"
			calendar +="<td class='calend11'>"
			calendar +="<div align='right'><img src='./images/calendar2.gif' ></div>"
			calendar +="</td>"
			calendar +="</tr>"
			//
			//calendar +="<tr>"
			//calendar +="<td bgcolor='#FEFEFE'><img src='calendar2.gif' align='right' ></td>"



		//	calendar +="<div align='right' ><img src='calendar2.gif' ></div>"
		//	calendar +="</td>"
			//calendar +="</tr>"
			calendar +="<tr>"
			calendar +="<td class='calend12'><img src='./images/spacer.gif' width='1' height='10'></td>"
			calendar +="</tr>"
			calendar +="<tr>"
			calendar +="<td class='calend111'> <span class='calend113'><b><font size='1'>"
			if(year==currentYearLabel)
			{
				calendar +=" <a style='text-decoration: none' 'javascript:opener.generateCalendar(self," + month + "," + currentYearLabel + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				calendar += "<span class='calend16'>"
				calendar += currentYearLabel + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span></font></span>"
			}
			else
		    {
				 calendar +=" <a href='javascript:opener.generateCalendar(self," + month + "," + currentYearLabel + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				 calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				 calendar += "<span class='calend15'>" + currentYearLabel + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span></font></span>"
			}
			

		   var inventoryYr = new Date().getFullYear();
   		   if (InventoryDate.getFullYear() != null)
   		   {
			   inventoryYr = InventoryDate.getFullYear();
   		   }

		if (nextYearLabel <= inventoryYr)
		{
			if(year==nextYearLabel)
			{
				calendar +=" <a style='text-decoration: none' 'javascript:opener.generateCalendar(self," + month + "," + nextYearLabel + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				calendar += "<span class='calend16'>"
				calendar += nextYearLabel + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span>"
		   }
		   else
		   {
				 calendar +=" <a href='javascript:opener.generateCalendar(self," + month + "," + nextYearLabel + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				 calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				 calendar += "<span class='calend15'>" + nextYearLabel + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span></font>"
		   }
		}
		if (nextYearLabel2 <= inventoryYr)
		{
		   if(year==nextYearLabel2)
		   {
				calendar +=" <a style='text-decoration: none' 'javascript:opener.generateCalendar(self," + month + "," + nextYearLabel2 + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				calendar += "<span class='calend16'>"
				calendar += nextYearLabel2 + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span>"
		   }
		   else
		   {
				 calendar +=" <a href='javascript:opener.generateCalendar(self," + month + "," + nextYearLabel2 + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				 calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				 calendar += "<span class='calend15'>" + nextYearLabel2 + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span></font>"
		   }
		}
		
		if (nextYearLabel3 <= inventoryYr)
		{
		
		   if(year==nextYearLabel3)
			{
				calendar +=" <a style='text-decoration: none' 'javascript:opener.generateCalendar(self," + month + "," + nextYearLabel3 + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				calendar += "<span class='calend16'>"
				calendar += nextYearLabel3 + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span>"
		   }
		   else
		   {
				 calendar +=" <a href='javascript:opener.generateCalendar(self," + month + "," + nextYearLabel3 + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				 calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				 calendar += "<span class='calend15'>" + nextYearLabel3 + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span></font>"
		   }
		}
		 if (nextYearLabel4 <= inventoryYr)
		{
		   if(year==nextYearLabel4)
			{
				calendar +=" <a style='text-decoration: none' 'javascript:opener.generateCalendar(self," + month + "," + nextYearLabel4 + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				calendar += "<span class='calend16'>"
				calendar += nextYearLabel4 + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span>"
		   }
		   else
		   {
				 calendar +=" <a href='javascript:opener.generateCalendar(self," + month + "," + nextYearLabel4 + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				 calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				 calendar += "<span class='calend15'>" + nextYearLabel4 + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span></font>"
		   }
		}
		if (nextYearLabel5 <= inventoryYr)
		{
		   if(year==nextYearLabel5)
			{
				calendar +=" <a style='text-decoration: none' 'javascript:opener.generateCalendar(self," + month + "," + nextYearLabel5 + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				calendar += "<span class='calend16'>"
				calendar += nextYearLabel5 + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span>"
		   }
		   else
		   {
				 calendar +=" <a href='javascript:opener.generateCalendar(self," + month + "," + nextYearLabel5 + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
				 calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"
				 calendar += "<span class='calend15'>" + nextYearLabel5 + "</span>" + "</a><span class='calend112'><b><font size='1'>&nbsp; &middot;</font></b></span></font>"
		   }
		}
			calendar +="<table width='100%' border='0' cellspacing='0' cellpadding='3'>"// table2

			calendar +="<tr>"
			/*
			<tr>
    <td bgcolor="#FEFBF0"> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">&nbsp; &middot;2003</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b><font size="1">&nbsp; &middot;</font></b></font><font size="1"><u>2004</u></font></b></font>
      <table width="100%" border="0" cellspacing="0" cellpadding="3">// table2
        <tr>

			<td>
            <div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&middot;</b>Jan</font></div>
          </td>
			*/
            var mthIdx = month;
            var endday = getDaysInMonth(mthIdx, year)
			var changingmonth=mthIdx;
            var index = (mthIdx-1)
            var goPrevMonth = prevMonth(mthIdx)
			// var goPrevMonth = nextMonth()
//
            var goNextMonth = nextMonth(mthIdx)

            var nextYear = changeYear ('next', parseInt (month, 10), parseInt (year, 10))
            var prevYear = changeYear ('prev', parseInt (month, 10), parseInt (year, 10))


        // Create the calendar header
            calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 1 + "," + year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[32]+"</a></span></div>"
			calendar +=" </td>"

			calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 2 + "," + year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[33]+"</a></span></div>"
			calendar +=" </td>"

			calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 3 + "," + year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[34]+"</a></span></div>"
			calendar +=" </td>"

			calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 4 + "," + year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[35]+"</a></span></div>"
			calendar +=" </td>"

			calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 5 + "," + year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[36]+"</a></span></div>"
			calendar +=" </td>"

			calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 6 + "," + year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[37]+"</a></span></div>"
			calendar +=" </td>"
			calendar +=" </tr>"

			calendar +=" <tr>"
			calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 7 + "," + year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[38]+"</a></span></div>"
			calendar +=" </td>"

			calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 8 + "," + year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[39]+"</a></span></div>"
			calendar +=" </td>"


			calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 9 + "," + year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[40]+"</a></span></div>"
			calendar +=" </td>"


			calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 10 + "," +year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[41]+"</a></span></div>"
			calendar +=" </td>"

			calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 11 + "," + year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[42]+"</a></span></div>"
			calendar +=" </td>"


			calendar +=" <td><div align='center'><span class='calend112'><b>&middot;</b>"
		    calendar +=" <a href='javascript:opener.generateCalendar(self," + 12 + "," + year + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\""
            calendar +=  dowCtrlStr + "\", \"" + language + "\",\" " + locale + "\",\" " + callBackFn + "\")'>"+Labels[43]+"</a></span></div>"
			calendar +=" </td>"
			calendar +=" </tr>"

			calendar +="</table>"// table2
			calendar +="<br>"

			calendar +="<table width='100%' border='0' cellspacing='0' cellpadding='1' align='center>"// table3
			/*

			calendar += "<tr align=center>"
			calendar +=" <td colspan=8 align=center class=\"monthtitle\">"
            calendar +=  getMonth (mthIdx) + " " + year
            calendar +=" </td>"
			calendar +=" </tr><hr>"


			*/
			calendar +="<tr class='calend17'>"
			calendar +="<td class='calend14'><span class='calend112' colspan=6><b><font"
			calendar +="size='1'>&nbsp;&nbsp;</font></b></span><span class='calend112'><b>"
            calendar += getMonth (mthIdx) + " " + year
			calendar +="</b></span></td>"
			calendar +="</tr>"


			calendar +="<tr>"
			calendar +="<td>"
            calendar +="<table width='100%' border='0' cellspacing='0' cellpadding='2'>"// table4
            calendar +="<tr>"
			//

			calendar +="<td>"
            calendar +="<div align='center'><span class='calend112'><b><font color=''>"+Labels[23]+"</font></b></span></div>"
            calendar +="</td>"
            calendar +="<td>"
            calendar +="<div align='center'><span class='calend112'><b><font color=''>"+Labels[24]+"</font></b></span></div>"
            calendar +="</td>"
            calendar +="<td>"
            calendar +="<div align='center'><span class='calend112'><b><font color=''>"+Labels[25]+"</font></b></span></div>"
            calendar +="</td>"
            calendar +="<td>"
            calendar +="<div align='center'><span class='calend112'><b><font color=''>"+Labels[26]+"</font></b></span></div>"
            calendar +="</td>"
            calendar +="<td>"
            calendar +="<div align='center'><span class='calend112'><b><font color=''>"+Labels[27]+"</font></b></span></div>"
            calendar +="</td>"
            calendar +="<td>"
            calendar +="<div align='center'><span class='calend112'><b><font color=''>"+Labels[28]+"</font></b></span></div>"
            calendar +="</td>"
            calendar +="<td>"
            calendar +="<div align='center'><span class='calend112'><b><font color=''>"+Labels[29]+"</font></b></span></div>"
            calendar +="</td>"
            calendar +="</tr>"

			/*
			 <td>
                  <div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#0033CC">1</font></div>
                </td>
			calendar += "<tr align=center>"
			calendar +=" <td colspan=8 align=center class=\"monthtitle\">"
            calendar +=  getMonth (mthIdx) + " " + year
            calendar +=" </td>"
			calendar +=" </tr><hr>"
			*/


        // Create the days.
            wholeDate = month + "/01/" + year
            thedate = new Date(wholeDate)
            firstDay = thedate.getDay()
            selectedmonth = mthIdx;
            var today = new Date();
			var month=today.getMonth();
			// added later
			var presentMonth=eval(today.getMonth()+1);
			//var presentMonth=eval(today.getMonth()+1);
			//var presentDay = today.getDay();
			var presentDay= today.getDate();

			var presentYear = today.getFullYear();
			var presentDate =new Date(presentMonth + "/" + presentDay + "/" + presentYear);
            var thisyear = today.getYear() + 1900;
            selectedyear = year
            var lastDay = (endday + firstDay+1)
            var iRows =0
            calendar +=" <tr>"
            for (var i = 1; i < lastDay; i++)
            {

               if (i <= firstDay)
               {
                  calendar +=" <td class='calend13'>&nbsp;</td>"
               }
               else
               {
				   var changeingDay =(i-firstDay);
				   var changigDate =new Date(changingmonth + "/" + changeingDay + "/" + year)

					if(changigDate <= InventoryDate)
					{
						if(  changigDate >= presentDate)
						{
							var changingTime = changigDate.getTime();
							var presentTime= presentDate.getTime();
							if(changingTime==presentTime)
							{
							changeingDay = "<font color = 'red' size = '1'>" + changeingDay + "</font>" ;
							}
							calendar +=" <td><div align=center><span class='calend18'><a href='JavaScript:opener.closeCalendar(" + (i-firstDay) + ", \"" + formStr + "\", \"" + dayCtrlStr + "\", \"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" + dowCtrlStr
							calendar += "\", \"" +  language + "\", \"" + locale + "\",\"" + callBackFn + "\");self.close();'>"+ changeingDay +"</a></span></div></td>"
						}
						else
						{
							calendar +=" <td><div align=center><span class='calend18'><a  'JavaScript:opener.closeCalendar(" + (i-firstDay) + ", \"" + formStr + "\", \"" + dayCtrlStr + "\", \"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" + dowCtrlStr
							calendar += "\", \"" +  language + "\", \"" + locale + "\",\"" + callBackFn + "\");self.close();'>"+(i-firstDay) +"</a></span></div></td>"

						}
					}
					else
					{
						calendar +=" <td align=center><div align=center><font size='1'><span class='calend19'><a 'JavaScript:opener.closeCalendar(" + (i-firstDay) + ", \"" + formStr + "\", \"" + dayCtrlStr + "\", \"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" + dowCtrlStr
						calendar += "\", \"" +  language + "\", \"" + locale + "\",\"" + callBackFn + "\");self.close();'>"+(i-firstDay) +"</a></span></font></div></td>"

					}


               }
               if (i % 7 == 0 )
               {
                  if (i != lastDay-1)
                  {
                     calendar +=" </tr><tr>"
                     iRows = iRows + 1
                  }
                  else
                  {
                     iRows = iRows
                  }
               }
            }
            calendar +=" </tr>"

        // Create the calendar footer
            iRows = iRows + 1
            for (var icounter = 1; icounter <= 6-iRows; icounter++)
            {
               calendar +=" <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>"
            }

          //  calendar +=" <td align=center colspan=7 class=\"monthtitle\"><a href='javascript:self.close()'>" + getCalendarCtrlString (CALCTRLSTR_CNCL, language, locale) + "</a></td>"
          //  calendar +=" </tr></table></td></tr></table></tr></table></body></html>"
			calendar +="</table></body></html>"
            target.document.write(calendar);
            target.document.close();
         }

         //************************************************************************
      // Function:  closeCalendar
      // Purpose:   Close the calendar and update the parent forms date controls.
      // Input:     day - selected day.
      //            formStr - HTML name of the form that contains the date controls.
      //            dayCtrlStr - HTML name of the day drop down.
      //            monthCtrlStr - HTML name of the month drop down.
      //            yearCtrlStr - HTML name of the year drop down.
      //            dowCtrlStr - HTML name of the day of week control.
      //            language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      //            callBackFn - JavaScript function to call when closing the calendar.
      // Output:    none
         //************************************************************************

         function closeCalendar (day, formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr, language, locale, callBackFn)
         {
                // Update the controls.
              var toDay= new Date();
              var today = new Date();
              var presentMonth=eval(today.getMonth() + 1);
              var presentDay = today.getDate();
              var Presentyear = today.getYear();
              var presentDate =new Date(presentMonth + "/" + presentDay + "/" + Presentyear);
              var selected =new Date(selectedmonth + "/" + day + "/" + selectedyear);
              try
              {
                  if(selected >= presentDate)
                  {
                        var yrIdx = parseYear (selectedyear, yearCtrlStr);
                        eval ("document.getElementById('" + dayCtrlStr + "').selectedIndex = " + parseInt(day-1, 10));
                        eval ("document.getElementById('" + monthCtrlStr + "').selectedIndex = "  + selectedmonth + "-1");
                        eval ("document.getElementById('" + yearCtrlStr + "').selectedIndex = " + yrIdx);

                        eval ("document.getElementById('" + dowCtrlStr + "').value = '"
                                       + getDayOfWeek (buildCRSDate (selectedyear,
                                                                     selectedmonth,
                                                                     day)) + "'");
                        // Call the callback function.
                        eval (callBackFn);
                        if(dayCtrlStr == "DATERANGESTART_DAY")
                        {
                           updateSTART_DATE('','','');
                           updateDATES('','','',-1);
                         }
                         else
                         {
                           updateDATES('','','',-1);
                         }
                   }
                }
                catch(errorObject)
                {
                    return false;
                }
          }

//-->
// $Header: /vc/cvsroot/netbooker/IBE/web/sources/js/calendar/searchcodefunctions.js,v 1.2.86.1 2007/03/20 18:23:35 pholser Exp $
      //************************************************************************
      // Global variables
      //************************************************************************

      var submitting = false;

      //************************************************************************
      // Function:  initForm
      // Purpose:   Initialize Arrival Date and Departure Date controls.
      // Input:     arr* - Arrival date
      //            dep* - Departure date
      //            language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      // Output:    None
      //************************************************************************

      function initForm (formStr, arrYear, arrMonth, arrDay, depYear, depMonth, depDay, language, locale)
      {

        // Initialize date to todays date + 1.
        var myDate = new Date ();
        var month = myDate.getMonth () + 1;
        var year = getFullYear (myDate);
        var day = myDate.getDate () + 1;
        if (day > getDaysInMonth (month, year))
        {
         day = 1;
         month = month + 1;
         if (month > 12)
         {
            year = year + 1;
            month = 1;
         }
        }


        if (arrYear != "" && arrMonth != "" && arrDay != "")
        {
          // If Arrival date was posted in then initialize.
          year = parseInt (arrYear, 10);
          month = parseInt (arrMonth, 10);
          day = parseInt (arrDay, 10);

          myDate = new Date (arrYear, arrMonth, arrDay);
        }

        // Initialize arrival date.
        // Initalize form year.
        var index;
        for (index = 0; (index < document.getElementById('DATERANGESTART_YEAR').length) &&
                        (document.getElementById('DATERANGESTART_YEAR').options[index].value != year);
             index++);
        document.getElementById('DATERANGESTART_YEAR').options[index].selected = true;

        // Initalize form month.
        for (index = 0; (index < document.getElementById('DATERANGESTART_MONTH').length) &&
                        (document.getElementById('DATERANGESTART_MONTH').options[index].value != month);
             index++);
        document.getElementById('DATERANGESTART_MONTH').options[index].selected = true;

        // Initalize form day.
        for (index = 0; (index < document.getElementById('DATERANGESTART_DAY').length) &&
                        (document.getElementById('DATERANGESTART_DAY').options[index].value != day);
             index++);
        document.getElementById('DATERANGESTART_DAY').options[index].selected = true;

        // Initalize Day of the week.
        document.getElementById('DATERANGESTART_DOW').value = getDayOfWeek (buildCRSDate (year, month, day));

        if (depYear != "" && depMonth != "" && depDay != "")
        {
          // If departure date was posted in then initialize.
          year = parseInt (depYear, 10);
          month = parseInt (depMonth, 10);
          day = parseInt (depDay, 10);
        }
        else
        {
          // Add 1 to the current date to get the initial departure date.
          day = day + 1;
          if (day > getDaysInMonth (month, year))
          {
            day = 1;
            month = month + 1;
            if (month > 12)
            {
              year = year + 1;
              month = 1;
            }
          }
        }

        // Initalize form year.
        for (index = 0; (index < document.getElementById('DATERANGEEND_YEAR').length) &&
                        (document.getElementById('DATERANGEEND_YEAR').options[index].value != year);
             index++);
        document.getElementById('DATERANGEEND_YEAR').options[index].selected = true;

        // Initalize form month.
        for (index = 0; (index < document.getElementById('DATERANGEEND_MONTH').length) &&
                        (document.getElementById('DATERANGEEND_MONTH').options[index].value != month);
             index++);
        document.getElementById('DATERANGEEND_MONTH').options[index].selected = true;

        // Initalize form day.
        for (index = 0; (index < document.getElementById('DATERANGEEND_DAY').length) &&
                        (document.getElementById('DATERANGEEND_DAY').options[index].value != day);
             index++);
        document.getElementById('DATERANGEEND_DAY').options[index].selected = true;

        // Initalize Day of the week.
        document.getElementById('DATERANGEEND_DOW').value = getDayOfWeek (buildCRSDate (year, month, day));

        // other dropdowns are inited in XSL.
      }

      //************************************************************************
      // Function:  validateDay
      // Purpose:   Ensure that a selected day is valid. Example 2/31 is an
      //            invalid day. If an invalid date is selected, select the
      //            previous valid day.
      // Input:     yearCtrl - Year dropdown.
      //            monthCtrl - Month dropdown.
      //            dayCtrl - Day dropdown.
      // Output:    None
      //************************************************************************

      function validateDay (formStr, yearCtrl, monthCtrl, dayCtrl)
      {
        eval ("var year = parseInt (document.getElementById('" + yearCtrl + "').options[document.getElementById('" + yearCtrl + "').selectedIndex].value, 10)");
        eval ("var month = parseInt (document.getElementById('" + monthCtrl + "').options[document.getElementById('" + monthCtrl + "').selectedIndex].value, 10)");
        eval ("var day = parseInt (document.getElementById('" + dayCtrl + "').options[document.getElementById('" + dayCtrl + "').selectedIndex].value, 10)");

        if (day > (maxDay = getDaysInMonth (month, year)))
        {
          for (index = 0; (index < eval ("document.getElementById('" + dayCtrl + "').length")) &&
                          (eval ("document.getElementById('" + dayCtrl + "').options[" + index+ "].value != " + maxDay));
               index++);
          eval ("document.getElementById('" + dayCtrl + "').options[" + index + "].selected = true");
        }

      }

      //************************************************************************
      // Function:  updateDOW
      // Purpose:   Set the Day of the Week to the valid string (Monday, Tuesday, etc.)
      // Input:     yearCtrl - Year dropdown.
      //            monthCtrl - Month dropdown.
      //            dayCtrl - Day dropdown.
      //            dowCtrl - Day of the Week Control - Control to set.
      //            language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      // Output:    None
      //************************************************************************

      function updateDOW (formStr, yearCtrl, monthCtrl, dayCtrl, dowCtrl, language, locale)
      {
        eval ("var year = parseInt (document.getElementById('" + yearCtrl + "').options[document.getElementById('" + yearCtrl + "').selectedIndex].value, 10)");
        eval ("var month = parseInt (document.getElementById('" + monthCtrl + "').options[document.getElementById('" + monthCtrl + "').selectedIndex].value, 10)");
        eval ("var day = parseInt (document.getElementById('" + dayCtrl + "').options[document.getElementById('" + dayCtrl + "').selectedIndex].value, 10)");

        eval ("document.getElementById('" + dowCtrl + "').value = getDayOfWeek (buildCRSDate (year, month, day))");
      }

      //************************************************************************
      // Function:  updateDATERANGEEND
      // Purpose:   Update the Departure Date to the Arrival Date + 1.
      // Input:     language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      // Output:    None
      //************************************************************************

      function updateDATERANGEEND (formStr, language, locale)
      {

        // Get the current arrival date.
        var startYear = parseInt (document.getElementById('DATERANGESTART_YEAR').options[document.getElementById('DATERANGESTART_YEAR').selectedIndex].value, 10);
        var startMonth = parseInt (document.getElementById('DATERANGESTART_MONTH').options[document.getElementById('DATERANGESTART_MONTH').selectedIndex].value, 10);
        var startDay = parseInt (document.getElementById('DATERANGESTART_DAY').options[document.getElementById('DATERANGESTART_DAY').selectedIndex].value, 10);

        var startDate = new Date (startYear, startMonth - 1, startDay);

        // Get the current departure date.
        var endYear = parseInt (document.getElementById('DATERANGEEND_YEAR').options[document.getElementById('DATERANGEEND_YEAR').selectedIndex].value, 10);
        var endMonth = parseInt (document.getElementById('DATERANGEEND_MONTH').options[document.getElementById('DATERANGEEND_MONTH').selectedIndex].value, 10);
        var endDay = parseInt (document.getElementById('DATERANGEEND_DAY').options[document.getElementById('DATERANGEEND_DAY').selectedIndex].value, 10);

        var endDate = new Date (endYear, endMonth - 1, endDay);

        // If the arrival date is greater than the departure date then update the departure date.
        if (startDate.getTime () >= endDate.getTime ())
        {
          endDay = startDay + 1;
          endMonth = startMonth;
          endYear = startYear;

          if (endDay > getDaysInMonth (startMonth, startYear))
          {
            // Move to the first day of the next month.
            endDay = 1;
            endMonth = endMonth + 1

            // If endMonth is > 12, cycle into the next year.
            if (endMonth > 12)
            {
              endMonth = 1;
              endYear = startYear + 1;
            }
          }

          // Update departure year.
          for (index = 0; (index < document.getElementById('DATERANGEEND_YEAR').length) &&
                          (document.getElementById('DATERANGEEND_YEAR').options[index].value != endYear);
               index++);
          document.getElementById('DATERANGEEND_YEAR').options[index].selected = true;

          // Update departure month.
          for (index = 0; (index < document.getElementById('DATERANGEEND_MONTH').length) &&
                          (document.getElementById('DATERANGEEND_MONTH').options[index].value != endMonth);
               index++);
          document.getElementById('DATERANGEEND_MONTH').options[index].selected = true;

          // Update departure day.
          for (index = 0; (index < document.getElementById('DATERANGEEND_DAY').length) &&
                          (document.getElementById('DATERANGEEND_DAY').options[index].value != endDay);
               index++);
          document.getElementById('DATERANGEEND_DAY').options[index].selected = true;

          updateDOW (formStr, 'DATERANGEEND_YEAR', 'DATERANGEEND_MONTH', 'DATERANGEEND_DAY', 'DATERANGEEND_DOW', language, locale);
        }
      }

      //************************************************************************
      // Function:  checkForm
      // Purpose:   Check if the departure date is prior to the arrival date before submitting.
      // Input:     language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      // Output:    None
      //************************************************************************

      function checkForm(formStr)
      {

        exit=false;

        // Get the current arrival date.
        var startYear = parseInt (document.getElementById('DATERANGESTART_YEAR').options[document.getElementById('DATERANGESTART_YEAR').selectedIndex].value, 10);
        var startMonth = parseInt (document.getElementById('DATERANGESTART_MONTH').options[document.getElementById('DATERANGESTART_MONTH').selectedIndex].value, 10);
        var startDay = parseInt (document.getElementById('DATERANGESTART_DAY').options[document.getElementById('DATERANGESTART_DAY').selectedIndex].value, 10);

        var startDate = new Date (startYear, startMonth - 1, startDay);

        // Get the current departure date.
        var endYear = parseInt (document.getElementById('DATERANGEEND_YEAR').options[document.getElementById('DATERANGEEND_YEAR').selectedIndex].value, 10);
        var endMonth = parseInt (document.getElementById('DATERANGEEND_MONTH').options[document.getElementById('DATERANGEEND_MONTH').selectedIndex].value, 10);
        var endDay = parseInt (document.getElementById('DATERANGEEND_DAY').options[document.getElementById('DATERANGEEND_DAY').selectedIndex].value, 10);

        var endDate = new Date (endYear, endMonth - 1, endDay);

        // If the arrival date is greater than the departure date then update the departure date.
        if (startDate.getTime () >= endDate.getTime ())
        {
            alert("Arrival date must be prior to the departure date!");
        }
        else
        {
            eval("document.getElementById('" + formStr +"').submit();");
        }
      }

      var exit=true;

      function leave(sURL) {
        ihit = 420;
        iwid = 500;
        ttl = (screen.availHeight/2)-(ihit/2);
        lll = (screen.availWidth/2)-(iwid/2);
        if (exit) {
          open(sURL,'Spoiler','toolbar=1,scrollbars=1,resizable=1,width=' + iwid + ',height=' + ihit + ',top=' + ttl + ',left=' + lll);
        }
      }

      //************************************************************************
      // Function:  getFullYear
      // Purpose:   Get the four digit year given a two digit year.
      // Input:     date - date to get the four digit year for.
      // Output:    Four digit year.
      //
      // Function required because NE 3.01 does not support date.getFullYear.
      // Code copied from O'Reilly - JavaScript The Definitive Guide
      //************************************************************************

      function getFullYear (date)
      {
        var year = date.getYear ();
        if (year < 1000) year += 1900;
        return (year);
      }

      //************************************************************************
      // Function:  getDayOfWeek
      // Purpose:   Get the day of the week for a given date.
      // Input:     date - date to get the four digit year for.
      // Output:    String containing the Day of the Week (Monday, Tuesday, etc).
      //************************************************************************

      function getDayOfWeek (crsDate)
      {
        var myDate = new Date (crsDate.substring (0, 4), parseInt(crsDate.substring (4, 6), 10) - 1,  parseInt(crsDate.substring (6, 8), 10));
        return (dayName [myDate.getDay ()]);
      }

      //************************************************************************
      // Function:  getDayOfWeek
      // Purpose:   Get the day of the week for a given date.
      // Input:     year, month, day
      // Output:    String containing the Day of the Week (Monday, Tuesday, etc).
      //************************************************************************

      function getDayOfWeek2 (year, month, day)
      {
        var myDate = new Date (year, parseInt(month, 10) - 1,  parseInt(day, 10));
        return (dayName [myDate.getDay ()]);
      }

      //************************************************************************
      // Function:  getMonth
      // Purpose:   Get the month description for a given date.
      // Input:     month - month to get the description for.
      // Output:    String containing the month (January, February, etc).
      //************************************************************************

      function getMonth (month)
      {
        //alert( month )
       // alert( monthName [month - 1] )
		return (monthName [month - 1]);
      }

      //************************************************************************
      // Function:  formatDateDisplay
      // Purpose:   Format a date in the form of January 1, 1999 Tuesday
      // Input:     crsDate - date to format
      //            language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      // Output:    String containing the formatted date.
      //************************************************************************

      function formatDisplayDate (crsDate, language, locale)
      {
        var monthStr = getMonth (parseInt (crsDate.substring (4, 6), 10));
        return (monthStr  + " " + crsDate.substring (6, 8) + ", " + crsDate.substring (0, 4)
                  + " " + getDayOfWeek (crsDate));
      }

      //************************************************************************
      // Function:  formatDateDisplay
      // Purpose:   Format a date in the form of January 1, 1999 Tuesday
      // Input:     year
      //            month
      //            day
      //            language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      // Output:    String containing the formatted date.
      //************************************************************************

      function formatDisplayDate2 (year, month, day, language, locale)
      {
        var monthStr = getMonth (parseInt (month, 10));
        return (monthStr  + " " + day + ", " + year
                  + " " + getDayOfWeek2 (year, month, day));
      }

      //************************************************************************
      // Function:  formatDateDisplayShort
      // Purpose:   Format a date in the form of January 1
      // Input:     crsDate - date to format
      //            language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      // Output:    String containing the formatted date.
      //************************************************************************

      function formatDisplayDateShort (crsDate, language, locale)
      {
        monthStr = getMonth (parseInt (crsDate.substring (4, 6), 10));
        return (monthStr  + " " + crsDate.substring (6, 8));
      }

      //************************************************************************
      // Function:  buildCRSDate
      // Purpose:   Format a date in the form YYYYMMDD
      // Input:     year
      //            month
      //            day
      // Output:    String containing the formatted date.
      //************************************************************************

      function buildCRSDate (year, month, day)
      {
        if (day < 10)
        {
          dayString = "0" + day;
        }
        else
        {
          dayString = new String (day);
        }

        if (month < 10)
        {
          monthString = "0" + month;
        }
        else
        {
          monthString = new String(month);
        }

        return (year + monthString + dayString);
      }
      //************************************************************************
      // Function:  isLeapYear
      // Purpose:   Determine if a year is a leap year.
      // Input:     yrStr - year to determine leapness..
      // Output:    true - if the year is a leap year.
      //            false - otherwise.
      //************************************************************************

      function isLeapYear(yrStr)
      {
        var leapYear=false;
        // every fourth year is a leap year
        if ((parseInt(yrStr, 10)%4) == 0)
        {
          leapYear=true;
        }
        return leapYear;
      }

      //************************************************************************
      // Function:  getDaysInMonth
      // Purpose:   Determine the number of days in a month.
      // Input:     mthIdx - month
      //            yrStr - year
      // Output:    true - if the year is a leap year.
      //            false - otherwise.
      //************************************************************************

      function getDaysInMonth(mthIdx, YrStr)
      {
        // all the rest have 31
        var maxDays = 31
        // expect Feb. (of course)
        if (mthIdx==2)
        {
          if (isLeapYear(YrStr))
          {
            maxDays=29;
          }
          else
          {
            maxDays=28;
          }
        }
        // thirty days hath...
        if (mthIdx==4 || mthIdx==6 || mthIdx==9 || mthIdx==11)
        {
          maxDays=30;
        }
        return maxDays;
      }
      
      // $Header: /vc/cvsroot/netbooker/IBE/web/sources/js/calendar/IBECalUtil.js,v 1.5.52.1 2007/03/20 18:23:35 pholser Exp $
      //************************************************************************
      // Global variables
      //************************************************************************

       function addDays(myDate,days)
       {
          return new Date(myDate.getTime() + days*24*60*60*1000);
       }
      //************************************************************************
      // Function:  updateDATES
      // Purpose:   Update the Departure Date to the Arrival Date + 1.
      // Input:     language - language used by the WEB page.
      //            locale - locale used by the WEB page.
      // Output:    None
      //************************************************************************

      function updateDATES(formStr, language, locale, days)
      {

        // Get the current arrival date.
        var startYear = parseInt (document.getElementById('DATERANGESTART_YEAR').options[document.getElementById('DATERANGESTART_YEAR').selectedIndex].value, 10);
        var startMonth = parseInt (document.getElementById('DATERANGESTART_MONTH').options[document.getElementById('DATERANGESTART_MONTH').selectedIndex].value, 10);
        var startDay = parseInt (document.getElementById('DATERANGESTART_DAY').options[document.getElementById('DATERANGESTART_DAY').selectedIndex].value, 10);

				// set to 3:00 am to ensure it works with daylight savings time
        var startDate = new Date (startYear, startMonth - 1, startDay, 3, 0, 0);

        // Get the current departure date.
        var endYear = parseInt (document.getElementById('DATERANGEEND_YEAR').options[document.getElementById('DATERANGEEND_YEAR').selectedIndex].value, 10);
        var endMonth = parseInt (document.getElementById('DATERANGEEND_MONTH').options[document.getElementById('DATERANGEEND_MONTH').selectedIndex].value, 10);
        var endDay = parseInt (document.getElementById('DATERANGEEND_DAY').options[document.getElementById('DATERANGEEND_DAY').selectedIndex].value, 10);

				// Set to 4 am to ensure the number of days will be calculated correctly with daylight savings time (Start + 1 hour)
        var endDate = new Date (endYear, endMonth - 1, endDay, 4, 0, 0);

        // If the arrival date is greater than the departure date then update the departure date.
        var done = true;
        var daydiff = DateDiff( startDate,endDate,'d');
        var nights=0;
        if (days != -1)
        {
          endDate = addDays(startDate,days);
          endYear = endDate.getFullYear() ;
          endMonth = endDate.getMonth() + 1;
          endDay = endDate.getDate() ;
          updateDateCombos(formStr,language, locale,endYear,endMonth,endDay,'DATERANGEEND_YEAR', 'DATERANGEEND_MONTH', 'DATERANGEEND_DAY', 'DATERANGEEND_DOW');
          updateDOW (formStr, 'DATERANGESTART_YEAR', 'DATERANGESTART_MONTH', 'DATERANGESTART_DAY', 'DATERANGESTART_DOW', language, locale);
        }
        else
        {
          if(daydiff > 0)
          {
            nights = daydiff;
          }
          else
          {
            nights = document.getElementById('NUMBER_OF_NIGHTS').value;
            /*var new_date = addDays(endDate,(nights*-1));
            startYear = new_date.getYear();
            startMonth = new_date.getMonth() + 1;
            startDay = new_date.getDate();
            updateDateCombos(formStr,language, locale,startYear,startMonth,startDay,'DATERANGESTART_YEAR', 'DATERANGESTART_MONTH', 'DATERANGESTART_DAY', 'DATERANGESTART_DOW');*/
          }
          if (document.getElementById('NUMBER_OF_NIGHTS')!=null)
          {
            document.getElementById('NUMBER_OF_NIGHTS').value = nights;
          }
          updateDOW (formStr, 'DATERANGEEND_YEAR', 'DATERANGEEND_MONTH', 'DATERANGEEND_DAY', 'DATERANGEEND_DOW', language, locale);
        }
      }

      function updateDateCombos(formStr,language, locale,endYear,endMonth,endDay,yearID,monthID,dayID,wkID)
      {
        try
        {
          var objYear = eval("document.getElementById('" + yearID + "')");
          var objMonth = eval("document.getElementById('" + monthID + "')");
          var objDay = eval("document.getElementById('" + dayID + "')");
          // Update departure year.
          for (index = 0; (index < objYear.length) &&
                          (objYear.options[index].value != endYear);
               index++);
          objYear.options[index].selected = true;

          // Update departure month.
          for (index = 0; (index < objMonth.length) &&
                          (objMonth.options[index].value != endMonth);
               index++);
          objMonth.options[index].selected = true;

          // Update departure day.
          for (index = 0; (index < objDay.length) &&
                          (objDay.options[index].value != endDay);
               index++);
          objDay.options[index].selected = true;
          updateDOW (formStr, yearID, monthID, dayID, wkID, language, locale);
        }catch(errorObject)
        {
          return false;
        }
        return true;
      }
      //************************************************************************
      // Function:  updateNUMBER_OF_NIGHTS
      // Purpose:   Update the nights as per the arrival and departure date diff.
      // Input:     nights - number of nights.
      // Output:    none.
      //************************************************************************
      function updateNUMBER_OF_NIGHTS(formStr,language,locale)
      {
        var nights = 0;
        if (document.getElementById('NUMBER_OF_NIGHTS')!=null)
        {
          nights = document.getElementById('NUMBER_OF_NIGHTS').value;
        }
        if (nights.substring(0,1) != '-')
        {
          updateDATES(formStr, language, locale, nights);
        }
      }
      function updateSTART_DATE(formStr, language, locale)
      {
          updateNUMBER_OF_NIGHTS(formStr, language, locale);
      }
      function updateEND_DATE(formStr, language, locale)
      {
          updateDATES(formStr, language, locale,-1);
      }
      function setArrivalDate(date,formStr,language,locale)
      {
          updateDateCombos(formStr,language, locale,date.getFullYear(),date.getMonth()+1,date.getDate(),'DATERANGESTART_YEAR', 'DATERANGESTART_MONTH', 'DATERANGESTART_DAY', 'DATERANGESTART_DOW')
      }
      function setDepartureDate(date,formStr,language,locale)
      {
          updateDateCombos(formStr,language, locale,date.getFullYear(),date.getMonth()+1,date.getDate(),'DATERANGEEND_YEAR', 'DATERANGEEND_MONTH', 'DATERANGEEND_DAY', 'DATERANGEEND_DOW');
      }

      //************************************************************************
      // Function:  DateDiff
      // Purpose:   Diff of two dates.
      // Input:     startDate, endDate, interval (m-month, d-day, y-year)
      // Output:    difference in interval.
      //************************************************************************
      function DateDiff( start, end, interval )
      {
        var iOut = 0;
        var rounding =0;

        // Create 2 error messages, 1 for each argument.
        var startMsg = "Check the Start Date and End Date\n"
            startMsg += "must be a valid date format.\n\n"
            startMsg += "Please try again." ;

        var intervalMsg = "Sorry the dateAdd function only accepts\n"
            intervalMsg += "d, h, m OR s intervals.\n\n"
            intervalMsg += "Please try again." ;

        var bufferA = Date.parse( start ) ;
        var bufferB = Date.parse( end ) ;

        // check that the start parameter is a valid Date.
        if ( isNaN (bufferA) || isNaN (bufferB) ) {
            alert( startMsg ) ;
            return null ;
        }

        // check that an interval parameter was not numeric.
        if ( interval.charAt == 'undefined' ) {
            // the user specified an incorrect interval, handle the error.
            alert( intervalMsg ) ;
            return null ;
        }

        var number = bufferB-bufferA ;

        // what kind of add to do?
        switch (interval.charAt(0))
        {
            case 'd': case 'D':
                iOut = parseInt(number / 86400000) ;
                if(rounding) iOut += parseInt((number % 86400000)/43200001) ;
                break ;
            case 'h': case 'H':
                iOut = parseInt(number / 3600000 ) ;
                if(rounding) iOut += parseInt((number % 3600000)/1800001) ;
                break ;
            case 'm': case 'M':
                iOut = parseInt(number / 60000 ) ;
                if(rounding) iOut += parseInt((number % 60000)/30001) ;
                break ;
            case 's': case 'S':
                iOut = parseInt(number / 1000 ) ;
                if(rounding) iOut += parseInt((number % 1000)/501) ;
                break ;
            default:
            // If we get to here then the interval parameter
            // didn't meet the d,h,m,s criteria.  Handle
            // the error.
            alert(intervalMsg) ;
            return null ;
        }
        return iOut ;
      }
      //************************************************************************
//************************************************************************

var monthName = new Array ("January","February","March","April","May","June","July","August","September","October","November","December") 
var dayName = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var calendarWindow;

//************************************************************************
//************************************************************************

function isLeapYear(yrStr) 
{
   var leapYear=false; 
   // every fourth year is a leap year
   if ((parseInt(yrStr, 10)%4) == 0)
   {
      leapYear=true;
   }
   return leapYear;
}

//************************************************************************
//************************************************************************

function getDaysInMonth(mthIdx, YrStr) 
{
   // all the rest have 31 
   var maxDays = 31 
   // expect Feb. (of course)
   if (mthIdx==2)
   {
      if (isLeapYear(YrStr))
      {
         maxDays=29;
      }
      else
      {
         maxDays=28;
      }
   }
   // thirty days hath...
   if (mthIdx==4 || mthIdx==6 || mthIdx==9 || mthIdx==11)
   {
      maxDays=30;
   }
   return maxDays;
}

//************************************************************************
//************************************************************************

function parseYear(year, inY) 
{
   var retval=0; 
   var i=0;
   for (i=0; i<=5; i++)
   {
      if (year == inY.options[i].text)
      {
         retval=i;
         break;
      }
}
   return retval;
}

//************************************************************************
//************************************************************************

function nextMonth(month) 
{
   if (month==12) 
   {
      return 1;
   }
   else
   {
      return (month+1);
   }
}

//************************************************************************
//************************************************************************

function prevMonth(month) 
{
   var prevMonth = (month - 1) 
   if (month==1)
   {
      prevMonth = 12;
   }
   return prevMonth
}

//************************************************************************
//************************************************************************

function changeYear(direction, month, year) 
{
   // increments or decrements month when it goes past Jan or Dec 
   var theYear = year 
   if (direction=='next')
   {
      if (month == 12)
      {
         theYear = (year + 1)
      }
   }
   if (direction=='prev')
   {
      if (month == 1)
      {
         theYear = (year - 1)
      }
   }
   return theYear
}

//************************************************************************
//************************************************************************

function createCalendar (formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr) 
{
   calendarWindow = window.open ('', 'Calendar', 'width=220, height=255, resizable=yes, scrollbars=no');

   var mthVal = eval ("document.getElementById('" + formStr + "')." + monthCtrlStr + ".options [document.getElementById('" + formStr + "')." + monthCtrlStr + ".options.selectedIndex].text"); 
   var yearVal = eval ("document.getElementById('" + formStr + "')." + yearCtrlStr + ".options [document.getElementById('" + formStr + "')." +yearCtrlStr + ".options.selectedIndex].text"); 
   generateCalendar (calendarWindow, mthVal, yearVal, formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr) 
}


//************************************************************************
//************************************************************************

function generateCalendar(target, month, year, formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr) 
{
   target.document.open()
   calendar = " <html><head><title>Calendar</title>"
   calendar +="</head><body bgcolor=ffffff>" 
   calendar +=" <table border=0 cellspacing=0 cellpadding=2 width=200>" 
   calendar +="<tr valign=top>" 
   var mthIdx = parseInt(month);
   var endday = getDaysInMonth(mthIdx, year) 
   calendar +=" <td colspan=7 align=center bgcolor=#808080>"  
   var index = (mthIdx-1) 
   calendar +=" <b><font face='Helvetica,Arial,Futura'>" + monthName[index] + " " + year + "</font></b></td></tr>"  
   calendar +=" </tr><tr align=center>"  
   calendar +=" <td width=10><font face='Helvetica,Arial,Futura' color='#FF0000'>&nbsp;<b>S</b></font></td>"  
   calendar +=" <td width=10><font face='Helvetica,Arial,Futura'>&nbsp;<b>M</b></font></td>"  
   calendar +=" <td width=10><font face='Helvetica,Arial,Futura'>&nbsp;<b>T</b></font></td>"  
   calendar +=" <td width=10><font face='Helvetica,Arial,Futura'>&nbsp;<b>W</b></font></td>"  
   calendar +=" <td width=10><font face='Helvetica,Arial,Futura'>&nbsp;<b>T</b></font></td>"  
   calendar +=" <td width=10><font face='Helvetica,Arial,Futura'>&nbsp;<b>F</b></font></td>"  
   calendar +=" <td width=10><font face='Helvetica,Arial,Futura' color='#FF0000'>&nbsp;<b>S</b></font></td>" 
   calendar +=" </tr>"  
   wholeDate = month + "/01/" + year 
   thedate = new Date(wholeDate) 
   firstDay = thedate.getDay() 
   selectedmonth = mthIdx; 
   var today = new Date(); 
   var thisyear = today.getYear() + 1900; 
   selectedyear = year 
   var lastDay = (endday + firstDay+1) 
   var iRows =0 
   calendar +=" <tr>"  
   for (var i = 1; i < lastDay; i++) 
   { 
      if (i <= firstDay) 
      { 
         calendar +=" <td>&nbsp;</td>"  
      } 
      else 
      { 
         calendar +=" <td align=center><a href='JavaScript:opener.closeCalendar(" + (i-firstDay) + ", \"" + formStr + "\", \"" + dayCtrlStr + "\", \"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" + dowCtrlStr + "\");self.close();'>"+(i-firstDay)+"</a></td>"
      } 
      if (i % 7 == 0 ) 
      { 
         if (i != lastDay-1) 
         { 
            calendar +=" </tr><tr>"  
            iRows = iRows + 1 
         } 
         else 
         { 
            iRows = iRows 
         } 
      } 
   } 
   calendar +=" </tr>"  
   iRows = iRows + 1 
   calendar +=" <tr><td colspan=7 align=center width=200><hr noshade></td></tr>"  
   for (var icounter = 1; icounter <= 6-iRows; icounter++) 
   { 
      calendar +=" <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>"  
   } 
   var goPrevMonth = prevMonth(mthIdx) 
   var goNextMonth = nextMonth(mthIdx) 
   var nextYear = changeYear('next',parseInt(month),parseInt(year)) 
   var prevYear = changeYear('prev',parseInt(month),parseInt(year)) 
   if(navigator.userAgent.indexOf('MSIE',0) != -1) 
   { 
      calendar +=" <tr><td align=left colspan=2 bgcolor=#E0E0E0><a href='javascript:opener.generateCalendar(self," + goPrevMonth + "," + prevYear + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" + dowCtrlStr + "\")'>prev</a></td>"  
      calendar +=" <td align=center colspan=3 bgcolor=#E0E0E0><a href='javascript:self.close()'>cancel</a></td>"  
      calendar +=" <td align=right colspan=3 bgcolor=#E0E0E0><a href='javascript:opener.generateCalendar(self," + goNextMonth + "," + nextYear + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" + dowCtrlStr + "\")'>next</a></td></tr>"  
      calendar +=" </table></body></html>"  
      target.document.close() 
   } 
   else 
   { 
      calendar +=" <form><tr><td align=left colspan=3 bgcolor=#E0E0E0><input type=button value=' < '" + 
      "onClick='document.clear();opener.generateCalendar(opener.calendarWindow," + goPrevMonth + "," + nextYear + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" + dowCtrlStr + "\");'></td>"  
      calendar +=" <td align=center colspan=1 bgcolor=#E0E0E0>&nbsp;</td>"  
      calendar +=" <td align=right colspan=3 bgcolor=#E0E0E0><input type=button value=' > '" + 
      "onClick='document.clear();opener.generateCalendar(opener.calendarWindow," + goNextMonth + "," + nextYear + ",\"" + formStr + "\",\"" + dayCtrlStr + "\",\"" + monthCtrlStr + "\",\"" + yearCtrlStr + "\",\"" + dowCtrlStr + "\");'></td></tr></form>"  
      calendar +=" </table></body></html>"  
   } 
   target.document.write(calendar); 
   target.document.close() 
}

//************************************************************************
//************************************************************************

function closeCalendar (day, formStr, dayCtrlStr, monthCtrlStr, yearCtrlStr, dowCtrlStr) 
{
   var yrIdx = parseYear (selectedyear, eval ("document.getElementById('" + formStr + "')." + yearCtrlStr));
   eval ("document.getElementById('" + formStr + "')." + dayCtrlStr + ".options.selectedIndex = " + parseInt(day-1));
   eval ("document.getElementById('" + formStr + "')." + monthCtrlStr + ".options.selectedIndex = "  + selectedmonth + "- 1");
   eval ("document.getElementById('" + formStr + "')." + yearCtrlStr + ".options.selectedIndex = " + yrIdx);
   var myDate = new Date (selectedyear, selectedmonth - 1, day);
   eval ("document.getElementById('" + formStr + "')." + dowCtrlStr + ".value = '" + dayName [myDate.getDay()] + "'");
}
// JavaScript Document
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function esEmail(valor)
{
	var a,p;
	a = valor.indexOf('@');
	p = valor.indexOf('.');
	if (a<1 || a==(valor.length-1) || p<1)
		 return false
return true
}

function chr(c) {
	var h = c . toString (16);
	h = unescape ('%'+h);
	return h;
}

function extension(str_filename){
	var i = str_filename.length;
	var slicer = String(slicer)
	var ext = String('')
	do{ 
		slicer = str_filename.slice(i-1,i);
		ext = slicer+ext
		i--
	} 
	while(slicer != '.' && i > 1)
	
	ext = ext.toLowerCase();
	return(ext);
}

//funcion encargada de crear el objeto
 function obj_ajax() {         
	try {                 
		 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
	catch (e) {                 
		 try {                          
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
		 catch (E) {                           
			 xmlhttp = false;}
         }
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {                 
 		xmlhttp = new XMLHttpRequest(); }
  return xmlhttp
 }

function addFileInput( elem ) {
		if ( false != elem )
		{
			filepath = elem.value.split("\\");
			filename = filepath[filepath.length-1];
			extensionpath = filename.split(".");
			extension = extensionpath[extensionpath.length-1];
		 	if( !extension.match(/(jpg)|(jpeg)|(gif)|(png)/) )
			{
				alert ( "Sólo se permite subir imágenes: jpg, gif y png" );
				return false;
			}
			$(elem).hide();
			$("#file_list").append("<li style='display:none'>&bull; "+filename+" <a href='javascript:;' onclick='delFile(this,"+($("#file_list li").size()+1)+")' style='color:red'>[x]</small></a></li>\n");
			$("#file_list li:last").slideDown("slow");
		}
		$("#Submit").get(0).disabled = false;
		$("#file_inputs").append('<input name="file'+($("#file_list li").size()+1)+'" type="file" id="file'+($("#file_list li").size()+1)+'" size="35" onChange="addFileInput(this);"  class="input">\n');

}

function delFile ( el, file )
{
	$(el.parentNode).remove();
	$("#file"+file).remove();
}

function ResetForm(which){
var pass=true
var first=-1
if (document.images){
	for (i=0;i<document.getElementById(which).length;i++){
		var tempobj=document.getElementById(which).elements[i]
		 if (tempobj.type=="text"){
			  eval(tempobj.value="")
			  if (first==-1) {first=i}
		 }
		 else 
		 	if (tempobj.type=="checkbox") {
		  		eval(tempobj.checked=0)
		  		if (first==-1) {first=i}
		 }
		 else if (tempobj.col!="") {
		  	eval(tempobj.value="")
		 	 if (first==-1) {first=i}
		 }
	}
}
document.getElementById(which).elements[first].focus()
return;
}

function createCombos(type,country,code) {
 	//creamos el objeto     
	 _obj_ajax=obj_ajax();   
	 
	 if(type==1){
		 _values_send="country=" + country + "&%20brand=" + code; 	 
		 _URL_="list_property.php?";       
		 }
	else{
		_values_send="country=" + country + "&%20namecontains=" + code; 	 
		_URL_="list_cities.php?";     
	}
	 _obj_ajax.open("GET",_URL_ + _values_send,true);   
	   
	 _obj_ajax.onreadystatechange=function() {                 
	if (_obj_ajax.readyState==4) {
		if(_obj_ajax.status==200){
		 	document.getElementById("content2_maincol1").innerHTML=_obj_ajax.responseText;
			}
		else
			document.getElementById("content2_maincol1").innerHTML="ERROR";
		}
	 }  
 	_obj_ajax.send(null); 
}

function loadHotel(property_keycode,list_hotels,indi) {
 	//creamos el objeto     
	 _obj_ajax=obj_ajax();   
	 
	 _values_send=property_keycode; 
	 _URL_="load_hotels.php?";       
	 _obj_ajax.open("GET",_URL_ + _values_send,true);   
	   
	 _obj_ajax.onreadystatechange=function() {                 
	if (_obj_ajax.readyState==4) {		
		if(_obj_ajax.status==200){
			document.getElementById("hotel_"+indi).style.height="194px";
		 	document.getElementById("hotel_"+indi).innerHTML=_obj_ajax.responseText;
			}
		loadHotels(list_hotels,indi+1);
		}
	 }  
 	_obj_ajax.send(null); 
}

function loadHotels(list_hotels,indi){
	arr_hotels=list_hotels.split(",");
	if(indi<arr_hotels.length)
		loadHotel(arr_hotels[indi],list_hotels,indi);
	else
		document.getElementById("loading").style.display="none";
}

/*-------------------------------------------------------------------
| LTrim(s)
| Devuelve una cadena sin los espacios del principio
| 
|       12/09/2002 			Por El KuNi
-------------------------------------------------------------------*/
function LTrim(s){
	var i=0;
	var j=0;
	
	// Busca el primer caracter <> de un espacio
	for(i=0; i<=s.length-1; i++)
		if(s.substring(i,i+1) != ' '){
			j=i;
			break;
		}
	return s.substring(j, s.length);
}

/*-------------------------------------------------------------------
| RTrim(s)
| Quita los espacios en blanco del final de la cadena
| 
|       12/09/2002 			Por El KuNi
-------------------------------------------------------------------*/
function RTrim(s){
	var j=0;
	
	// Busca el último caracter <> de un espacio
	for(var i=s.length-1; i>-1; i--)
		if(s.substring(i,i+1) != ' '){
			j=i;
			break;
		}
	return s.substring(0, j+1);
}

/*-------------------------------------------------------------------
| Trim(s)
| Quita los espacios del principio y del final
| 
|       12/09/2002 			Por El KuNi
-------------------------------------------------------------------*/
function Trim(s){
	return LTrim(RTrim(s));
}

/*-------------------------------------------------------------------
| UCase(s)
| Devuelve la cadena convertida a mayúsculas
| 
|       12/09/2002 			Por El KuNi
-------------------------------------------------------------------*/
function UCase(s){
	return s.toUpperCase();
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

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();
}


	