function getprices(productcode, producttype, skistation, productname){
	if (document.getElementById("prices")){
		document.getElementById("prices").style.display = '';
		document.getElementById("prices").innerHTML = 'Calculando Precios...';
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="/xmlmessages/ski.cfm?productname=" + productname + "&producttype=" + producttype + "&product=" + productcode + "&d=" + document.getElementById("dstartdate").value + "&m=" + document.getElementById("mstartdate").value + '&y=' + document.getElementById("ystartdate").value + '&duration=' + document.getElementById("duration").value + '&adults=' + document.getElementById("adults").value + '&children=' + document.getElementById("children").value + '&skistationid=' + document.getElementById("skistationid").value;
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function getpricesHomepage(productcode, producttype, skistation, productname, page){
	var url= page + "?dd=" + document.getElementById("dstartdate").value + "&dm=" + document.getElementById("mstartdate").value + '&dy=' + document.getElementById("ystartdate").value + '&ddur=' + document.getElementById("duration").value + '&ad=' + document.getElementById("adults").value + '&ch=' + document.getElementById("children").value + '&skistationid=' + skistation;
	document.location.href = url;
	//document.getElementById("home").action = url;
	
	//document.getElementById("home").submit();
	return false;
}


function stateChanged(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		document.getElementById("prices").innerHTML = xmlHttp.responseText;
		document.getElementById("prices").style.display = '';
	}
}

function GetXmlHttpObject(){
	var objXMLHttp=null;
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

function showOptionsDiv(chk, id){
	if (document.getElementById(chk).checked == true){
		document.getElementById(id).style.display = '';
	} else {
		document.getElementById(id).style.display = 'none';
	}
}

function startBooking(){
	return true;
}

function prepareForm(){
	var myString = document.getElementById("skistationid").value;
	var mySplitResult = myString.split("|");
	var skistationid = mySplitResult[0]; 
	var embprodcode = mySplitResult[1]; 
	var embprodtype = mySplitResult[2]; 
	var productdescription = mySplitResult[3]; 
	var page = mySplitResult[4]; 
	getpricesHomepage(embprodcode, embprodtype, skistationid, productdescription, page);	
}