$(document).ready(function(){	
	bind_hover ();
	bind_search ();
	// bind_cycle ();
	bind_animation ();
	bind_table ();
	bind_news ();
	bind_fancyzoom();
	bind_fancybox();
});

function bind_news ()
{
	$('#news dd').cycle({
		fx:'scrollDown',
		timeout:7000,
		speed:500
	});
}

/**
 * animation na home
 **/
function bind_animation ()
{
	
	if ($('#animation .panel').length > 1)
	{
		$('#animation').after('<div id="nav"><ul class="menu banner shadow"></ul>').cycle({ 
			fx:     'scrollRight', 
			pause: 1,  
		    fx:     'fade', 
		    speed:   1000,
		    timeout: 5000,
			startingSlide: 0,
			pager:  '#nav ul', 
		 
			// callback fn that creates a thumbnail to use as pager anchor 
			pagerAnchorBuilder: function(idx, slide) {
				if (slide.title.length>25)
					return '<li class="two"><a href="#"><span>'+slide.title+'</span></a></li>';
				else
					return '<li><a href="#"><span>'+slide.title+'</span></a></li>';
			}
		});
	}
}

/**
 * hover efekt na menu
 **/
function bind_hover ()
{
	$(".menu li, .path li, #button-register, #button-download").hover(
		function() {
			$(this).addClass("sfhover");
		},
		function() {
			$(this).removeClass("sfhover");
		}
	);
}

/**
 * smazani textu v search input
 **/
function bind_search ()
{
	// vynulovani pole pri focusu
	$(".search-input").focus(function() {
		$(this).val('');
	});
}

function bind_cycle ()
{
	$('#navi').cycle({ 
	    fx:     'fade', 
	    speed:   1000,
	    timeout: 5000,
	    pagerEvent: 'mouseover',
		pager:  '#banner-menu',
		pagerAnchorBuilder: function(idx, slide) {  
			return '#banner-menu ul li:eq(' + idx + ') a';  
		}
 	});
 	
 	$('.info-panel dl dd').cycle({ 
	    fx:     'fade', 
	    speed:   1000,
	    timeout: 7000
 	});
}

function bind_table ()
{
	var i=0;
	$(".table-product tr").each(function(){
		if(i==1) {
			$(this).addClass("dark");
			i=0;
		}
		else
			i++;
	});
}

function bind_fancyzoom() {

	$('.fancyzoomnarrow').fancyZoom({directory: '/plugins/plugin-pg/css/fancyzoom', width: 300});
	$('.fancyzoomwide').fancyZoom({directory: '/plugins/plugin-pg/css/fancyzoom', width: 900});
}



function bind_fancybox() {

	$('.fancybox').fancybox({
		'scrolling': 'no',
		'titleShow'	: false,
		'autoScale' : false,
		'margin': 0
	});}



