function show(element_id)
{
    if( document.getElementById(element_id).style.display == "none" ){
        document.getElementById(element_id).style.display = "";
    }else{
        document.getElementById(element_id).style.display = "none";
    }
}

function getSelectedValue(selectId)
{
    var select = document.getElementById(selectId);
    if (select)
    {
        return select.options[select.selectedIndex].value;
    }
    return false;
}

function reload()
{
    window.location.reload();
}

function reloadOpener()
{
    if (window.opener) window.opener.doReload();
}

function SetFullScreen()
{
    // Teeme akna kogu ekraani suuruseks.
    window.resizeTo(screen.width,screen.availHeight);
    // Sätime akna paika. 
    window.moveTo(0,0);    
}

function externalLinks() 
{
    if (!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for (var i=0; i<anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") &&
            anchor.getAttribute("rel") == "external")
            anchor.target = "_blank";
    }
}

var IS_ALERTING = false;
function StartAlerting(bgElement)
{
    if (IS_ALERTING == true)
        return;
    IS_ALERTING = true;
    var oldTitle = document.title;
    var newTitle = "Uus sõnum! " + oldTitle;
    var oldColor = YAHOO.util.Dom.getStyle(bgElement, 'backgroundColor');
    var newColor = '#fee';
    YAHOO.util.Dom.setStyle(bgElement, 'backgroundColor', newColor);
    var timeoutId = setInterval(function() {
        document.title = document.title == newTitle ? oldTitle : newTitle;
    }, 1000);
    window.onmousemove = function()
    {
        clearInterval(timeoutId);
        document.title = oldTitle;
        YAHOO.util.Dom.setStyle(bgElement, 'backgroundColor', oldColor);
        window.onmousemove = null;
        IS_ALERTING = false;
    };
}
