/******************************************************
 ** AJAX JAVASCRIPT FUNCTION **************************
 ******************************************************
 ** Created By: Jepot *********************************
 ** Date Created: August 3, 2009 **********************
 ** Date Updated: None ********************************
 ******************************************************
	pageName = .aspx file to be executed
	objId = the control to show the output
	str = the GET variable to be pass on the .aspx file 
		these will have the "strAjax" GET Variable Name
	strGrid = (optional) the string to be added on the 
		.aspx output added on the buttom as outout
	NOTE:
  	* function needs the loding.gif image to be place 
		at "../images/loading.gif"    
 ******************************************************/

var xmlHttp
var obj
var strGridDisplay

function ajax(pageName, objId, str, strGrid){

    // MAKE "strGrid" OPTIONAL
    if (typeof strGrid == 'undefined' ) strGrid = '';

    var url=pageName;
    obj = objId;
    strGridDisplay = strGrid;
        
    document.getElementById(obj).innerHTML='<br /><br />';
    
    if (str.length==0) { 
  		document.getElementById(obj).innerHTML='Null AJAX variable!';
 		return;
 	}
	
	url=url+"?strAjax="+str;
	xmlHttp=GetXmlHttpObject(url);
    
    if (xmlHttp==null){
  		alert ('Browser does not support HTTP Request');
  		return '';
  	}
  	 
    try{
        xmlHttp.onreadystatechange=stateChanged();
    } catch(err) {
    }
} 

function stateChanged(){
    if(xmlHttp.readyState==4){
		var t1=setTimeout('document.getElementById(obj).innerHTML=xmlHttp.responseText + strGridDisplay;', 600);
    }
}

function GetXmlHttpObject(url){
	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");}
    }
    xmlHttp.open("GET",url,false);
    xmlHttp.send(null);
    return xmlHttp;
}