// Reference count
var refCount = 20; // Add content GA tracking below

	  $(".logo").ready(function()
	  {
		  $(".logo").animate({ opacity: "1",}, {queue:false, duration:1000, easing:"expoEaseInOut"});
	  })
	  
	  $("#contact").ready(function()
	  {
		  $("#contact").animate({ opacity: "1",}, {queue:false, duration:1000, easing:"expoEaseInOut"});
	  })
	  
	  $(".refListItem").ready(function()
	  {
		  var i = 0;
		  $(".refListItem").each(function()
		  {
			  $(this).delay((i * 100) + 800).animate({ opacity: "1",}, {queue:true, duration:1000, easing:"expoEaseInOut"}); 
			  i++;
		  })
		
	  })
	  
	  $("#footer").ready(function(){
		  $("#footer").delay(2000).animate({ bottom: "0",}, {queue:false, duration:1000, easing:"expoEaseInOut", complete:function(){
		  	$(document.body).css('overflow-y', "auto");
		  }});
	  })
	  
	  $("#social").ready(function()
	  {
		  $("#social").delay(1000).animate({ opacity: "1",}, {queue:true, duration:1000, easing:"expoEaseInOut"});
		  
		  
		    $('.refListItem').mouseover(function() {

			pageTracker._trackPageview("Mouse over refListItem");				
				
   $(this).animate({ opacity: "0.8",}, {queue:false, duration:100, easing:"expoEaseInOut"});
  });
  
	  $('.refListItem').mouseout(function() {
   $(this).animate({ opacity: "1",}, {queue:false, duration:100, easing:"expoEaseInOut"});
  });		
		  
		 
		  
	  })
	  
	  
	  var currentPage = 0;
	  function loadPage(val)
	  {	
  
  		  // content GA tracking	
		  if (val == 20) { pageTracker._trackPageview("View of reference: Valibov e-eshop"); }
		  if (val == 19) { pageTracker._trackPageview("View of reference: TV Praha 8"); }
		  if (val == 18) { pageTracker._trackPageview("View of reference: To byl náš hit Microsite Webdesign"); }
		  if (val == 17) { pageTracker._trackPageview("View of reference: Mad Apple Webdesign"); }
		  if (val == 16) { pageTracker._trackPageview("View of reference: Unigram Webdesign"); }
		  if (val == 15) { pageTracker._trackPageview("View of reference: TV Barrandov Stream App"); }
		  if (val == 14) { pageTracker._trackPageview("View of reference: TV Barrandov Videostop App"); }
		  if (val == 13) { pageTracker._trackPageview("View of reference: Radiographic Atlas App"); }
		  if (val == 12) { pageTracker._trackPageview("View of reference: TV Barrandov Webdesign"); }
		  if (val == 11) { pageTracker._trackPageview("View of reference: TV Barrandov Microsite – Nikdy neříkej nikdy"); }
		  if (val == 10) { pageTracker._trackPageview("View of reference: Spacetap App"); }
		  if (val == 9)  { pageTracker._trackPageview("View of reference: TV Barrandov Animáček Pexeso App"); }
		  if (val == 8)  { pageTracker._trackPageview("View of reference: Natty Apps Webdesign"); }
		  if (val == 7)  { pageTracker._trackPageview("View of reference: Kill The Internet Explorer Project"); }
		  if (val == 6)  { pageTracker._trackPageview("View of reference: Arcana Webdesign"); }
		  if (val == 5)  { pageTracker._trackPageview("View of reference: Metropolis Webdesign"); }
		  if (val == 4)  { pageTracker._trackPageview("View of reference: Havana Restaurant Webdesign"); }
		  if (val == 3)  { pageTracker._trackPageview("View of reference: L'Oréal Careers Webdesign"); }
		  if (val == 2)  { pageTracker._trackPageview("View of reference: HiddenSMS Webdesign"); }
		  if (val == 1)  { pageTracker._trackPageview("View of reference: Autodíly Kluci Webdesign"); }
		
		  
		  if (val == 1){
				$(".goNext").css('display', "none");	
				
			  }
			  else
			  {
				   $(".goNext").css('display', "inline");	
				  }
				  
				  if (val == refCount){
				$(".goPrev").css('display', "none");	
			  }
			  else
			  {
				   $(".goPrev").css('display', "inline");	
				  }
	  
			  currentPage = val;
			  
			  $("#content").stop();
			  $("#contentHolder").stop();
			  $("#refList").stop();
			  $("#icon").stop();
			   $("#icon1").stop();
			  $("#navigation").stop();
			  $(".loader").delay(700).animate({ opacity: "1" }, {queue:true, duration:800, easing:"expoEaseOut"});
			  $("#content").animate({ opacity: "0" }, {queue:false, duration:500, easing:"expoEaseOut"});
			  $(".homeInfo").animate({ opacity: "0" }, {queue:false, duration:1000, easing:"expoEaseOut"});
			  $("#icon").css('display', "none");
			   $("#icon1").css('display', "none");
			   $(document.body).css('overflow-y', "hidden");
			  $("#contentHolder").empty();
			  $("#contentHolder").append('<div id="content"><img class="contentImage" src="img/ref-detail'+val+'.jpg" alt="Detail Reference Petr Ondrusz Design Portfolio" /><a id="icon1" onclick="goPrev()"></a><a id="icon" onclick="goNext()"></a></div>')
					  
			  $("#contentHolder").ready(function()
			  {
				  $("#contentHolder").delay(1000).animate({ left: "0px" }, {queue:false, duration:1000, easing:"expoEaseInOut"}); 
				  
				  $("#refList").delay(1000).animate({ left: "-3000px" },{queue:false, duration:1000, easing:"expoEaseInOut", complete:function(){
					  $("#refList").css('display', "none");
					  show();
				  }});
			  }); 	
	  
	  }
	  
	  
	  var cPage = 0;
	  function goNext(){
		  
		  pageTracker._trackPageview("Show next item"); 
		  
		  if (currentPage !=1)
		  {
			  $('.ref'+currentPage).animate({ opacity: "0" }, {queue:false, duration:500, easing:"expoEaseInOut"});
		  cPage = currentPage-1;
		  loadPage (cPage);
		  }
		  }
		  
		  var nPage = 0;
		  function goPrev(){
			  
		  pageTracker._trackPageview("Show previous item"); 
		  
		  if (currentPage !=refCount)
		  {
			  $('.ref'+currentPage).animate({ opacity: "0" }, {queue:false, duration:500, easing:"expoEaseInOut"});
		  nPage = currentPage+1;
		  loadPage (nPage);
		  }
		  
		  }
		  
  
	  var i = 0;
	  function showContact()
	  {
		  pageTracker._trackPageview("Show contact");
		  
		  if (i == 1)
		  {
			  $(".contactInfo").animate({ opacity: "0",}, {queue:false, duration:500, easing:"expoEaseInOut"});
			  i = 0;
			  }
			  
			  else
			  {
			  $(".contactInfo").animate({ opacity: "1",}, {queue:false, duration:500, easing:"expoEaseInOut"});
			  i = 1;
			  }
		  }
	  // content management
	  function show()
	  {
		  $("#content").stop();
		  $("#controls").stop();
		  $("#icon").stop();
		  $(".loader").animate({ opacity: "0" }, {queue:true, duration:500, easing:"expoEaseOut"});
		  window.scrollTo(0, 0);
		 
		 
				  
		  $("#content").ready(function()
		  {
			  getSize();
			  resizeMe();
			  $("#content").delay(500).animate({ opacity: "1",}, {queue:true, duration:1000, easing:"expoEaseInOut"});
			  
			  $('.ref'+currentPage).delay(1000).animate({ opacity: "1" }, {queue:true, duration:1000, easing:"expoEaseOut"});
		  
		  			 if (currentPage == 1)
		  {
			  	$("#icon").css('display', "none");	
			  }
				 else
				 {
					  $("#icon").css('display', "block");
					    bindIcons();
					 }
					 
					 
		  			 if (currentPage == refCount)
		  {
			  	$("#icon1").css('display', "none");	
			  }
				 else
				 {
					  $("#icon1").css('display', "block");
					    bindIcons1();
					 }
				
		  })
		  $('#navigation').delay(1000).animate({ opacity: "1"}, {queue:false, duration:1000, easing:"expoEaseOut"});
	  }
	  
	  
	  function bindIcons(){
			  $('#icon').mouseover(function() {
   $("#icon").animate({ opacity: "1",}, {queue:false, duration:100, easing:"expoEaseInOut"});
  });
  
	  $('#icon').mouseout(function() {
   $("#icon").animate({ opacity: "0",}, {queue:false, duration:100, easing:"expoEaseInOut"});
  });		
		  }
		  
		   function bindIcons1(){
			  $('#icon1').mouseover(function() {
   $("#icon1").animate({ opacity: "1",}, {queue:false, duration:100, easing:"expoEaseInOut"});
  });
  
	  $('#icon1').mouseout(function() {
   $("#icon1").animate({ opacity: "0",}, {queue:false, duration:100, easing:"expoEaseInOut"});
  });		
		  }
	  
	  function closePage()
	  {	
	  	
		pageTracker._trackPageview("Close page");
	  
		  $('.ref'+currentPage).animate({ opacity: "0" }, {queue:false, duration:1000, easing:"expoEaseOut"});
		  currentPage = 0;
		  $("#content").stop();
		  $("#navigation").stop();
		  $("#contentHolder").stop();
		  $("#refList").stop();
		  $("#refList").css('display', "block");
		  $("#icon").css('display', "none");  
		   $("#icon1").css('display', "none");  
		  $("#content").animate({ opacity: "0" }, {queue:false, duration:1000, easing:"expoEaseInOut"});
		  $('#navigation').animate({ opacity: "0", right: "-8px" }, {queue:false, duration:1000, easing:"expoEaseInOut"});
		  $("#contentHolder").animate({ left: "3000px",}, {queue:false, duration:1000, easing:"expoEaseInOut"});
		  $(".homeInfo").delay(1000).animate({ opacity: "1" }, {queue:true, duration:1000, easing:"expoEaseOut"});
		  $("#refList").animate({ left: "0px" }, {queue:false, duration:1000, easing:"expoEaseInOut", complete:function(){
			    $(document.body).css('overflow-y', "auto");}
});
		  
		

	  }
  
	  // resize content
	  $(window).resize(function()
	  {
		  resizeMe();
	  });
	  
	  $(".loader").ready(function()
	  { 
		  resizeMe();
	  });
	  
	  var curWidth;
	  var curHeight;
	  
	  function getSize()
	  {
		  curWidth = $(".contentImage").width();
		  curHeight = $(".contentImage").height();
	  }
		
	  function resizeMe()
	  {
		  var myWidth = $(window).width();
		  var myHeight = $(window).height();
		  
		  nuScale = (myHeight - 218) / curHeight;
		  
		   pageTracker._trackPageview("Resize window");
		  
		  var nuWidth = curWidth * nuScale;
		  var nuHeight = curHeight * nuScale;
		  var myLeft = (myWidth - nuWidth) / 2;
		  var myTop = ((myHeight - 218) - nuHeight) / 2;
		  
		  var contentWidth = $("#content").width();
		  
		  if(nuWidth > contentWidth)
		  {
			  nuScale = (myWidth - 100) / nuWidth;
			  
			  nuWidth = nuWidth * nuScale;
			  nuHeight = nuHeight * nuScale;
			  myTop = ((myHeight - 218) - nuHeight) / 2;
		  }
			  
		  $(".contentImage").animate({ width: nuWidth, height: nuHeight, top: myTop}, 0);
		  $("#icon1").animate({width: nuWidth/2, height: nuHeight, top: myTop, left: ((contentWidth  / 2) - nuWidth)+(nuWidth/2)}, 0);
		  $("#icon").animate({width: nuWidth/2, height: nuHeight, top: myTop, left: ((contentWidth  / 2) - nuWidth)+(nuWidth)}, 0);
		  $(".loader").animate({ top: (myHeight / 2) - 12, left: (myWidth / 2) -4}, 0);
	  }
	  
  
  
	
