function CheckDate() {
	var newmonthnbday = [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];

	with(document.idForm) {
		var j = fromday[fromday.selectedIndex].value;
		var m = frommonth[frommonth.selectedIndex].value;
		var a = fromyear[fromyear.selectedIndex].value;
	}
	maxday = (m == 2 && a % 4 == 0 && (a % 100 != 0 || a % 400 == 0)) ? 29 : newmonthnbday[m];
	if (j > maxday) {
		alert(errStr1);	//"La date est invalide !"
		return 0;
	}

	return 1;
}

function validation(flag)
{
	if (flag == 1 && document.idForm.AccessCode.value == "") 
		{
		alert(errStr2);
		return (false);
		}

	if(vendorShow)
		if (document.idForm.Vendor.value == "") 
			{
			alert('Please enter your Vendor code');
			return (false);
			}

	if (CheckDate() == 0)
		return false;
	if (document.idForm.nbdays.options == null) {
		var num = parseInt(document.idForm.nbdays.value);
		if (num > 0 && num < 200) {
			document.idForm.nbdays.value = num;
			//alert("New val : " + num);
		} else {
			alert("invalid number of nights");
			return (false);
		}
	}

	if (!sameWindow)
		window.open('','dispoprice', 'toolbar=no,width=700,height=600,menubar=no,scrollbars=yes,resizable=yes');

	document.idForm.submit();
	return (true);
}

function UpdateHotelnames(myForm)
{
	menuNum = myForm.HotelList.selectedIndex;
	if (menuNum == null)
		return;
	myForm.Hotelnames.value = myForm.HotelList.options[menuNum].value;
}

function cancel()
{
	var CName = document.idForm.Hotelnames.value;
	var langue = document.idForm.langue.value;
	if (CName == null || CName == 'All' || CName == ''){
		alert(errStr3);	//"Please select a hotel first"
		return (false); }
	return hannul(CName, langue);
}

function allcancel()
{
	var langue = document.idForm.langue.value;
	return hallannul(langue);
}

function view()
{
	var CName = document.idForm.Hotelnames.value;
	var langue = document.idForm.langue.value;
	if (CName == null || CName == 'All' || CName == ''){
		alert(errStr3);	//"Please select a hotel first"
		return (false); }
	return hview(CName, langue);
}

function reload()
{
	var CName = document.idForm.Hotelnames.value;
	var langue = document.idForm.langue.value;
	if (CName == null || CName == 'All' || CName == ''){
		alert(errStr3);	//"Please select a hotel first"
		return (false); }
	return hreload(CName, langue);
}

function hannul(val, lg)
{
	var waction = "cancel.phtml?state=77&Hotelnames="+val+"&langue="+lg;

	if(versionApp == 2)
		waction = "cancelv2.phtml?state=77&Hotelnames="+val+"&langue="+lg;
		
	newwindow = window.open(waction, "reservation", "toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
	newwindow.focus();
	return false;
}

function hallannul(lg)
{
	var waction = "http://www.fastbooking-hotels.com/cancel.phtml?langue="+lg;

	newwindow = window.open(waction, "reservation", "toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
	newwindow.focus();
	return false;
}

function hview(val,lg)
{
	var waction = "history.phtml?state=2&Hotelnames="+val+"&langue="+lg;

	if(versionApp == 2)
		waction = "historyv2.phtml?state=2&Hotelnames="+val+"&langue="+lg;
		
	newwindow = window.open(waction, "reservation", "toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
	newwindow.focus();
	return false;
}

function hreload(val,lg)
{
	var waction = "reload.phtml?state=2&Hotelnames="+val+"&langue="+lg;
	newwindow = window.open(waction, "reservation", "toolbar=no,width=400,height=350,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes");
	newwindow.focus();
	return false;
}

function resizewindow()
{
	if (parent.frames.length > 0) return;
	widthW = screen.availWidth; heightW = screen.availHeight;
	if(widthW > 820) widthW = 820; if(heightW > 650) heightW = 650; 
	self.resizeTo(widthW,heightW); self.moveTo(15,25);
	window.focus();
}
