var xmlHttp
var item;
function AjaxRequest(id,url){
	ajaxFunction(id,url,"<img src='FileManager/icons/loading.gif' />");
}
function AjaxRequest1(id,url,object){
	item = id;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return 0;
	}
	var date = new Date();
	var timestamp = date.getTime();
		xmlHttp.abort();
	var RequestURL=url + "&time=" + timestamp;
		xmlHttp.open("GET",RequestURL,true);
		xmlHttp.setRequestHeader("Content-Type", "charset=utf-8");
	  xmlHttp.onreadystatechange=function() {
				if(xmlHttp.readyState == 4|| xmlHttp.readyState=="complete") {
				  	  document.getElementById(item).innerHTML = xmlHttp.responseText;
				  
				}
				if(xmlHttp.readyState == 1|| xmlHttp.readyState=="complete") {
					
				  document.getElementById(item).innerHTML = object;
				  

				}

	  }

	xmlHttp.send(null);
}
function AjaxRequestPost(id,url,to,subject,message){
	item = id;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	}
	var date = new Date();
	var timestamp = date.getTime();
	var RequestURL=url + "&time=" + timestamp;
	xmlHttp.open("POST", RequestURL, true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 
	xmlHttp.setRequestHeader("Content-length", message.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState == 4|| xmlHttp.readyState=="complete") {
		  document.getElementById(item).innerHTML = xmlHttp.responseText;
		}
		if(xmlHttp.readyState == 1|| xmlHttp.readyState=="complete") {
			  document.getElementById(item).innerHTML = "<img src='FileManager/icons/loading.gif' />";
		}
	 }

	xmlHttp.send("to=" + to+"&subject="+subject+"&message="+message);
return true;
}
function AjaxRequestPost1(id,url,to,subject,message,object){
	item = id;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	}
	var date = new Date();
	var timestamp = date.getTime();
	var RequestURL=url + "&time=" + timestamp;
	xmlHttp.open("POST", RequestURL, true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); 
	xmlHttp.setRequestHeader("Content-length", message.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState == 4|| xmlHttp.readyState=="complete") {
		  document.getElementById(item).innerHTML = xmlHttp.responseText;
		}
		if(xmlHttp.readyState == 1|| xmlHttp.readyState=="complete") {
			  document.getElementById(item).innerHTML = "<img src='icons/loading.gif' />";
		}
	 }

	xmlHttp.send("to=" + to+"&subject="+subject+"&message="+message);
return true;
}
function ReturnAjaxRequest(url){

var ajaxRequest;  // The variable that makes Ajax possible! 
     
    try{ 
        // Opera 8.0+, Firefox, Safari 
        ajaxRequest = new XMLHttpRequest(); 
    } catch (e){ 
					// Internet Explorer Browsers 
					try{ 
						ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); 
					} catch (e) { 
						try{ 
							ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
						} catch (e){ 
							// Something went wrong (User Probably Doesn't have JS or JS is turned off) 
							alert("You Browser Doesn't support AJAX."); 
							return false; 
						} 
					}
	}
  
	var date = new Date();
	var timestamp = date.getTime();
	var RequestURL=url + "&time=" + timestamp;
	ajaxRequest.onreadystatechange=function() {
				if (ajaxRequest.readyState==4 || ajaxRequest.readyState=="complete"){
						return ajaxRequest.responseText;
				}
		  }

	ajaxRequest.open("GET",RequestURL,false);
	ajaxRequest.send(null);
return ajaxRequest.responseText;
}


function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
		// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function ajaxFunction(id,URL,ob){ 
    var ajaxRequest;  // The variable that makes Ajax possible! 
     
    try{ 
        // Opera 8.0+, Firefox, Safari 
        ajaxRequest = new XMLHttpRequest(); 
    } catch (e){ 
        // Internet Explorer Browsers 
        try{ 
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); 
        } catch (e) { 
            try{ 
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
            } catch (e){ 
                // Something went wrong (User Probably Doesn't have JS or JS is turned off) 
                alert("You Browser Doesn't support AJAX."); 
                return false; 
            } 
        } 
    } 
    // Create a function that will receive data sent from the server 
    ajaxRequest.onreadystatechange = function(){ 
        //This if satement will check if the status of the script 
        //If the readyState is not equal to 4 (The request is complete) 
        //It will display text that says loading... 
        if(ajaxRequest.readyState < 4){ 
            //AJAX in the prenthacies, is what id element in the body will be changed. 
            document.getElementById(id).innerHTML = ob; 
        } 
        //Once the readyState is equal to four, this means that the request was sent, 
        //and successfully processed. 
        if(ajaxRequest.readyState == 4){ 
            //This is where the output of the file we called and it will be placed 
            //in the div where we named the ID = AJAX 
            document.getElementById(id).innerHTML = ajaxRequest.responseText; 
        } 
    } 
    //This section processes the data 
    ajaxRequest.open("GET", URL, true); 
    ajaxRequest.send(null);     
} 
//--> 
function do_ajax_get(id,url,object,time,syn){
	try{
	item = id;
	xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){
			alert ("Browser does not support HTTP Request")
			return 0;
		}
		xmlHttp.abort();
	var RequestURL;
	if(time==true){
		var date = new Date();
		var timestamp = date.getTime();
		 RequestURL=url + "&time=" + timestamp;
	}else{
		RequestURL=url;
	}
		xmlHttp.open("GET",RequestURL,syn);
		xmlHttp.setRequestHeader("Content-Type", "charset=utf-8");
		 xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.responseText!=1)
		  	  document.getElementById(item).innerHTML = xmlHttp.responseText;
			else
			 document.getElementById(item).innerHTML = "";

		}else	if(xmlHttp.readyState == 1) {
		  document.getElementById(item).innerHTML = object;
		}
	 }
		
		xmlHttp.send(null);
	return xmlHttp.responseText;
	}catch(Err){}
}
