$(document).ready(function(){
	
  /******************************************************************************************************/
  var IE7 = ($.browser.msie && $.browser.version.slice(0,1) == "7");
  // when the startsite-page is loaded
  var zIndexNumber = 95;
  $('.tx-npstartsitetemplates-pi2').css('z-index','100');
  $('.tx-npstartsitetemplates-pi2 div').each(function() {
	$(this).css('zIndex', zIndexNumber);
	zIndexNumber -= 5;
  });
  $('.template_link').css('zIndex', '94');
  /******************************************************************************************************/
	
  /******************************************************************************************************/
  // set first container to visible and animate all elements
  var firstTabId = $(".st_startsite_content").first().attr('uid'); 
  $("#st_startsite_content_"+firstTabId).removeClass("st_cont_hidden");
  // ------------ Folie 1 -----------------------------------
  $("#st_startsite_background_image_"+firstTabId).show();
  $("#st_startsite_packshot1_image_"+firstTabId).show();
  $("#st_startsite_content_text1_"+firstTabId).show();
  $('#template_link_'+firstTabId).show(); // activate div for link on top of all

  // IE7-Weiche
  if(IE7){
	  // ######################## IE7 ##############################
	  // ------------ Folie 2 -----------------------------------
	  $(document).oneTime("3s", "startsitetemplate_1", function() {
		  $("#st_startsite_content_text1_"+firstTabId).hide();
		  $("#st_startsite_content_text2_"+firstTabId).show();
		  $("#st_startsite_packshot1_image_"+firstTabId).hide();
		  $("#st_startsite_packshot2_image_"+firstTabId).show();
		  // ------------ Folie 3 -----------------------------------
		  $(document).oneTime("3s", "startsitetemplate_2", function() {
			  $("#st_startsite_content_text2_"+firstTabId).hide();
			  $("#st_startsite_content_text3_"+firstTabId).show();
			  $("#st_startsite_addpic_image_"+firstTabId).show();
			  $("#st_startsite_packshot3_image_"+firstTabId).show();
		  });
	  });
  }else{
	  // ######################## alle anderen Browser ;) ##############################
	  // ------------ Folie 2 -----------------------------------
	  $(document).oneTime("2s", "startsitetemplate_1", function() {
		  $("#st_startsite_content_text1_"+firstTabId).fadeOut(2000);
		  $("#st_startsite_content_text2_"+firstTabId).fadeIn(2000);
		  $("#st_startsite_packshot1_image_"+firstTabId).animate({
			    opacity: 0.5,
			    left: '-=0',
			    height: '400',
			    top: '+=100'
			  }, 1800, function() {
				$("#st_startsite_packshot1_image_"+firstTabId).hide();
		   });
			$("#st_startsite_packshot2_image_"+firstTabId).fadeIn(4000, function(){
				  // ------------ Folie 3 -----------------------------------
				  $(document).oneTime("1s", "startsitetemplate_2", function() {
					  $("#st_startsite_content_text2_"+firstTabId).fadeOut(2000);
					  $("#st_startsite_content_text3_"+firstTabId).fadeIn(2000);
					  $("#st_startsite_packshot3_image_"+firstTabId).fadeIn(1000, function(){
						  $("#st_startsite_addpic_image_"+firstTabId).fadeIn(1000);
					  });
				  });
			});
	  });
  }
  /******************************************************************************************************/
  
  
  
  
  /******************************************************************************************************/
  // register eventhandler for klicking on link-div
  $('.st_startsite_content').click(function(){
	  var linkurl = $(this).attr('linkurl');
	  $(location).attr('href', $(location).attr('protocol')+'//'+$(location).attr('hostname')+'/'+linkurl);
  });
  /******************************************************************************************************/
  
});
