$(document).ready(function(){
/********** Begin init **********/
	$(window).load(function () {
		if ($('#actionReportModal').html()) {
			var $dialog = $('<div id="actionReportModal"></div>').dialog({
				autoOpen: true,
				modal: true,  
				resizable: false
			});			

			$('.closeDialog').dialog('close');
			
			var $content = $('#actionReportModal').html();
			$dialog.dialog({title:"Akce byla úspěšná.", width: '300px', height: 'auto'}).html($content);
			$dialog.dialog('open').html($content);
			// prevent the default action, e.g., following a link
			
			$('.closeDialog').click(function() {
				$dialog.dialog('close');
			});
			
			return false;
		}	
	});

	$("a[rel^='lightbox']").prettyPhoto();
	$("a[rel^='prettyPhoto']").prettyPhoto();
	$("a[rel^='shadowbox']").prettyPhoto();
	
	$('#navRight ul li ul, #modal').hide();
	$('.tipsyTitleW').tipsy({gravity: 'w'});
	$('.tipsyTitleE').tipsy({gravity: 'e'});
	$('.tipsyTitleN').tipsy({gravity: 'n'});
	$('.tipsyTitleS').tipsy({gravity: 's'});
	
	showHide();
/********** End init **********/
	
/********** Begin jCarousel **********/	
	jQuery('#first-carousel').jcarousel({
    	scroll: 1,
		auto: 0,
		wrap: "last",
		animation: "1",
		easing: 'linear'
    });
	
	jQuery('#second-carousel').jcarousel({
    	scroll: 1,
		auto: 0,
		wrap: "last",
		animation: "1",
		easing: 'linear'
    });
/********** End jCarousel **********/

/********** Start jQuery Cycle **********/	
	$(window).load(function () {
		$('#kolage .slideshow').show();
		$('.slideshow').cycle({
		fx: 'fade', 
			delay: -4500,  
			speed:   3850
		});  
	});
/********** End jQuery Cycle **********/		

/********** Begin show/hide submenu info **********/	
	$('#navRight li.hasSubclass').hover(
            function(){
				$(this).find('ul.isSubclass').show();
				$(this).parent().parent().addClass('show');
            },
            function(){	
				$(this).find('ul.isSubclass').hide();
				$(this).parent().parent().removeClass('show');
            }
    );
/********** End show/hide submenu info **********/

/********** Begin show more text **********/		
	$('.clearFixPadding2 .showMoreNoStyle').click(
            function(){
				$(this).parent().parent().find('p.shorter').css('height','auto');
				$(this).css('display','none');
				
            }
    );  
/********** End show more text  **********/	

/********** Begin show/hide submenu sortiment **********/
	$('.sortimentNavigation li.hasSubclass').click(
            function(){
				$(this).find('ul.isSubclass').toggle();
            }
    ); 
/********** End show/hide submenu sortiment **********/

/********** Begin hover action default non-hover elements **********/	
	$('.sortimentNavigation li, ul.listProducts li, #detail #detailBottom #detailAdd #addToSC, .customer table tr').hover(
            function(){
				$(this).addClass('hover');
            }, 
			function(){
				$(this).removeClass('hover');
            }
    ); 	
/********** End hover action default non-hover elements **********/

/********** Begin show/hide panel **********/	
	$('.user1, .close, .user3').click(
            function(){
				$('#popUp').slideToggle("normal");
            }
    ); 	
/********** End show/hide panel **********/

/********** Begin show/hide boxes **********/	
	$('.showHide').click(
	    function(){
	    	/*var akce;
	    	
	    	/*if ($(this).parent().parent().find('.showHideContent')) {
	    		if ($(this).parent().parent().find('.showHideContent').css('display') == 'none') {
	    			akce = 'show';
	    		} else {
	    			akce = 'hide';
	    		}
	    	}
	    	else
	    	if ($(this).parent().parent().find('.boxContent')) {
	    		if ($(this).parent().parent().find('.boxContent').css('display') == 'none') {
	    			akce = 'show';
	    		} else {
	    			akce = 'hide';
	    		}
	    	}*/
	    	
	    	$(this).parent().parent().find('.showHideContent').slideToggle("normal", null, function() {
	    		if ($(this).css('display') == 'none') {
	    			$(this).parent().find('.showHide').html("▼ Zobrazit");
	    		} else {
	    			$(this).parent().find('.showHide').html("▲ Skrýt");
	    		}
	    	}	    	
	    	);
			$(this).parent().parent().find('.boxContent').slideToggle("normal", null, function() {
	    		if ($(this).css('display') == 'none') {
	    			$(this).parent().find('.showHide').html("▼ Zobrazit");
	    		} else {
	    			$(this).parent().find('.showHide').html("▲ Skrýt");
	    		}
	    	}	    	
	    	);
			
			//alert($(this).parent().parent().find('.showHideContent').css('display'));
			
	    	/*if (akce = 'hide') {
	    		$(this).html("▼ Zobrazit");
	    		$(this).parent().parent().find('.showHideContent').hide();
	    		$(this).parent().parent().find('.boxContent').hide();
	    	} else {
	    		$(this).html("▲ Skrýt");
	    	}*/
	    }
	);
	
	/*$('.showHide').click(
            function(){
				switch ($show) {
					case "0": {
						$(this).parent().parent().find('.showHideContent').slideToggle("normal");
						$(this).parent().parent().find('.boxContent').slideToggle("normal");
						$(this).html("▼ Zobrazit");
						$show = "1";
						break;
					}
					case "1": {
						$(this).parent().parent().find('.showHideContent').slideToggle("normal");
						$(this).parent().parent().find('.boxContent').slideToggle("normal");
						$(this).html("▲ Skrýt");
						$show = "0";
						break;
					}	
				}
            }
    );*/
		 
	function showHide(){
		var $page = $('body').attr("class");
		if ($page == "sp") {
			$('.showNews').find('.boxContent').hide();
			$('.showNews').find('.showHide').html("▼ Zobrazit");
		}
		$('#contentArea').find('.showHideContent').hide();
		$('#contentArea').find('.showHide').html("▼ Zobrazit");
	};

/********** End Show/Hide boxes  **********/

/********** Begin scrollTo plugin **********/
	$('a.up').click(function(e){		
		$.scrollTo( this.hash || 0, 1500);
		e.preventDefault();
	});
/********** End scrollTo plugin**********/	

/********** Begin modal boxes **********/				
	var $dialog = $('<div id="actionReportModal"></div>').dialog({
		autoOpen: false,
		modal: true,  
		resizable: false
	});
	
	/*$('.addToCard,  #addToSC').click(function() {
		var $content = $('#actionReportModal').html();
		$dialog.dialog({title:"Akce byla úspěšná.", width: '460px', height: 'auto'}).html($content);
		$dialog.dialog('open').html($content);
		// prevent the default action, e.g., following a link
		return false;
	});*/
	
	$('.closeDialog').dialog('close');
	$('.closeDialog2').dialog('close');
	
	$('.jcarousel-clip').append('<div class="gradientL"></div><div class="gradientR"></div>');
	
});
/********** End modal boxes **********/	

/********** Begin JS email replacement **********/	
function WriteMailTo(domain,user) {
	location.replace ('mailto:'+user+'@'+domain);
}
/********** Begin JS email replacement **********/
