var xmlhttp;
var country = 0;
var country2 = 0;
var city = 0;
var city2 = 0;
var destina = 0;
var price = 0;
var destina2 = 0;
var price2 = 0; var adv_type = 'ht'; var fup = 1; var hup = 1;
var smark = 0;
var tour_id = 'ov';

function showeacht(str,id)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	document.getElementById("tour_"+tour_id).style.color = '#FFF';
	document.getElementById("tour_"+str).style.color = '#000';
	tour_id = str;
	var url="pages/showtour.php";
	url=url+"?q="+str;
	url=url+"&id="+id;
	xmlhttp.onreadystatechange=stateChanged2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged2()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("showtour").innerHTML=xmlhttp.responseText;
	}
}
function showfear(n,direct)
{
	if(direct=='up')
	{
		if(fup>1)
			fup--;
	}else if(direct=='down')
		if(fup<n)
			fup++;
			
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/updown.php";
	url=url+"?q=fear&p="+fup;
	url=url+"&id="+Math.random();
	xmlhttp.onreadystatechange=statefear;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function statefear()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("showfearup").innerHTML=xmlhttp.responseText;
	}
}
function showhotel(n,direct)
{
	if(direct=='up')
	{
		if(hup>1)
			hup--;
	}else if(direct=='down')
		if(hup<n)
			hup++;
			
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/updown.php";
	url=url+"?q=hotel&p="+hup;
	url=url+"&id="+Math.random();
	xmlhttp.onreadystatechange=statehotel;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function statehotel()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("showhotelup").innerHTML=xmlhttp.responseText;
	}
}
function show_advance()
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var img1 = document.getElementById("image1");
	var img2 = document.getElementById("image2");
	img1.innerHTML = '<span onClick="searchtab_2()" style="cursor:pointer"><img src="images/search_r2.jpg" width="93" height="29" /></span>';
	img2.innerHTML = '<span onClick="show_advance()" style="cursor:pointer"><img src="images/search2.jpg" width="115" height="29" /></span>';
	smark = 1;
	var url="pages/searchtab.php";
	url=url+"?q=adv_"+adv_type;
	url=url+"&id="+Math.random();
	xmlhttp.onreadystatechange=stateadvance;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateadvance()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("searchbox").innerHTML=xmlhttp.responseText;
	}
}
function show_advance_2(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	adv_type = str;
	var url="pages/searchtab.php";
	url=url+"?q=adv_"+str;
	url=url+"&id="+Math.random();
	xmlhttp.onreadystatechange=stateadvance2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateadvance2()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("searchbox").innerHTML=xmlhttp.responseText;
	}
}
function searchtab(str)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var alink = document.getElementById("select_advance");
	
	adv_type = str;
	
	var url="./pages/searchtab.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("searchbox").innerHTML=xmlhttp.responseText;
	}
}
function searchtab_2()
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var alink = document.getElementById("select_advance");
	var img1 = document.getElementById("image1");
	var img2 = document.getElementById("image2");
	img1.innerHTML = '<span onClick="searchtab_2()" style="cursor:pointer"><img src="images/searchtopl.jpg" width="115" height="29" /></span>';
	img2.innerHTML = '<span onClick="show_advance()" style="cursor:pointer"><img src="images/searchtopr.jpg" width="93" height="29" /></span>';
	//adv_type = str;
	smark = 0;
	var url="./pages/searchtab.php";
	url=url+"?q="+adv_type;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged_2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged_2()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("searchbox").innerHTML=xmlhttp.responseText;
	}
}
//-------------------------hide search box-----------------------------
function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}
function ShowLayer() {
    // hide all dropdowns on the page

        
    // looping through all forms on the page
	var browser=navigator.appName;
	var ver = vIE();
	//if ((browser=="Microsoft Internet Explorer") && (version<4))
	if ((browser=="Microsoft Internet Explorer") && (ver==6))
  	{
  		for (f = 0; f < document.forms.length; f++)
    	{
        	var elements = document.forms[f].elements;
        	// looping through all elements on certain form

        	for (e = 0; e < elements.length; e++)
        	{
            	if (elements[e].type == "select-one")
            	{
                	elements[e].style.display = 'none';
            	}
        	}
    	}
		//alert('hello');
		/*if(smark){
		switch(adv_type){
			case 'ht':
				document.getElementById('country').style.display = 'none';
				document.getElementById('location').style.display = 'none';
				document.getElementById('star').style.display = 'none';
				document.getElementById('honame').style.display = 'none';
				document.getElementById('doprice').style.display = 'none';
				break;
			case 'fl':
				document.getElementById('dofrom').style.display = 'none';
				document.getElementById('doto').style.display = 'none';
				document.getElementById('docorp').style.display = 'none';
				break;
			case 'tr':
				document.getElementById('country').style.display = 'none';
				document.getElementById('dodes').style.display = 'none';
				document.getElementById('docat').style.display = 'none';
				document.getElementById('doprice').style.display = 'none';
				document.getElementById('activity').style.display = 'none';
				break;
		}
		}else{
		switch(adv_type){
			case 'ht':
				document.getElementById('country').style.display = 'none';
				document.getElementById('location').style.display = 'none';
				document.getElementById('star').style.display = 'none';
				document.getElementById('honame').style.display = 'none';
				break;
			case 'fl':
				document.getElementById('dofrom').style.display = 'none';
				document.getElementById('doto').style.display = 'none';
				document.getElementById('docorp').style.display = 'none';
				break;
			case 'tr':
				document.getElementById('country').style.display = 'none';
				document.getElementById('dodes').style.display = 'none';
				document.getElementById('docat').style.display = 'none';
				document.getElementById('doprice').style.display = 'none';
				break;
		}
		}
		//document.getElementById('doprice').style.display = 'none';*/
	}
}
function HideLayer() {
    // hide all dropdowns on the page

    for (f = 0; f < document.forms.length; f++)
    {
        var elements = document.forms[f].elements;
        for (e = 0; e < elements.length; e++)
        {
            if (elements[e].type == "select-one")
            {
                elements[e].style.display = 'block';
            }
        }
    }
	/*if(smark){
		switch(adv_type){
			case 'ht':
				document.getElementById('country').style.display = 'block';
				document.getElementById('location').style.display = 'block';
				document.getElementById('star').style.display = 'block';
				document.getElementById('honame').style.display = 'block';
				document.getElementById('doprice').style.display = 'block';
				break;
			case 'fl':
				document.getElementById('dofrom').style.display = 'block';
				document.getElementById('doto').style.display = 'block';
				document.getElementById('docorp').style.display = 'block';
				break;
			case 'tr':
				document.getElementById('country').style.display = 'block';
				document.getElementById('dodes').style.display = 'block';
				document.getElementById('docat').style.display = 'block';
				document.getElementById('doprice').style.display = 'block';
				document.getElementById('activity').style.display = 'block';
				break;
		}
		}else{
		switch(adv_type){
			case 'ht':
				document.getElementById('country').style.display = 'block';
				document.getElementById('location').style.display = 'block';
				document.getElementById('star').style.display = 'block';
				document.getElementById('honame').style.display = 'block';
				break;
			case 'fl':
				document.getElementById('dofrom').style.display = 'block';
				document.getElementById('doto').style.display = 'block';
				document.getElementById('docorp').style.display = 'block';
				break;
			case 'tr':
				document.getElementById('country').style.display = 'block';
				document.getElementById('dodes').style.display = 'block';
				document.getElementById('docat').style.display = 'block';
				document.getElementById('doprice').style.display = 'block';
				break;
		}
		}*/
}
//--------------------------------------------------------------------------------
function showeachht(str,id)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/showhotel.php";
	url=url+"?q="+str;
	url=url+"&id="+id;
	xmlhttp.onreadystatechange=stateChanged1;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged1()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("showhotel").innerHTML=xmlhttp.responseText;
	}
}
function getcity(id)
{
	country = id;
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/searchform.php";
	url=url+"?q=getcity";
	url=url+"&id="+id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stategetcity;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
 function switch_display(obj)
{
        if(obj.style.display=='none')
        {
            obj.style.display='';
        }
        else
        {
obj.style.display='none';
        }
}
function stategetcity()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("location").innerHTML=xmlhttp.responseText;
	}
}
function getcity2(id)
{
	country2 = id;
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/searchform.php";
	url=url+"?q=getcity2";
	url=url+"&id="+id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stategetcity2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function stategetcity2()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("location2").innerHTML=xmlhttp.responseText;
	}
}
function gethotel(id)
{
	city = id;
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/searchform.php";
	url=url+"?q=gethotel";
	url=url+"&id="+id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stategethotel;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function stategethotel()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("honame").innerHTML=xmlhttp.responseText;
	}
}
function gethotel2(id)
{
	city2 = id;
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/searchform.php";
	url=url+"?q=gethotel2";
	url=url+"&id="+id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stategethotel2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function stategethotel2()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("honame2").innerHTML=xmlhttp.responseText;
	}
}
function starhotel(id)
{
	if(country!=0 && city!=0)
	{
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
  		{
  			alert ("Browser does not support HTTP Request");
  			return;
  		}
		var url="pages/searchform.php";
		url=url+"?q=star";
		url=url+"&hid="+city;
		url=url+"&id="+id;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=statestar;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
}
function statestar()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("honame").innerHTML=xmlhttp.responseText;
	}
}
function starhotel2(id)
{
	if(country2!=0 && city2!=0)
	{
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
  		{
  			alert ("Browser does not support HTTP Request");
  			return;
  		}
		var url="pages/searchform.php";
		url=url+"?q=star2";
		url=url+"&hid="+city2;
		url=url+"&id="+id;
		url=url+"&sid="+Math.random();
		xmlhttp.onreadystatechange=statestar2;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
}
function statestar2()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("honame2").innerHTML=xmlhttp.responseText;
	}
}
function getdes(id)
{
	destina = id;
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/searchform.php";
	url=url+"?q=des";
	url=url+"&id="+id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=statedes;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function statedes()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("destination").innerHTML=xmlhttp.responseText;
	}
}
function getdes2(id)
{
	destina2 = id;
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/searchform.php";
	url=url+"?q=des2";
	url=url+"&id="+id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=statedes2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function statedes2()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("destination2").innerHTML=xmlhttp.responseText;
	}
}
function getprice(id)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/searchform.php";
	url=url+"?q=price";
	url=url+"&cid="+id;
	url=url+"&id="+price;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateprice;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function stateprice()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("pricefrom").innerHTML=xmlhttp.responseText;
	}
}
function getprice2(id)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/searchform.php";
	url=url+"?q=price2";
	url=url+"&cid="+id;
	url=url+"&id="+price;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateprice2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function stateprice2()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("pricefrom2").innerHTML=xmlhttp.responseText;
	}
}
function getcategory(id)
{
	price = id;
	if(destina==1)
		cid = 2;
	else if(destina==2)
		cid = 3;
	else if(destina==3)
		cid = 4;
	xmlhttp=GetXmlHttpObject();	
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/searchform.php";
	url=url+"?q=cate";
	url=url+"&id="+cid;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=statecate;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function statecate()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("category").innerHTML=xmlhttp.responseText;
	}
}
function getcategory2(id)
{
	price2 = id;
	if(destina2==1)
		cid = 2;
	else if(destina2==2)
		cid = 3;
	else if(destina2==3)
		cid = 4;
	xmlhttp=GetXmlHttpObject();	
	if (xmlhttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	var url="pages/searchform.php";
	url=url+"?q=cate2";
	url=url+"&id="+cid;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=statecate2;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function statecate2()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("category2").innerHTML=xmlhttp.responseText;
	}
}
function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
  	{
  	// code for IE7+, Firefox, Chrome, Opera, Safari
  		return new XMLHttpRequest();
  	}
	if (window.ActiveXObject)
  	{
  		// code for IE6, IE5
  		return new ActiveXObject("Microsoft.XMLHTTP");
  	}
	return null;
}
