//In the name of Allah who is the lord of all the universe
// Result.js

var xobject=connectIt();

/*---------------------------------------------------------------------------------------------------------------------*/


function connectIt(){
	var xobject;
	try{
		xobject=new XMLHttpRequest();
		}
	catch(e){
		try{
			xobject=new ActiveXObject("Microsoft.XMLHTTP");
			}
		catch(e){
			try{
				xobject=new ActiveXObject("Msxml2.XMLHTTP");
				}
			catch(e){}
			}
		}
	if(!xobject){
		window.alert("May be your browser are unable to support AJAX or may be it is not suitable for AJAX that has been used in this site");
		}
	else{
		return xobject;
		}
	}
	

/*---------------------------------------------------------------------------------------------------------------------*/

targetId=0;
caller=0;
function loadSubCat(parent, id){
		pid=parent.value;
		var categories=document.getElementsByTagName("div");
		var remove=false;
		for(i=0;i<categories.length;i++){
			if(categories[i].id.substr(0, 11)!="categories_")continue;

			if(remove)categories[i].innerHTML="";
			if(categories[i].id=="categories_"+id)remove=true;
			
			}
			if(xobject){			
				try{ 
					xobject.open("POST","ajaxsubcat.php?pid="+pid,true);
					xobject.onreadystatechange=displayResult;
					xobject.send(null);
					}
				catch(e){
						window.alert("Can't connect to server:\n"+e.toString());
					}
				}	
	}
	

/*--------------------------------------------------------------------------------------*/


	
	function displayResult(){
		if(xobject.readyState==4){
			if(xobject.status==200){
				try{
					response=xobject.responseText;
					if(response==""){
						return ;
						}
					document.getElementById("cat-selection").innerHTML+=(response);
					}
				catch(e){
						window.alert("Problem facing in retrieving data from server "+xobject.statusText+e.toString());
					}
				}	
			}
		}
/*-------------------------------------------------------------------------------*/


