function dInM(mon){
	curDate = new Date();
	if (mon == 2){
		Year = curDate.getFullYear();
		if(Math.round(Year/4) == Year/4){
			if(Math.round(Year/100) == Year/100){
				if(Math.round(Year/400) == Year/400)
					return 29;
				else return 28;
			}else
				return 29;
		}
		return 28;
	}else if (mon == 4 || mon == 6 || mon == 9 || mon == 11) {
		return 30;
	}
	return 31;
}

function getNDay() {
	theMonth = document.hcomForm.am.options.selectedIndex;
	theDay = parseInt(document.hcomForm.ad.options.selectedIndex);

	if (! theMonth == 0 && ! theDay == 0){
		dInMonth = dInM(theMonth);
		if (theDay > dInMonth){
			document.hcomForm.ad.options.selectedIndex = theDay = dInMonth;
		}
		newDay = theDay + 1;
		newMonth = theMonth;

		if (newDay > dInMonth){
			newDay = 1;
			newMonth = theMonth + 1;

			if (newMonth > 12){
				newMonth = 1;
			}
		}

		document.hcomForm.dd.selectedIndex = newDay;
		document.hcomForm.dm.selectedIndex = newMonth;
	}
}

function checkDDate() {
	theMonth = document.hcomForm.dm.options.selectedIndex;
	theDay = parseInt(document.hcomForm.dd.options.selectedIndex);
	dInMonth = dInM(theMonth);
	if (theDay > dInMonth){
		document.hcomForm.dd.options.selectedIndex = theDay = dInMonth;
	}
}

function chkCT(selectID){
	if(selectID != 'city'){
		$('#city option').removeAttr('selected');
		$('#city option:first').attr('selected', 'selected');
	}

	if(selectID != 'hotelID'){
		$('#hotelID option').removeAttr('selected');
		$('#hotelID option:first').attr('selected', 'selected');
	}

	if(selectID != 'region'){
		$('#region option').removeAttr('selected');
		$('#region option:first').attr('selected', 'selected');
	}
}

function doCheckForm(){
	am = document.hcomForm.am.options.selectedIndex;
	ad = document.hcomForm.ad.options.selectedIndex;
	dm = document.hcomForm.dm.options.selectedIndex;
	dd = document.hcomForm.dd.options.selectedIndex;
	if (am > 0 && ad > 0 && dm > 0 && dd > 0) {
		var el = $('#content');
		var n = el.length;
		if(n > 0){
			if($('#iframeContainer').length == 0){
				el.html('<div id="iframeContainer"><iframe name="hoteliersIframe" src="" frameborder="0" style="width:100%; height: 700px;" /></div>');
			}
		}

		document.hcomForm.target = document.hcomForm.hTarget.value;
						document.hcomForm.action = pageTracker._getLinkerUrl('http://www.hoteliers.com/wlpEngine.php?ID=' + document.hcomForm.hotelID.value + '&lang='+lang);
						$('#hcomForm').submit();

		try {
			var gwoTracker=_gat._getTracker("UA-2228798-42");
			gwoTracker._trackPageview("/3740638623/goal");
		}catch(err){}
	}
}

function doCheckFormPortal(){
	am = document.hcomForm.am.options.selectedIndex;
	ad = document.hcomForm.ad.options.selectedIndex;
	dm = document.hcomForm.dm.options.selectedIndex;
	dd = document.hcomForm.dd.options.selectedIndex;
	if (am > 0 && ad > 0 && dm > 0 && dd > 0) {
		var el = $('#content');
		var n = el.length;
		if(n > 0){
			if($('#iframeContainer').length == 0){
				el.html('<div id="iframeContainer"><iframe name="hoteliersIframe" src="" frameborder="0" style="width:100%; height: 700px;" /></div>');
			}
		}

		document.hcomForm.target = document.hcomForm.hTarget.value;
		document.hcomForm.action = pageTracker._getLinkerUrl('http://www.hoteliers.com/cgEngine.php?ID=20&lang='+lang);
		$('#hcomForm').submit();
	}
}