
function getXmlHttp(){
    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 Headers(xmlhttp,parms)
{
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", parms.length);
    xmlhttp.setRequestHeader("Connection", "close");
}
function Load(id,win,params)
{
    document.getElementById(win+"h").innerHTML="Wait. Loading the title...";
    document.getElementById(win+"c").innerHTML="Wait. Loading the content...";
    document.getElementById(win+"p").innerHTML="Loading...";
    var xmlhttp1 = getXmlHttp();//get the content
    var xmlhttp2 = getXmlHttp();//get the title
    id = encodeURIComponent(id);
    var params1="id="+id+"&"+params+"&random="+Math.random();
    var params2="id="+id+"&random="+Math.random();
    xmlhttp1.open('POST', './driver/load.php', true);
    xmlhttp2.open('POST', './driver/title.php', true);
    Headers(xmlhttp1,params1);
    Headers(xmlhttp2,params2);
    xmlhttp1.onreadystatechange = function() {
        if (xmlhttp1.readyState == 4) {
            if(xmlhttp1.status == 200) {
                //content into window
                document.getElementById(win+"c").innerHTML=xmlhttp1.responseText;
                if(win=='cwin'){
                    document.getElementById(win+"c").innerHTML=document.getElementById(win+"c").innerHTML.concat("<div class=\"print\"><img src=\"./imge/print.gif\" alt=\"\" /><a class=\"print1\" href=\"print.php?id="+id+"&"+params+"\" target=\"_blank\">Версия для печати</a></div>");
                    location.hash = id;
                    globalid = id;
                }
                activatemenu();
            }
        }
    };
    xmlhttp2.onreadystatechange = function() {
        if (xmlhttp2.readyState == 4) {
            if(xmlhttp2.status == 200) {
                var titl=xmlhttp2.responseText;
                //some chars from title to title
                document.getElementById(win+"h").innerHTML=titl;
                if(win=='cwin')document.title = titl + ".";
                //some chars from title to panel
                if(titl.length>12)titl=titl.slice(0,12)+'...';
                document.getElementById(win+"p").innerHTML=titl;
                
            }
        }
    };
    xmlhttp2.send(params2);
    xmlhttp1.send(params1);
  
    return false;
}
