// JavaScript Document
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 ( typeof(element) != 'undefined' )
        if ( element.blur ) element.blur();
}

function tryShow (id)
{
    if ( form = getElement(id) )
    {
        form.style.display = 'block';
        return false;
    }
    else return true;
}

function toggle()
{
	for ( var i=0; i < arguments.length; i++ )
    {
        if ( e = getElement(arguments[i]) )
        {
            e.style.display = (e.style.display == '' || e.style.display == 'none') ? 'block' : 'none';
        }
	}
	return false;
}

function foc()
{
    if (f = getElement('focusThis'))
    {
        f.focus();
    }
} 

function prepnoutCheckboxPolozky(els) 
{
    if (els.checked)
    {
        for (var i=0; i < els.form.length; i++)
        {
            if (els.form[i].type=='checkbox')
            {
                els.form[i].checked = true;
            }
        }
    }
    else
    {
        for (var i=0; i < els.form.length; i++)
        {
            if (els.form[i].type=='checkbox')
            {
                els.form[i].checked = false;
            }
        }
    }
}

function checkInputGalerie (element)
{
    var vstup = getElement('galerieVstup');

    var newdiv = document.createElement("div");
        newdiv.className = 'imgInputBoxFLS';
	
	var inHTML = '<input type="file" name="fotka[]" onchange="checkInputGalerie();"><br>';
	    newdiv.innerHTML = inHTML;

    for (var x = 0; vstup.childNodes[x]; x++)
    {
        if (vstup.childNodes[x].tagName=='DIV')// document.getElementById("info").value += vstup.childNodes[x].getAttribute("grp");
        {
            if (vstup.childNodes[x].childNodes[0].value == '')
            {
                vstup.removeChild(vstup.childNodes[x]);
                x--;
            }
        }
    }
    vstup.appendChild(newdiv);
}

function handleMultiBlockInput (blockId)
{
    if ( vstup = getElement(blockId) )
    {
        var newCopy = vstup.childNodes[0].cloneNode(true);
        fList = newCopy.getElementsByTagName('INPUT');
        for (var i = 0; i < fList.length; i++)
        {
            if ( fList[i].type == 'text' || fList[i].type == 'password' || fList[i].type == 'file' )
                if ( fList[i].parentNode )
                    fList[i].value = '';
        }
        fList = newCopy.getElementsByTagName('TEXTAREA');
        for (var i = 0; i < fList.length; i++)
            if ( fList[i].parentNode )
                fList[i].value = '';
    }
    else return false;
    if ( typeof(newCopy) == 'undefined' )
        return false;
    for (var x = 0; vstup.childNodes[x]; x++)
    {
        if (vstup.childNodes[x].tagName=='DIV')
        {
            if (vstup.childNodes[x].childNodes[0].value == '')
            {
                vstup.removeChild(vstup.childNodes[x]);
                x--;
            }
        }
    }
    vstup.appendChild(newCopy.cloneNode(true));
}

function onLoad()
{
    Cron.set('boxiDnesNews1.update()', 1800000, true);
    Cron.set('boxiDnesNews2.update()', 1800000, true);
    //unBlurAllLinks();
}

window.onload = onLoad;
