var old_id = '';

function GetObj(id)
{
    var obj;
    
    if (document.all)
        obj = document.all[id];
    else
        obj = document.getElementById(id);
        
    return obj;
}

function ShowAction(id, action)
{
    var obj = GetObj(id);
    
    obj.src = '/Images/' + action + '.png';
    obj.style.display = 'block';
}

function HideAction(id)
{
    var obj = GetObj(id);
    
    obj.style.display = 'none';
}

function ChangeImage(imageID, linkID, imageUrl)
{
    if (imageUrl.length > 0)
    {
        var img = GetObj(imageID);
        var lnk = GetObj(linkID);
    
        img.src = imageUrl;
        lnk.href = imageUrl.replace('TMB', 'LRG');
    }

    return false;
}

function AlignObjects(targetID, objID)
{
    var x = 0;
    var y = 0;

    var oElement = GetObj(targetID);
    
    var height = oElement.height;
    var width = oElement.width;
    
    while( oElement != null ) 
    {
        y += oElement.offsetTop;
        x += oElement.offsetLeft;
        
        oElement = oElement.offsetParent;
    }
    
    var obj = GetObj(objID);
    
    var sourceHeight = parseInt(obj.style.height);
    var sourceWidth = parseInt(obj.style.width);
    
    if (sourceWidth > width)
        x = x - (sourceWidth - width) / 2;
    if (sourceHeight > height)
        y = y - (sourceHeight - height) / 2;
    
    obj.style.left = x + "px";
    obj.style.top = y + "px";
}

function Expand(id)
{
    if (old_id.length > 0)
        Collapse(old_id);

    if (id != old_id)
    {
        var i = 0;
        var obj = GetObj(id + '_' + i++);

        while (obj != null)
        {
            obj.style.display = '';
            
            obj = GetObj(id + '_' + i++);
        }
        
        old_id = id;
    }
    else
        old_id = '';
}

function Collapse(id)
{
    var i = 0;
    var obj = GetObj(id + '_' + i++);
    
    while (obj != null)
    {
        obj.style.display = 'none';
        
        obj = GetObj(id + '_' + i++);
    }
}
