function setCurrentDate()
{
	checkin = new Date();
	checkout = new Date();
	checkin.setDate(checkin.getDate()+1);
	checkout.setDate(checkout.getDate()+2);
	selectElement(window.document.checka.daysI,checkin.getDate());
	selectElement(window.document.checka.monthsI,checkin.getMonth()+1);
	selectElement(window.document.checka.yearI,checkin.getFullYear());
	selectElement(window.document.checka.daysS,checkout.getDate());
	selectElement(window.document.checka.monthsS,checkout.getMonth()+1);
	selectElement(window.document.checka.yearS,checkout.getFullYear());
}
function selectElement(param,testValue)
{
	for (var i = 0; i < param.length; i++) 
	{
		if (param.options[i].value == testValue) 
		{
			param.options[i].selected = true;
		}
	}
}
function verifica_date() {
	//Data Inizio valida, nel futuro
	//Data Fine valida, maggiore di data inizio
	var data_oggi, data_inizio, data_fine;
	var ts_oggi, ts_inizio, ts_fine;
	
	if (window.document.checka.yearI.options[window.document.checka.yearI.selectedIndex].value == "0" || window.document.checka.monthsI.options[window.document.checka.monthsI.selectedIndex].value == "0" ||
		window.document.checka.daysI.options[window.document.checka.daysI.selectedIndex] == "0" || window.document.checka.yearS.options[window.document.checka.yearS.selectedIndex] == "0" ||
		window.document.checka.monthsS.options[window.document.checka.monthsS.selectedIndex] == "0" || window.document.checka.daysS.options[window.document.checka.daysS.selectedIndex] == "0")
	{
		alert ("Date di arrivo e di partenza non valide.");
		return false;
	}
	
	data_oggi = new Date();
	data_inizio = new Date(window.document.checka.yearI.options[window.document.checka.yearI.selectedIndex].value, parseInt(window.document.checka.monthsI.options[window.document.checka.monthsI.selectedIndex].value) -1 ,window.document.checka.daysI.options[window.document.checka.daysI.selectedIndex].value);
	data_fine = new Date(window.document.checka.yearS.options[window.document.checka.yearS.selectedIndex].value, parseInt(window.document.checka.monthsS.options[window.document.checka.monthsS.selectedIndex].value) -1 ,window.document.checka.daysS.options[window.document.checka.daysS.selectedIndex].value);
	
	ts_oggi = Date.parse(data_oggi.toUTCString());
	ts_inizio = Date.parse(data_inizio.toUTCString());
	ts_fine = Date.parse(data_fine.toUTCString());
	
	if(data_inizio < ts_oggi || data_fine < ts_oggi )
	{
		alert("Date di arrivo e di partenza non valide.");
		return false;
	}
	if(data_inizio > data_fine )
	{
		alert("La data di arrivo deve precedere la data di partenza!");
		return false;
	}
	return true;
}

function openW()
{
	if (!verifica_date()) return false;
	var width = 800;
	var height = 600;
	
	var str = "height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	if (window.screen)
	{
		var ah = screen.availHeight - 100;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;
		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	window.open('','obm22','scrollbars=yes,status=yes,menubar=no,toolbar=yes,resizable=yes,' + str);
	window.document.checka.submit();
	return true;
}

//setCurrentDate();

// JavaScript Document
