﻿function MarkMenu(MenuNum) 
{
	var i=1
	while(document.getElementById("Menu"+String(i))!=null)
		{
		if(i==MenuNum)
			document.getElementById("Menu"+String(i)).className='Menu_Active';
		else 
			document.getElementById("Menu"+String(i)).className='Menu';
		i++
		}
}
function LoadBestBackground(ImageUrl,ControlId)
{
    var myXMLHttpRequest;

    // Lets try using ActiveX to instantiate the XMLHttpRequest object
    try{myXMLHttpRequest= new ActiveXObject("Microsoft.XMLHTTP");}
    catch(ex1)
    {
        try{myXMLHttpRequest= new ActiveXObject("Msxml2.XMLHTTP");}
        catch(ex2){myXMLHttpRequest= null;}
    }

    // If the previous didn't work, lets check if the browser natively support XMLHttpRequest 
    if(!myXMLHttpRequest&& typeof XMLHttpRequest != "undefined")
    {
        //The browser does, so lets instantiate the object
        myXMLHttpRequest= new XMLHttpRequest();
    }
    
    if(myXMLHttpRequest)
    {
        //Tell the XMLHttpRequest object what we want it to do.
        //In the first parameter we're telling it to use HTTP GET for the request
        //In the second parameter we're telling it what page to request
        //In the third parameter we're telling it to do the request asychronously
        myXMLHttpRequest.open("GET", ImageUrl, true);
        
        //Lets define the method that gets called when the request finishes
	    myXMLHttpRequest.onreadystatechange = function (aEvt) {
	        //Any time the readyState of the XMLHttpRequest object changes this method is called.
	        //Loading is complete when the readyState equals 4, so that's the only value we care about right now.
    		if(myXMLHttpRequest.readyState == 4){
    		    //Sweet! The page loaded. Now lets set the contents of the request to the TextArea
				//Image should be loaded in the cache, so, now we can assign to the background and will be loades
				//immediatelly...
				document.getElementById(ControlId).style.backgroundImage="url('"+ImageUrl+"')";
				}
	    };
	    
	    //Lets fire off the request
        myXMLHttpRequest.send(null);
    }
    else
    {
        //Oh no, the XMLHttpRequest object couldn't be instantiated.
        //document.getElementById(ControlId).innerHTML='Error';
    }
}


