function HTTPClient()
{};
HTTPClient.prototype = {
    xmlhttp: null,
    callback: null,
    loadRemoteContent: function(url, callbackFunction) 
    {
        this.callback = function(self) {
            eval(callbackFunction + '(self.xmlhttp);');
        }
        var self = this;
        if (window.XMLHttpRequest) {
            this.xmlhttp = new XMLHttpRequest();
            this.xmlhttp.onreadystatechange = function() {
                self.processReqChange(self);
            }
            this.xmlhttp.open("GET", url, true);
            this.xmlhttp.send(null);
        } else if (window.ActiveXObject) {
            this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            if (this.xmlhttp) {
                this.xmlhttp.onreadystatechange = function() {
                    self.processReqChange(self);
                };
				//alert(url);
                this.xmlhttp.open("GET", url, true);
                this.xmlhttp.send();
            }
        }
    },
    processReqChange: function(self) 
    {
        if (this.xmlhttp.readyState == 4) {
           if (this.xmlhttp.status == 200) {
              self.callback(self);
            } else {
                alert("There was a problem retrieving the data:\n" + this.xmlhttp.statusText);
            }
        }
    }
}





/* Function for the zoomox registeration*/
function call_zoomox_country( continentID, countryID )
{
		var r = Math.random();
        var httpClient = new HTTPClient();
		//alert(continentID)
		httpClient.loadRemoteContent("get_zoomox_country.php?continentID="+continentID+"&country="+ countryID +"&t2="+r, 'handlezoomoxCountry');
}

function handlezoomoxCountry(response)
{
    var message = response.responseText;
    var temp;
	Countrydiv.innerHTML = message;
}

/* for the state function*/
function call_zoomox_state( countryID, stateID )
{
	if(countryID=='US')
	{
	    var isMozilla=(navigator.appName.indexOf('Netscape')>=0);		
		document.getElementById('countyRow').style.display=isMozilla?"table-row":"block";
		document.getElementById('countySpaceRow').style.display=isMozilla?"table-row":"block";
	}
	else
	{
		 document.getElementById('countyRow').style.display="none";
		 document.getElementById('countySpaceRow').style.display="none";
		
	}
		var r = Math.random();
        var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("get_zoomox_state.php?countryID="+countryID+"&state="+stateID+"&t2="+r, 'handlezoomoxstate');
}

function handlezoomoxstate(response)
{
    var message = response.responseText;
    var temp;
	Statediv.innerHTML = message;
}
/* closing for the state function*/


/* for the county function*/
function call_zoomox_county( stateID, countryID, countyID, cityID )
{		
		var r = Math.random();
        var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("get_zoomox_county.php?stateID="+stateID+"&countryID="+ countryID +"&countyID="+ countyID +"&cityID="+ cityID +"&t2="+r, 'handlezoomoxcounty');
}

function handlezoomoxcounty(response)
{
    var message = response.responseText;
    var temp;
	temp = message.split("#");
	Countydiv.innerHTML = temp[0];

	if(temp[1] <= 0){
		call_zoomox_city( '', temp[2], temp[3], temp[4] );
	} else
		call_zoomox_city( temp[5], temp[2], temp[3], temp[4] );
	}

/* closing for the county function*/

/* for the city function*/
function call_zoomox_city( countyID, stateID, countryID, cityID )
{
		//alert(countyID +" "+stateID+" "+countryID+" "+cityID );
		var r3 = Math.random();
     	var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("get_zoomox_city.php?countyID="+countyID+"&stateID="+ stateID +"&countryID="+ countryID +"&cityID="+ cityID +"&n="+r3, 'handlezoomoxcity');
}

function handlezoomoxcity(response)
{
	
    var message = response.responseText;
    var temp;
	CityDiv.innerHTML = message;
	//AccCityDiv.innerHTML = message;
}
/* closing for the state function*/



function checkselection()
{
	
   if(document.getElementById('continent').value == 0)
   {
	   alert('Please select continent. ');
	   return false;
		//AccCityDiv.innerHTML = message;
	}
	else if(document.getElementById('country').value == 0)
	{
		alert('Please select country.');	
		return false;
	}
	else if(document.getElementById('state').value == 0)
	{
		alert('Please select state.');	
		return false;
	}
	else if(document.getElementById('citycombo').value == 0)
	{
		alert('Please select city.');	
		 return false;
	}
	else
	{
		document.getElementById('cid').value=document.getElementById('citycombo').value; 
		return true;	
	}

}

