/**
 * @author marcus
 */


function hentAjax()
{
        var xmlHttp;
        try
        {
                // Firefox, Opera 8.0+, Safari
                xmlHttp=new window.XMLHttpRequest();
        }
        catch (e)
        {
                // Internet Explorer
                try
                {
                        xmlHttp=new window.ActiveXObject("Msxml2.XMLHTTP");
                }
                catch (e)
                {
                        try
                        {
                                xmlHttp=new window.ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch (e)
                        {
                                alert("Der er noget der ikke virker");
                                return false;
                        }
                }
        }
        return xmlHttp;
}

function doAjax(adrmedpara,divId){

        var visprofil = hentAjax();
        if(divId=="rightvareliste" || divId=="noout" || divId=="inexpoutput" || divId=="output"){document.getElementById("waitwindow").style.visibility="visible";}

        visprofil.onreadystatechange = function ()
        {
                if(visprofil.readyState ==4){
                        if(divId !="noout"){
                                document.getElementById(divId).innerHTML = visprofil.responseText;
                                //	if(behave==1){divId = kontaktwindow;divId.document.write(divId);}
                        }
                        if(divId=="rightvareliste" || divId=="noout" || divId=="inexpoutput" || divId=="output"){document.getElementById("waitwindow").style.visibility="hidden";}
                        //ponr = adrmedpara.ponr;
                        //	document.write(visprofil.responseText); // <- Heiberg's egen
                }
                if(visprofil.readyState ==3){document.getElementById("waittext").innerHTML ='Behandler';}
                if(visprofil.readyState ==2){document.getElementById("waittext").innerHTML ='Hentet';}
                if(visprofil.readyState ==1){document.getElementById("waittext").innerHTML ='Behandler';}
                if(visprofil.readyState ==0){}
        }
        visprofil.open("GET",adrmedpara,true);

        visprofil.send(null);
}

function doAjaxvalue(adrmedpara,divId){

        var visprofil = hentAjax();

        visprofil.onreadystatechange = function ()
        {
                if(visprofil.readyState ==4){

                        document.getElementById(divId).value = visprofil.responseText;

                }
                if(visprofil.readyState ==3){}
                if(visprofil.readyState ==2){}
                if(visprofil.readyState ==1){}
                if(visprofil.readyState ==0){}
        }
        visprofil.open("GET",adrmedpara,true);

        visprofil.send(null);
}
function search(morf){
       alert('i was called!!!!');
        document.getElementById('displayInfo').style.display  = 'block';
       doAjax(''+morf.rel+'','displayInfo');
        return false;
}


