//JQUERY Settings
jQuery(document).ready(function() {




    //main nav setup
    $("#nav li:has(ul)").addClass("sub_menu_true");
    $("#nav li").hover(function() {
        $(this).find("ul").css({ display: 'block' });
        $(this).find(".menuGlavni_normal").addClass("menu_hover");
    },
	    function() {
	        $(this).find("ul").css({ display: 'none' });
	        $(this).find(".menuGlavni_normal").removeClass("menu_hover");
	    }
    );
    $(function(){
        jQuery("ul.gallery").prettyGallery({
        itemsPerPage: 5,
        of_label: ' / ' /* The content in the page "1 of 2" */
        });
    });
    $("a[rel^='prettyPhoto']").prettyPhoto({
        animationSpeed: 'normal', /* fast/slow/normal */
        padding: 40, /* padding for each side of the picture */
        opacity: 0.35, /* Value betwee 0 and 1 */
        showTitle: false, /* true/false */
        allowresize: true, /* true/false */
        counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
        theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square */
        callback: function() { }
    });
    //AUDIO VIDEO 

    var tabRelValue;
    jQuery("a.av_tabs").click(function() {
        jQuery('#RssVideo').css({ display: 'none' });
        jQuery('#RssAudio').css({ display: 'none' });
        if (jQuery("#av_show_all_video").css('display') == 'block') { jQuery('#av_show_all_video').css({ display: 'none' }); }
        if (jQuery("#av_show_all_audio").css('display') == 'block') { jQuery('#av_show_all_audio').css({ display: 'none' }); }
        jQuery("a.av_tabs").removeClass("av_tabs_active");
        jQuery(this).addClass("av_tabs_active");
        tabRelValue = jQuery(this).attr('rel');
        jQuery('#av_tab_1, #av_tab_2').css({ display: 'none' });
        jQuery("#" + tabRelValue).css({ display: 'block' });
        switch (tabRelValue) {
            case "av_tab_1":

                jQuery('#RssVideo').css({ display: 'block' });
                break;
            case "av_tab_2":
                jQuery('#RssAudio').css({ display: 'block' });
                break;
        }

    });

    jQuery('.av_tabs_content_video ul').cycle({
        fx: 'scrollLeft',
        speed: 700,
        timeout: 0,
        next: '#next2',
        prev: '#prev2'
    });

    var showAllRelValue;
    jQuery("a.av_show_all_btn").click(function() {
        showAllRelValue = jQuery(this).attr('rel');
        jQuery("#" + showAllRelValue).slideToggle(600);
        return false;
    });

    var showAllCloseRelValue;
    jQuery("a.av_show_all_close").click(function() {
        showAllCloseRelValue = jQuery(this).attr('rel');
        jQuery("#" + showAllCloseRelValue).slideToggle(600);
        return false;
    });

    //SEARCH INPUT
    var labelTxt = $('.head_search input').attr('value');
    $('.head_search input').focus(function() {
        if ((this.value == '') || (this.value == labelTxt)) {
            $(this).val('');
            $(this).css({ borderColor: "#b7b7b7" });
        }
    });
    $('.head_search input').blur(function() {
        if (this.value == '') {
            $(this).val(labelTxt);
            $(this).css({ borderColor: "#cecdcd" });
        }
    });
    $('.head_search input').keypress(function(event) {
        if (event.keyCode == '13') {
            var labelTxt = $('.head_search input').attr('value');
            if (labelTxt == '') { $(this).css({ background: '#ffdbd5' }); }
            else {
                window.open("search.aspx?search=" + labelTxt, "_top");
                return false;
            }

        }
    });

    $("#nav li ul").find("li:last a").css({ borderBottom: 'none 0' });

    //kraj
});
function pokaziVideoKlik(pokaziVideoKlikRedniBroj) {
    $('.av_tabs_content_video ul').cycle(pokaziVideoKlikRedniBroj);
    if (jQuery("#av_show_all_video").css('display') == 'block') { jQuery('#av_show_all_video').slideUp(); }
    return false;
};
function Search(root) {
    var input = URLDecode(document.getElementById("search_input"));
    alert("Trazili ste: " + input.value);
    //var search = "search.aspx?value=" + input.value;
    //top.location.href = search; return false;
}

function SearchClear(defaultText) {
    var input = document.getElementById("search_input");
    //alert(input);
    if (input.value == defaultText)
        input.value = "";
    else
        if (input.value == "")
        input.value = defaultText;
}

function URLDecode(encodedString) {
    var output = encodedString;
    var binVal, thisString;
    var myregexp = /(%[^%]{2})/;
    while ((match = myregexp.exec(output)) != null
             && match.length > 1
             && match[1] != '') {
        binVal = parseInt(match[1].substr(1), 16);
        thisString = String.fromCharCode(binVal);
        output = output.replace(match[1], thisString);
    }
    return output;
}
