var http = createRequestObject();
var http2 = createRequestObject();
var http3 = createRequestObject();
var x;

function createRequestObject(){
    var xmlhttp;
    /*@cc_on

    @if (@_jscript_version >= 5)
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
        catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
        catch (E) {
            xmlhttp = false;
        }
    }

    @else
        xmlhttp = false;
        @end @*/

    if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
        try {
            xmlhttp = new XMLHttpRequest();
        }
        catch(e){
            xmlhttp = false;
        }
    }
    return xmlhttp;
}

function getInfo(url){
    dateid = new Date();
    nameid = dateid.getSeconds()+dateid.getMinutes()+dateid.getHours();
    
    http.open('get', url);
    http.onreadystatechange = handleInfo;
    http.send(null);
}

function getInfo2(url){
    dateid = new Date();
    nameid = dateid.getSeconds()+dateid.getMinutes()+dateid.getHours();

    http2.open('get', url);
    http2.onreadystatechange = handleInfo2;
    http2.send(null);
}

function getInfod3(url,id){
    x = id;
    dateid = new Date();
    nameid = dateid.getSeconds()+dateid.getMinutes()+dateid.getHours();
    
      var getstr = "&";
      if (document.getElementById("kind1"+x).checked) {
         getstr += "kind1=" + document.getElementById("kind1"+x).value + "&";
      }
      if (document.getElementById("kind2"+x).checked) {
         getstr += "kind2=" + document.getElementById("kind2"+x).value + "&";
      }
      if (document.getElementById("kind3"+x).checked) {
         getstr += "kind3=" + document.getElementById("kind3"+x).value + "&";
      }
      if (document.getElementById("kind4"+x).checked) {
         getstr += "kind4=" + document.getElementById("kind4"+x).value + "&";
      }

      getstr += "ma3alitext=" + document.getElementById("ma3alitext"+x).value;

      http3.open('GET', url + getstr, true);
      http3.onreadystatechange = handleInfod3;
      http3.send(null);

}

function handleInfo(){
    if(http.readyState == 1){
        document.getElementById('ma3alidiv').innerHTML = '<img src="ma3ali-ajax.gif" alt="انتظر" border=0><br>جاري جلب الإعلانات ...<br>إذا لم يتم عرض الإعلانات آلياً .. <a href="javascript:getInfo(\'banners.php\')">إضغط هنا</a>';
    }
    if(http.readyState == 4){
        var response = http.responseText;
        document.getElementById('ma3alidiv').innerHTML = response;
    }
}

function handleInfo2(){
    if(http2.readyState == 1){
        document.getElementById('ma3alidiv2').innerHTML = '<img src="ma3ali-ajax.gif" alt="انتظر" border=0><br>جاري جلب الإعلانات ...<br>إذا لم يتم عرض الإعلانات آلياً .. <a href="javascript:getInfo(\'banner.php\')">إضغط هنا</a>';
    }
    if(http2.readyState == 4){
        var response = http2.responseText;
        document.getElementById('ma3alidiv2').innerHTML = response;
    }
}

function handleInfod3(){
    if(http3.readyState == 1){
        document.getElementById('ma3alidiv3d'+x+'').innerHTML = '<img src="images/misc/progress.gif" alt="انتظر" width="17" height="17" border=0>&nbsp;';
    }
    if(http3.readyState == 4){
        var response = http3.responseText;
        document.getElementById('ma3alidiv3d'+x+'').innerHTML = response;
    }
}

function showInfo(url){
    tmpWindow = document.getElementById('ma3alidiv');
    newWindow = tmpWindow.cloneNode(true);
    Wi = newWindow.width

    if(!Wi){Wi = '400';}

    if(Wi == '200'){;}
    if(Wi == '400'){
        getInfo(url);
    }
}

