// $Id: common_rosters.js 42104 2007-06-18 15:29:16Z sbattaglia $

var W3C_DOM = ((typeof document.getElementById != 'undefined') && (typeof document.createElement != 'undefined')) ? true : false;

var editInnerHTML = "";
var deleteInnerHTML = "";
var currentRow = null;

// Add events to onload event handler
// typeof can be "string", "number", "boolean", "object", "array", "function", or "undefined"
function addLoadEvent(fn)
{
    // Mozilla
    if (typeof window.addEventListener != 'undefined')
    {
        window.addEventListener('load', fn, false);
    }
    // Opera
    else if (typeof document.addEventListener != 'undefined')
    {
        document.addEventListener('load', fn, false);
    }
    // IE
    else if (typeof window.attachEvent != 'undefined')
    {
        window.attachEvent('onload', fn);
    }
    // IE5Mac and others that don't support the above methods
    else
    {
        var oldfn = window.onload;
        if (typeof window.onload != 'function')
        {
            window.onload = fn;
        }
        else
        {
            window.onload = function()
            {
                oldfn();
                fn();
            };
        }
    }
}

// Return a reference to element
function getRef(el)
{
    if(typeof el == "string")
    {
        return document.getElementById(el);
    }
    else if(typeof el == "object")
    {
        return el;
    }
    else return null;
}

function init(){
	if(document.forms[1] != null && document.forms[1].elements[0] != null) {
		document.forms[1].elements[0].focus();
		document.forms[1].elements[0].select();
	}
}

// transition effect to fade background of element from darker to lighter color
// could use var redBackground = new initArray(12);redBackground[0]="#33CC00"; format
function setbgColor(elId, r, g, b){
    getRef(elId).style.backgroundColor = "rgb("+r+","+g+","+b+")";
}

function fade(elId, sr, sg, sb, er, eg, eb, step, current, speed){
    // printfire("----- START fade()");
    if (current <= step){
        setbgColor(elId,Math.floor(sr * ((step-current)/step) + er * (current/step)),Math.floor(sg * ((step-current)/step) + eg * (current/step)),Math.floor(sb * ((step-current)/step) + eb * (current/step)));
        current++;
        setTimeout("fade('"+elId+"',"+sr+","+sg+","+sb+","+er+","+eg+","+eb+","+step+","+current+","+speed+")",parseInt(speed));
    }
    // printfire("----- END fade()");
}

function fadeIn(){
    if(!W3C_DOM)return;
    if(getRef('successMessages')) fade('successMessages', 51,204,0, 221,255,170, 30,1,20);
    if(getRef('errorMessages')) fade('errorMessages', 187,0,0, 255,238,221, 30,1,20);

//    var arrayElements = getElementsByAttribute("tr", "class", "added");
    //var arrayElements;

//    if (!isEmpty(arrayElements) && arrayElements.length > 0) {
  //      fade(arrayElements[0].id, 255,255,51, 255,255,255, 30, 1, 70)
//    }
}
addLoadEvent(fadeIn);