function init_onup() {

   var ajaxRequest;  // The variable that makes Ajax possible!
	var filename;	
	try {
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} 
	
	catch (e) {
		// Internet Explorer Browsers
		try {
		
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		
		catch (e)  {
		
			try {
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			
			catch (e) {
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	return ajaxRequest;
}

function changetab(id) {
	
	var filename;
	var ajaxRequest;
	ajaxRequest=init_onup();
	resTextFlag = 0;
	
	
	ajaxRequest.onreadystatechange = function(){
	
		if(ajaxRequest.readyState == 4) {
	
				resText=ajaxRequest.responseText;
				
				for(i=1;i<=3;i++) {	
					tab = "tab"+i;
					if(i==id) {						
						document.getElementById(tab).className= "tabselected";						
					}else{
						document.getElementById(tab).className= "";
						}					
				}
				
			//	alert(resText);
				document.getElementById("td_content").innerHTML=resText;
				
	} else {
			
			document.getElementById("td_content").innerHTML = "<img src=/images/loading.gif>";
			
		}
			
		
	} //call back function
		switch(id) {
		case '1':
			filename = "inc_wallpaper.php";
		break;
		case '2':
			filename = "inc_games.php";
		break;
		
		case '3':
			filename = "inc_mehndi.php";
		break;
		case '4':
			filename = "inc_screensaver.php";
		break;
		
				
	} //switch		
		
		rand = Math.random();		
		ajaxRequest.open("GET", "/includes/"+filename+"?rand="+rand, true);
		ajaxRequest.send(null);

}


function UpdateWeather() {
	
	
	var filename;
	var ajaxRequest;
	ajaxRequest=init_onup();
	resTextFlag = 0;
	
	ajaxRequest.onreadystatechange = function(){
	
		if(ajaxRequest.readyState == 4) {
	
			resText=ajaxRequest.responseText;
			//alert(resText);
			document.getElementById("td_weather").innerHTML=resText;
		} 
			
		
	} //call back function
		
		city_index = document.getElementById("current_city").selectedIndex;
		city = document.getElementById("current_city").options[city_index].value;
		//alert(city);
		rand = Math.random();		
		ajaxRequest.open("GET", "/weather/inc_current_weather.php?weather_city="+city+"&rand="+rand, true);
		ajaxRequest.send(null);

}


function ShowSubCat(id) {
	
	var filename;
	var ajaxRequest;
	ajaxRequest=init_onup();
	resTextFlag = 0;
	
	
	ajaxRequest.onreadystatechange = function(){
	
		if(ajaxRequest.readyState == 4) {
	
				resText=ajaxRequest.responseText;
												
			//	alert(resText);
				
				document.getElementById("showsubcat_content").innerHTML=resText;
				
	} else {
			
			document.getElementById("showsubcat_content").innerHTML = "<img src=/images/loading.gif>";
			
		}
			
		
	} //call back function
		
		filename = "inc_subcat.php?parentcat="+id;
		
		rand = Math.random();		
	//	alert('looking');
		ajaxRequest.open("GET", "/classified/includes/"+filename+"?rand="+rand, true);
		ajaxRequest.send(null);

}

