function guest_ad(guestid,adtype) {	
var strURL;
	if(adtype == 1 )
	{
		document.getElementById("logo_ad").style.visibility = "visible";
		strURL = "right_banner.php?gid="+guestid ;
		}
	else if(adtype == 2 )
	{
		document.getElementById("minipage_ad").style.visibility = "visible";
		strURL = "mini_page.php?gid="+guestid ;
		}
	else if(adtype == 3 )
	{
		document.getElementById("fullpage_ad").style.visibility = "visible";
		strURL = "full_page.php?gid="+guestid ;
		}
	else if(adtype == 4 )
	{
		document.getElementById("logo_ad").style.visibility = "visible";
		var strURL="right_info.php?gid="+guestid ;		
		}
var req = GetXmlHttpObject();
	if (req) 
	{
		req.onreadystatechange = function() {
		if (req.readyState == 4) 
		{
			if (req.status == 200) 
			{	
				if(adtype == 1 )		
				{
					document.getElementById('logo_ad').innerHTML=req.responseText;
					}
				else if (adtype == 2)
				{ 
					document.getElementById('minipage_ad').innerHTML=req.responseText; 
					}
				else if (adtype == 3)
				{ 
					document.getElementById('fullpage_ad').innerHTML=req.responseText; 
					}
				else if (adtype == 4)
				{ 
					document.getElementById('logo_ad').innerHTML=req.responseText; 
					}
					
			} 
			else 
			{
				alert("There was a problem while using XMLHTTP:\n" + req.statusText);
			}
		}				
	}			
			req.open("GET", strURL, true);			
			req.send(null);
		}		
		
	}

function validate()
{

	//validation for Guest Search
	//alert(document.getElementById("findname").value);
	//alert(document.getElementById("hidden_jid").value);
	//alert(document.getElementById("findkeyword").value);
	if ( (document.getElementById("findname").value == "" && document.getElementById("hidden_jid").value == "" && document.getElementById("hidden_kid").value == "") )
	{
		
		alert("Profession/Guest Name Empty/City");
			return false;
					
		}
	else
	{ return true; }
	
 }
	
	
function change_text(str,jobname)
{
	
	document.getElementById("hidden_jid").value = str;
	document.getElementById("findjob").value = jobname ;
	document.getElementById("livesearch").style.visibility = "hidden";
	txtname = document.getElementById("findname").value ;
	
	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
 	{
	 alert ("Browser does not support HTTP Request");
	 return;
	 } 

	var url="search_jobguest.php";
	url=url+"?q="+str + "&job=" + jobname + "&name=" + txtname;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged_jobsearch1 ;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}

function change_text_keyword(kid,kname)
{
	
	document.getElementById("livesearch_keyword").style.visibility = "hidden" ;
	document.getElementById("findkeyword").value = kname ;
	document.getElementById("hidden_kid").value = kid ;
}

function stateChanged_jobsearch1() 
{ 
	

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		
	 document.getElementById("guest").innerHTML=xmlHttp.responseText;
	 
	 } 
}

function change_text_city(ccid,jname)
{
	txtname = document.getElementById("findname").value;
	//document.getElementById("findjob").value = jobname ;
	
	document.getElementById("livesearch_city").style.visibility = "hidden" ;
	document.getElementById("findcity").value = jname ;
	hidden_jid = document.getElementById("hidden_jid").value ;
	
	document.getElementById("hidden_ccid").value = ccid ;
	
	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
 	{
	 alert ("Browser does not support HTTP Request");
	 return;
	 } 

	var url="guest_search_city.php";
	url=url+"?cityid=" + ccid + "&name=" + txtname + "&hjid=" + hidden_jid + "&job=" + jname;
	url=url+"&sid="+Math.random();
	
	xmlHttp.onreadystatechange=stateChanged_change_text_city;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}
	
function stateChanged_change_text_city() 
{ 
	

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		
	 document.getElementById("guest").innerHTML=xmlHttp.responseText;
	 
	 } 
}
function showresult(str,user_language)
{
	
	var teritory = document.getElementById("teritory").value
	document.getElementById("livesearch").style.visibility = "visible";	
	document.getElementById("findjob").value = str ;
	var did = document.getElementById("department").value;
	
	//document.getElementById("livesearch").style.visibility = visible;
if (str.length==0)
 { 
 document.getElementById("livesearch").innerHTML="";
 document.getElementById("livesearch").style.border="0px";
 return;
 }

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 } 

var url="livesearch1.php";
url=url+"?q="+str + "&language=" + user_language + "&ter=" + teritory + "&sid=" + did ;

xmlHttp.onreadystatechange=stateChanged_jobsearch ;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged_jobsearch() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	//alert(xmlHttp.responseText) ;
 
	 document.getElementById("livesearch").innerHTML=xmlHttp.responseText;
 } 
}

