

    var xCha="WYNDHAM"
    var xRef="08232001055506"
    var xCor=""

    function isLeapYear(year)
    	{
        if (year == Math.round(year/4)*4)
		{
		return true;
		}
        else
		{
		return false;
		}
    }

    function buildYearSelect()
    	{
       
	}
	

    function buildDaySelect()
    	{
             	
        var numDays = 0;
        if ((month == 1) && (isLeapYear(year)))
		{
		numDays = 29;
		}
        else
		{
		numDays = days[month];
		}

        for (loop=1; loop < numDays + 1; loop++)
		{
		document.formProperty.lstDay.options[loop-1]=new Option(loop, loop);
		document.formProperty.xDepDay.options[loop-1]=new Option(loop, loop);
		document.formState.lstDay.options[loop-1]=new Option(loop, loop);
		document.formState.yDepDay.options[loop-1]=new Option(loop, loop);
		}
		var aDay = day-1;
        document.formProperty.lstDay.selectedIndex = aDay;
	    document.formState.lstDay.selectedIndex = aDay;
	   
	    //year Select 
	    var lyear =year;
	     for (loop=0; loop < 2; loop++)
		{
		
		document.formProperty.lstYear.options[loop]=new Option(lyear, lyear);
		document.formProperty.xDepYear.options[loop]=new Option(lyear, lyear);
		document.formState.lstYear.options[loop]=new Option(lyear, lyear);
		document.formState.yDepYear.options[loop]=new Option(lyear, lyear);
		lyear++;
		}			
	    document.formProperty.lstYear.selectedIndex = 0;
	    document.formProperty.lstMonth.selectedIndex = month;	
	    document.formState.lstMonth.selectedIndex = month;
	    changeDeptDate(day,(month+1),year);
	    changePropDeptDate(day,(month+1),year);
	}

    function checkNumDays(xMonth, xDay, xYear)
    	{
    	
		var selected = xDay.selectedIndex;
		var oldSelectedDate = xDay.options[xDay.selectedIndex].value;
	
		var numDays = 0;
		if ((xMonth.selectedIndex == 1) && (isLeapYear(xYear.options[xYear.selectedIndex].value)))
			{
			numDays = 29;
			}
		else
			{
			numDays = days[xMonth.selectedIndex];
			}
		
		for (loop=1; loop < numDays + 1; loop++)
			{
			xDay.options[loop-1]=new Option(loop, loop);
			}
		if (numDays < oldSelectedDate)
			{
			xDay.selectedIndex = 0;
			}
		else
			{
			xDay.selectedIndex = selected;
			}
		xDay.options.length = numDays;				
		     
	}
	

    function checkPropNumDays(xMonth, xDay, xYear)    
    	{
            	
		var selected = xDay.selectedIndex;
		var oldSelectedDate = xDay.options[xDay.selectedIndex].value;
		var numDays = 0;
		if ((xMonth.selectedIndex == 1) && (isLeapYear(xYear.options[xYear.selectedIndex].value)))
			{
			numDays = 29;
			}
		else
			{
			numDays = days[xMonth.selectedIndex];
			}
		for (loop=1; loop < numDays + 1; loop++)
			{
			xDay.options[loop-1]=new Option(loop, loop);
			}
		if (numDays < oldSelectedDate)
			{
			xDay.selectedIndex = 0;
			}
		else
			{
			xDay.selectedIndex = selected;
			}
		xDay.options.length = numDays;				
       
	}
  
// -------------------------------------------------------------------------
// calendar functions

