
function formatTitle(title, currentArray, currentIndex, currentOpts) {
    if (title) return '<div id="tip7-title">' + (title && title.length ? '<b>' + title + '</b>' : '' ) + '</div>';
    else return '';
}


var slajd=1;
var top_slajd=1;
var t1=0;
var t2=0;

function zobacz (s_id) {
    var kat_id=$('#kats'+s_id).val();
    var link = window.location.protocol + "//" + window.location.host  +'/'+lskrot+'/kategoria/'+kat_id;
    window.location.href=link;
}

function zmien (numer,stop) {
    if (!stop) clearInterval(t1);
    if (!stop) $('#s'+slajd).hide();
    else $('#s'+slajd).fadeOut(800);
    slajd=numer;
    if (!stop) $('#s'+numer).show();
    else $('#s'+numer).fadeIn(800);
     kwadrat(numer);
     return false;
}

function top_zmien (numer,stop) {
    if (!stop) clearInterval(t2);
    if (!stop) $('#r'+top_slajd).hide();
    else $('#r'+top_slajd).fadeOut(800);
    top_slajd=numer;
    if (!stop) $('#r'+numer).show();
    else $('#r'+numer).fadeIn(800);
     return false;
}


function foto_zmiana (numer) {
    $('#foto_link').attr('href',linki_f[numer]);
    $('#foto').attr('src',fotosy[numer]);
}




function slajd_change() {
    var next=slajd+1;
    if (next>slajd_count) next=1;
    zmien(next,1);
    t1=setTimeout("slajd_change()",delay);
}

function top_slajd_change() {
    var top_next=top_slajd+1;
    if (top_next>top_slajd_count) top_next=1;
    top_zmien(top_next,1);
    t2=setTimeout("top_slajd_change()",top_delay);

}

function kwadrat (numer) {
    $('.kwadraty img').each(function(){

        $(this).attr('src',$(this).attr('src').replace('on','off'));
    });

    $('#k'+numer).attr('src',$('#k'+numer).attr('src').replace('off','on'));

}


$(function() {

$('#fraza').click(function() {

        if ($(this).val()==wpisz_fraze)  {
            $(this).val('');
            $(this).css({
                'color':'#333',
                'font-style':'normal'
            });
        }
    });

       if ($('.rotator').length) t1=setTimeout("slajd_change()",delay);
       if ($('.top').length) t2=setTimeout("top_slajd_change()",top_delay);


    $('.news_list_faq_header').click(function(){
        var id_f=$(this).attr('id').split('_');
        var disp=$('#click2_'+id_f[1]).css('display');
        $('.news_list_faq_zajawka').css('display','none');
        $('.news_list_faq_header').css('color','#333333');
        if (disp=='block') {
            $('#click2_'+id_f[1]).css('display','none');
        } else {
            $('#click2_'+id_f[1]).css('display','block');
            $(this).css('color','#000000');
        }
    });
    $("a.fancy").fancybox({
        'titleShow'		: true,
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'elastic',
        'titlePosition' : 'inside',
        'titleFormat'	: formatTitle
    });
    $("a[rel=fancy]").fancybox({
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'titlePosition' 	: 'over',
        'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">'  + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }
    });
    $("a[rel=fancygal]").fancybox({
        'transitionIn'		: 'none',
        'transitionOut'		: 'none'
    });

});





function szukaj2 () {

    var fraza=$('#fraza').val();

    if (fraza.replace(/\s/g,"")=='' || fraza==wpisz_fraze) {

        $.prompt(fraza_mus,{
            focus:1,
            top: 180,
            buttons:{
                'OK':true
            },
            callback: function(v,m,f){
                $('#fraza').css({
                    'color':'#333',
                    'font-style':'normal'
                });
                $('#fraza').val('');
                $("#fraza").focus();
            }
        }
        );
        return false;
    }
    else if (fraza.length<3) {

        $.prompt(fraza_mus,{
            focus:1,
            top: 180,
            buttons:{
                'OK':true
            },
            callback: function(v,m,f){

                $("#fraza").focus();
            }
        }
        );
        return false;
    } else return true;

}
