    // Validates the input element whose event was handled only contains numeric values.
    function numbersonly(e)
    {       
        var unicode = e.charCode? e.charCode : e.keyCode
        if (unicode >31 && unicode < 128)
        { 
            //if the key isn't the backspace key (which we should allow)
            if (unicode<48||unicode>57) //if not a number
                return false;
        }
    }
         
    // Gets Elements Position within the browser
    function getElementPosition(element)
    {
        var x=0,y=0;
        while (element!=null)
        {
            x+=element.offsetLeft //-element.scrollLeft; -- Does not the opposite of its intentions.
            y+=element.offsetTop //-element.scrollTop; -- Does not the opposite of its intentions.
            element=element.offsetParent;
        }
        return {x:x,y:y};
    }
    
    
    // Fade From one opacitiy to another.
    function fadeOpacity(id, opacStart, opacEnd, millisec) 
    {    
        //speed for each frame 
        var speed = Math.round(millisec / 100); 
        var timer = 0; 

        // determine the direction for the blending, if start and end are the same nothing happens 
        // If its an IE Browser it's smoother without the timer variable added.
        if(opacStart > opacEnd) 
        { 
            for(i = opacStart; i >= opacEnd; i--) 
            { 
                setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
                timer++; 
            } 
        } 
        else if(opacStart < opacEnd) 
        { 
            for(i = opacStart; i <= opacEnd; i++) 
            { 
                setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
                timer++; 
            } 
        }
    } 

    //change the opacity for different browsers 
    function changeOpac(opacity, id) 
    { 
        var element = document.getElementById(id);
        element.style.opacity = (opacity / 100); 
        element.style.MozOpacity = (opacity / 100); 
        element.style.KhtmlOpacity = (opacity / 100); 
        element.style.filter = "alpha(opacity=" + opacity + ")"; 
    } 
    
    // Converst a hexidecimal value to a decimal value.
    function hexToDecimal(value)
    {
        return parseInt(value,16);
    }
      
    // Converts the value given to the given radix
    // Radix = 2 if binary
    // Radix = 16 if hex
    // Radix = 8 if oct
    function decimalToRadix(value,radix)
    {
        var retval = '';
        var ConvArray = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F');
        var intnum;
        var tmpnum;
        var i = 0;

        intnum = parseInt(value,10);
        if (isNaN(intnum)){
            retval = 'NaN';
        }else{
            while (intnum > 0.9){
                i++;
                tmpnum = intnum;
                // cancatinate return string with new digit:
                retval = ConvArray[tmpnum % radix] + retval;  
                intnum = Math.floor(tmpnum / radix);
                if (i > 100){
                    // break infinite loops
                    retval = 'NaN';
                    break;
                }
            }
        }
        return retval;
    }
    
    // Adds an onload event to the window load handler.
    function addLoadEvent(func) 
    {

        var oldonload = window.onload;

        if (typeof window.onload != 'function') 
        {
            window.onload = func;
        }
        else 
        {
            window.onload = function() 
            {
                oldonload();
                func();
            }
        }
    }