/* Function for the changing header dyanamically*/
function call_header(string)
{
		//alert(string);
		var flashstr=string;
		var r = Math.random();
        var httpClient = new HTTPClient();
		//alert(continentID)
		httpClient.loadRemoteContent("get_zoomox_header.php?str="+flashstr+"&t2="+r, 'handleheader');
}

function handleheader(response)
{
    var message = response.responseText;
    //var temp;
	headerdiv.innerHTML = message;
}

/* function for creating bradcrumb on header */
function call_breadcumb(string)
{
		var flashstr=string;
		var r = Math.random();
        var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("get_breadcumb.php?str="+flashstr+"&t2="+r, 'handle_breadcumb');
}

function handle_breadcumb(response)
{
    var message = response.responseText;
    var message2=message.split('second');
	 
	 if(message2[1]==1)
	 {
		 bredcumb1.innerHTML = message2[0];
		 bredcumb2.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	 }
	 else
	 {
	   bredcumb2.innerHTML = message2[0];
	  bredcumb1.innerHTML= message2[1];
	 }
}

function call_headerloc(string)
{
		//Change For The Location Massg
		id_str = string;
		//code commneted by satya on 18 dec 2009 due to map load issue on firefox
		/*_array = id_str.split("|");
		menu_str = "";
		map_str = "";
		
		for (var i = 0; i < _array.length; i++) {
			item_array = _array[i].split(",");
			
			if (item_array[1] != "")
			{ 	
			map_str = map_str + item_array[1] + ",";
			}
			
		}
		
		_array_find = map_str.split(",");
		
		if(_array_find.length < 5){
		 document.getElementById('state_msg').style.display='none';	
		 document.getElementById('main_msg').style.display='inline';	
		}
		
		else if(_array_find.length == 5)
		{ 
		
			for (var j = 0; j < _array_find.length-1; j++)
				{
				
				 if(_array_find[j]!='United States')
				 {
				 document.getElementById('state_msg').style.display='inline';
				 document.getElementById('main_msg').style.display='none';	
				 }
				 else{
						 document.getElementById('state_msg').style.display='none';
						 document.getElementById('main_msg').style.display='inline';	
						 break;
	
					 }
				 
				}
		}
		
		else if(_array_find.length == 6)
		{ 
			
			for (var j = 0; j < _array_find.length-1; j++) 
			{
			 if(_array_find[j]=='United States')
			 document.getElementById('state_msg').style.display='inline';
			 document.getElementById('main_msg').style.display='none';	
			}
		}
	//Closing For the Mssg Coding 	
		*/
		var flashstr=string;
		var r = Math.random();
        var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("get_header_location.php?str="+flashstr+"&t2="+r, 'handle_location');
}

function handle_location(response)
{
	
    var message = response.responseText;
    head1.innerHTML = message;
 
}
//function for showing wikipedia link
function call_headercontent(string)
{
		var flashstr=string;
		var r = Math.random();
        var httpClient = new HTTPClient();
//		alert("get_header_wikilink.php?str="+flashstr+"&t2="+r)
		httpClient.loadRemoteContent("header_content.php?str="+flashstr+"&t2="+r, 'handle_headercontent');
}

function handle_headercontent(response)
{
	
    var message = response.responseText;
    head2.innerHTML = message;
 
}
function call_mapheadtext(str)
{
	if(flashmapDiv.style.display=="none")
	{
		document.getElementById('world_txt').style.display='inline';
		document.getElementById('world_txt').innerHTML='<span class="zoom" style="padding-left: 80px;">Select</span><span class="anycity"> ANY city in the world </span>';		
	    document.getElementById('nonworld_txt').style.display='none';
		document.getElementById('counterImage').style.visibility='hidden';
		
	}
	else if(str!=='World')
	{
		document.getElementById('world_txt').style.display='none';
		document.getElementById('nonworld_txt').style.display='inline';
		document.getElementById('counterImage').style.visibility='visible';
	}
	else
	{
		
		document.getElementById('world_txt').style.display='inline';
		document.getElementById('nonworld_txt').style.display='none';
		document.getElementById('counterImage').style.visibility='visible';
	}
}

function call_countryflag(string)
{
	var flashstr=string;
	var r = Math.random();
    var httpClient = new HTTPClient();
	httpClient.loadRemoteContent("get_countryflag.php?str="+flashstr+"&t2="+r, 'handle_countryflag');
	
}
function handle_countryflag(response)
{
	
    var message = response.responseText;
    flagdiv.innerHTML = message;
 
}


//code added on 08-07-2008 
function updateFlashmapSession(flashmapValue)
{
	var r = Math.random();
    var httpClient = new HTTPClient();
	httpClient.loadRemoteContent("flashmap_session.php?flashmapValue="+flashmapValue+"&t2="+r, 'handle_flashmapSession');	
	
}

