var loadHandlers = new Array(); // array of function that execute in the end of the page 

var bPageIsLoading = false;  // if page is load

var AjaxQuad = new Array(); //array of quads tabs that will be load in ajax (to load them in the end of page)



function onLoadAjax()

{

	bPageIsLoading = true;

	

	for(var nextInd=0; nextInd<AjaxQuad.length; nextInd++)

	{

		AjaxQuad[nextInd].LoadQuadHtmlAjax();

	}

}

			

function onLoadMethodHandlers()

{

	for(var handlerIndex=0; handlerIndex<loadHandlers.length; handlerIndex++ )

	{

		try

		{

			loadHandlers[handlerIndex]();

		}

		catch(e){}

	}

}



function addLoadEvent(func) 

{

    var oldonload = window.onload;

    if (typeof window.onload != 'function') 

        window.onload = func;

    else 

    {

        window.onload = function() 

            {

                if (oldonload) 

                    oldonload();

                func();

            }

    }

}

function addUnLoadEvent(func) 

{

    var oldonunload = window.onunload;

    if (typeof window.onunload != 'function') 

        window.onunload = func;

    else 

    {

        window.onunload = function() 

            {

                if (oldonunload) 

                    oldonunload();

                func();

            }

    }

}

function addResizeEvent(func) 

{

    var oldonresize = window.onresize;

    if (typeof window.onresize != 'function') 

        window.onresize = func;

    else 

    {

        window.onresize = function() 

            {

                if (oldonresize) 

                    oldonresize();

                func();

            }

    }

}

function purge(d) 

{    

    var a = d.attributes, i, l, n;    

    if (a) 

    {        

        l = a.length;        

        for (i = 0; i < l; i += 1) 

        {            

            n = a[i].name;            

            if (typeof d[n] === 'function') 

            {                

                d[n] = null;            

            }        

        }    

     }    

     a = d.childNodes;    

     if (a) 

     {        

        l = a.length;        

        for (i = 0; i < l; i += 1) 

        {            

            purge(d.childNodes[i]);        

        }    

     }

}

function purgeAll() 

{

    purge(document.body);

}

addUnLoadEvent(purgeAll);

function Browser() 

{

  var ua, s, i;

  this.isIE    = false;

  this.isNS    = false;

  this.version = null;

  ua = navigator.userAgent;



  s = "MSIE";

  if ((i = ua.indexOf(s)) >= 0) 

  {

    this.isIE = true;

    this.version = parseFloat(ua.substr(i + s.length));

    return;

  }

  s = "Netscape6/";

  if ((i = ua.indexOf(s)) >= 0) 

  {

    this.isNS = true;

    this.version = parseFloat(ua.substr(i + s.length));

    return;

  }

  s = "Gecko";

  if ((i = ua.indexOf(s)) >= 0) 

  {

    this.isNS = true;

    this.version = 6.1;

    return;

  }

}

var browser = new Browser();

var _MSXML_PROGIDS = new Array('Msxml2.XMLHTTP.6.0',

                               'Msxml2.XMLHTTP.4.0',                                

                               'Msxml2.XMLHTTP.3.0',                                

                               'Msxml2.XMLHTTP',                                

                               'Microsoft.XMLHTTP');  



function getXmlhttpObject() 

{

    var oXHR = null;

    if (typeof XMLHttpRequest != "undefined")

        oXHR = new XMLHttpRequest();

    else

    {

        for (var i=0; i < _MSXML_PROGIDS.length; i++)

        {

            try 

            {

                oXHR = new ActiveXObject(_MSXML_PROGIDS[i]);

                _MSXML_PROGIDS = [_MSXML_PROGIDS[i]];

                break;

            } 

            catch (e) 

            {

                oXHR = null;

            }

        }

     }

    return oXHR;

}



function BaseXmlHttp(destXml)

{

    this.oXHR = null;

    this.xmlurl = destXml;

    var self = this;

    this.callXml = function()

    {

        this.callXmlWithUrl(this.xmlurl,this.onCallAnswerd);

    }

    this.callXmlWithUrl = function(callURL,methodToCall)

    {

        this.oXHR = getXmlhttpObject();

        if( this.oXHR == null )

            return;

        try

        {

            this.oXHR.open("GET",callURL,true);

            this.oXHR.onreadystatechange = methodToCall;

            this.oXHR.send(null);

        }

        catch(e) {}

    }

    this.onCallAnswerd = function() {}

    this.cleanUp = function()

    {

        self.oXHR = null; 

    }

    addUnLoadEvent(this.cleanUp);

}

var loadedobjects="";

function loadobjs(file,cssTitle,relCss)

{

    if (!document.getElementById)

        return;

    

     var fileref="";

    ///Check to see if this object has not already been added to page before proceeding

    if (loadedobjects.indexOf(file)==-1)

    { 

        //If object is a js file

        if (file.indexOf(".js")!=-1)

        { 

            fileref=document.createElement('script')

            fileref.setAttribute("type","text/javascript");

            fileref.setAttribute("src", file);

        }

        ///If object is a css file

        else if (file.indexOf(".css")!=-1)

        { 

            fileref=document.createElement("link")

            fileref.setAttribute("rel", relCss);

            fileref.setAttribute("type", "text/css");

            fileref.setAttribute("href", file);

            if(cssTitle!=null)

				fileref.setAttribute("title", cssTitle);

        }

        

        if (fileref!="")

        {

			document.getElementsByTagName("head").item(0).appendChild(fileref);

			loadedobjects+=file+" "; 

			//Remember this object as being already added to page

        }

    }

}



function preloadImages(imageArray)

{

	if (document.images && imageArray)

	{

		preload_image_object = new Image();

		for (i=0; i<imageArray.length; i++)

			preload_image_object.src = imageArray[i];

	}

}





//this method set src for html element (explorer & fireFox)

function setSrcToElem(htmELm,strSrc)

{

	htmELm.src = strSrc;

}

//this method set Text for html element(explorer & fireFox)

function setTextToElem(htmELm,strText)

{

	if(browser.isIE)

	{

		htmELm.innerText = strText;

	} 

	else

	{

		htmELm.textContent = strText;

	}	

}


