var images = new Array ('/img/wl/1.png','/img/wl/2.png','/img/wl/3.png','/img/wl/4.png','/img/wl/5.png','/img/wl/6.png','/img/wl/7.png', '/img/wl/8.png', '/img/wl/9.png');
var index = 1;
 
function rotateImage()
{
  $('#myImage').fadeOut('slow', function()
  {
    $(this).attr('src', images[index]);
 
    $(this).fadeIn('slow', function()
    {
      if (index == images.length-1)
      {
        index = 0;
      }
      else
      {
        index++;
      }
    });
  });
}
 


$(document).ready(function() {
	setInterval (rotateImage, 2000);
	
//	if ( typeof($.ieSelectStyle) != "undefined" )
//		$('select').ieSelectStyle();
//	
//	if ( typeof($.panzoom) != "undefined" )
//		$.panzoom("#produkt-bigimg a");
//	
//	if ( typeof($().piroBox) != "undefined" )
//		$().piroBox({
//			  my_speed: 400, //animation speed
//			  bg_alpha: 0.2, //background opacity
//			  slideShow : true, // true == slideshow on, false == slideshow off
//			  slideSpeed : 3, //slideshow
//			  close_all : '.piro_close, .piro_overlay' // add class .piro_overlay(with comma)if you want overlay click close piroBox
//			  });
			  

 	
	
//	jQuery.each(jQuery.browser, function(i, val) {
//	   if(i=="mozilla" && jQuery.browser.version.substr(0,3)=="1.9")
//		  {
//			  $("#ie-check").fadeIn("fast");
//		  }
//	});	  

//	$(".popupclose").click(
//		function()
//		{
//			$("#ie-check").fadeOut("slow");	
//		}
//	);
	
			  
	$("#ie-check").ie6warning();
	
	var globaltime = 1000;
	
	
	
	
	   var $sequence = $('div[class$=fadein]').hide(), div = 0;
	   (function(){
		   $($sequence[div++]).fadeIn(200, arguments.callee);
	   })();
	
	
				$('.zoom img').hover(
					function(){
						var $this = $(this);
						$this.stop().animate({'width':'210px','top':'0px','left':'0px'});
					},
					function(){
						var $this = $(this);
						$this.stop().animate({'width':'320px','top':'-32px','left':'-55px'});
					}
				);

	
	
	//$(".index-flash").delay(800).fadeIn("slow");
	$(".index-flash-closer").delay(1500).fadeIn("slow");
	$(".index-flash").delay(14000).fadeOut("slow");
	$(".index-flash-closer").click(
		function()
		{
			$(".index-flash").css( "display" , "none");	
		}
	);
	
	
	if ( typeof($().meerkat) != "undefined" )
	{
		$("#foot").meerkat({
			background: "transparent",
			height: "",
			width: "100%",
			position: "bottom",
			close: ".close-meerkat",
			dontShowAgain: ".dont-show",
			animationIn: "slide",
			animationSpeed: globaltime
		});
	}
	
	
	$(".foot-slide-other-references").delay(globaltime).animate({ top : "-105px"}, globaltime);
	$(".topslider").animate({ top : "0px"}, globaltime);
	$(".menusecond").animate({ top : "114px"}, globaltime + 50);
	
	
	$(window).bind("unload", function() {
	});
	
	$('a[href^="/"]').click(function(event){
		event.preventDefault();
		linkLocation = this.href;
		$(".topslider").animate({top : "-200px"},globaltime);
		$(".menusecond").animate({top : "-40px"},globaltime - 300);
		//$("#wraper").fadeOut(globaltime);
		$("#meerkat-wrap").animate({bottom : "-130px"},globaltime, redirectPage);	
			
	});
		
	function redirectPage() {
		window.location = linkLocation;
	}

	
	
	
	
	var submenu = $(".allreferences-sub").height() + 30 + "px"
	
	$(".allreferences").hover(
		function()
		{
			if ( ($(".allreferences").css("height") == "17px" ) && ($(".menusecond").css("top") == "114px" ))
			{
			$(".allreferences").stop().animate({ height : submenu},{duration:1000,queue:false, easing: "easeOutQuint"});
			}
		},
		function()
		{
			$(".allreferences").stop().animate({ height : "17px"},{duration:600,queue:false});
		}
	);


	$(".box210x125").hover(
		function()
		{
			if ($(".box-title", this).css("bottom") == "-21px" )
			{
			$(".box-title", this).stop().animate({ bottom : "0px"},{duration:500,queue:false, easing: "easeOutQuint"});
			}
		},
		function()
		{
			$(".box-title", this).stop().animate({ bottom : "-21px"},{duration:300,queue:false, easing: "easeInQuint"});
		}
	);







	$(".menutop-item a").hover(
		function()
		{
			if ( $(this).css("top") == "0px" )
			{
			$(this).animate({ top : "6px"},{duration:200,queue:false});
			}
		},
		function()
		{
			$(this).animate({ top : "0px"},{duration:500,queue:false});
		}
	);
	
	
	
	
	$(".i-want-read").click(
		function()
		{
			if ( $(".hidden-text-field").css("top") == "386px" )
			{
				$(".browse-big, .klienti-field").fadeOut("slow");	
				$(".hidden-text-field").animate({ top : "0px"},{duration:1000,queue:false, easing: "easeOutQuint"} );
				$(".i-want-read").fadeOut("slow");
				$(".i-dont-want-read").fadeIn("slow");	
				$(".navi").fadeOut("slow");	
				$(".box210x125").fadeOut("slow");	
				$(".rozcestnik").fadeOut("slow");	
			}
		}
	);
	$(".i-dont-want-read").click(
		function()
		{
			if ( $(".hidden-text-field").css("top") == "0px" )
			{
				$(".hidden-text-field").animate({ top : "386px"},{duration:800,queue:false, easing: "easeInQuint"});
				$(".i-dont-want-read").fadeOut("slow");	
				$(".i-want-read").fadeIn("slow");	
				$(".browse-big, .klienti-field").delay(globaltime).fadeIn("slow");	
				$(".navi").delay(globaltime).fadeIn("slow");
				$(".box210x125").fadeIn({duration:1000, easing: "easeInQuint"});
				$(".rozcestnik").fadeIn({duration:1000, easing: "easeInQuint"});	
			}
		}
	);


	$(".closefoot").delay(1500).fadeIn("slow");
	$(".closefoot").click(
		function()
		{ 
			if ( $(".foot-slide-other-references").css("top") == "-105px" )
			{
			$(".foot-slide-other-references").animate({ top : "0px"},{duration:1000,queue:false, easing: "easeOutQuint"} );
			$(".closefoot").fadeOut("slow");
			$(".openfoot").fadeIn("slow");			
			}
		}
	);
	$(".openfoot").click(
		function()
		{
			if ( $(".foot-slide-other-references").css("top") == "0px" )
			{
			$(".foot-slide-other-references").animate({ top : "-105px"},{duration:800,queue:false});
			$(".openfoot").fadeOut("slow");	
			$(".closefoot").fadeIn("slow");		
			}
		}
	);

	
		$(".scrollable").scrollable({easing: "easeOutQuint", speed: 1000, circular: false});
		
		$(".scrollable-foot").scrollable({ next: '.next-foot', prev: '.prev-foot', easing: "easeOutQuint", speed: 1000, circular: false});		

		$(".scrollable-big").scrollable({ next: '.next-big', prev: '.prev-big', easing: "easeOutQuint", speed: 1500, circular: false }).navigator({

		// select #flowtabs to be used as navigator
		navi: ".navi",

		// select A tags inside the navigator to work as items (not direct children)
		naviItem: "div.pagination",//"a",

		// assign "current" class name for the active A tag inside navigator
		activeClass: "current",

		// make browser's back button work
		history: true

		});
		
		
		// detail
		
		$(".detail-reference655x385").hover(
			
			function()
			{
				if ($(".small-detail").css("display") == "none" )
				{
				$(".small-detail").fadeIn("globaltime");
				}
			},
			function()
			{
				$(".small-detail").fadeOut("globaltime");
			}

		
		);
		
		$(".small-detail").tabs(".detail-reference655x385 > .big-detail", {
			
				// enable "cross-fading" effect
				effect: 'fade',
				fadeOutSpeed: 1000,
				fadeInSpeed: 1000,
			
				// start from the beginning after the last tab
				rotate: true
				
			
			// use the slideshow plugin. It accepts its own configuration
			}).slideshow(
			{
				autoplay: true,
				interval: 4000
			}
			);






	// time
	var now = new Date();
    var hours = now.getHours();
	var day = now.getDay();
	
    //20-7 hod
	
    if ( hours >= 20 && hours <= 24 )

    {
		
		$("body").css("background-image" , "url(/img/bg-night.jpg)");
    }

    if ( hours >= 0 && hours < 7 )

    {
		
		$("body").css("background-image" , "url(/img/bg-night.jpg)");
    }

	// víkend
	
    if ( day == 6 || day == 0 )

    {
		
		$("body").css("background-image" , "url(/img/bg-weekend.jpg)");
    }
	
	

	
	// show map
	$("#showparking").toggle(
		function()
		{
			$("#parking").fadeIn("slow");		
		},
		function()
		{
			$("#parking").fadeOut("slow");		
		}
	);

	// show map
	$("#showmap").toggle(
		function()
		{
			$("#map").fadeIn("slow");		
		},
		function()
		{
			$("#map").fadeOut("slow");		
		}
	);
	
	// show FORM
	$("#showForm").toggle(
		function()
		{				
			$(".right-textslide-image").fadeOut("slow");
			$(".kontaktfade").fadeOut("slow");
			$(".kontaktniforlumar").fadeIn("slow");	
			$(".kontaktniforlumarOdpoved").fadeIn("slow");
		},
		function()
		{
			$(".kontaktniforlumarOdpoved").fadeOut("slow");
			$(".kontaktniforlumar").fadeOut("slow");
			$(".right-textslide-image").fadeIn("slow");
			$(".kontaktfade").fadeIn("slow");
		}
	);
	
	// kontakni formular
	$('#kontaktniFormular').ajaxForm( { 
		target:'.kontaktniforlumarOdpoved'
	} ); 	

});


