// CUSTOM VERSION FOR DNV

// Image strip kiosk script
// iPressroom (c) 2009-2010
// v 1.7.0

// switch content for strip kiosks
function switchContent () {
 var kiosk = $(this).parents(".imageStrip");
 $(".newsBody-active", kiosk).empty();
 $(".newsBody-active", kiosk).append("<div id='pr-media"+stripCounter+"'></div>");

 // get embed script and run it with new placement id
 var s = $(this).parents(".newsBody").find("script").html().replace(/(mediaspace|playerpagePlayer)\d+/gi, "pr-media"+stripCounter++);
 eval(s);
 
 $(".newsImageSmall a", kiosk).removeClass("active");
 $(this).addClass("active");

 // show video title in special tooltip        
 var s = $(this).parents(".newsBody").children("span").html();
 if (s) {
  $(".titleHolder", kiosk).show().html(s)
 }
 else {
  $("span", this).hide();       
  $(".titleHolder", kiosk).hide();
 }

 return false;
};



// bind events for strip kiosks
function bindKioskStrip() {
 var active;
 window.stripCounter = 0; // build unique ids for embeding
 
 $(".imageStrip").each(function() {
  var links = $(".newsImageSmall a", this);
  links.click(function(){
  	switchContent.call(this);
	  active = $(this);
    return false;
  });
  
  // activate first element
  if (links.length > 0) 
   switchContent.call(links[0]);
  
  // hide for single image
  //  if (links.length == 1)
  //   $("ul", this).hide();
   
  // colorbox option
  if ($(this).hasClass("imageStrip-colorbox"))
   $(".newsBody a", this).not(".newsImageSmall a").colorbox();
   
   
   //custom code
	links.mouseenter(function(){
		var kiosk = $(this).parents(".imageStrip");
		var s = $(this).parents(".newsBody").children("span").html();
		 if (s) {
		  $(".titleHolder", kiosk).show().html(s)
		 }
		 else {
		  $("span", this).hide();       
		  $(".titleHolder", kiosk).hide();
		 }
	}).mouseleave(function(){
		var kiosk = $(this).parents(".imageStrip");
		var s = active.parents(".newsBody").children("span").html();
		 if (s) {
		  $(".titleHolder", kiosk).show().html(s)
		 }
		 else {
		  $("span", this).hide();       
		  $(".titleHolder", kiosk).hide();
		 }
	})
	
	active = links.filter('.active')
 });
};

$(function() {
 bindKioskStrip();
});

