$(document).ready(function(){
// ************** player: img rotator******************** //
	//This keeps track of the slideshow's current location
	var current_panel = 1;
	//Controlling the duration of animation by variable will simplify changes
	var animation_duration = 2500;
	
	$.timer(4000, function (timer) {
		//Determine the current location, and transition to next panel
		switch(current_panel){
			case 1:
				$("#slideshow").stop().animate({left: "-800px", top: "0px"}, {easing: 'easeOutBack', duration: animation_duration});
				current_panel = 2;
			break;
			case 2:
				$("#slideshow").stop().animate({left: "0px", top: "-180px"}, {easing: 'easeOutBack', duration: animation_duration});
				current_panel = 3;
			break;
			case 3:
				$("#slideshow").stop().animate({left: "-800px", top: "-180px"}, {easing: 'easeOutBack', duration: animation_duration});
				current_panel = 4;
			break;
			case 4:
				$("#slideshow").stop().animate({left: "0px", top: "0px"}, {easing: 'easeOutBack', duration: animation_duration});
				current_panel = 1;
			break;	
	  		timer.reset(12000);
		}
	});
// END

// ************** animowane menu   r******************** //
	//Fix Errors - http://www.learningjquery.com/2009/01/quick-tip-prevent-animation-queue-buildup/
	
	//Remove outline from links
	$("#menu").find("a").click(function(){
		$(this).blur();
	});
	
	//When mouse rolls over
	$("#menu").find("li").mouseover(function(){
		$(this).stop().animate({height:'90px'},{queue:false, duration:600, easing: 'easeOutBounce'})
	});
	
	//When mouse is removed
	$("#menu").find("li").mouseout(function(){
		$(this).stop().animate({height:'50px'},{queue:false, duration:600, easing: 'easeOutBounce'})
	});
// END

// ************** submenu: opacisty  ******************** //
//$(function(){
	$('#submenu img.opasity50').hover(
	function(){	$(this).animate({ opacity: 1.0}, 100 )},
	function(){	$(this).animate({ opacity: 0.5 }, 100 )}
	);
//	});
// END
    $('#gallery img').animate({ opacity: 0.8}, 80 );
    $('#gallery').find('img').mouseover(
	function(){ $(this).animate({ opacity: 1.0}, 100 )});
    $('#gallery').find('img').mouseout(
    function(){	$(this).animate({ opacity: 0.8}, 80 )});


// zaokraglenie rogow
$('#subtitle').corner("cc:#EEEAEC 10px");	
$('.border_round').corner("cc:#EEEAEC 10px");	

// ************** TVN Style  ******************** //
  $('div.jimgMenu ul li a').hover(function() {  

    if ($(this).is(':animated')) {
      $(this).addClass("active").stop().animate({width: "310px"}, {duration: 450, easing: "easeOutQuad", complete: "callback"});
    } else {
      $(this).addClass("active").stop().animate({width: "310px"}, {duration: 400, easing: "easeOutQuad", complete: "callback"});
    }
  }, function () {
    if ($(this).is(':animated')) {
      $(this).removeClass("active").stop().animate({width: "78px"}, {duration: 400, easing: "easeInOutQuad", complete: "callback"})
    } else {
      $(this).removeClass("active").stop(':animated').animate({width: "78px"}, {duration: 450, easing: "easeInOutQuad", complete: "callback"});
    }
  });
});
