var curDate = new Date();
var hEngine = 'http://www.hoteliers.com/wlpEngine.php?lang=nl&ID='; 

function dInM(mon)
{ 
	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 doCheckForm()
{
	
	el = document.getElementById('main');
	
	if (el)
	{
		el.innerHTML = '<iframe style="margin:30px 0 0 0;" name="' + document.hcomForm.hTarget.value + '" src="" width="627" height="830" frameborder="0" >';
	}
	
	
	document.hcomForm.target = document.hcomForm.hTarget.value;
	document.hcomForm.action = document.hcomForm.action = 'http://www.hoteliers.com/wlp' + document.hcomForm.EngineType.value + 'ngine.php?ID=' + document.hcomForm.hotelID.value + '&lang=' + document.hcomForm.language.value;
	document.hcomForm.submit();
}

function checkDDate()
{
	theMonth = parseInt(document.hcomForm.dm.options.selectedIndex);
	theDay = parseInt(document.hcomForm.dd.options.selectedIndex);
	dInMonth = dInM(theMonth); 
	
	if (theDay > dInMonth)
	{
		document.hcomForm.dd.options.selectedIndex = dInMonth;
	}
}

function hoteliers_check_engine(engine)
{
	var index = engine.selectedIndex;
	
	if ( engine.options[index].value == "Tafel")
	{

		document.getElementById("bookHoteliers").style.display = "none";
		//window.open('http://www.seatme.nl/restaurant/489/wellerlooi/de_hamert/hostellerie_de_hamert.htm','_blank','width=400,height=200,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
		
		el = document.getElementById('main');
		
		if (el)
		{
			el.innerHTML = '<iframe style="margin:30px 0 0 0;" name="Seat me" src="http://www.seatme.nl/affiliate/517/restaurant/detail.aspx?rid=489" width="627" height="730" frameborder="0" >';
		}
	}
	else {
		document.getElementById("bookHoteliers").style.display = "block";
	}
}

var act = $('#corpoForm').attr('action');
	function submitForm(){
		var hID = $('#corpoHotelID').val();
		$('#main').html('<iframe name="hoteliersIframe" src="" frameborder="0" style="width:100%; height: 830px;" />');
		$('#corpoForm').attr({target:"hoteliersIframe",action:(act+'?ID=' + '2016' + '&lang=' + document.hcomForm.language.value + '')});;
		$('#hotelierAction').attr('name','action');
		$('#corpoForm').submit();
		$('#hotelierAction').attr('name','tmp');
	}
