    //Variables used for fixing Transparent PNG files in IE.
    var strRootPath = '/';
    
    //The master load function.
    window.onload=function() {                		
		//Does buttons with prefetch in all browsers
		SetupButtons();
		
		//Fix times
		FixTimes();						
    }
    
    function FixTimes() {
        var spanElements = document.getElementsByTagName('span');
        
        for(var i = 0; i < spanElements.length; i++) {
            var e = spanElements[i];
            if (e.title && e.title == "time") {
                e.innerText = new Date('Jan 01, 1900 ' + e.innerText + ' UTC').toLocaleTimeString();
            }            
        }    
    }
          
    function SetupButtons() {
        var ImgElements = document.getElementsByTagName('img');
        var BtnElements = document.getElementsByTagName('input');
        
        for(var i = 0; i < ImgElements.length; i++) {
            AssignButtonProperties(ImgElements[i]);
        }    
        
        for(var i = 0; i < BtnElements.length; i++) {
            if (BtnElements[i].getAttribute("type") == "image") {
                AssignButtonProperties(BtnElements[i]);    
            }
        }     
    }
       
    function AssignButtonProperties(Element) {
        if (Element.getAttribute("srcdown") || Element.getAttribute("srcover")) {
            //We have a winner
            //Pre-load the images and set the mouse events.
            
            Element.onmouseup = ButtonUp;
            Element.onmouseout = ButtonOut;
            Element.onmouseover = ButtonOver;

            if (Element.getAttribute("srcdown")) {
                Element.onmousedown = ButtonDown;
                var img = new Image();
                img.src = GetRootPath(Element.getAttribute("srcdown"));
            }

            if (Element.getAttribute("srcover")) {
                var img = new Image();
                img.src = GetRootPath(Element.getAttribute("srcover"));
            }               
        }
    }
      
    function ButtonDown(e) {
        if (!this.onmousedown) return;
        
        SetButtonImage(this, GetRootPath(this.getAttribute("srcdown")));        
    }
    
    function ButtonUp(e) {
        if (!this.onmouseup) return;
        
        if (this.getAttribute("srcup")) //Only need to call it if the srcup exists, otherwise it hasn't been changed anyhow.
            SetButtonImage(this, GetRootPath(this.getAttribute("srcup")));    
    }
    
    function ButtonOut(e) {
        if (!this.onmouseout) return;
        
        if (this.getAttribute("srcup")) //Only need to call it if the srcup exists, otherwise it hasn't been changed anyhow.
            SetButtonImage(this, GetRootPath(this.getAttribute("srcup")));    
    }
    
    function ButtonOver(e) {
        if (!this.onmouseover) return;
        
        var ButtonDown = false;
        
        //This one is a little trickier, because we have to figure out if the mouse button is down or now.
        if (!e) var e = window.event;
        var ButtonDown = GetMouseButton(e);       
        
        if (ButtonDown > 0 && this.getAttribute("srcdown")) {
            SetButtonImage(this, GetRootPath(this.getAttribute("srcdown")));
        } else {
            if (this.getAttribute("srcover")) {
                SetButtonImage(this, GetRootPath(this.getAttribute("srcover")));
            } else if (this.getAttribute("srcup")) {
                SetButtonImage(this, GetRootPath(this.getAttribute("srcup")));
            } 
        }
    }
      
    function SetButtonImage(e, Src) {
        if (e.style.filter && navigator.appVersion.indexOf("MSIE") != -1) {
  	        e.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + Src  + "', sizingMethod='image')";
        } else {
            if (!e.getAttribute("srcup"))
                e.setAttribute("srcup", e.src);
            e.src = Src;
        }
    }
    
    function checkIt(string)
    {
	    place = detect.indexOf(string) + 1;
	    thestring = string;
	    return place;
    }


    function GetRootPath(Path) {
        if (Path.indexOf('~/') > -1) {
            return strRootPath + Path.substring(2, Path.length);
        } else {
            return Path;    
        }
    }
        
     ///Returns the button that is down in all browsers consistantly. Amazing.
    function GetMouseButton(theEvent) {
        if (theEvent.which && theEvent.which == 1) {
            ButtonDown = true;
        } else if (navigator.appVersion.indexOf("MSIE") != -1) {
            if (theEvent.button) {
                return theEvent.button;
            } else {
                return 0;
            }
        } else {
            if (theEvent.button) {
                if (theEvent.button == 0) {
                    return 1;
                } else if (theEvent.button == 1) {
                    return 4
                } else if (theEvent.button == 2) {
                    return 2;
                } else {
                    return 0;
                }
            } else {
                return 0;
            }
        }
    }
    
    function uppercase(e) {
        var key;
        if (e.keyCode)
            key = e.keyCode;
        else if (e.which) 
            key = e.which;

        
        if ((key > 0x60) && (key < 0x7B)) {
            if (navigator.appVersion.indexOf("MSIE") != -1)
                e.keyCode = key-0x20;
        }
    }
    
    function uppercaseexit(e) {
        e.value = e.value.toUpperCase();
    }
