
function write_banner(slot_id)
{
    var rnd=Math.round(Math.random()*100000000);
    document.write("<scr"+"ipt language='javascript' src='");
    //document.write("http://misdaad.aktueel.nu/organic-admanager/slot_id=" + slot_id + "/rnd=" + rnd + "/display.js'></scr"+"ipt>");
    document.write("http://adserver.audaxmedia.nl/bannertool/banner/slot_id=" + slot_id + "/rnd=" + rnd + "/display.js'></scr"+"ipt>");
	//document.write("http://test.bannertool.audax.p.eyefi.nl/banner/slot_id=" + slot_id + "/rnd=" + rnd + "/display.js'></scr"+"ipt>");
//	document.write("http://test.bannertool.audax.p.eyefi.nl/banner/slot_id=" + slot_id + "/rnd=" + rnd + "/display.js");
}


function write_banner_iframe(slot_id,width,height)
{
    var rnd=Math.round(Math.random()*100000000);
    document.write("<if"+"rame width='"+width+"' height='"+height+"' frameborder='0' scrolling='no' src='");
    document.write("http://misdaad.aktueel.nu/organic-admanager/slot_id=" + slot_id + "/rnd=" + rnd + "/iframe.html'></if"+"rame>");
}

/* delayed displaying of banners make the page display faster */

var req = Array();

function do_write_banner_delayed(p) {
    
  
    // only if req shows "loaded" 
        
    
        if (req[p].readyState == 4) {
            // only if "OK"
            if (req[p].status == 200) {
                
                var res = req[p].responseXML;
                
                //alert(res.childNodes[0].nodeName);
                //var collection = res.getElementsByTagName('banner');
                //var output = collection[1].getAttribute('slot');
                
                
                
                for(i = 0; i < res.childNodes.length; i++) {
                    //if (ban.NodeName == 'banner') alert(':)');
                    if (res.childNodes[i].nodeName == 'banner') {
                        break; 
                    }
                }
                var o = document.getElementById(res.childNodes[i].getAttribute('elementid'));
                o.innerHTML = res.childNodes[i].childNodes[0].nodeValue;
                //req[i] = null;
            } 
        }
}

function write_banner_delayed(slot_id,obj)
{
    var rnd=Math.round(Math.random()*100000000);
    url = "http://misdaad.aktueel.nu/organic-admanager/o="+obj+"/slot_id=" + slot_id + "/rnd=" + rnd + "/ajaxdisplay.xml";
    //document.write(url);
    //alert(url);
    if (window.XMLHttpRequest) {
        req[slot_id] = new XMLHttpRequest();
        req[slot_id].onreadystatechange = function() { do_write_banner_delayed(slot_id);}
        req[slot_id].open("GET", url, true);
        req[slot_id].send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {        
        req[slot_id] = new ActiveXObject("Microsoft.XMLHTTP");
        if (req[slot_id]) {
            //req.onreadystatechange = do_write_banner_delayed(slot_id,obj);
            req[slot_id].onreadystatechange = function() { do_write_banner_delayed(slot_id);}
            req[slot_id].open("GET", url, true);
            req[slot_id].send();
        }
    } else {
        write_banner(slot_id);   
    }



    //setTimeout("do_write_banner_delayed('"+slot_id+ "','"+ obj+ "')",500);
}

/*
function do_write_banner_delayed(slot_id,obj)
{
    var rnd=Math.round(Math.random()*100000000);
    
    o = document.getElementById(obj);
    
    o.innerHTML = "test "+ slot_id; 
    //o.innerHTML = "<scr"+"ipt language='javascript' src='http://www.ejure.nl/bannertool/banner/slot_id=" + slot_id + "/rnd=" + rnd + "/display.js'></scr"+"ipt>";
}

*/
	

