﻿
function Initialize()
{
    try{req=new ActiveXObject("MSXML2.XMLHTTP.5.0");}catch(e){     try{req=new ActiveXObject("MSXML2.XMLHTTP.4.0");}catch(oc){    try{req=new ActiveXObject("MSXML2.XMLHTTP.3.0");}catch(occ){     try{req=new ActiveXObject("MSXML2.XMLHTTP");}catch(oc4){    try{req=new ActiveXObject("MICROSOFT.XMLHTTP.1.0");}catch(oc5){    try{req=new ActiveXObject("MICROSOFT.XMLHTTP.1");}catch(oc6){     try{req=new ActiveXObject("Microsoft.XMLHTTP");}catch(oc){req=null;}    }   }    }     }      }     }

    if(!req&&typeof XMLHttpRequest!="undefined")
    {
        req= new
    XMLHttpRequest();
}
} 

var myprog="free" ;
var todiv;
var tem_nom;
function SendQuery(address,too,vari)
    {
    todiv=too;
	Initialize(); 
	if(req!=null)
    	{
    	
    			if (too!="") {document.getElementById(todiv).innerHTML=document.getElementById("prog").innerHTML};

 			req.onreadystatechange = Process;
        	if (vari=="" )
        	{
           		req.open("GET", address, true);
        	}
        	else
        	{
        		req.open("POST", address, true);
        	}
   
        	req.send(vari);

    	}
	}
	
	
	
function Process()
{ 

    if (req.readyState == 4)
    {
            if (req.status == 200)
            {

				if (todiv=="") 
					{
					
					}
				else
					{
					document.getElementById(todiv).innerHTML=req.responseText;
					
					}		
				if (myprog=="free"){}else{highportal_prog(myprog)}
            }
            else
            {
			     if (todiv=="") {alert("There was a problem retrieving data: "+req.statusText);} else {document.getElementById(todiv).innerHTML="There was a problem retrieving data:<br>"+req.statusText;}
            }
     }
}




var pre_temnom=new Array(500)
var pre_mypro=new Array(500)
var his=0;

function highportal_do(temnom,mypro)
{
if (temnom==undefined){}else {
//alert('tem:' + temnom);alert('pro:' + mypro);

his++;
pre_temnom[his]=temnom;
pre_mypro[his]=mypro;

	myprog=mypro;
	if (temnom==tem_nom){highportal_prog(mypro)}else {SendQuery( serverurl  + "template_" + temnom + ".html","tem","")}
tem_nom=temnom;
//alert('oldtem:' + tem_nom);
}
}


function highportal_prog(mypro)
{
if (document.getElementById('content') ){
if (String(mypro).substring(0,5)=="load:"){myprog="";SendQuery( serverurl + "files/" + String(mypro).substring(5,100) ,"content","");}

if (String(mypro).substring(0,7)=="search:"){myprog="";SendQuery( serverurl + "inc/search.aspx?sid=" + siteid + "&k=" + ( String(mypro).substring(7,500)) ,"content","");}


}}


