/**
 * @author filip
 */
if (typeof(jQuery) != 'undefined') {
	
	
	/* stridani upoutavek na titulni strane - START */
	jQuery(document).ready(function () {
		var cycle_elements = new Array('#actionBeer', '#actionFood');
		jQuery(cycle_elements).each(function (i, elm) {
			if (jQuery(elm + ' ul li').length > 1) {
				jQuery(elm + ' ul').cycle({
					fx: 'fade',
					timeout:  5000
				});
			}
		});
	});
	/* stridani upoutavek na titulni strane - END */
	
	
	
	/* scrollovani aktualnich jidel/piti na titulu - START */
	jQuery(document).ready(function () {
		var scroller_elements = new Array('#scrollerBeer', '#scrollerFood');
		var timeout = 2000;
		jQuery(scroller_elements).each(function (i, elm) {
			window.setTimeout('scrollUnorderedList("' + elm + ' ul"' + ', ' + timeout + ')', timeout);
		})
	});
	/* scrollovani aktualnich jidel/piti na titulu - START */
	
	
	/* funkce pro scrolovani teckovaneho seznamu - START */
	function scrollUnorderedList(list_elm, timeout) {
		var item = jQuery(list_elm + ' li:first');
		item.slideUp('slow', function () {
			jQuery(this).insertAfter(jQuery(this).parent().children('li:last'));
			jQuery(this).parent().children('li:last').slideDown('slow');
		});
		
		window.setTimeout('scrollUnorderedList("' + list_elm + '"' + ', ' + timeout + ')', timeout);
	}
	/* funkce pro scrolovani teckovaneho seznamu - END */
	
}





/* -------------------------------------------------------------------------- */
/* pop-up okno                                                                */

$(document).ready( function () {
    
    return;
    
    // existuje popup?
    if ($('#popup').length == 0) return;
    
    // kopie obsahu popup okna na konec stranky
    $('body').append('<div id="popup-shadow"></div><div id="popup-window">' + $('#popup').html() + '<p id="popup-close-link"><a href="">pokračovat >></a></p></div>');
    
    // stylovani popup-shadow
    $('#popup-shadow').css({'width' : '100%', 'height' : '100%', 'position' : 'absolute', 'left' : '0px', 'top' : '0px', 'z-index' : '10000', 'background-color' : '#000000', 'opacity' : '.65'}).css;
    
    // stylovani popup-window
    $('#popup-window').css('z-index', '10001');

    // umisteni na stred
    $('#popup-window').css('position', 'absolute');
    var left = ($('#popup-shadow').innerWidth() - $('#popup-window').innerWidth()) / 2;
    var top = ($('#popup-shadow').innerHeight() - $('#popup-window').innerHeight()) / 2;
    $('#popup-window').css({ 'left' : left + 'px', 'top' : top + 'px'});
    
    // link "pokracovat"
    $('#popup-close-link a').click(function (e) {
        e.preventDefault();
    });
    
    
    // pozatecni skryti
    $('#popup-window').hide();
    $('#popup-shadow').hide();
    
    // rozsviceni
    $('#popup-shadow').fadeIn('slow', function () {
        $('#popup-window').slideDown('slow');
    });
    
    // klik pro zavreni
    $('#popup-shadow, #popup-window').click(function () {
        $('#popup-window').fadeOut('slow', function () {
            $('#popup-shadow').fadeOut('slow');
        });
    });
    
    
});

/* -------------------------------------------------------------------------- */



jQuery.fn.center = function (absolute) {
    return this.each(function () {
        var t = jQuery(this);

        t.css({
            position:    absolute ? 'absolute' : 'fixed', 
            left:        '50%', 
            top:        '50%', 
            zIndex:        '99'
        }).css({
            marginLeft:    '-' + (t.outerWidth() / 2) + 'px', 
            marginTop:    '-' + (t.outerHeight() / 2) + 'px'
        });

        if (absolute) {
            t.css({
                marginTop:    parseInt(t.css('marginTop'), 10) + jQuery(window).scrollTop(), 
                marginLeft:    parseInt(t.css('marginLeft'), 10) + jQuery(window).scrollLeft()
            });
        }
    });
};

