
  
	var todayDate = new Date();
	var todayDay = todayDate.getDate();
	var thisMonth = todayDate.getMonth();
	var thisYear = todayDate.getFullYear();
	var optionsStartDay = todayDay;
	var selectedMonth = thisMonth;
	var selectedYear = thisYear;
	
	function daysInMonth(month,year) {
		var dd = new Date(year, month + 1, 0);
		return dd.getDate();
	} 
	
	function BuildDayOptions() {
		//alert(thisMonth + ' ' + thisYear + ' ' + selectedMonth + ' ' + selectedYear);
		//alert(document.getElementById('ci_day2').value + ' ' + document.getElementById('ci_ym2').value);
		optionStartDay = todayDay;
		if(selectedMonth > thisMonth && selectedYear > thisYear) {
			optionsStartDay = 1;
		}
		
		firstTime = true;
		for(ix=optionsStartDay; ix<=daysInMonth(selectedMonth,selectedYear); ix++)
		{
			if (firstTime) document.write("<option value='" + ix + "' selected='selected'>" + ix + "</option>");
			document.write("<option value='" + ix + "'>" + ix + " </option>");
			firstTime = false;
		}
		
		
	}

	function MonthYearOptionsChanged() {
		newMonthYear = document.getElementById('ci_ym2').value;
		selectedYear = newMonthYear.substring(4);
		selectedMonth = 11;
		
		//alert(newMonthYear + '  ' + selectedYear + ' ' + selectedMonth);
		
		// Rebuild the day options ci_day2 ?????
		if(selectedMonth > thisMonth || selectedYear > thisYear) {
			optionsStartDay = 1;
		}
		
		daySelectElm = document.getElementById('ci_day2');
		daySelectElm.innerHTML = "";
		aStr = "";
		
		firstTime = true;
		for(ix=optionsStartDay; ix<=daysInMonth(selectedMonth,selectedYear); ix++)
		{
			if (firstTime) aStr = "<option value='" + ix + "' selected='selected'>" + ix + "</option>";
			aStr += "<option value='" + ix + "'>" + ix + " </option>";
			firstTime = false;
		}
		daySelectElm.innerHTML = aStr;
	}
	

	
  function buildYearsDubai() 
  {
	var select_month=new Array("Null", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
	var datenow=new Date();
	var month=datenow.getMonth()+1;
	var year=datenow.getFullYear();
	for(var i=1; i<=25; i++)
	{
		document.write("<option value='" + select_month[month] + " " + year + "'>" + select_month[month] + " " + year + "</option>");
		if ( month >= 12 )
		{
			year++;
					month=1;
		} else
		{
			month++;
		}
	}
  }	

function DoPreSubmit()
	{
		
		
		if (document.getElementById('jumpMenu').value == 'NONE') {
				document.getElementById('msg').innerHTML = "Please select an apartment and then click search";
				document.getElementById('msg').style.display = "block";

				return false;
			}
		
		
		theSformAction = 'https://www.myfidelio.net/webui/AvailabilitySearch.aspx?chain=IQ' +
			'&arrival=' + document.getElementById('ci_day2').value + ' ' + document.getElementById('ci_ym2').value +
			'&nights=' + document.getElementById('nights2').value +
			'&rooms=' + document.getElementById('rooms2').value +
			'&adults=' + document.getElementById('adults2').value +
			'&children=0' +
			'&property=' + document.getElementById('jumpMenu').value +
			'&step=0';
		document.sform.action = theSformAction;
		document.sform.target = "_blank";
		
		document.getElementById('msg').innerHTML = "";
		document.getElementById('msg').style.display = "none";

		//alert('sform Form action = ' + document.sform.action );
		return true;
	}
