// JavaScript Document
var URL = '/';
dirImages = URL+'images/';

$(document).ready(function()
{
    $(".partners .cyc").jCarouselLite({
        btnNext: ".partners .next",
        btnPrev: ".partners .prev",
        auto:3000,
        speed:3000,
        visible:3//,
        //easing:'easeOutCirc'
    });
});

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;
        case 'vozovy':
            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 popUpImage(url, x, y, wname, title)
{
    if (!x)
        x=640;
    if (!y)
        x=480;
    if (!wname)
        wname = 'popUpImageWindow'
    if (!title)
        wname = 'Image';
    nw = window.open('_blank','_blank','width='+x+', height='+y+', toolbar=0, scrollbars=yes, resizable');
    if ( typeof(nw) != 'undefined' )
    {
        ne = nw.document.createElement('body');
        nw.document.appendChild(ne);
        nw.document.getElementsByTagName('body')[0].innerHTML = '<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs"><head><meta http-equiv="content-type" content="text/html; charset=utf-8"><title>'+title+'</title><style type="text/css" media="all">html {height: 98%; padding: 0; margin: 0;} body {margin: 0px; padding: 0; text-align: center; height: 99%;} #table {border-collapse: collapse; width: 100%; margin: 0 auto; height: 100%;} #table td {height: auto;} #pager {height: 100%;} table td {vertical-align: middle; text-align: center; padding: 10px;}</style></head><body onclick="window.close();"><div id="pager"><table id="table" cellpadding="0" cellspacing="0"><tr><td><img src="'+url+'" alt="'+title+'" title="'+title+'"></td></tr><table></div></body></html>';
        nw.focus();
        //nw.document.onclick = nw.close;
    }
    return false;
}

function onLoad()
{
    unBlurAllLinks();
    setDefaultValue('fiHledatObec', 'hledat obec');
    setDefaultValue('fiMaxCena', 'max.cena');
    setDefaultValue('fiHledatText', 'text');
    setDefaultValue('filHledatText', 'hledat text');
}

function selectItems(id, checked, expr)
{
    if (!expr)
        expr = /itemId.*/;
    if (e=getElement(id))
    {
        rList = e.getElementsByTagName('INPUT');
        for (var i = 0; i < rList.length; i++)
        {
            if ( rList[i].type == 'checkbox' && rList[i].name.match(expr) )
                if ( rList[i].parentNode )
                    rList[i].checked = (checked==2) ? (rList[i].checked ? false : true) : checked;
        }
    }
}

function selectItem(id, value, expr)
{
    if (!expr)
        expr = /itemId.*/;
    if (e=getElement(id))
    {
        rList = e.getElementsByTagName('INPUT');
        for (var i = 0; i < rList.length; i++)
        {
            if ( rList[i].type == 'checkbox' && rList[i].name.match(expr) && rList[i].value==value )
                if ( rList[i].parentNode )
                    rList[i].checked = true;
        }
        //if (submit && typeof(e.submit)=='function')
            //e.submit();
    }
}

function submitList (id, q)
{
    if ((e=getElement(id)) && typeof(e.submit)!='undefined')
    {
        if (q)
            e.action.value=q;
        e.submit();
    }
}

function redir(url, delay)
{
    if (typeof(delay)=='undefined' || delay=='')
        window.location.href = url;
    else
        setTimeout('window.location.href = \''+url+'\'', delay*1000);
}

function foc()
{
    if (f = getElement('focusThis'))
    {
        f.focus();
    }
}

function truebody()
{
    return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function handleMultiBlockInputOld (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].type == 'file')
                {
                    var newInput = document.createElement('input');
                    newInput.type = 'file';
                    newInput.name = fList[i].name;
                    newInput.className = fList[i].className;
                    newInput.onchange = fList[i].onchange;
                    fList[i].parentNode.replaceChild(newInput, fList[i]);
                }
                else 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));
    vstup.appendChild(newCopy);
}

window.onload = onLoad;

$(document).ready(function() {
	$('input:checkbox').checkbox({cls:'styled-checkbox',empty:URL+'images/empty.png'});
});

