var xmlHttp
var xmlHttpHeader
var xmlHttpLeft
var xmlHttpRight
var xmlHttpAvail
var xmlHttpAvail2
var xmlHttpReviews
var xmlHttpPriceDetails
var xmlHttpForm
var xmlHttpLoginForm
/******************** LOCAL ColumnLEFT **********************/
function GetRequestlocalLeft(city_id,request, products_id,ssid, text) {
	document.getElementById("leftContent").innerHTML='<p align="center"> ' + text + '...<br><img src="images/apartment-loader.gif" width="110px"></p>'
	xmlHttpLeft=GetXmlHttpObject(stateChangedLocalLeft)
	xmlHttpLeft.open("GET",  local_server+ "?city_id="+city_id+"&request="+request+  "&ssid="+ssid+"&products_id="+products_id, true)
	xmlHttpLeft.send(null)
}
function stateChangedLocalLeft() { 
	if (xmlHttpLeft.readyState==4 || xmlHttpLeft.readyState=="complete") { 
		document.getElementById("leftContent").innerHTML=xmlHttpLeft.responseText ;
	}
}
/******************** LOCAL ColumnRIGHT **********************/
function GetRequestlocalRight(city_id,request,products_id,booking_step,payment,ssid, text) {
	document.getElementById("rightContent").innerHTML='<p align="center"> ' + text + '...<br><img src="images/apartment-loader.gif" width="110px"></p>'
	xmlHttpRight=GetXmlHttpObject(stateChangedLocalRight)
	xmlHttpRight.open("GET",  local_server+ "?city_id="+city_id+"&request="+request+  "&ssid="+ssid+"&booking_step="+booking_step+"&payment="+payment+"&products_id="+products_id, true)
	xmlHttpRight.send(null)
}
function stateChangedLocalRight() { 
	if (xmlHttpRight.readyState==4 || xmlHttpRight.readyState=="complete") { 
		document.getElementById("rightContent").innerHTML=xmlHttpRight.responseText ;
	}
}
/******************** LOCAL PriceDetails **********************/
function GetRequestlocalPriceDetails(city_id,request,products_id,ssid, text) {
	document.getElementById("price_details").innerHTML='<p align="center"> ' + text + '...<br><img src="images/apartment-loader.gif" width="110px"></p>'
	xmlHttpPriceDetails=GetXmlHttpObject(stateChangedPriceDetails)
	xmlHttpPriceDetails.open("GET",  local_server+ "?city_id="+city_id+"&request="+request+  "&products_id="+products_id+ "&ssid="+ssid, true)
	xmlHttpPriceDetails.send(null)
}
function stateChangedPriceDetails() { 
	if (xmlHttpPriceDetails.readyState==4 || xmlHttpPriceDetails.readyState=="complete") { 
		document.getElementById("price_details").innerHTML=xmlHttpPriceDetails.responseText ;
	}
}

/******************** LOCAL SHUTTLE  **********************/
function GetRequestlocalShuttle(city_id,request,order_id,airflight,flight_from,plane_time,shuttle_cash, airport,arrival_date,comment,people, ssid, text) {
	if (order_id && airflight && plane_time && airport && arrival_date) {
		
	document.getElementById("contact").innerHTML='<p align="center"> ' + text + '...<br><img src="images/apartment-loader.gif" width="110px"></p>'
	xmlHttpShuttle=GetXmlHttpObject(stateChangedShuttle)
	xmlHttpShuttle.open("GET",  local_server+ "?city_id="+city_id+"&request="+request+  "&order_id="+order_id+ "&airflight="+airflight+ "&flight_from="+flight_from+ "&plane_time="+plane_time+ "&shuttle_cash="+shuttle_cash+"&airport="+airport+"&arrival_date="+arrival_date+"&comment="+comment+ "&people="+people+ "&ssid="+ssid, true)
	xmlHttpShuttle.send(null)
	}
}
function stateChangedShuttle() { 
	if (xmlHttpShuttle.readyState==4 || xmlHttpShuttle.readyState=="complete") { 
		document.getElementById("contact").innerHTML=xmlHttpShuttle.responseText ;
	}
}

/******************** LOCAL REVIEWS **********************/
function GetRequestlocalReviews(city_id,request,reviews_id,products_id,page,ssid, text) {
		document.getElementById("Reviews").innerHTML='<p align="center"> ' + text + '...<br><img src="images/apartment-loader.gif" width="110px"></p>'
		xmlHttpReviews=GetXmlHttpObject(stateChangedLocalReviews)
		xmlHttpReviews.open("GET",  local_server+ "?city_id="+city_id+"&request="+request+ "&ssid="+ssid+"&reviews_id="+reviews_id+"&page="+page+"&products_id="+products_id, true)
		xmlHttpReviews.send(null)
}
function stateChangedLocalReviews() { 
	if (xmlHttpReviews.readyState==4 || xmlHttpReviews.readyState=="complete") { 
		document.getElementById("Reviews").innerHTML=xmlHttpReviews.responseText ;
	}
}

