
var http,http2,http3;

function createRequestObject() {
	var ro;
	if (window.XMLHttpRequest){
		try {
			ro = new XMLHttpRequest();
		} catch(e) {
			alert("An error has occured");
			ro = false;
		}
	} else if(window.ActiveXObject){
		try{
			ro = new ActiveXObject("Msxml2.HTMLHTTP");
		} catch(e) {
			try{
				ro=new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				alert("An error has occured");
				ro = false;
			}
		}
	}
	return ro;
}

function getXML_Cats(catID) {


	http = createRequestObject();

	if (http==null) {
		alert("Your Browser does not support AJAX.");
	} else {


	var scriptLocation=document.getElementById("webRoot").innerHTML;
	var getCatURI = scriptLocation+"/XML_subCats.php?" + "catID=" + catID;
	var getCatURI = "XML_subCats.php?" + "catID=" + catID;

	try {
		http.open('get', noCache(getCatURI) , true);

		http.onreadystatechange = function() {
			handleResponse(catID);
		};
		http.send(null);
	} catch(e) {
	}

	}
	

}

function getXML_Cats2(catID) {


	http = createRequestObject();

	if (http==null) {
		alert("Your Browser does not support AJAX.");
	} else {


	var scriptLocation=document.getElementById("webRoot").innerHTML;
	var getCatURI = scriptLocation+"/XML_subCats.php?" + "catID=" + catID;
	var getCatURI = "XML_subCats.php?" + "catID=" + catID;

	try {
		http.open('get', noCache(getCatURI) , true);

		http.onreadystatechange = function() {
			handleResponse(catID);
		};
		http.send(null);
	} catch(e) {
	}

	}
	

}

function getXML_Packages(catID) {


	http3 = createRequestObject();

	if (http3==null) {
		alert("Your Browser does not support AJAX.");
	} else {


		var scriptLocation=document.getElementById("webRoot").innerHTML;

//		var getCatURI = scriptLocation+"/XML_Packages.php?" + "catID=" + catID;
		var getCatURI = "XML_Packages.php?" + "catID=" + catID;



		try {
			http3.open('get', noCache(getCatURI) , true);

			http3.onreadystatechange = function() {
				handleResponse_Packages();
			};
			http3.send(null);
		} catch(e) {
		}
	}


}

function getExample(catID) {


	http2 = createRequestObject();

	if (http2==null) {
		alert("Your Browser does not support AJAX.");
	} else {


	var scriptLocation=document.getElementById("webRoot").innerHTML;
//	var getExampleURI = scriptLocation+"/exampleItem.php?" + "catID=" + catID;
	var getExampleURI = "exampleItem.php?" + "catID=" + catID;

	http2.open('get', noCache(getExampleURI) , true);

	http2.onreadystatechange = function() {
		if(http2.readyState == 4) {
			var response = http2.responseText;
			setExampleText(response);
		}
	};
	http2.send(null);

	}

}


function handleResponse(catID) {

	if(http.readyState == 4) {

		var response = http.responseXML;
		XML_Cats=response.documentElement;
		setXML_Cats(XML_Cats);

		body=_fillList(catID,0);
		fillInnerHTML(catID,body,0,"cats");
	}
}

function handleResponse_Packages() {

	if(http3.readyState == 4) {

		var response = http3.responseXML;
		XML_Packages=response.documentElement;
		setXML_Packages(XML_Packages);

		body=packagesOutput();

		fillInnerHTML(0,body,0,"packages");
	}
}

