

var xmlHttp1;
var gelem;
var address = 'http://www.juicyhotels.com';

function ajaxRequest(uri,elem)
{ 
	gelem = elem;
	xmlHttp1=GetXmlHttpObject()
	if (xmlHttp1==null)
	 {
		 alert ("Browser does not support HTTP Request");
		 return;
	 } 
	var url=uri;
	//alert(url);
	xmlHttp1.onreadystatechange=stateChanged ;
	xmlHttp1.open("GET",url,true);
	xmlHttp1.send(null);
	
}
function stateChanged() 
{ 
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete"){
		document.getElementById(gelem).innerHTML = xmlHttp1.responseText;
	}
}

function clearIsland()
{
	$('#s_island').val('');	
}

function clearCountry()
{
	$('#s_country').val('');
	loadState('');	
}


function GetXmlHttpObject()
{
	var xmlHttp1=null;
	try
 	{
	 // Firefox, Opera 8.0+, Safari
	 	xmlHttp1=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
		try
		{
			xmlHttp1=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
		}
	 }
	return xmlHttp1;
}






// JavaScript Document

	function swapbutton(which){
		
		$(which).show();
		$('#buttonright').hide();
		
	}

function windowOpener(windowHeight, windowWidth, windowName, windowUri)
{
    var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;

    newWindow = window.open(windowUri, windowName, 'scrollbars=1,width=' + windowWidth + 
        ',height=' + windowHeight + 
        ',left=' + centerWidth + 
        ',top=' + centerHeight);

    newWindow.focus();
    return newWindow.name;
}

function addToCompareList(id)
{
	if (document.getElementById("ht"+id).checked == true ) 
		ajaxRequest(address+'/ajax/add_to_compare_list.php?id='+id,'compare_list');
	else
		ajaxRequest(address+'/ajax/remove_from_compare_list.php?id='+id,'compare_list');			
	
}

function showCompareList()
{
	ajaxRequest(address+'/ajax/compare_list.php','compare_list');
}

function removeFromList(id)
{
	try {
		document.getElementById("ht"+id).checked = false;
	} catch(err){}	
	ajaxRequest(address+'/ajax/remove_from_compare_list.php?id='+id,'compare_list');
}

function removeAllFromList()
{
	ajaxRequest(address+'/ajax/remove_from_compare_list.php?remove=all','compare_list');
}

function loadListing(ord,direction)
{
	showAjaxLoader('listing_container_left');
	ajaxRequest('/ajax/load_listing.php?order_by='+ord+'&direction='+direction,'listing_container_left');
}
function loadState(cu)
{
	if (cu == 'US' ) {
		document.getElementById("usstates").style.display = '';
		showAjaxLoader('usstates');
		ajaxRequest(address+'/ajax/load_states.php?cu='+cu,'usstates');
	} else {
		document.getElementById("usstates").style.display = 'none';
		showAjaxLoader('searchcities');
		ajaxRequest(address+'/ajax/load_cities.php?cu='+cu,'searchcities');
		$("#searchcities").show();
	}	
	
	if (cu == 0){
		$("#searchcities").hide();
	}
}
function loadCities(state)
{
	showAjaxLoader('searchcities');
	ajaxRequest(address+'/ajax/load_cities.php?state='+state,'searchcities');
}
function loadState_admin(cu)
{
	if (cu == 'US' ) {
		document.getElementById("usstates").style.display = '';
		showAjaxLoader('usstates');
		ajaxRequest(address+'/ajax/load_states2.php?cu='+cu,'usstates');
	} else {
		document.getElementById("usstates").style.display = 'none';
		showAjaxLoader('searchcities');
		ajaxRequest(address+'/ajax/load_cities2.php?cu='+cu,'searchcities');
	}		
}

function showmapwith(state)
{
	if(state=='1')
	{
		state=document.getElementById("usstates_dd").value;
		if(state=="")
		{
			alert("Please select state first.");
		}
		else
		{
			showAjaxLoader('searchcities2');
			ajaxRequest(address+'/ajax/load_cities3.php?state='+state+'&cityMap=1','searchcities2');
		}
	}
	else
	{
		var state=document.getElementById("s_country").value;
		if(state=="")
		{
			alert("Please select country first.");
		}
		else
		{
			showAjaxLoader('searchcities2');
			ajaxRequest(address+'/ajax/load_cities3.php?cu='+state+'&cityMap=1','searchcities2');
		}
	}	
}
function loadCities_admin(state)
{
	showAjaxLoader('searchcities');
	ajaxRequest(address+'/ajax/load_cities2.php?state='+state,'searchcities');
}

function showAjaxLoader(container)
{
	document.getElementById(container).innerHTML = '<img src="http://www.juicyhotels.com/images/results_loading.gif">';
}

function showAjaxLoader1(container)
{
	document.getElementById(container).innerHTML = '<p align="center" style="padding:20px"><img src="http://www.juicyhotels.com/images/results_loading.gif"></p>';
}


function removeLoginValues(valu,option){
	if(option == valu) 
		document.getElementById('s_hotel').value = '';
}	
function rstoreLoginValues(valu,option){
	if(valu == '')	
		document.getElementById('s_hotel').value = option;
		
}

function gotoIsland(island){
	window.location.href = 'http://www.juicyhotels.com/islands.html?island=' + island;
}


function openLastMinuteDeals()
{
	var url="chooselastminutedeals.php";
	url=url+"&sid="+Math.random();
	
	ajaxRequest(url,"weather_resilts");
}


function openWeather(min,max,measure,region)
{

	var url="http://www.juicyhotels.com/weather/msn.weather.php?min="+min;
	url=url+"&max="+max;
	url=url+"&temp="+measure;
	url=url+"&region="+region;
	
	url=url+"&sid="+Math.random();
	
	var str =  min+","+max+",'"+measure+"','"+region+"'";
	breadCrumb = 'openWeather('+str+')';
	
	showAjaxLoader1('weather_resilts');
	
	ajaxRequest(url,"weather_resilts");
}


function openAllWeather(min,max,measure,region)
{
	var url="http://www.juicyhotels.com/weather/msn.all.weather.php?min="+min;
	url=url+"&max="+max;
	url=url+"&temp="+measure;
	url=url+"&region="+region;
	
	url=url+"&sid="+Math.random();
	
	showAjaxLoader1('weather_resilts');
	
	ajaxRequest(url,"weather_resilts");	
}

function listHotelsFromWeathers(val)
{
	var url="http://www.juicyhotels.com/listhotelsfromweather/"+val+"/";
	/*
	url=url+"&sid="+Math.random();
	showAjaxLoader1('weather_resilts');
	ajaxRequest(url,"weather_resilts");	
	*/
	window.location.href=url;
}

function showGoodWeather(val)
{
	var url="http://www.juicyhotels.com/weather/page.weather.php?start="+val;
	url=url+"&sid="+Math.random();
	
	showAjaxLoader1('weather_resilts');
	
	ajaxRequest(url,"weather_resilts");
}

function showAllWeather(val)
{
	var url="http://www.juicyhotels.com/weather/page.weather.php?start="+val;
	url=url+"&sid="+Math.random();
	
	showAjaxLoader1('weather_resilts');
	
	ajaxRequest(url,"weather_resilts");
}
