//global variables used to store object;
var req;
var setobj;
var falgchk=0;

//Create xmlhttp object.
function createXMLHttpRequest() {    
	var ua;
	
	if(window.XMLHttpRequest) {    
		try {     
			ua = new XMLHttpRequest();    
		} catch(e) {     
			ua = false;    
		}    
	} else if(window.ActiveXObject) {     
		try {       
			ua = new ActiveXObject("Microsoft.XMLHTTP");     
		} catch(e) {       
			ua = false;     
		}    
	}   return ua;   
}     

//Request file to get output.
function sendRequest(file) { 
	var str = "";  
	req.open('GET', file);    
	req.onreadystatechange = handleResponse;    
	req.send(null);   
	return false;  
}   

// REQUEST FILE WITH METHOD POST
function sendRequest_POST(file,params) {  
	var str = "";    

	req.open('POST', file, true);    

	//Send the proper header information along with the request
	req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	req.setRequestHeader("Content-length", params.length);
	req.setRequestHeader("Connection", "close");

	req.onreadystatechange = handleResponse;    
	req.send(params);   
	return false;  
}


//Get response for div poppulation.
function handleResponse() {   
	if(req.readyState == 4){    
		var response = req.responseText;
		//document.getElementById('getSubCat').innerHTML = response;

		if(setobj.nodeName.toLowerCase() == "select")
		{	

			var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
			while(setobj.options.length)
			{
				setobj.remove(0);
			}		

			$option = req.responseXML.getElementsByTagName("option");
			for($count = 0;$count < $option.length;$count++)
			{

	            newElem = document.createElement("option");
	            newElem.value = $option[$count].value;
	            newElem.text = $option[$count].childNodes[0].nodeValue;
	            setobj.add(newElem, where);

			} // end of the for loop

			
		}
		else
		{
			setobj.innerHTML = response;
		}
	}  
}

//function to show a div.
function showdiv(divobj)
{
	//if(window.parent.sel_search != "undefined")
	//	window.parent.sel_search.style.visibility = "hidden";
	
	divobj.style.visibility="visible";
}

//function to hide a div.
function hidediv(divobj)
{
	//if(window.parent.sel_search != "undefined")
	//	window.parent.sel_search.style.visibility = "visible";

	divobj.style.visibility="hidden";
	
}
function displayLoading(element) {
  while (element.hasChildNodes()) {
    element.removeChild(element.lastChild);
  }
  var image = document.createElement("img");
  image.setAttribute("src","images/loading.gif");
  image.setAttribute("alt","Loading Loading...");
  element.appendChild(image);
}