function handle_flashmapSession(response)
{
	 var message = response.responseText;
}

function createHeaderSession(continent,country,state,county)
{
		var r3 = Math.random();
     	var httpClient = new HTTPClient();
		httpClient.loadRemoteContent("header_session.php?continent="+continent+"&country="+ country +"&state="+ state +"&county="+ county +"&n="+r3, 'handleHeaderSession');
		
}

function handleHeaderSession(response)
{
	
    var message = response.responseText;
}

var selCountry='';
var selState='';
function hideMap()
{
	var str=document.getElementById('loc').value;
	var btnTurnOf=document.getElementById('btnTurnOffMap');
	
	var showMap=document.getElementById('showMap');
	//if map is already not shown then: Show Map
	if(showMap.value==0)
	{	
		showMap.value=1;
		updateFlashmapSession(showMap.value);
		document.location.href ='index.php';		
	}
	else
	{
		
		//change turnof button image to turnon 		
		btnTurnOf.value="Turn Map On";
		flashmapDiv.style.display="none"
		locationboxDiv.style.display="block";
		call_mapheadtext('');
		
		showMap.value=0;//TODO: update session value through AJAX 0
		updateFlashmapSession(showMap.value);
		
		var myarray=str.split("|");
		var strlength=myarray.length;		
		for(var i=0;i<strlength;i++)
		{
			 myarray[i]=(myarray[i].split(","))[1];				
		}
		
		if(strlength>1)
		{			
			var selCountinent=SelectDDL('continent',myarray[1]);
			if(selCountinent!='')
			call_zoomox_country(selCountinent);	
			if(strlength>2)
			{				
				setTimeout("SelectCountry('"+myarray[2]+"')",500);						
				if(strlength>3)	
				{
					setTimeout("SelectState('"+myarray[3]+"','"+myarray[2]+"')",1000);		
					
					if(strlength>4)	
					{
						setTimeout("SelectCounty('"+myarray[4]+"','"+myarray[3]+"','"+myarray[2]+"')",2000);		
					}
					
				}
					
			}
					
		}
		
	}	
}
 
 function SelectDDL(ddlId,value)
 {
	 var selectedValue='';
	 var ddl=document.getElementById(ddlId);	 
	 var ddllength=ddl.options.length;	 
	 for(var i=0;i<ddllength;i++)
	 {
		 if(ddl.options[i].text==value || ddl.options[i].value==value)
		 {
			selectedValue=ddl.options[i].value;
		 	 ddl.options[i].selected=true;
		 }
		 else
		 ddl.options[i].selected=false;
	 }
	 return selectedValue;
	 
 }
 
 function SelectCountry(country)
 {
	 selCountry=SelectDDL('country',country);
	 if(selCountry!='')
	 call_zoomox_state(selCountry);		
 }

function SelectState(state,country)
 {
	 selState=SelectDDL('state',state);
	 if(selState!='')
	 {
		 if(country=='United States')
		 call_zoomox_county(selState,selCountry);
		 else
		 call_zoomox_city('',selState,selCountry);
	 }
 }

function SelectCounty(county,state,country)
{
	selCounty=SelectDDL('county',county);
	if(selCounty!='')
	 {
		 call_zoomox_city(selCounty,selState,selCountry);
	 }
	
}

function SelectDDLText(ddlId,optionId)
 {
	 var selectedValue='';
	 var ddl=document.getElementById(ddlId);	 
	 var ddllength=ddl.options.length;	 
	 var ddltext
	 for(var i=0;i<ddllength;i++)
	 {
		 if(ddl.options[i].value==optionId )
		 {
			 ddltext=ddl.options[i].text;
			
		 }
		 
	 } 
	 return ddltext;
	 
 }


