/* bleskovky */

$(document).ready(function(){
    if ($("#bleskovky").length !=0) {
        $("#bleskovky").easySlider({
            auto: true,
            continuous: true,
            numeric: true,
            pause: 5000,
            speed: 300
        });
    }
});



/* prihlasovanie */
$(document).ready(function(){

    $('#prihlas').click(function(){
 
        var login = $("input#login").val();
        var password = $("input#password").val();

        if (login.lenght==0 || password.length==0)
        {
            $.jnotifica("Vyplňte prosím prihlasovacie meno aj heslo");
            return false;
        }

    });
    
});

$('#prihlasit-top').click(function () {
    $("#modul-prihlasovanie").effect('pulsate', {
        times:2
    });
    return false;
});


/* vyhladavanie */
$(document).ready(function(){	

    if ($("#modul-vyhladavanie #input-vyhladavanie").length !=0) {
        $("#modul-vyhladavanie #input-vyhladavanie" ).autocomplete({
            minLenght:3,
            source: function(request, response) {
            $.ajax({
                url: "/ajax/vyhladavanie",
                data: {
                term: $("#input-vyhladavanie").val()
                },
                dataType: "json",
                type: "POST",
                success: function(data){
                response(data);
              
                }
                });
            },
            select: function(event, ui) {
            location.href=ui.item.url;
            },
            minLength: 3
            }).data( "autocomplete" )._renderItem = function( ul, item ) {
            return $( "<li></li>" )
            .data( "item.autocomplete", item )
            .append( '<a href="'+item.url+'"><b>' + item.label + "</b><br />" + item.desc + "</a>" )
            .appendTo( ul );
        };
    }



    var inputvyhladavanie = $('#input-vyhladavanie');

    inputvyhladavanie.focus(function () {
        if (  inputvyhladavanie.val()=='Hľadaj ...' )
        {
            inputvyhladavanie.val('');
            inputvyhladavanie.css({
                color: "#000"
            });
        }
        return false;
    });

    inputvyhladavanie.blur(function () {
        if ( inputvyhladavanie.val()=='' )
        {
            inputvyhladavanie.css({
                color: "#999"
            });
            inputvyhladavanie.val('Hľadaj ...');
        }
        return false;
    });





    function selectItem(li) {
        if (li.extra) {
            location.href=li.extra[1];
        }
    }

    function formatItem(row) {
        return row[0] + "<br><span class=\"italic subinfo\">" + row[1] + "</span>";
    }




    /* anketa */
    $(document).ready(function(){

        $("#modul-anketa a.odpoved").live("click", function() {
            var url = $(this).attr("href");
            if (url=='#')
            {
                return false;
            }
            else
            {
                $.ajax({
                    url: url,
                    type: "GET",
                    success: function(data)
                    {
                        $("#modul-anketa") .replaceWith( data );
                    }
                });
                return false;
            }
        });

    });


    $('input-vyhladavanie').click(function() {
        $("#form-vyhladavanie").submit();
    });

});



