
    function open_help_window(filename)
    {
  
      eval(window.open(filename, '', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=475,height=360'));
    }
    
    function open_window(filename)
    {
  
      eval(window.open(filename, '', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=540,height=500'));
    }
    
    
    //hack to allow popup allow pop-up of 'more images link on accomodations page'
    function show_more_photos(image,room_type)
    {
    	//alert(room_type);return;
    	
    	var pop_window = window.open('more_images.php?image='+image+'&room_type='+room_type, '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=540,height=450');

		pop_window.moveBy(10,150);
    }
    

    function NMG_popup(pic,dd,width,height) 
    {
      //alert(pic);
      
      
      day = new Date();
      id = day.getTime();
      URL = "../images/popup/" + pic;
      eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=475,height=360');");
      
    }
    
  
    function is_future(date)
    {
      today = new Date().getTime(); //convert to milliseconds
      
      date = date.getTime(); ////convert to milliseconds
      
      if((date - today) > 0)
      {
        return true;
      }
      else
        return false;
      
    }
    
    var last_shown = 'form_3';
    
    function show_hide(id)
    {

      
      document.getElementById(last_shown).style.display = 'none';
      last_shown = id;
      document.getElementById(id).style.display = 'block'; //display that div
          
 
    }
    
   
    function show_check(id,check_box)
    {
    
        if (document.getElementById)
        {
          // this is the way the standards work
          var style2 = (check_box.checked) ? "block" : "none";
          document.getElementById(id).style.display = style2;
        }
        
    }
    
    function change_state_display()
    {
      var country = document.getElementById("country").value;
      if(country!="US")
      {
        document.getElementById("statebox2").style.display = 'block';
        document.getElementById("statebox1").style.display = 'none';

        document.getElementById("required_state").style.display = 'none';
        document.getElementById("required_zip").style.display = 'none';

		document.getElementById("space1").style.display = 'block';
        document.getElementById("space2").style.display = 'block';
      }
      else
      {
        document.getElementById("required_zip").style.display = 'block';
        document.getElementById("required_state").style.display = 'block';

        document.getElementById("statebox1").style.display = 'block';
        document.getElementById("statebox2").style.display = 'none';

		document.getElementById("space1").style.display = 'none';
        document.getElementById("space2").style.display = 'none';
        //document.getElementById("statebox2").value = document.getElementById("statebox1").value;
      }
    }
    
    //calculate the number of days in agiven month
    function days_in_month (year, month) 
    {
     return 32 - new Date(year, month, 32).getDate();
    }
    
    
    //update day drop down list
    function update_day_options(year,month,day)
    {
        //change the day drop down box to reflect
        //the number of days in that particular month
        day = document.getElementById("day").value;
        drop_day = document.getElementById("day");
        drop_day.options.length=0; //empty the options array
        
        num_days = days_in_month (year, month - 1);
        
        for (var i=1; i<=num_days; i++) 
        {
          if(i == day)
          { drop_day.options[i] = new Option(i,i,true);}
          else
          drop_day.options[i] = new Option(i,i);
        }
        drop_day.options[0].disabled = true;
        drop_day.remove(0);
        document.getElementById("day").value = day;
    }
    
    //update day drop down list
    function update_res_day_options(year,month,day)
    {
        //change the day drop down box to reflect
        //the number of days in that particular month
        day = document.getElementById("res_day").value;
        drop_day = document.getElementById("res_day");
        drop_day.options.length=0; //empty the options array
        
        num_days = days_in_month (year, month - 1);
        
        for (var i=1; i<=num_days; i++) 
        {
          if(i == day)
          { drop_day.options[i] = new Option(i,i,true);}
          else
          drop_day.options[i] = new Option(i,i);
        }
        drop_day.options[0].disabled = true;
        drop_day.remove(0);
        document.getElementById("res_day").value = day;
    }
 
    
//when date changed on the little calendar, 
//the new date first populates a hidden form field
//which has an onchange function to change the date fields 
  function change_date(new_date_hidden_field) 
  {
 
  	
    var split_date = new_date_hidden_field.value.split("/");
    
    var month = split_date[0] - 0;
    var year = split_date[2] - 0;
    
    document.getElementById("month").value = month; //array index starts at zero
    document.getElementById("day").value = split_date[1] - 0; //array index starts at zero
    document.getElementById("year").value = year;
    
  
    if(document.getElementById("mycal"))
    {
      change_calendar();
    }
    else if(document.getElementById("departure"))
    {
      update_departure();
    }
    
  }
  
  //build a new calendar using month day year from form  fields
  //this one is called from the drop down on the calendar
  function change_calendar2()
  {
    
   if(document.getElementById("mycal"))
   {
        var month = document.getElementById("month2").value;
        var year  = document.getElementById("year2").value;
        
        //check the month. If the month is before current month then
	    //change the next year to the following year
	    var current_date = new Date();
	    var current_month = (current_date.getMonth() + 1); //getMonth return s (0-11)
	    var current_year = current_date.getFullYear();
	    if( month < current_month && year <= current_year) //and is current year or before
	    {
	  		year = parseInt(year) + 1;
	  		document.getElementById("year2").value = year;
	  		//alert(year);
	    }
        
        var room_type  = document.getElementById("room_type").value;
        var day = document.getElementById('day').value - 0;
        
        // Only go on if there are values for both fields
        if ((month == null) || (month == "")) 
        {return;}
        else if ((year == null) || (year == ""))
        { return; }
        else if ((room_type == null) || (room_type == ""))
        { return; }
        
        document.getElementById("month").value = document.getElementById("month2").value;
        document.getElementById("year").value = document.getElementById("year2").value;
        //update the day drop down list box
        update_day_options(year,month,day);      
        
        
    
        // Build the URL to connect to
        var url = "calendar3_with_sold_out.php";//?;//city=" + escape(city) + "&state=" + escape(state);
      
      //this object is instantiated in ajax_class.php
        xmlHttp.connect(url,"get","month=" + escape(month) + "&year=" + escape(year)+"&update_calendar=true&room_type=" + room_type,update_calendar);
        
        
        
    }
                                                                                                                      
    
  }
  
  
  //build a new calendar using month day year from form  fields
  function change_calendar()
  {
    
   if(document.getElementById("mycal"))
   {
        var month = document.getElementById("month").value;
        var year  = document.getElementById("year").value;
        var room_type  = document.getElementById("room_type").value;
        var day = document.getElementById('day').value - 0;
        
   		//check the month. If the month is before current month then
	    //change the next year to the following year
	    var current_date = new Date(); 
	    var current_month = (current_date.getMonth() + 1); //getMonth return s (0-11)
	    var current_year = current_date.getFullYear();
	    if( month < current_month && year <= current_year) //and is current year or before
	    {
	  		year = parseInt(year) + 1;
	  		document.getElementById("year").value = year;
	  		document.getElementById("year2").value = year;
	  		//alert(year);
	    }
        
        // Only go on if there are values for both fields
        if ((month == null) || (month == "")) 
        {return;}
        else if ((year == null) || (year == ""))
        { return; }
        else if ((room_type == null) || (room_type == ""))
        { return; }
        
        
        //update the day drop down list box
        update_day_options(year,month,day);      
        
        
    
        // Build the URL to connect to
        var url = "calendar3_with_sold_out.php";//?;//city=" + escape(city) + "&state=" + escape(state);
      
      //this object is instantiated in ajax_class.php
        xmlHttp.connect(url,"get","month=" + escape(month) + "&year=" + escape(year)+"&update_calendar=true&room_type=" + room_type,update_calendar);
        
    }
                                                                                                                      
    
  }
  //ajax return function
  function update_calendar(xmlHttp) 
  {
    
    if (xmlHttp.readyState == 4) 
    { 
      var response = xmlHttp.responseText;
      document.getElementById("mycal").innerHTML = response;
      
      update_departure();
    }
  }
  
  
  //gets id from the <td> tag in the calendar to change the 'day' field drop
  //down list
  function change_to_calendar_day(oObject) 
  {
      var id = oObject.id;
      var day = id.split("_");

      document.getElementById('day').value = day[1];
      
      //update the color of the day
      
      update_departure();
      //alert("This object's ID attribute is set to \"" + id + "\"."); 
  }
  
  function next_month()
  {
    month = document.getElementById('month').value;
    year = document.getElementById('year').value;
    
    month++;
    
    if(month > 12)
    {
      ++year;
      month = 1;
    }
    
    document.getElementById('month').value = month;
    document.getElementById('year').value = year;
    
    change_calendar();
  }
  
  function prev_month()
  {
    
    
    month = document.getElementById('month').value;
    year = document.getElementById('year').value;
    
    month--;
    
    if(month < 1)
    {
      --year;
      month = 12;
    }
    
    /*
    date = new Date(year,month - 1,days_in_month(year,month));
    if(!is_future(date))
      return;
    */
    
    document.getElementById('month').value = month;
    document.getElementById('year').value = year;
    
    change_calendar();
  }
  
  function update_departure()
  {
    monthNames = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun",
                            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    
    month = document.getElementById('month').value - 0;
    year = document.getElementById('year').value - 0;
    day = document.getElementById('day').value - 0;
    nights = document.getElementById('nights').value - 0;
    
    //update day drop down list
    update_day_options(year,month,day);
    
  
    date = new Date();
    date.setUTCDate(day);
    date.setUTCMonth(month - 1);
    date.setUTCFullYear(year);
    date.setDate(date.getDate()+ nights);
  
    
    document.getElementById('departure').innerHTML = monthNames[date.getUTCMonth()] + "-" + date.getUTCDate() + "-" + date.getUTCFullYear();
    
    //document.write(document.lastModified);
    
  }
  function update_res_departure()
  {
    monthNames = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun",
                            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    
    month = document.getElementById('res_month').value - 0;
    year = document.getElementById('res_year').value - 0;
    day = document.getElementById('res_day').value - 0;
    nights = document.getElementById('res_nights').value - 0;
    
    //update day drop down list
    update_res_day_options(year,month,day);
    
  
    date = new Date();
    date.setUTCDate(day);
    date.setUTCMonth(month - 1);
    date.setUTCFullYear(year);
    date.setDate(date.getDate()+ nights);
  
    
    document.getElementById('res_departure').innerHTML = monthNames[date.getUTCMonth()] + "-" + date.getUTCDate() + "-" + date.getUTCFullYear();
    
    //document.write(document.lastModified);
    
  }
  
  function change_color(oObject)
  {
    td_id = oObject.id;
    document.getElementById(td_id).style.background='#99ccff';
  }
  
  function default_color(oObject)
  {
    td_id = oObject.id;
    document.getElementById(td_id).style.background='#fff';
  }
  
  
  function change_person_total(oObject)
  {
    
        var persons = document.getElementById(oObject.id).value;
        
        var res = oObject.id.split("_");
        var app = ""; //so that this function will work with both forms (side bar availability and the fetch booking form)
        if(res[0]=="res")
        {
          app = res[0] + "_";
        }
        
        var occupancy = 5;
  
        if(oObject.id == (app + "adults"))
        {
          
          var change = document.getElementById(app + "children");
          var other = document.getElementById(app + "adults");
          change_value = document.getElementById(app + "children").value;
          other_value = document.getElementById(app + "adults").value;
          var ocStartAt = 1;
          var ccStartAt = 0;
          var max_OC_value = 5;
        }
        
        else if(oObject.id == (app + "children"))
        {
          var change = document.getElementById(app + "adults");
          var other = document.getElementById(app + "children");
          change_value = document.getElementById(app + "adults").value;
          other_value = document.getElementById(app + "children").value;
          var ocStartAt = 0;
          var ccStartAt = 1;
          var max_OC_value = 4;
        }
 
        remainder = (occupancy - persons);
        
        change.options.length = 0;
        other.options.length = 0;
        
        for(var oc=ocStartAt; oc<=max_OC_value; oc++) {
          var opt3 = document.createElement('option');
          opt3.text = oc;
          opt3.value = oc;
          try 
          {
            other.add(opt3, null); // standards compliant; doesn't work in IE
          }
          catch(ex) {
            other.add(opt3); // IE only
          }
        }
        
        for(var cc=ccStartAt; cc<=remainder; cc++) {
          var opt4 = document.createElement('option');
          opt4.text = cc;
          opt4.value = cc;
          try 
          {
            change.add(opt4, null); // standards compliant; doesn't work in IE
          }
          catch(ex) {
            change.add(opt4); // IE only
          }
        }
        
        if(change_value > remainder)
        {
            change.value = remainder;
        }
        else
        {
            change.value = change_value;
        }
        
        other.value = other_value;

}


function textCounter(field,cntfield,maxlimit)
{
	if (field.value.length > maxlimit) // if too long...trim it!
	{
		field.value = field.value.substring(0, maxlimit);
	}
	// otherwise, update 'characters left' counter
	else
	{
		cntfield.value = maxlimit - field.value.length;
	}
}


var oldobj = new Object();
oldobj.id = "oldid";

function change_arrangement(obj)
{
	if(oldobj.id != obj.id) //we don't want to do this everytime a key is pressed
	{
		oldobj.id = obj.id;
		
		var arrange =  new Array("AAA","AARP","promotionCode","groupCode"); //contains id's
		
		for(var i = 0; i < arrange.length; i++ )
		{
			var othobj = document.getElementById(arrange[i]);
			
			if(othobj.id != obj.id)
			{
				//alert(othobj.id + " : " +  othobj.type);
				
				if(othobj.type == "text")
				{
					othobj.value = "";
				}
				else if(othobj.type == "radio")
				{
					othobj.checked = false;
				}
			}
		}
	}
	
	return true;
}