﻿
// Namespace function
function Common()
{
}


// Adds a function to the window.onload event
Common.addLoadEvent = function(func)
{
    var oldonload = window.onload; 
    
    if (typeof window.onload != "function")
    { 
        window.onload = func; 
    }
    else
    { 
        window.onload = function()
        { 
            oldonload(); 
            func(); 
        } 
    } 
}


// Gets "the best bet" of an element, when the client-id has been altered by ASP.NET
Common.getElementByIdPart = function(idPart, elementArray)
{
    var element = null;
    
    for(var i=0; i<elementArray.length; i++)
    {
        if(elementArray[i].id.indexOf(idPart) != -1)
        {
            element = elementArray[i];
        }
    }
    
    return element;
}