// JavaScript Document
var URL = '/';
dirImages = URL+'images/';

function getElement(name)
{
    if (document.getElementById)
    return document.getElementById(name)
    else if (document.all)
    return document.all.name
    return false;
}

function trySubmit (id)
{
    if ( form = getElement(id) ) form.submit();
}

function unBlur(element)
{
    if ( element.blur ) element.blur();
}

function wMail(login, domain, link, name)
{
    if (link)
        document.write('<a href="mailto:'+login+'@'+domain+'">'+((name)?name:login+'@'+domain)+'</a>');
    else
        document.write(login+'@'+domain);
}

function preloadImage()
{
    images = new Array();
	for ( var i=0; i < arguments.length; i++ )
    {
        images[i] = new Image(25, 25);
        images[i].src = dirImages + arguments[i];
        images[i].onerror = onerror;
	}
}

function onerror()
{
    alert('err image loading');
}

function toggle()
{
	for ( var i=0; i < arguments.length; i++ )
    {
        if ( e = getElement(arguments[i]) )
        {
            e.style.display = ((e.style.display == 'none') || ((e.style.display=='') && (e.offsetWidth==0))) ? 'block' : 'none';
        }
	}
}

function toggleChkb(form, stat, id)
{
    if (f=getElement(form))
    {
        rList = f.getElementsByTagName('INPUT');
        exp = RegExp('' + id + '.*', 'i');
        for (var i = 0; i < rList.length; i++)
        {
            if (rList[i].type=='checkbox')
            {
                if (id!='' && rList[i].id.toString().match(exp))
                    rList[i].checked = stat ? true : false;
                else if (id=='')
                    rList[i].checked = stat ? true : false;
            }
        }
    }
}

function popUp(type, href, x, y)
{
    switch (type)
    {
        case 'galerie':
            if (!x)
                x=640;
            if (!y)
                x=480;
            nw = window.open(href,'Foto','width='+x+', height='+y+', toolbar=0, scrollbars=yes, resizable');
            break;
    }
    if ( typeof(nw) != 'undefined' )
        nw.focus();
}

function onLoad()
{
    unBlurAllLinks();
}

function redir(url, delay)
{
    if (typeof(delay)=='undefined' || delay=='')
        window.location.href = url;
    else
        setTimeout('window.location.href = \''+url+'\'', delay*1000);
}

function unBlurAllLinks()
{
    rList = document.getElementsByTagName('A');
    for (var i = 0; i < rList.length; i++)
    {
        rList[i].onfocus = new Function('if (this.blur) this.blur();');
    }
}

function foc()
{
    if (f = getElement('focusThis'))
    {
        f.focus();
    }
}

window.onload = onLoad;

