// Synchronous version of Ajax with timeout Updated 4/12/2010
//
var Async_action_status=false;

function showItems(pageId,action){ 
    var url="http://www.construction-estimating.com/ajax-test/ajax-tracker.php";
    var str="pageId=" + pageId + "&action=" + action;
    var xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
        alert("Browser does not support HTTP Request");
    else{
            xmlHttp.onreadystatechange=function(){
                                                    if(xmlHttp.readyState==4){
                                                        Async_action_status=true;
                                                    }
                                                 }
            Async_action_status=false;
            if (((action==2) && (navigator.userAgent.toLowerCase().indexOf('safari') > -1) && (navigator.userAgent.toLowerCase().indexOf('chrome')==-1))){
                xmlHttp.open("GET",url + "?" + str,false);
                xmlHttp.send(null);
            }
            else{
                xmlHttp.open("GET",url + "?" + str,true);
                xmlHttp.send(null);
                Ajax_Async_Sleep(2);            
            }
    }
}
function Ajax_Async_Sleep(time){
    var now=Date.parse(new Date());
    do{
        var current=Date.parse(new Date());
        if (Async_action_status)
            break;
    }while (((current - now)/1000) < time);
}


function GetXmlHttpObject(){ 
    var objXMLHttp=null;
    if (window.XMLHttpRequest)
        objXMLHttp=new XMLHttpRequest();
    else if (window.ActiveXObject)
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
    return objXMLHttp;
}


