(function($){$.promoHover=function($container,options){var promoHover=this;
promoHover.options=options;
promoHover.promoTimer=0;
promoHover.$currentPromo=null;
promoHover.promoHeight=null;
promoHover.margins=null;
promoHover.paddings=null;
promoHover.promoWidth=0;
promoHover.domElement=$container[0];
var $promos=$container.find(".promo"),maxHeight=0,equaliseAcrossRow=null,ie7=$.browser.msie&&$.browser.version<8?true:false;
if(promoHover.options.acrossRow){equaliseAcrossRow=true;
promoHover.rows=[];
var itemsPerRow=promoHover.options.acrossRow.itemsPerRow,rowMaxHeight=0,bottomSpacing=0
}$promos.each(function(i){var $promo=$(this);
function getButtonHeight($promo){var $button=$promo.find(".my4od-button"),buttonHeight;
$button.addClass("show");
buttonHeight=$button.outerHeight(true);
$button.removeClass("show");
buttonHeight=(buttonHeight===null)?0:buttonHeight;
return buttonHeight
}var currentHeight=$promo.find(".promo-link").outerHeight(true)+getButtonHeight($promo);
if(equaliseAcrossRow&&(currentHeight>=rowMaxHeight)){rowMaxHeight=currentHeight
}if(currentHeight>=maxHeight){maxHeight=currentHeight
}if(equaliseAcrossRow){$promo.attr("data-promoIndex",i);
if((i+1)%itemsPerRow===0||i===$promos.length-1){$promos.slice((i+1)-itemsPerRow,i+1).height(rowMaxHeight);
bottomSpacing=ie7?parseInt($promo.css("padding-bottom")):parseInt($promo.css("margin-bottom"));
promoHover.rows.push({rowHeight:rowMaxHeight,rowOuterHeight:rowMaxHeight+bottomSpacing});
rowMaxHeight=0
}}$promo.bind("mouseenter focusin",function(e){var $currentPromo=$(e.currentTarget);
if($currentPromo.hasClass("promo-fully-opened")||$currentPromo.hasClass("promo-half-opened")){}else{if(e.type==="focusin"){setTimeout(openPromo,10)
}else{openPromo()
}}function openPromo(){promoHover.$currentPromo=$currentPromo;
promoHover.openHalf();
if(options.showFullyOpened===true){promoHover.setTimer()
}}});
$promo.bind("mouseleave focusout",function(e){promoHover.closePromo(e)
})
});
if(!equaliseAcrossRow){$promos.height(maxHeight)
}promoHover.promoHeight=maxHeight;
promoHover.promoWidth=$promos.outerWidth(true);
promoHover.promoPadding=parseInt($promos.css("padding-top"))+parseInt($promos.css("padding-bottom"));
promoHover.promoMargin=parseInt($promos.css("margin-top"))+parseInt($promos.css("margin-bottom"));
promoHover.promoOuterHeight=$promos.outerHeight(true)
};
$.promoHover.prototype={closePromo:function closePromo(e){var promo=this;
if(promo.$currentPromo[0]===$(e.currentTarget)[0]){var $promo=promo.$currentPromo;
promo.clearTimer();
$promo.removeClass("promo-half-opened");
$promo.removeClass("promo-fully-opened");
$promo.css({left:"auto",top:"auto"});
if($promo.prev(".shim").css("clear")==="left"){$promo.css("clear","left")
}$promo.prev(".shim").remove();
if($.browser.msie&&$.browser.version<9){$promo.find(".promo-top").remove()
}if(promo.options.acrossRow){var rowIndex=Math.ceil((promo.$currentPromo.data("promoIndex")+1)/promo.options.acrossRow.itemsPerRow)-1;
$promo.height(promo.rows[rowIndex].rowHeight)
}else{$promo.height(promo.promoHeight)
}}},openHalf:function openHalf(){var promo=this;
promo.$currentPromo.addClass("promo-half-opened")
},openFull:function openFull(){var pos,promo=this,$promo=promo.$currentPromo,$shim,shimWidth,rowIndex=null,isOldIE=($.browser.msie&&$.browser.version<9),diffPx=(isOldIE)?10:11;
promo.clearTimer();
$promo.removeClass("promo-half-opened");
pos=$promo.position();
$promo.css({left:(pos.left-diffPx),top:(pos.top-diffPx)});
$promo.addClass("promo-fully-opened");
$promo.before("<div class='shim'/>");
if(isOldIE){shimWidth=$promo.width()
}$shim=$promo.prev(".shim");
$shim.width(promo.promoWidth).css("float","left");
if(promo.options.acrossRow){rowIndex=Math.ceil((promo.$currentPromo.data("promoIndex")+1)/promo.options.acrossRow.itemsPerRow)-1;
$shim.height(promo.rows[rowIndex].rowOuterHeight)
}else{$shim.height(promo.promoOuterHeight)
}if($promo.css("clear")==="left"){$promo.css("clear","none").prev(".shim").css("clear","left")
}$promo.css("height","auto");
if($.browser.msie&&$.browser.version<9){$promo.append('<span class="promo-top"></span>')
}},clearPromos:function clearPromos(){var $promo=null;
$(this.domElement).find(".promo").each(function(){$promo=$(this);
$promo.unbind("mouseenter focusin");
$promo.unbind("mouseleave focusout");
$promo.css("height","auto")
});
$(this.domElement).removeClass("promo-hover-instance")
},setTimer:function setTimer(){var promo=this;
promo.promoTimer=setTimeout(function(){promo.openFull()
},500)
},clearTimer:function clearTimer(){clearTimeout(this.promoTimer)
}};
$.fn.promoHover=function(options){options=options||{};
options.buttonClickEvent=options.buttonClickEvent||$.promoHover.buttonClick;
options.delay=options.delay||500;
options.rootAncestor=options.rootAncestor||"content-wrapper";
options.showFullyOpened=options.showFullyOpened||false;
options.acrossRow=options.acrossRow||false;
var newInstance=null;
C4=C4||{};
C4.promoHovers=C4.promoHovers||[];
this.each(function(){if($(this).hasClass("promo-hover-instance")===false){newInstance=new $.promoHover($(this).addClass("promo-hover-instance cf"),options);
C4.promoHovers.push(newInstance)
}});
return this
}
})(jQuery);