/******************** LOCAL AVAILABILITIES **********************/
function GetRequestlocalAvailability(city_id,request,products_id,dateArr,dateDep,adults ,ssid,text) {
		document.getElementById("prices").innerHTML='<p align="center"> ' + text + '...<br><img src="images/apartment-loader.gif" width="100px"></p>'
		xmlHttpAvail2=GetXmlHttpObject(stateChangedLocalAvailability)
		xmlHttpAvail2.open("GET",  local_server+ "?city_id="+city_id+"&request="+request +"&products_id="+products_id+"&dateArr="+dateArr+"&dateDep="+dateDep+"&adults="+adults+"&ssid="+ssid, true)
		xmlHttpAvail2.send(null)
}

function stateChangedLocalAvailability() { 
	if (xmlHttpAvail2.readyState==4 || xmlHttpAvail2.readyState=="complete") {
		document.getElementById("prices").innerHTML=xmlHttpAvail2.responseText ;
	}
}


function GetRequestlocalAvailabilityShort(city_id,request,products_id,dateArr,dateDep, adults,children, ssid,text) {
		document.getElementById("availability").innerHTML='<p align="center"> ' + text + '...<br><img src="images/apartment-loader.gif" width="100px"></p>'
		xmlHttpAvail=GetXmlHttpObject(stateChangedLocalAvailabilityShort)
		xmlHttpAvail.open("GET",  local_server+ "?city_id="+city_id+"&request="+request +"&products_id="+products_id+"&adults="+adults+"&children="+children+"&dateArr="+dateArr+"&dateDep="+dateDep+"&ssid="+ssid, true)
		xmlHttpAvail.send(null)
}

function stateChangedLocalAvailabilityShort() { 
	if (xmlHttpAvail.readyState==4 || xmlHttpAvail.readyState=="complete") { 
		document.getElementById("availability").innerHTML=xmlHttpAvail.responseText ;
	}
}


/******************** LOCAL GENERIC **********************/
function GetRequestlocal(city_id,request,products_id, ssid, text) {
		document.getElementById("result").innerHTML='<p align="center"> ' + text + '...<br><img src="images/apartment-loader.gif" width="100px"></p>'
		xmlHttp=GetXmlHttpObject(stateChangedLocal)
		xmlHttp.open("GET",  local_server+ "?city_id="+city_id+"&request="+request+ "&ssid="+ssid+"&products_id="+products_id, true)
		xmlHttp.send(null)
}

function stateChangedLocal() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById("result").innerHTML=xmlHttp.responseText ;
	}
}

/******************** LOCAL FORM **********************/
function GetRequestForm(city_id,request,products_id, ssid, text) {
	datas =''
	if (document.getElementById('email_address').value){	
		datas= '&email_address='+ document.getElementById('email_address').value
	}
	if (document.getElementById('password').value){
		datas= datas+'&password='+ document.getElementById('password').value
	}
		document.getElementById("contact").innerHTML='<p align="center"> ' + text + '...<br><img src="images/apartment-loader.gif" width="100px"></p>'
		xmlHttpForm=GetXmlHttpObject(stateChangedForm)
		xmlHttpForm.open("GET",  local_server+ "?city_id="+city_id+"&request="+request+ "&ssid="+ssid+"&products_id="+products_id +datas, true)
		xmlHttpForm.send(null)
}
function stateChangedForm() { 
	if (xmlHttpForm.readyState==4 || xmlHttpForm.readyState=="complete") { 
		document.getElementById("contact").innerHTML=xmlHttpForm.responseText ;
	}
}

/******************** LOCAL HEADER FORM -- LOGIN **********************/
function GetRequestHeaderForm(city_id,request,ssid, text) {
	datas =''
	if (document.getElementById('email_address').value){	
		datas= '&email_address='+ document.getElementById('email_address').value
	}
	if (document.getElementById('password').value){
		datas= datas+'&password='+ document.getElementById('password').value
	}
		document.getElementById("loginForm").innerHTML='<p align="center"> ' + text + '...<br><img src="images/apartment-loader.gif" width="100px"></p>'
		xmlHttpLoginForm=GetXmlHttpObject(stateChangedHeaderForm)
		xmlHttpLoginForm.open("GET",  local_server+ "?city_id="+city_id+"&request="+request+ "&ssid="+ssid +datas, true)
		xmlHttpLoginForm.send(null)
}

function stateChangedHeaderForm() { 
	if (xmlHttpLoginForm.readyState==4 || xmlHttpLoginForm.readyState=="complete") { 
		document.getElementById("loginForm").innerHTML=xmlHttpLoginForm.responseText ;
	}
}
 
function GetXmlHttpObject(handler) { 
	var objXmlHttp=null
	
	if (navigator.userAgent.indexOf("Opera")>=0) {
		alert("This doesn't work in Opera") 
		return; 
	}
	if (navigator.userAgent.indexOf("MSIE")>=0) { 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0) {
			strName="Microsoft.XMLHTTP"
		} 
		try { 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} 
		catch(e) { 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0) {
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
} 

