/*
	Purpose: Fetch contents dynamically using HTTP protocol
	Author: Shahriar Kabir (SKJoy2001@Yahoo.Com)
	Date : Monday, November 20, 2006

	Funtion list:

	    HTTPGet(HTTPURL, UseOwnDomain)
*/

function HTTPGet(HTTPURL, UseOwnDomain){
	/*
	    Implementation of AJAX to fetch the output of a given URL for HTPP GET method.

	    HTTPURL (string) = URL to navigate to for HTTP output in GET method
	    UseOwnDomain (boolean) = Will prepend current domain name part before the given url and the output will be "http://" + www.domainname.com + "/" + URL
	*/

	var pageRequest = false; //variable to hold ajax object
	/*@cc_on
	   @if (@_jscript_version >= 5)
	      try {
	      pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
	      }
	      catch (e){
	         try {
	         pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
	         }
	         catch (e2){
	         pageRequest = false
	         }
	      }
	   @end
	@*/

	if(!pageRequest && typeof XMLHttpRequest != 'undefined')pageRequest = new XMLHttpRequest();

	if(pageRequest){ //if pageRequest is not false
	    if(UseOwnDomain)HTTPURL='http://'+window.location.hostname+'/'+HTTPURL;
		pageRequest.open('GET', HTTPURL, false); //get page synchronously
		pageRequest.send(null);
		//if viewing page offline or the document was successfully retrieved online (status code=2000)
		if(window.location.href.indexOf("http")==-1 || pageRequest.status==200)return pageRequest.responseText;
	}
}


function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{
			try{
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}

		return xmlhttp;
	}



	function getCategory(strURL) {
		var req = getXMLHTTP();
		if (req) {
			req.onreadystatechange = function() {
                if(req.readyState != 4){
                	var BusyIcon="<img src='./upload/icon_animated_busy2_2.gif'>";
					document.getElementById('citydiv').innerHTML = BusyIcon ;
				}else if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						//alert(req.responseText);
						document.getElementById('citydiv').innerHTML=req.responseText;
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}
	}


	function getSecoundCategory(strURL) {
		var req = getXMLHTTP();
		if (req) {
			req.onreadystatechange = function() {
                if(req.readyState != 4){
                	var BusyIcon="<img src='./upload/icon_animated_busy2_2.gif'>";
					document.getElementById('citydiv2').innerHTML = BusyIcon ;
				}else if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						//alert(req.responseText);
						document.getElementById('citydiv2').innerHTML=req.responseText;
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}
	}

	function getCategorytype(strURL) {

		var req = getXMLHTTP();

		if (req) {

			req.onreadystatechange = function() {
				 if(req.readyState != 4)
				{
					document.getElementById('categorydiv').innerHTML = '<select disabled><option>Please Wait...</option></select>' ;
				}
				else if (req.readyState == 4) {

					// only if "OK"
					if (req.status == 200) {
//					alert(document.getElementById('citydiv').innerHTML);
	getCity('./script/findcategory.php?categorytype=""');
						document.getElementById('categorydiv').innerHTML=req.responseText;
					
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
				
				
				
			}
			req.open("GET", strURL, true);
			req.send(null);
		}

	}
	function getart(strURL) {

		var req = getXMLHTTP();

		if (req) {

			req.onreadystatechange = function() {
				 if(req.readyState != 4)
				{
					document.getElementById('all').innerHTML = 'Please wait, loading... ' ;
				}
				else if (req.readyState == 4) {

					// only if "OK"
					if (req.status == 200) {
					//alert(document.getElementById('all').innerHTML);
						document.getElementById('all').innerHTML=req.responseText;
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}

	}
