
function ajaxCreatHttpObject()
    {
    var objXMLHttp=null;
    
    try{
        objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP");        //later IE
    }catch (e){
        try {
            objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); //earlier IE
        }catch (e){ objXMLHttp = null; }
    }
    
    if (objXMLHttp==null) objXMLHttp=new XMLHttpRequest()        //IE7, Firefox, Safari
    
    return objXMLHttp
    }



// default request object
//var xmlhttp = null;

function ajaxFunction( uri, tgt, txt, xmlhttp )
        {
        // cancel outstanding request
        try{ if( xmlhttp ) xmlhttp.abort; xmlhttp=null; }catch(e){}
        
        // create new request object
        if( window.XMLHttpRequest )    xmlhttp = new XMLHttpRequest(); 
        else if (window.ActiveXObject) xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // code for IE5 and IE6
        
        // set temporary text..
        var obj = document.getElementById( tgt );
        if( obj ) obj.innerHTML = txt;
        
        // prepare and start the new request
        if( xmlhttp!=null ){
            xmlhttp.onreadystatechange = function(){ ajaxResponse(obj,txt,xmlhttp); };
            xmlhttp.open("GET",uri,true);                           // set url
          //xmlhttp.setRequestHeader("Content-Type", "text/xml");   // set header
            xmlhttp.send( null );                                   // send postdata...
        }
    }

function ajaxResponse( obj, txt, xmlhttp )
    {// readyState: 0=unknown, 1=setup, 2=sent, 3=inprogress, 4=complete 
    if( xmlhttp && xmlhttp.readyState == 4 && xmlhttp.status == 200 )
        {
        if(obj) obj.innerHTML = xmlhttp.responseText;
        try{
            ajaxHandler( txt, xmlhttp.responseText, xmlhttp.responseXML );
        }catch(e){}
        if( txt == "keepalive" && responseText!="" ) setTimeout( "ajaxKeepAlive()", 60000 );
        //if( responseText=="" ) history.go( history.current );   // ?
        //else setTimeout( "ajaxKeepAlive()", 60000 );
        }
    if( xmlhttp && xmlhttp.readyState == 4 ) xmlhttp = null;
    }


// ajax keepalive
var httpKeepAlive=null;
function ajaxKeepAlive()
    {
    var sessionId= "<?=$_SESSION['user_id'];?>";
    if( sessionId>0 && sessionId!="" ){
        ajaxFunction( 'lib/session_keepalive.php', 'mapuri', 'keepalive', httpKeepAlive );
        }
    }

