function createRequestObject() {
	var newReq = null;

	if(window.XMLHttpRequest) {
		try { newReq = new XMLHttpRequest(); }
		catch(e) { newReq = false; }
        }
	else if(window.ActiveXObject) {
		try { newReq = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(e) { 
			try { newReq = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(e) { newReq = false; }
		}
	}
	
	return newReq;
}


/* The variable http will hold our new XMLHttpRequest object. */
var http = createRequestObject(); 
var http2 = createRequestObject(); 





function getcategory(form){
	/* Create the request. 
		The first argument to the open function is the method (POST/GET),
		The second argument is the url... 
	*/
	if (http) {
		var catid = document.cat.category.value;
		//alert(catid);
		http.abort();
		http.open('post','files/action.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleData_getcategory; 
		http.send('action=getcat&catid=' + catid);
		document.getElementById('match').innerHTML = "Please wait.. updating data";
	}
	else { alert("Your Browser does not support Advance features"); }
}


/* Function called to handle the data that was returned from the action.php file.. */
function handleData_getcategory(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
        var response = http.responseText;

		//alert (response);
		document.cat.filename.options.length = 0;							// clear select box
		var parse = response;
		var temp = new Array();
		temp = parse.split("::");
		document.forms['cat'].filename.options[0] = new Option('None','None');
		for (i=0,j=0;i<(temp.length)/2;i++,j=j+2) {
		if (temp[i] != "")
		document.forms['cat'].filename.options[i] = new Option(temp[j+1],temp[j]);
	     //document.getElementById('match').innerHTML = http.responseText;
		}
		
	}
}







