/*****************************************************************************
** -------------------- Program Name    : eCom Multi System © . --------------
** -------------------- Program Version :  v.3.5.3 ---------------------------
** -------------------- Program Author  : Athco Pros Team . ------------------
** -------------------- Graphics        : Athco Graphics . -------------------
** -------------------- Web Site        : www.Athco.com.sa -------------------
** -------------------- E-Mail          : Sales@Athco.com.sa -----------------
** -------------------- Last Modified   : 01.03.2009 -------------------------
** -------------------- Distribution    : Via  Web Site ----------------------
** -------------------- (C) Copyright 2005 Athco Co. -------------------------
*****************************************************************************/

    var BustCacheVar       = 1 ; //bust potential caching of external pages after initial request? (1=yes, 0=no)
    var LoadedObjects      = "";
    var BustCacheParameter = "";
    var ImgLoader          = "images/AjaxLoader.gif";
    var strImgLoader       = "<CENTER><IMG SRC="+ ImgLoader +"></CENTER>";
    var strMsgLoader       = "<CENTER> Ø¬Ø§Ø±ÙŠ Ø§Ù„ØªØ­Ù…ÙŠÙ„ </CENTER>";
    var strNoneLoader      = "";
    var strLoader = strImgLoader + strMsgLoader;

/***----------------------------------------------------------------------***/
 
//** Don't Change Any Thing **/
function GetXmlHttpObject(){
    var xmlHttp = null;
    try{
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e){
        // Internet Explorer
        try{
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e){
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

//****************************************************************************/
//*** LOAD HANDLER ***********************************************************/
//** Don't Change Any Thing **/
function LOAD_HANDLER(TheHttp, ContainerId,strLoader){
    if(TheHttp.readyState == 1 || TheHttp.readyState == 2 || TheHttp.readyState == 3){
    document.getElementById(ContainerId).innerHTML = strLoader;
    }
    if(TheHttp.readyState == 4){
       if(TheHttp.status == 200 ){
         var Response = TheHttp.responseText;
         document.getElementById(ContainerId).innerHTML = Response;
         } else {
         throw new Error("Could not connect to page")
         }
    }
} //END HANDLER

//****************************************************************************/
//*** INCLUDE URL ************************************************************/
function INCLUDE_URL(URL, ContainerId){

    var TheHttp = GetXmlHttpObject();
    TheHttp.onreadystatechange = function(){
    LOAD_HANDLER(TheHttp, ContainerId,strLoader)
    }
    if (BustCacheVar) //if bust caching of external page
    BustCacheParameter = (URL.indexOf("?")!=-1)? "&" + new Date().getTime() : "?" + new Date().getTime()
    TheHttp.open('GET', URL + BustCacheParameter, true)
    TheHttp.send(null)
} //END INCLUDE_URL

//****************************************************************************/
//*** LOAD_OBJS **************************************************************/
function LOAD_OBJS(){
    if (!document.getElementById)
    return
    for (i=0; i<arguments.length; i++){

        var File    = arguments[i]
        var FileRef = ""

    if (LoadedObjects.indexOf(File)==-1){ //Check to see if this object has not already been added to page before proceeding
    if (File.indexOf(".js")!=-1){ //If object is a js file
    FileRef=document.createElement('script')
    FileRef.setAttribute("type","text/javascript");
    FileRef.setAttribute("src", File);
    }
    else if (File.indexOf(".css")!=-1){ //If object is a css file
    FileRef=document.createElement("link")
    FileRef.setAttribute("rel", "stylesheet");
    FileRef.setAttribute("type", "text/css");
    FileRef.setAttribute("href", File);
    }
    }
    if (FileRef=""){
    document.getElementsByTagName("head").item(0).appendChild(FileRef)
    LoadedObjects+=File+" " //Remember this object as being already added to page
    }
    }
} //END LOAD_OBJS

//*** GET BLOCK **************************************************************/
//** Don't Change Any Thing **/
function GET_BLOCK(ID, ContainerId){

    var TheHttp = GetXmlHttpObject();
    var Url = "eComAjaxContent.php?dp=Blocks&" ;
        Url = Url + "ID=" + ID ;

    TheHttp.onreadystatechange=function(){
    LOAD_HANDLER(TheHttp, ContainerId,strLoader);
    }
    if (BustCacheVar) //if bust caching of external page
    BustCacheParameter =(ID.indexOf("?")!=-1)? "&" + new Date().getTime() : "?" + new Date().getTime();
    TheHttp.open('GET', Url + BustCacheParameter, true);
    TheHttp.send(null);
} //END GET BLOCK

//*** Get Result Poll **************************************************************/
//** Don't Change Any Thing **/
function GetPoll(Pollid,Optionid, ContainerId){

    var TheHttp = GetXmlHttpObject();
    var Url = "eComAjaxContent.php?dp=DoVotingAjax&" ;
        Url = Url + "Pollid=" + Pollid ;
        Url = Url + "&Optionid=" + Optionid ;
        Url = Url +"&aT=" + Math.random();

    TheHttp.onreadystatechange=function(){
    LOAD_HANDLER(TheHttp, ContainerId,strImgLoader);
    }

    TheHttp.open('GET', Url , true);
    TheHttp.send(null);
} //END Get Result Poll

//*** Get Result Newsletter **************************************************************/
//** Don't Change Any Thing **/  ACTION
function GetNewsletter(Action,ContainerId){

    var TheHttp = GetXmlHttpObject();
    var Url = "eComAjaxContent.php?dp=" ;
        Url = Url + Action ;
        Url = Url + '&Email=' + aTNewsletterForm.Email.value

    TheHttp.onreadystatechange=function(){
    LOAD_HANDLER(TheHttp, ContainerId,strImgLoader);
    }

    TheHttp.open('GET', Url , true);
    TheHttp.send(null);
} //END Get Result Newsletter


