﻿
$(function($){setOrderedListItemLooks();thirdItemLooks('.Teasers.RelatedArticles.DottedBorder > ul');thirdItemLooks('.Teasers.RelatedArticles.FrontPage > ul');thirdItemLooks('.Teasers.ProductLine > ul');firstRowLooks('.Teasers.RelatedArticles.FrontPage > ul');manageNumberofItems('.ImageEntryBox + .Teasers.RelatedArticles.FrontPage > ul');manageNumberofItems('.Teasers.ProductLine > ul')
manageNumberofItems('.Teasers.RelatedArticles.DottedBorder > ul');PdfListItemLooks();cloudItemsWrapp();BubbleToggleBehavior();AdjustFrontPageTeasersHeight();AdjustProductLineIntroHeight(".ProductLine.Teasers");AdjustProductLineIntroHeight(".ProductLines.Teasers");if($('#slideshow').length!=0){$('div.navigation').css({'width':'123px'});$('div#gallery').css('display','block');var onMouseOutOpacity=0.67;$('#thumbs ul.thumbs li').opacityrollover({mouseOutOpacity:1.0,mouseOverOpacity:1.0,fadeSpeed:'fast',exemptionSelector:'.selected'});var gallery=$('#thumbs').galleriffic({delay:2500,numThumbs:4,preloadAhead:10,enableTopPager:true,enableBottomPager:true,maxPagesToShow:7,imageContainerSel:'#slideshow',controlsContainerSel:'#controls',captionContainerSel:'#caption',loadingContainerSel:'#loading',renderSSControls:false,renderNavControls:true,playLinkText:'Spill',pauseLinkText:'Pause',prevLinkText:'&lsaquo; Forrige Bilde',nextLinkText:'Neste Bilde &rsaquo;',nextPageLinkText:'Next',prevPageLinkText:'Prev',enableHistory:false,autoStart:false,syncTransitions:true,defaultTransitionDuration:900,onSlideChange:function(prevIndex,nextIndex){this.find('ul.thumbs').children().eq(prevIndex).fadeTo('fast',onMouseOutOpacity).end().eq(nextIndex).fadeTo('fast',1.0);},onPageTransitionOut:function(callback){this.fadeTo('fast',0.0,callback);},onPageTransitionIn:function(){this.fadeTo('fast',1.0);},onTransitionIn:function(slide,caption,isSync){slide.fadeTo(this.getDefaultTransitionDuration(isSync),1.0);if(caption)
caption.fadeTo(this.getDefaultTransitionDuration(isSync),1.0);$("a.OpenPopup").fancybox({'autoScale':false});removeNbsps();controls=$('div#controls').detach();$('#slideshow').append(controls);},onTransitionOut:function(slide,caption,isSync,callback){slide.fadeTo(this.getDefaultTransitionDuration(isSync),0.0);if(caption)
caption.remove();}});}
fixProductLineZindex();adjust_store_info();setStoreInfoBehaviour();$(window).resize(function(){adjust_store_info();});if($('.ContactCard').size()>0){$('.FocusBox .EditorsContent').css('margin-top','22px');}});function setImagesMaxDimensions(image){var height=image.height();var width=image.width();var max_width=parseInt(image.css('max-width').replace("px",""));var max_height=parseInt(image.css('max-height').replace("px",""));if(width==max_width)width=image.attr("width");if(height==max_height)height=image.attr("height");if(width>=height){if(width>max_width)image.css({'width':max_width+'px','height':height*max_width/width+'px'});}else{if(height>max_height)image.css({'height':max_height+'px','width':width*max_height/height+'px'});}}
function removeNbsps(){$('.advance-link').each(function(){$(this).html($(this).html().replace(/(&nbsp;)*/g,""));});}
function getDocHeight(){var D=document;return Math.max(Math.max(D.body.scrollHeight,D.documentElement.scrollHeight),Math.max(D.body.offsetHeight,D.documentElement.offsetHeight),Math.max(D.body.clientHeight,D.documentElement.clientHeight));}
function centerPrintButton(){var printButton=$("#fancybox-frame").contents().find(".PrintButton");printButton.css('left',($("#fancybox-frame").contents().find(".Content").outerWidth()-printButton.outerWidth())/2+'px');}
function adjust_store_info(){var store_info=$('.StoreInfo').first().detach();store_info.appendTo("body");store_info.css("left",($('.Select').offset().left+20)+'px');}
function setStoreInfoBehaviour(){$('.Select, .StoreInfo').hover(function(){$('.StoreInfo').show();$('.Select').addClass('Active');},function(){$('.StoreInfo').hide();$('.Select').removeClass('Active');});}
function BubbleToggleBehavior(){if($('.Bubble').length){$('.ListWithTooltips li, .BubbleHandler, .LocalStoreBox li').hover(function(){bubble=$(this);setTimeout(function(){bubble.children(".Bubble").first().css('behavior','url(/Content/Styles/PIE.htc)')},10);hideBadge();},function(){bubble=$(this);setTimeout(function(){bubble.children(".Bubble").first().css('behavior','none')},10);showBadge();});}}
function hideBadge(){badge=$('.FocusImageWrapper .Badge').first();if(badge.length){badge.css('z-index','1');}}
function showBadge(){badge=$('.FocusImageWrapper .Badge');if(badge.length){badge.css('z-index','500');}}
function setOrderedListItemLooks(){if($('.EditorsContent ol li').length)$('.EditorsContent ol li').wrapInner('<p/>');}
function fixProductLineZindex(){badges=$('.Teasers.ProductLine .Badge');if(badges.length>0){$.each(badges,function(){$(this).closest('ul').css('z-index','0');$(this).closest('li').css('z-index','2');$(this).closest('.ImageWrapper').css('z-index','3');$(this).css('z-index','100');$('h1').hide().show();});}}
function thirdArticleLooks(){thirdItemLooks('#Articles');}
function thirdItemLooks(selector){if($(selector).length){var items=$(selector+' > li');for(var i=2;i<items.length;i+=3){$(items[i]).css('padding-right',0);}}}
function firstRowLooks(selector){if($(selector).length){var items=$(selector+' > li');for(var i=0;i<3;i+=1){$(items[i]).css('background','none');}}}
function manageNumberofItems(selector){if($(selector).length){var items=$(selector+' > li');lis=3-(items.length%3);if(lis!=3){for(i=0;i<lis;i+=1){$(selector).append('<li>');}}}}
function PdfListItemLooks(){var thumbs=$('.ItemThumbnail.PDF');if(thumbs.length){for(var i=0;i<thumbs.length;i+=1){$(thumbs[i]).parent().css('padding-bottom','26px');}}}
function AdjustFrontPageTeasersHeight(){var headers,teasers_divs;if((teasers_divs=$(".FrontPage.Teasers")).length){teasers_divs.each(function(index,div){headers=$(div).find("li strong");for(var i=0;i<headers.length;i+=3){var current_headers=new Array();for(var j=0;j<3;j++){var header=headers[i+j];if(header)current_headers.push(header);}
var heights=jQuery.map(current_headers,function(header,index){return $(header).height();});var max_height=Math.max.apply(null,heights)
$(current_headers).each(function(h_index,header){$(header).height(max_height);});}});}}
function AdjustProductLineIntroHeight(selector){var intros,teasers_divs;if((teasers_divs=$(selector)).length){teasers_divs.each(function(index,div){intros=$(div).find("p.TipIntro");for(var i=0;i<intros.length;i+=3){var current_intros=new Array();for(var j=0;j<3;j++){var intro=intros[i+j];if(intro)current_intros.push(intro);}
var heights=jQuery.map(current_intros,function(intro,index){return $(intro).height();});var max_height=Math.max.apply(null,heights)
$(current_intros).each(function(h_index,intro){$(intro).height(max_height);});}});}
$(window).load(function(){positionFooter();});function positionFooter(){var content_height=$('.Header').outerHeight()+$('.Content').outerHeight();var footer_height=$('.FooterWrapper').outerHeight();if(content_height+footer_height<$(window).height()){$(".FooterWrapper").css({position:"absolute",left:"0",right:"0",top:($(window).scrollTop()+$(window).height()-footer_height-20)+"px"})}}
$(window).resize(positionFooter)}
function cloudItemsWrapp(){var container_width=$('.cloud').width();var cloud_items=$('.cloud a');for(i=0;i<cloud_items.size();i+=1){if($(cloud_items[i]).width()>container_width){$(cloud_items[i]).css('white-space','normal');}}}
