$(document).ready(function() {
	$(".product_image a").fancybox({
		'zoomOpacity'			: true,
		'overlayShow'			: false,
		'zoomSpeedIn'			: 600,
		'zoomSpeedOut'			: 500,
		'easingIn'				: 'easeOutBack',
		'easingOut'				: 'easeInBack'
	});
	
	$("a#footsize, a#footsize2").fancybox({
		'zoomOpacity': true,
		'overlayShow': true,
		'overlayOpacity': 0.8,
		'zoomSpeedIn': 600,
		'zoomSpeedOut': 500,
		'easingIn': 'easeOutBack',
		'easingOut': 'easeInBack',
		'hideOnContentClick': true,
		'frameWidth'	: 1000,
		'frameHeight': 430,
		'centerOnScroll': true,
		'callbackOnShow': function() {
			$("table.velikostibot tr td").hover(
			function()
			{
				var boxid = $(this).attr("abbr");
				$("td.uk_" + boxid).addClass("alt");
				$("td.usa_" + boxid).addClass("alt");
				$("td.euro_" + boxid).addClass("alt");
				$("td.cm_" + boxid).addClass("alt");
			},
			function()
			{
				var boxid = $(this).attr("abbr");
				$("td.uk_" + boxid).removeClass("alt");
				$("td.usa_" + boxid).removeClass("alt");
				$("td.euro_" + boxid).removeClass("alt");
				$("td.cm_" + boxid).removeClass("alt");
			}
			);
			$("table.wovelikostibot tr td").hover(
			function()
			{
				var boxid = $(this).attr("abbr");
				$("td.wouk_" + boxid).addClass("alt");
				$("td.wousa_" + boxid).addClass("alt");
				$("td.woeuro_" + boxid).addClass("alt");
				$("td.wocm_" + boxid).addClass("alt");
			},
			function()
			{
				var boxid = $(this).attr("abbr");
				$("td.wouk_" + boxid).removeClass("alt");
				$("td.wousa_" + boxid).removeClass("alt");
				$("td.woeuro_" + boxid).removeClass("alt");
				$("td.wocm_" + boxid).removeClass("alt");
			}
			);
		} 
	});
	
	theRotator();
	
	$("ul.menu_body li:even a").addClass("alt");

  $('#znacky_damske, #znacky_damske_menu').mouseover(function () {
    $('#znacky_damske_menu').show();
  });
  
  $('#znacky_damske, #znacky_damske_menu').mouseout(function () {
    $('#znacky_damske_menu').hide();
  });
  
  $('#znacky_panske, #znacky_panske_menu').mouseover(function () {
    $('#znacky_panske_menu').show();
  });
  
  $('#znacky_panske, #znacky_panske_menu').mouseout(function () {
    $('#znacky_panske_menu').hide();
  });
  
  $('#znacky_detske, #znacky_detske_menu').mouseover(function () {
    $('#znacky_detske_menu').show();
  });
  
  $('#znacky_detske, #znacky_detske_menu').mouseout(function () {
    $('#znacky_detske_menu').hide();
  });

   $('#showdetails').click(function(){
     $('div#details').toggle();
   });
	
	
});

function changeSkladovost()
	{
		var sizeeu = $("#sizeeu").val();
		var prodid = $("#productid").val(); 
		var typid = $("#typid").val(); 
		$.ajax({
		method: "get",url: "handleasync.php",data: "function=1&prodid="+prodid+"&sizeeu="+sizeeu+"&typid="+typid,
		beforeSend: function(){$("#loadingimage").show("normal"); $("#skladovost").hide("fast");}, 
		complete: function(){ $("#loadingimage").hide("fast");}, 
		success: function(html){ //so, if data is retrieved, store it in html
		$("#skladovost").show("slow"); //animation
		$("#skladovost").html(html); //show the html inside .content div
		}
		})
	}

function checkInsert(text)
{
	if(document.getElementById('sizeeu').value != 0) 
	{ 
		document.getElementById('addtocart').submit();
	} 
	else 
	{ 
		alert(text);
	}
}

function getLink(link)
{
	document.location.href = link;
}

function theRotator() {
	//Set the opacity of all images to 0
	$('div#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',3000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};