var zMonth;
var zDay;
var zYear;
var dRange= false;

    function selectCalElements(xMonth, xDay, xYear)
    	{
	zMonth = xMonth;
	zDay = xDay;
	zYear = xYear;    
	}

    function setDateValue(dateVal,mon,yr)
   {

	 if(checkDate(dateVal,mon,yr,"true"))
		{
            zMonth.selectedIndex = mon;
            for(i=0; i < zYear.length ; i++)
			{
			if(zYear.options[i].value == yr)
				{
				var selected = i;				
				break;
				}
			}
		zYear.selectedIndex = selected;
		checkNumDays(zMonth, zDay, zYear);
		zDay.selectedIndex = dateVal-1;
			
		if(zDay.name == "lstDay")
		{	
		  
		  changeDeptDate(dateVal,zMonth.value,zYear.value);
		  changePropDeptDate(dateVal,zMonth.value,zYear.value);
        
         }
		}
        else
        	{
		alert("The date you have selected is in the past. Please select another date.");
		}
        }

        function popupCalendar()
        	{
		window.open("/calendar/cal0002.htm","Calendar","width=180,height=200,status=no,resizable=no,scrollbars=0,top=128,left=128,alwaysRaised=1 ").focus();
		}
    function changeDeptDate(day,mon,year)
    {

        var ydeptday = 0;
        var ydepmonth = 0;
        var ydepyear = 0; 
        var arrmon = (mon) - 1;
             
        arr_date = new Date(year,arrmon,day);
        arr_date.setTime(arr_date.getTime()+21600000);           
        dep_date = new Date(arr_date.getTime()+86400000);
        ydepday = dep_date.getDate();
        ydepmonth = dep_date.getMonth();
        ydepyear = dep_date.getFullYear();
         if(ydepyear > currentYear+1)
        {
         alert("The date you have chosen is beyond the booking range.");
         dRange = true;
         return;
         }
        
        document.formState.yDepMonth.selectedIndex = ydepmonth;        
               
        for(i = 0 ; i< document.formState.yDepYear.options.length ; i++)
        {
      
         if(document.formState.yDepYear.options[i].value == ydepyear)
          document.formState.yDepYear.selectedIndex = i;
         }
         checkNumDays(document.formState.yDepMonth,document.formState.yDepDay,document.formState.yDepYear);
        document.formState.yDepDay.selectedIndex = ydepday-1;      
      
    }
     
    function changePropDeptDate(day,mon,year)
    {
        var xdeptday = 0;
        var xdepmonth = 0;
        var xdepyear = 0;
        var depmon = (mon) - 1;
        arr_date = new Date(year,depmon,day);
        arr_date.setTime(arr_date.getTime()+21600000);   
        dep_date = new Date(arr_date.getTime()+86400000);
        xdepday = dep_date.getDate();
        xdepmonth = dep_date.getMonth();
        xdepyear = dep_date.getFullYear();
        
         if(xdepyear > currentYear+1 && !dRange)
	        {
	         alert("The date you have chosen is beyond the booking range.");
	         return;
	         }
	     if(xdepyear > currentYear+1 && dRange)
	       {
	         dRange = false;
	         return;
	       }    
        document.formProperty.xDepMonth.selectedIndex = xdepmonth;               
        for(i = 0 ; i< document.formProperty.xDepYear.options.length ; i++)
	        {
	         if(document.formProperty.xDepYear.options[i].value == xdepyear)
	         document.formProperty.xDepYear.selectedIndex = i;
	         }
	    checkPropNumDays(document.formProperty.xDepMonth,document.formProperty.xDepDay,document.formProperty.xDepYear);        
        document.formProperty.xDepDay.selectedIndex = xdepday-1;

        
    }
     

    function checkDate(dateVal,mon,yr,isCal) {
        if(!isCal)
        var monthCal = month+1;
        else
        monthCal = month;
        
        
        if (yr < currentYear) {
            return false;
        }
        else if ((yr == currentYear) && (mon < monthCal))
        {
            return false;
        }
        else if ((yr==currentYear)&&(mon==monthCal)&&(dateVal< day)){
        return false;
        }
        else
        {
        return true;
        }
        }
        
    function compareDate(arr_date,arr_mon,arr_yr,dep_date,dep_mon,dep_yr) {

        var arrmon = (arr_mon) - 1;
        var depmon = (dep_mon) - 1;
        arrival_date = new Date(arr_yr,arrmon,arr_date);        
        departure_date = new Date(dep_yr,depmon,dep_date);
        if(arrival_date >= departure_date)
          return false;
        else
          return true;
        }    

	function clearByRequestNumber()
	{
		if (document.formState.ByReqNum.value == "Number")
		{
			document.formState.ByReqNum.value = "";
		}
	}

	function clearLastName()
	{
		if (document.formState.LastName.value == "Last Name")
		{
			document.formState.LastName.value = "";
		}
	}

	function clearbrnum()
	{
		if (document.formProperty.ByReqNum.value == "Number")
		{
			document.formProperty.ByReqNum.value = "";
		}
	}

	function clearbrname()
	{
		if (document.formProperty.LastName.value == "Last Name")
		{
			document.formProperty.LastName.value = "";
		}
	}
	function changeState(form) {
		   	form.state.selectedIndex = 0 ;

    }