﻿(function($) {
    $.fn.bipltooltip = function(options) {
        return $(this).each(function(){
            $(this).hover( function(e) {
                var image = $(this);
                $('#tooltip').remove();
                var tooltip = $('<div id="tooltip">' + image.attr('titlex') + '</div>')
                tooltip.appendTo('body');
                tooltip.css({
                    'margin-top': image.offset().top+30,
                    'margin-left': image.offset().left-130,
                    'display': 'block'
                });         
            }
            , function() {
                     $('#tooltip').hide();
            } 
            ); //hover
                
        });
    };
    
    $.fn.biplslider = function(navi_id) {
        
        var navi = $($(navi_id)[0]);
        return $(this).each(function() {
            var slider = $(this);

            function on_before() { 
                idx = slider.children().index(this);               
                navi.children('li').css('font-weight', 'normal');
                navi.children('li:eq('+ idx + ')').css('font-weight', 'bold');
            } 
            
            slider.cycle({
                fx:     'fade', 
                speed:  'fast',
                timeout: 3000,
                before:  on_before,
                pause:   1
            });
            
            navi.find('a').hover(function() {
                idx = navi.children().index($(this).parent());
                slider.cycle(parseInt(idx));
                slider.cycle('toggle');              
            }); 
        
        });  
    };
    
})(jQuery);     



$(function () {
    $('.tooltip').bipltooltip();
    
    $('.filter_add_btn').click(function() {
        if($('.filter_delete_btn').length >= 3) {
            alert('Dodałeś do kontekstu (filtra) maksymalną liczbę trzech kategorii. Aby dodać nową, usuń którąś z obecnych.');
            return false;
        }
    });
    
});
