var xmlhttp;

function getSchool()
{
    var customerType = document.getElementById("customerType").options[document.getElementById("customerType").selectedIndex].value;

    
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null){
      alert ("Browser does not support HTTP Request");
      return;
    }
    var url="cs/teamtoursdk/newCustomerAjax.php";
    url=url+"?customerType="+customerType;
    url=url+"&sid="+Math.random();
    xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function stateChanged(){
    if (xmlhttp.readyState==1)
    {
        document.getElementById("ajaxloading").style.visibility = "visible";
    }
    if (xmlhttp.readyState==4)
    {
        xmlDoc=xmlhttp.responseXML;
        
        //Udskriv
        var skole = document.getElementById("skole");
        skole.options.length = 0;
    
        if(xmlDoc!=null){
            
            if(navigator.appName=="Microsoft Internet Explorer"){
                xmlLength = xmlDoc.getElementsByTagName("CustomerType")[0].childNodes.length/2;
            }
            else {xmlLength = xmlDoc.getElementsByTagName("CustomerType")[0].childElementCount/2};
            
            for(var j=0;j<xmlLength;j++){
                skole.options[skole.options.length] = new Option(xmlDoc.getElementsByTagName("Name")[j].childNodes[0].nodeValue, xmlDoc.getElementsByTagName("Id")[j].childNodes[0].nodeValue);
            }
        }
        document.getElementById("ajaxloading").style.visibility = "hidden";
    }
}
    
function GetXmlHttpObject(){
    if (window.XMLHttpRequest){
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject){
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
}