function updateHeader()
{
	
	if(document.getElementById('continent').value!=0&&document.getElementById('country').value==0)
	{
		
		var coninentId=document.getElementById('continent').value;
		var coninent=SelectDDLText('continent',coninentId);
		var loc="1,World|2,"+coninent;
		showMenu(loc);
		
	}
	else if(document.getElementById('country').value!=0&&document.getElementById('state').value==0)
	{
		
		var coninentId=document.getElementById('continent').value;
		var coninent=SelectDDLText('continent',coninentId);
		var countryId=document.getElementById('country').value;
		var country=SelectDDLText('country',countryId);
		var loc="1,World|2,"+coninent+"|3,"+country;
		showMenu(loc);
		
	}
	else if(document.getElementById('state').value!=0 && document.getElementById('county').value==0 && document.getElementById('citycombo').value==0)
	{
		
		var coninentId=document.getElementById('continent').value;
		var coninent=SelectDDLText('continent',coninentId);
		var countryId=document.getElementById('country').value;
		var country=SelectDDLText('country',countryId);
		var stateId=document.getElementById('state').value;
		var state=SelectDDLText('state',stateId);
		var loc="1,World|2,"+coninent+"|3,"+country+"|4,"+state;
		showMenu(loc);
		
	}
	else if(document.getElementById('county').value!=0 && document.getElementById('citycombo').value==0)
	{
		
		var coninentId=document.getElementById('continent').value;
		var coninent=SelectDDLText('continent',coninentId);
		var countryId=document.getElementById('country').value;
		var country=SelectDDLText('country',countryId);
		var stateId=document.getElementById('state').value;
		var state=SelectDDLText('state',stateId);
		var countyId=document.getElementById('county').value;
		var county=SelectDDLText('county',countyId);
		var loc="1,World|2,"+coninent+"|3,"+country+"|4,"+state+"|5,"+county;
		showMenu(loc);
	}
	else if(document.getElementById('citycombo').value!=0)
	{
		var coninentId=document.getElementById('continent').value;
		var coninent=SelectDDLText('continent',coninentId);
		var countryId=document.getElementById('country').value;
		var country=SelectDDLText('country',countryId);
		var stateId=document.getElementById('state').value;
		var state=SelectDDLText('state',stateId);
		var countyId=document.getElementById('county').value;
		var county=SelectDDLText('county',countyId);
		var countyId=document.getElementById('county').value;
		var county=SelectDDLText('county',countyId);
		createHeaderSession(coninent,country,state,county);
		var cityId=document.getElementById('citycombo').value;
		document.location.href ='citypage.php?cityid='+cityId;
			
	}	
	
	//ShowHideMapHeader('none');

}

function LoadMapData()
{
	var btnTurnOf=document.getElementById('btnTurnOffMap');
	var showMap=document.getElementById('showMap');
	//if map is already not shown then: Show Map
	if(showMap.value==1)
	{
		
		
		//change turnoff button image to turnon 		
		btnTurnOf.value = "Turn Map Off";
		flashmapDiv.style.display="block";
		locationboxDiv.style.display="none";		
	}
	else
	{		
		
		//change turnof button image to turnon 		
		btnTurnOf.value = "Turn Map On";
		flashmapDiv.style.display="none"
		locationboxDiv.style.display="block";	
	}
}


//function for right content

function call_rightcontent(string)
{
	var str=string.split(',');
	
	if(str.length!=2)
	{
		document.getElementById('googleaddDiv').style.display="inline";
		document.getElementById('soldcityDiv').style.display="none";
		
	}
	else
	{
		document.getElementById('googleaddDiv').style.display="none";
		document.getElementById('soldcityDiv').style.display="inline";
	}
}
	
// new function added on 26-08-08 for Time Module

function stateList(countryID)
{
	var r = Math.random();
    var httpClient = new HTTPClient();
	httpClient.loadRemoteContent("stateList.php?countryID="+countryID+"&t2="+r, 'handle_stateList');	
	
	
}
function handle_stateList(response)
{
	var message = response.responseText;
    Statediv1.innerHTML = message;
	
}
function cityList(stateID,countryID)
{
	var r = Math.random();
	var httpClient = new HTTPClient();
	httpClient.loadRemoteContent("citylist.php?countryID="+countryID+"&stateID="+stateID+"&t2="+r, 'handle_cityList');	
}
function handle_cityList(response)
{
	var message = response.responseText;
	CityDiv1.innerHTML = message;
	
}

function zoomoxTime()
{
	var cityID=document.getElementById('cityId').value;
	var r = Math.random();
	var httpClient = new HTTPClient();
	httpClient.loadRemoteContent("zoomoxtime.php?cityID="+cityID+"&t2="+r, 'handle_zoomoxTime');	
	
}

function handle_zoomoxTime(response)
{
	var message = response.responseText;
	timeDiv.innerHTML = message;
	
}



function check_maplevel(string)
{
		//Change For The Breadcrumb Menu
		
		id_str = string;
		_array = id_str.split("|");
		map_str = "";
		
		for (var i = 0; i < _array.length; i++) 
		{
			item_array = _array[i].split(",");
			
			if (item_array[1] != "")
			{ 	
			map_str = map_str + item_array[1] + ",";
			}
			
		}
		
		_array_find = map_str.split(",");
				
		if(_array_find.length == 6)
			return false;
		else
			return true;
		

}