function search_guest(strcid,strname) //Search country
{

var url="guest_search.php";

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

url =url+"?cid="+strcid+ "&name=" + strname;

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function francemap() //Search country
{
	
	
	var url="francemap.php";

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

url =url;

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("guest").innerHTML=xmlHttp.responseText;

}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


function showcity(str,user_language)
{
	
	var teritory = document.getElementById("teritory").value
	
	
	//if (document.getElementById("teritory").value != 84 )
//	{
//		alert ("No need to select the cities");
//	}
//	else
//	{
				document.getElementById("livesearch_city").style.visibility = "visible";	
				var did = document.getElementById("department").value;
				
			if (str.length==0)
			 { 
			 document.getElementById("livesearch_city").innerHTML="";
			 document.getElementById("livesearch_city").style.border="0px";
			 return;
			 }
		
			xmlHttp=GetXmlHttpObject()
		
			if (xmlHttp==null)
			 {
			 alert ("Browser does not support HTTP Request");
			 return;
			 } 
		
			var url="livesearch_city1.php";
			
			url=url+"?q="+str + "&language=" + user_language + "&ter=" + teritory + "&sid=" + did ;
			
			//url=url+"?q="+str + "&language=" + user_language + "&ter=" + teritory ;
			

			xmlHttp.onreadystatechange=stateChanged_citysearch ;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
			
//	}
} 

function stateChanged_citysearch() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("livesearch_city").innerHTML = xmlHttp.responseText;
 } 
}

function fun_exit()
{
	document.getElementById("minipage_ad").style.visibility = "hidden";	
	document.getElementById("fullpage_ad").style.visibility = "hidden";
	document.getElementById("logo_ad").style.visibility = "hidden";
	}

//START - This function is a copy of fun function in yellow.php
	function fun(guestid,nextbu)
	{
		//salert("A");
		document.getElementById('disimg').innerHTML = "";
		document.getElementById('disimg').style.height = "0px";
		var strURL="mini_banner.php?gid="+guestid + "&img=" + nextbu ;	
		
		var req = GetXmlHttpObject();		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					//alert (req.responseText);
										
						document.getElementById('divImage').innerHTML=req.responseText;					
						
						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);			
			req.send(null);
		}
	}

function rightlinks()
{
	document.getElementById("logo_ad").style.visibility = "hidden";	
}



	function fun_full(imgid,pid,fid)
	{
		//alert("A");
		document.getElementById('disimg').innerHTML = "";
		document.getElementById('disimg').style.height = "0px";
		var strURL="full_banner.php?pid="+ pid + "&img=" + imgid + "&fid=" + fid;	
	//	alert(strURL);
		var req = getXMLHTTP();		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					//alert (req.responseText);
										
						document.getElementById('divImage').innerHTML=req.responseText;					
						
						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);			
			req.send(null);
		}
	}	
	


function fun_banner(pubid,fid,guestid)
	{
		
		document.getElementById('disfull').innerHTML = "";
		document.getElementById('disfull').style.height = "0px";
		var strURL="full_rightbanner.php?pid="+ pubid + "&fid=" + fid + "&gid=" + guestid;	
		//alert(strURL);
		
		var req = getXMLHTTP();		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					//alert (req.responseText);
										
						document.getElementById('fullpage').innerHTML=req.responseText;					
						
						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);			
			req.send(null);
		}
	}
	
  function getState(countryId) {	
	alert(countryId);
		
		var strURL="auto_state.php?country="+countryId;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					//alert (req.responseText);
						
						document.getElementById('statedivreal').style.visibility = "hidden";
						document.getElementById('statediv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
function showkeyword(str,user_language)
{
	
	var teritory = document.getElementById("teritory").value
	
	

				document.getElementById("livesearch_keyword").style.visibility = "visible";	
				var did = document.getElementById("department").value;
				
			if (str.length==0)
			 { 
			 document.getElementById("livesearch_keyword").innerHTML="";
			 document.getElementById("livesearch_keyword").style.border="0px";
			 return;
			 }
		
			xmlHttp=GetXmlHttpObject()
		
			if (xmlHttp==null)
			 {
			 alert ("Browser does not support HTTP Request");
			 return;
			 } 
		
			var url="livesearch_keyword.php";
			
			url=url+"?q="+str + "&language=" + user_language + "&ter=" + teritory + "&sid=" + did ;
			
			xmlHttp.onreadystatechange=stateChanged_keywordsearch;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);

} 

function stateChanged_keywordsearch() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("livesearch_keyword").innerHTML = xmlHttp.responseText;
 } 
}

function fetch_text()
{
	document.getElementById("findname").value = document.getElementById("findname1").value;
	}