cycleFeatured=typeof mainVideos=="undefined"&&!window.location.hash||isArchive?false:true;captionPos=77;
$(function(){setElementSizes("fade");isPlaying=false;if(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i))window.location="http://m.sebyen.no";else swfobject.hasFlashPlayerVersion("9")||$("#videoBox").html("<div id='noflash'><p>Du m\u00e5 installere <a href='http://get.adobe.com/flashplayer/' rel='external'>Flash Player 9 eller h\u00f8yere</a> for \u00e5 se video p\u00e5 SeByen.<br><br>En utgave som ikke benytter seg av Flash, og som fungerer p\u00e5 mobiltelefoner og andre enheter, kommer i l\u00f8pet av 2010.</p><p><a href='http://m.sebyen.no'>G\u00e5 tilmobilutgaven</a></p></div>");$(window).bind("hashchange",
function(){var a=$.param.fragment();if(isArchive){if(a){$("#videosNextArchive").show();loadArchiveVideos(1,null,a)}}else if(a)if(a.search("/")==-1){loadVideosBottom("#"+a);shuffleImg();isPlaying||$("#videoPreview").fadeIn()}else{cycleFeatured&&$("#videoPreview").is(":visible")&&clearInterval(cycleID);pageTracker._trackPageview(a);loadVideo(null,true);shuffleImg()}else{loadVideosSide(false);$("#videoPreview").fadeIn();$("#featuredLoader,#video,#videoAd").hide()}});$(window).trigger("hashchange");defaultTitle=
"SeByen.no";numFeaturedSideVideos=2;siteurlWithTrailing=RegExp(siteUrl+"/","g");theVideoAd=$("#videoAd");var b='<a href="'+$(".videoPlayLink").attr("href")+'" id="videoPlay"><img src="'+templateDir+'/images/play.png" alt="" width="80" height="90"></a>';$("#videoPreview").append(b);$("#featuredWrap").is(":hidden")&&!window.location.hash&&$("#featuredWrap").show();$("#helplink").click(function(){showHelp();return false});if(cycleFeatured){if(mainVideosNum>1){cycleID=setInterval("cycleMainFeatured()",
5E3);$("#videoPreview img.mainImage").each(function(){$(this).load()})}else $("#videoNextPrevious").hide();$("#videoNextPrevious").click(function(a){$(a.target).attr("id")=="videoPrevious"?cycleMainFeatured("prev"):cycleMainFeatured();clearInterval(cycleID);return false})}if($.browser.msie&&$.browser.version==6){$("body").append('<div id="iemsg">Du bruker en eldre nettleser. Vi kan ikke garantere at SeByen fungerer optimalt. <a href="http://www.microsoft.com/norge/windows/internet-explorer/default.aspx">Vennligst oppgrader</a>.</div>');
$("#logo img,#videoPlay img,a.toArchive,#videosPrevNext a,#featuredSide img").ifixpng()}numVideosBottom=$(".featuredVideo",$("#featuredBottom")).length;$("#videosPrevNext").click(function(a){a=$(a.target).attr("id");scrollFeatured(a=="videosNext"?"right":a=="videosPrev"?"left":"start");return false});$("#s").autocomplete(templateDir+"/search_autocomplete.php",{minChars:2,matchSubset:0,matchContains:1,cacheLength:1,onItemSelect:selectItem,formatItem:formatItem,selectOnly:1});$("#s").addClass("idleField");
$("#s").focus(function(){$(this).removeClass("idleField").addClass("focusField");if(this.value==this.defaultValue)this.value="";this.value!=this.defaultValue&&this.select()}).blur(function(){$(this).removeClass("focusField").addClass("idleField");if(this.value=="")this.value=this.defaultValue?this.defaultValue:""});$("#search").submit(function(){return false})});scrolledNum=0;
function shuffleImg(b){var a=$("a.miniArchive img").length,c=$("#videosArchive img.img"+Math.floor(Math.random()*a+1));a=$("#videosArchive img:visible");if(c.attr("class")!=a.attr("class")||b)a.fadeOut("slow",function(){b?$("#videosArchive img.img1").fadeIn("fast"):c.fadeIn("fast")});return true}
function scrollFeatured(b){$("#videosArchive img.imgSebyen");var a=false,c=$("#featuredBottom div.wrapper"),e=$("#videosPrev,#videosPrevFade"),f=$("#videosNext,#videosNextFade"),g=$("#videosStart"),d=false;if(scrolledNum==2&&b=="left"||b=="start"){$.browser.msie?e.hide():e.fadeOut("fast");g.hide()}else if(scrolledNum>=numVideosBottom-6&&b=="right"){$.browser.msie?f.hide():f.fadeOut("fast");shuffleImg("atEnd");d=a=true}a||shuffleImg();a=featuredBottomVideosWidth*2+8;switch(b){case "right":var h="+="+
a;e.css("filter","alpha(opacity=0)").fadeIn();break;case "left":h="-="+a;f.css("filter","alpha(opacity=0)").fadeIn();break;case "start":h="0";$.browser.msie?e.hide():e.fadeOut("fast");f.show();g.hide();break}c.filter(":not(:animated)").animate({scrollLeft:h},800,function(){switch(b){case "right":scrolledNum+=2;scrolledNum>2&&g.show();break;case "left":scrolledNum-=2;break;case "start":scrolledNum=0;break}})}
function resize_viewport(){$.event.remove(this,"resize",setElementSizes);$.event.add(this,"resize",setElementSizes)}resize_viewport();
function setElementSizes(b){if(isArchive){$("#archiveContent");$("#archiveVideos");f=$(window).width();g=$(window).height()-195;$.trim($("#archiveVideos").text());initBinding();if($("#navAbout").length){g=g>450?450:g;f<1020?$("#archive").addClass("smaller"):$("#archive").removeClass("smaller")}else g=$(window).height()-140;firstScreen=scrolledTo=null;loadArchiveVideos(1,null,null);$("#videosPrevNextArchive,div a.clickme").live("click",function(l){l=$(l.target);var n=l.attr("id"),o=parseInt($("#offset").text());
if(!l.hasClass("clickme"))return false;$(l).removeClass("clickme");$("div.screen").fadeOut("fast",function(){$("#featuredLoaderMain").show()});if(n=="screenTop"){$("#videosNextArchive").show();$("#videosPrevArchive").hide();var m=1}else if(n=="videosNextArchive"){m=o+1;$("#videosPrevArchive").show();m==totalScreens&&$("#videosNextArchive").hide()}else if(n=="videosPrevArchive"){m=o-1;$("#videosNextArchive").show();m==1&&$("#videosPrevArchive").hide()}loadArchiveVideos(m,l,null);return false});$("div.archiveCatogories a").bind("click",
function(){$("div.archiveCatogories div").removeClass("selected");$(this).parent().addClass("selected")})}else{var a=$("#featuredBottom"),c=$("#featuredSide"),e=$("#ad-top"),f=$(window).width(),g=$(window).height()-120;maxVideoHeight=350;var d=4;if(g>739)g=739;else if(g<330)g=330;f=180;videoHeight=Math.round(g*0.73);videoWidth=Math.ceil(videoHeight*1.764);featuredSideHeight=videoHeight-200;g=(videoHeight-300)/2;var h=videoWidth+327,i=h-75,j=videoHeight+8,k=i-17-218;featuredBottomVideosWidth=Math.round((k-
23)/4);featuredBottomVideosHeight=Math.round(featuredBottomVideosWidth/1.764);videoHeight<450&&videoHeight>360?$("#featuredWrap").addClass("smaller"):$("#featuredWrap").removeClass("smaller");if(videoHeight<400){featuredBottomVideosWidth=Math.round(k/3);var p="none";numFeaturedSideVideos=2;d=3;if(videoHeight<320){$("#interact").addClass("noText small");tooltip();f=120}else if(videoHeight<360){$("#interact").addClass("noText");$("#interact").removeClass("small");tooltip();f=153}else{$("#interact").removeClass("noText small");
f=180}$("li.featuredVideo",a).length==4&&$("li.featuredVideo:last-child",a).hide()}else{$("li.featuredVideo.video4:hidden",a).show();$("#interact").removeClass("noText");f=180;numFeaturedSideVideos=3;d=4;p="block"}$.cookie("numVideos",d,{expires:7,path:"/",domain:"sebyen.no",secure:false});if(window.location.hash.search("/")!==-1)if(featuredSideHeight<190){numFeaturedSideVideos=1;featuredSideVideosHeight=featuredSideHeight/numFeaturedSideVideos-20;$("div.video2:visible,div.video3:visible",c).hide()}else{numFeaturedSideVideos=
2;featuredSideVideosHeight=featuredSideHeight/numFeaturedSideVideos-25}else featuredSideVideosHeight=videoHeight/numFeaturedSideVideos-48;if(featuredBottomVideosHeight>114)featuredBottomVideosHeight=114;if(featuredSideVideosHeight>100)featuredSideVideosHeight=100;embedOrObject=$.browser.msie?"object":"embed";a=$(embedOrObject,e).attr("width");c=$(embedOrObject,e).attr("height");if(a==undefined){embedOrObject="img";a=$("img",e).attr("width");c=$("img",e).attr("height")}d=Math.round(a/c*100)/100;a=
(adWidth=h-420)>a?a:adWidth;c=(adHeight=Math.round(adWidth/d))>c?c:adHeight;d=(marginTop=75-c)/2>0?marginTop:0;h<1140?e.css("text-align","right").width("auto"):e.css({"text-align":"center","margin:":"auto"}).width("768px");if(c>110){c=110;a=568}$(embedOrObject,e).width(a+"px").height(c+"px").css("margin-top",d+"px");$("#wrap,header").width(h+"px");$("#net").width(h-200+"px");$("#logo").width(h-a-260+"px");$("#videoBox").width(videoWidth+"px").height(videoHeight+"px");$.browser.msie&&$.browser.version==
7||$("#interact").css({top:"50%","margin-top":-f+"px"});$(".videoOverlay").width(videoWidth-20+"px");$(".videoOverlay p").width(videoWidth-210+"px");$("#featured").height(j+"px");$("#videos").width(i+"px").height(featuredBottomVideosHeight+40+"px");$("#featuredWrap").width(k+"px");$("#generatedStyle").remove();$("div.videoCaption").css("top","");$("head").append('<style id="generatedStyle">#featuredBottom .featuredVideo {width: '+featuredBottomVideosWidth+"px;} #featuredBottom .featuredBox,#videosMore ul {height: "+
featuredBottomVideosHeight+"px;} #featuredBottom .videoCaption{top: "+(featuredBottomVideosHeight-23)+"px;}#featuredSide .featuredBox{height: "+featuredSideVideosHeight+"px;}#featuredSide .videoCaption{top: "+(featuredSideVideosHeight-23)+"px;}#featuredSide {height: "+(j+14)+"px;}#featuredSide .video3 {display: "+p+"}#videoAdAfterInside {margin-top: "+g+"px}</style>");$("#featuredBottom div.wrapper").show()}b==="fade"&&$("#wrap").css("visibility","visible")}
function loadArchiveVideos(b,a,c){$("div.screen").hide();c||(c=$.param.fragment());if(c&&c!="alle"&&c!="#"){switch(c){case "aktuelt":c=5;break;case "sport":c=6;break;case "kultur":c=7;break;case "serier":c=13;break;default:c=null}b+="&cat="+c}var e=b;totalScreens=1;$("#archiveVideos").load(templateDir+"/archiveContent.php?offset="+b,function(){$("#featuredLoaderMain").hide();$("#offset").text(parseInt(e));$("div.screen:hidden").fadeIn("slow",function(){a&&a.addClass("clickme");totalScreens=parseInt($("#totalScreens").text());
initBinding()})})}$("#interact a").bind("click",function(){var b=$(this),a=b.parent().attr("id");showOverlay(a);b.addClass("selected");return false});$("a.playAgain").live("click",function(){var b=$("div.playingPic a").attr("href");if(b.search("http")!==-1)b=b.replace(siteUrl+"/","");loadVideo(b,false);return false});
function srbankPlay(){window.open("https://designer.tagmycard.com/testing/sparebank1.aspx?bankId=33&hash=E5A618C91F0768316FEEDF4C26B34E1221A6F0BB712DB2248FB63DBB25F6877DAFFE39062CB724044FA4BC82CDD5AC9DE4041D066E8038D3C7FB592C7E79005C","srbankDesign","status=0,menubar=0,resizable=0,width=742,height=550,scrollbars=0,top=10,left=100")}$("#tippContent a.tippIt").live("click",function(){$(this).fadeOut("fast",function(){$("#tippekonk").fadeIn()});return false});
$("a.tippBack").live("click",function(){$("#tippekonk").fadeOut("fast",function(){$("#tippContent a.tippIt").fadeIn()});return false});
$("#tippTipp").bind("submit",function(){if($("#email").val()==""||$("#res").val()==""){alert("Du m\u00e5 fylle inn e-postadressen din og skrive inn et resultat");return false}else{var b=$("input#email"),a=$("input#res"),c=$("input[name=uke]"),e=$("input#reminder:checked").length;b="email="+b.val()+"&uke="+c.val()+"&res="+a.val()+"&reminder="+e;$("#formLoader").fadeIn();$.ajax({url:this.action,type:"POST",data:b,cache:false,success:function(f){if(f==1)$("#tippTipp").fadeOut("fast",function(){$("#quizSvart").fadeIn();
$("#formLoader").hide()});else{$("#formLoader").hide();alert(f)}},error:function(f){$("#formLoader").hide();alert("En feil oppstod."+f)}})}return false});$("#srbankPlay").live("click",function(){srbankPlay();return false});
$("#srbankForm").bind("submit",function(){if($("#srbankEmail").val()==""||$("input#srbankName").val()==""||$("input#srbankPhone").val()==""){alert("Du m\u00e5 fylle inn alle feltene for \u00e5 bli med i trekningen av en iPad");return false}else{srbankPlay();var b="email="+$("input#srbankEmail").val()+"&name="+$("input#srbankName").val()+"&phone="+$("input#srbankPhone").val();$("input.srbankButton").val("Vent...").addClass("disabled");$.ajax({url:siteUrl+"/srbank-design/store_email.php",type:"POST",
data:b,cache:false,success:function(a){if(a==1)$("#srbankInside").fadeOut("fast",function(){$("#srbankHarSpilt").fadeIn("fast")});else{$("#formLoader").hide();alert(a)}},error:function(a){alert("En feil oppstod."+a)}})}return false});
function tooltip(){xOffset=10;yOffset=30;$(".tooltip").live("mouseover",function(b){if(this.title!=""){this.t=this.title;this.title="";if(this.t!="undefined"){$("body").append("<p id='tooltip'>"+this.t+"</p>");$("#tooltip").css("top",b.pageY-yOffset+"px").css("left",b.pageX+xOffset+"px").fadeIn("fast")}}}).live("mouseout",function(){this.title=this.t;$("#tooltip").remove()});$(".tooltip").live("mousemove",function(b){$("#tooltip").css("top",b.pageY-yOffset+"px").css("left",b.pageX+xOffset+"px")})}
function rawurlencode(b){var a=function(h){return"%"+h.toString(16).toUpperCase()},c="",e=/[\w.~-]/;b=(b+"").toString();for(var f=0,g=b.length;f<g;f++){var d=b.charAt(f);if(e.test(d))c+=d;else{d=b.charCodeAt(f);if(d<128)c+=a(d);else if(d>=128&&d<2048){c+=a(d>>6|192);c+=a(d&63|128)}else if(d>=2048&&d<65536){c+=a(d>>12|224);c+=a(d>>6&63|128);c+=a(d&63|128)}else if(d>=65536){c+=a(d>>18|240);c+=a(d>>12&63|128);c+=a(d>>6&63|128);c+=a(d&63|128)}}}return c}
if(cycleFeatured)mainVideosNumString="mainVideo"+mainVideosNum;function cycleMainFeatured(b){var a=$("div.mainVideo:visible");loadNext=b?a.attr("id")=="mainVideo1"?$("#"+mainVideosNumString):a.prev():a.attr("id")==mainVideosNumString?$("#mainVideo1"):a.next();$(a).fadeOut("fast",function(){loadNext.fadeIn("fast");if(loadNext.hasClass("mainAd")){$("#videoPlay").hide();$("div.mainAd a").length==2&&$("div.mainAd a").toggle()}else $("#videoPlay").show()})}
function selectItem(b){if(b.extra){b=b.extra[0].split("==");videoUrl=b[3].search("http")==-1?siteUrl+"/#"+b[3]+"/"+b[2]:b[3];window.location=videoUrl}}function formatItem(b){var a=b[1].split("==");return b[0]+"<br><i>"+a[0]+"&mdash; "+a[1]+"</i>"}$("a.oembed").click(function(){return false});
function loadVideo(b,a){if(!b)b=window.location.hash;var c=b.substr(1),e=c.replace(/[^\d]/g,""),f=c.match(/^[a-z]+/g,""),g=f.toString();if(document.getElementById("moogaloop").nodeName!="DIV"){swfobject.removeSWF("moogaloop");$("#video").append("<div id='moogaloop'></div>")}$("#video,#moogaloop,#videoAdAfter,#videoAdVideo,#videosStart").hide();$("#videoAdAfterInside").remove();isPlaying=showAds=true;switch(g){case "aktuelt":videoColor="00adef";break;case "sport":videoColor="8ab612";break;case "kultur":videoColor=
"ff0179";break;case "pasiden":case "quizter":videoColor="8C98A3";break;case "serier":videoColor="EB8B2B";break;case "reklame":videoColor="000000";break;case "gullkortet":videoColor="bf8423";break;default:videoColor="00adef"}$.ajax({type:"GET",url:siteUrl+"/find-post-info/",data:{thePostId:e},dataType:"json",success:function(d){postUrl=d.extUrl;postType=d.postType;theVideoAd.hide();if(embedOrObject=="embed")if($("embed",theVideoAd).length==0){$("#videoPreview").fadeOut();theVideoAd.html("");videoPreload("adblock");
$("#video").show().removeClass("videoHide");showAds=false}maxPlayedAds=false;if(g=="pasiden"||g=="reklame"||g=="serier"||g=="gullkortet")maxPlayedAds=true;else{d=new Date;d.setHours(parseInt(d.getHours())+2);if($.cookie("adPlays")){adPlays=parseInt($.cookie("adPlays"));if(adPlays==3)maxPlayedAds=true;else $.cookie("adPlays",adPlays+1,{expires:d,path:"/",domain:"sebyen.no",secure:false})}else $.cookie("adPlays",1,{expires:d,path:"/",domain:"sebyen.no",secure:false})}if(!$("#videoAd div:first").html()){showAds=
false;maxPlayedAds=true}if(maxPlayedAds==true&&g!="quizter"){$("#videoPreview").length>0&&$("#videoPreview").fadeOut();videoPreload("adblock");$("#video").show().removeClass("videoHide");showAds=false}$("a.oembed:visible").attr({href:"http://vimeo.com/"+postUrl,title:postUrl});if(showAds){$("#videoAd object,#videoAd embed").remove();$("#videoPreview").fadeOut(30,function(){$("#video").show().addClass("videoHide");$.getJSON("http://sebyen.no/openx/www/delivery/ajs_custom.php?zoneid=5",function(i){var j=
i.adUrl;i=i.clickUrl;if(j=="")j="http://sebyen.no/openx/www/images/a8e47067f36682cf738a124bea8190d7.swf";var k=$("#videoAd div:first").attr("id");j=new FlashObject(j,"Advertisement","720","405","10");j.addVariable("clickTAG",i);j.addVariable("clickTARGET","_blank");j.addParam("allowScriptAccess","always");j.write(k)})})}a&&$("#featuredWrap").show();if(typeof a=="string"||typeof e=="string"){var h=typeof e=="string"?e:a.replace(/[^\d]/g,"");d="?postid="+h;$("#playingContent").fadeOut();$("#nowPlaying").load(siteUrl+
"/fetch-now-playing/"+d+" #playingContent",function(){f=="pasiden"&&$("#featuredSide").fadeOut();loadVideosSide("play","setSizes",h);var i="\u00ab"+$("#nowPlayingTitle").html();i+="\u00bb ("+$("#nowPlaying .tag3").html()+")";if(i.length)document.title=i+" | "+defaultTitle;$("#playingContent").fadeIn();videoHeight<maxVideoHeight&&hideFeatured()});showAds&&theVideoAd.show()}$("#featuredLoader").hide()}})}
function ieInnerHTML(b){b=b.innerHTML;var a=b.match(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/g);if(a)for(var c=0;c<a.length;c++){var e,f=a[c];a[c]=a[c].replace(/(<?\w+)|(<\/?\w+)\s/,function(d){return d.toLowerCase()});if(e=a[c].match(/\=\w+[?\s+|?>]/g))for(var g=0;g<e.length;g++)a[c]=a[c].replace(e[g],e[g].replace(/\=(\w+)([?\s+|?>])/g,'="$1"$2'));b=b.replace(f,a[c])}return b}
function vimeo_player_loaded(){document.getElementById("moogaloop").api_addEventListener("onFinish","vimeo_on_finish")}
function vimeo_on_finish(){var b=false;if(hasAdAfter&&location.href.search("quizter")==-1){var a=new Date;a.setHours(parseInt(a.getHours())+2);if($.cookie("adAfterPlays")){adAfterPlays=parseInt($.cookie("adAfterPlays"));if(adAfterPlays!=3){$.cookie("adAfterPlays",adAfterPlays+1,{expires:a,path:"/",domain:"sebyen.no",secure:false});b=true}}else{$.cookie("adAfterPlays",1,{expires:a,path:"/",domain:"sebyen.no",secure:false});b=true}}if(b){urlToLoad="http://sebyen.no/#reklame/"+hasAdAfter;location.href=
urlToLoad}else $("#video").fadeOut("fast",function(){u_clean_with_hash=u_clean=$("div.playingPic a").attr("href");u_clean=u_clean.replace("#","");u=encodeURIComponent(u_clean);var c=u_clean.replace(/[^\d]/g,"");if(u_clean.search("gullkortet")!=-1||u_clean.search("quizter")!=-1){videoName=$("#nowPlayingTitle").text();var e=u_clean.search("gullkortet")!=-1?"gullkort":"quizter";$("#videoAdAfter").show().load(templateDir+"/ad-after-"+e+".php?postid="+c+"&videoTitle="+encodeURIComponent(videoName),function(){$("#"+
e+"Form").bind("submit",function(){var f=$("#answers input:checked").length;if($("#email").val()==""||f==0){alert("Du m\u00e5 fylle inn e-postadressen din og velge et svaralternativ");return false}else{f=$("input#email");var g=$("input[name=svar]:checked"),d=$("input[name=uke]");f="email="+f.val()+"&uke="+d.val()+"&svar="+g.val();$("#formLoader").fadeIn();$.ajax({url:this.action,type:"POST",data:f,cache:false,success:function(h){if(h==1)$("#"+e+"Form,#formLoader").fadeOut("fast",function(){$("#quizSvart").fadeIn();
tellafriend(e)});else{$("#formLoader").hide();alert(h)}},error:function(h){$("#formLoader").hide();alert("En feil oppstod."+h)}})}return false})})}else $("#videoAdAfter").show().load(templateDir+"/ad-after.php?postid="+c,function(){videoName=$("#nowPlayingTitle").text();$("input#videoname").val(videoName);$("input#videolink").val(u_clean);$("#videoAdAfterInside a.playAgain").attr("href",u_clean_with_hash);$("#videoAdAfterInside h2.share").text("Del \u00ab"+videoName+"\u00bb");$("a.x").bind("click",
function(){$("#videoAdVideo").fadeOut("fast").remove();return false});shareButtons(videoName,u);$("#share_email").bind("click",function(){showOverlay("int_tellafriend");return false})})})}
function videoPreload(){var b={clip_id:postUrl,server:"vimeo.com",show_title:0,show_byline:0,show_portrait:0,fullscreen:1,js_api:1,color:videoColor,hd_off:0,width:videoWidth,autoplay:1,js_onLoad:"vimeo_player_loaded",js_swf_id:"moogaloop",fp_version:9},a={};a.id="moogaloop";swfobject.embedSWF("http://www.vimeo.com/moogaloop.swf","moogaloop",videoWidth,videoHeight,"8.0","",b,{scalemode:"showall",swliveconnect:true,allowscriptaccess:"always",allowfullscreen:true,wmode:"opaque"},a)}
function adEnd(){document.getElementById("moogaloop");theVideoAd.fadeOut("fast",function(){$("#video").show().removeClass("videoHide")})}function showVideoAd(){theVideoAd.fadeIn()}function hideVideoAd(){theVideoAd.hide()}
function loadVideosBottom(b,a){if(typeof b=="string")var c=b.search("http")!==-1?b.replace(siteurlWithTrailing,""):b,e=$("#nav"+c.substr(1)).parent().attr("class");else{e=$(this);c=e.attr("href");e=e.parent().attr("class")}c=c.substr(1);if(c=="pasiden"||c=="reklame"||c=="gullkortet"||c=="quizter"){c="siste";e="section1"}switch(c){case "siste":var f="?num=12";break;case "aktuelt":f="?cat=5&num=12";break;case "sport":f="?cat=6&num=12";break;case "kultur":f="?cat=7&num=12";break;case "serier":f="?cat=13&num=12";
break}if(parseInt(a))f+="&excludepost="+a;$("#featuredLoader").show();$("#videos").removeClass().addClass("sel"+e);$("#featuredBottom .wrapper").fadeOut("fast");$("#featuredWrap").fadeIn().load(siteUrl+"/fetch-featured-videos/"+f+" #featuredBottom",function(){$("#featuredBottom .wrapper").fadeIn("fast");$("#featuredLoader").hide();initBinding();$("#videosPrev,#videosPrevFade,#videosStart").hide();$("#videosNext,#videosNextFade").show();numVideosBottom=$(".featuredVideo",$("#featuredBottom")).length});
hasLoadedBottom=true}function loadVideosSide(b,a,c){var e="";if(b=="play")e="?num=2";if(parseInt(c))e+="&excludepost="+c;$("#featuredSideWrap").load(siteUrl+"/fetch-side-videos/"+e+" #featuredSide",function(){$("#featuredSide").fadeIn("fast");b==="play"&&$("#nowPlaying").slideDown("fast",function(){animateArrow()});if(a=="setSizes"){setElementSizes();hideFeatured()}initBinding()})}
function initBinding(){$((isArchive?"div":"a")+".featuredBox").hover(function(){var b=parseInt($(this).css("height"))-8;captionPos=$(this).parents("#featuredBottom").length?Math.floor(featuredBottomVideosHeight)-23:$(this).parents("#featuredSide").length?Math.floor(featuredSideVideosHeight)-23:76;var a=parseInt($(this).find(".videoCaption").height())-1;b=b-a;$(".videoCaption",this).animate({top:b+"px"},{queue:false,duration:150})},function(){$(".videoCaption",this).stop().animate({top:captionPos},
{queue:false,duration:100})});scrolledNum=0}
if(isArchive){changeOrClick=$.browser.msie?"click":"change";$("input[name=uploadfile]").bind(changeOrClick,function(){$(this).attr("checked")?$("#uploadfilebox").fadeIn():$("#uploadfilebox").fadeOut();if(changeOrClick=="click"){this.blur();this.focus()}});$("a.int_tellafriend").bind("click",function(){showOverlay("int_tellafriend2");return false});var preSubmit=function(){if($("#name").val()==""||$("#email").val()==""||$("#message").val()==""){alert("Navn, e-post og tips m\u00e5 fylles inn");return false}else $("#formLoader").show()},
postSubmit=function(){$("#formLoader").fadeOut("fast",function(){$("input:file").MultiFile("reset");$("#uploadfilebox").hide();$("div.wpcf7-response-output").fadeIn(300)})};$("li.featuredVideo").live("click",function(){if(seriesId=$(this).attr("id")){$("li."+seriesId).fadeIn();$("li.featuredVideo[id][id!="+seriesId+"]").slideUp("slow",function(){$("li.showAll").show()});return false}});$("li.showAll a").live("click",function(){$("li.featuredVideo[id]").slideDown();$("li.serie").hide();$(this).parent().hide();
return false});var submitOptions={beforeSubmit:preSubmit,success:postSubmit,clearForm:true};$("#uploadForm").length&&$("#uploadForm").ajaxForm(submitOptions)}
function showHelp(){var b=$(document).height(),a=$(document).width();$("body").prepend("<div id='overlay'></div>");$("#overlay").fadeTo("fast",0.5,function(){$(this).css({width:a,height:b,display:"block"});var c="<img src='"+templateDir+"/images/ajax-loader.gif'>";$("#overlayBox").height(b-200+"px").addClass("big").append(c).fadeIn("fast").load(siteUrl+"/hjelp/","",function(){$("#overlayBoxInside").jScrollPane({showArrows:true,scrollbarWidth:13});closeOverlay()})})}
function showOverlay(b){var a=$(document).height(),c=$(document).width();$("body").prepend("<div id='overlay'></div>");$("#overlay").fadeTo("fast",0.5,function(){$(this).css({width:c,height:a,display:"block"});var e="<img src='"+templateDir+"/images/ajax-loader.gif'>";if($("#nowPlayingTitle").length==0){videoName=$("h1",$(".mainVideo:visible")).text();u_clean=$(".videoPlayLink",$(".mainVideo:visible")).attr("href")}else{videoName=$("#nowPlayingTitle").text();u_clean=location.href}if(u_clean){u_clean=
u_clean.replace("#","");var f=u_clean.match(/\d+/)}u=encodeURIComponent(u_clean);$("#overlayBox").height("auto").removeClass("big").append(e).fadeIn("fast").load(templateDir+"/overlay.php?section="+b+"&postId="+f+"&videoTitle="+encodeURIComponent(videoName),"",function(){closeOverlay();$.browser.msie&&$("#overlayBox input[type=text]").addClass("textInput");$("#overlayBox em.videoname").text(videoName);if(b=="int_tellafriend"||b=="int_tellafriend2"||b=="int_twitter"){tellafriend();$("#videoname").val(videoName);
$("#videolink").val(u_clean);$("#twitter_txt").text(u_clean+" - ");$("#overlayContent a.twitter_msg").each(function(){var d=rawurlencode($(this).text()+" "+u_clean);$(this).attr("href","http://twitter.com/home?status="+d)});$("#twitter_txt").keyup(function(){$("#twitter_chars").fadeIn();var d=140-$(this).val().length;$("#twitter_chars span").text(d)});$("#twitter_compose").submit(function(){encodeURICompontent($("#twitter_txt").value());return false});$("#tellafriend #name").bind("keyup",function(){var d=
$(this);d.val()!=""?$("em.name").text(d.val()):$("em.name").text("[Ditt navn]")});$("#tellafriend #message").bind("keyup",function(){var d=$(this);d.val()!=""?$("p.message").text("\u00ab"+d.val()+"\u00bb"):$("p.message").text("")});$("#addMore").bind("click",function(){var d=$("#tellafriend div:visible").length;d==5&&$("#addMore").hide();$("#tellafriend #rec"+d).fadeIn("fast").find("input").focus();return false})}else if(b=="int_share"||b=="int_facebook")shareButtons(videoName,u);else if(b=="int_embed"){var g=
$("div.mainVideo:visible a.oembed").attr("title");g||(g=$("#playingArrow").attr("title"));$("#embedCode").text($("#embedCode").text().replace(/\[videoid\]/ig,g));return false}else if(b=="int_subscribe"){changeOrClick=$.browser.msie?"click":"change";$("#subscribeLabels input[type=checkbox],#filterLabels input[type=checkbox]").bind(changeOrClick,function(){var d=$(this);if(changeOrClick=="click"){this.blur();this.focus()}var h=$("#subscribeLabels").length>0?"#subscribeLabels":"#filterLabels";d.is(":checked")?
d.parent().addClass("selected"):d.parent().removeClass("selected");if(d.attr("id")=="videos_all"&&d.is(":checked")){$(h+" input[id!=videos_all]").attr("checked","");$(h+" label[for!=videos_all]").removeClass("selected")}else if(d.attr("id")!="videos_all"){$(h+" label[for=videos_all]").removeClass("selected");$(h+" input[id=videos_all]").attr("checked","");d=d.attr("id");if(h=="#filterLabels"){$("#archiveVideos li."+d).toggle();$("#archiveVideos").jScrollPane({showArrows:true,scrollbarWidth:13})}}});
$("#subscribeLabels").submit(function(){var d=$("#subscribeLabels input:checked").length;if($("#email").val()==""||d==0){alert("Du m\u00e5 fylle inn e-postadressen din og velge minst \u00e9n kategori.");return false}else{d=$("input[name=subscribe]");var h="";$("input[name=videos]:checked").each(function(){h+="&videos[]="+$(this).val()});var i=$("input#videos_all:checked"),j=$("input#email");d="subscribe="+d.val()+"&email="+j.val()+h+"&videos_all="+i.val();$("#formLoader").fadeIn();$.ajax({url:templateDir+
"/subscribe.php",type:"POST",data:d,cache:false,success:function(k){if(k==1)$("#formLoader,#subscribeLabels,.preview").fadeOut("fast",function(){$("#subscribed").fadeIn()});else{$("#formLoader").hide();alert(k)}},error:function(k){$("#formLoader").hide();alert("En feil oppstod."+k)}})}return false})}})})}function closeOverlay(){$("#overlay,#overlayBox a.closeBox").bind("click",hideOverlay);$(document).keydown(escToClose)}
function tellafriend(b){$("#tellafriend").unbind();$("#tellafriend").bind("submit",function(){if($("#email1").val()==""||$("#name").val()=="")alert("Du m\u00e5 fylle inn minst \u00e9n mottaker og navnet ditt");else{$("#tellafriend input[type=submit]").fadeTo("fast",0.3).attr("disabled","disabled").val("Sender ...");var a=$("#name"),c=$("#videoname"),e=$("#videolink"),f=$("#email1"),g=$("#email2"),d=$("#email3"),h=$("#email4"),i=$("#email5"),j=$("#message");a="name="+a.val()+"&email1="+f.val()+"&email2="+
g.val()+"&email3="+d.val()+"&email4="+h.val()+"&email5="+i.val()+"&videoname="+c.val()+"&videolink="+e.val()+"&message="+j.val();if(b){a+="&"+b+"=yes";knappValue="Send tips"}else knappValue="Send video";$.ajax({url:templateDir+"/tellafriend.php",type:"POST",data:a,cache:false,success:function(k){if(k==1){$("#tellafriend input[type=submit]").fadeTo("fast",1).attr("disabled","").val(knappValue);$("#tellafriend input#email1").val("");$("#tipSent").fadeIn(300).animate({foo:1},3E3).slideUp()}},error:function(k){alert("En feil oppstod."+
k)}})}return false})}
function shareButtons(b,a){t=encodeURIComponent(b);var c="http://www.facebook.com/sharer.php?u="+a+"&t="+t;$("#share_facebook").attr("href",c);c="http://twitter.com/home?status=%C2%AB"+t+"%C2%BB%20-%20"+a;$("#share_twitter").attr("href",c);c="http://www.kudos.no/nysak/?kudosKnapp=1&url="+a+"&tittel="+t;$("#share_kudos").attr("href",c);c="http://delicious.com/save?v=5&noui&jump=close&url="+a+"&amp;title="+t;$("#share_delicious").attr("href",c);c="http://www.myspace.com/index.cfm?fuseaction=postto&t="+t+
"&u="+a;$("#share_myspace").attr("href",c);c="http://digg.com/submit?phase=2&url="+a+"&title="+t;$("#share_digg").attr("href",c);c="http://www.stumbleupon.com/submit?url="+a+"&title="+t;$("#share_stumble").attr("href",c)}function hideOverlay(){$("#overlay,#tooltip").fadeOut("fast").remove();$("#overlayBox").hide().html("");$("#interact a").removeClass("selected");return false}function escToClose(b){b.which==27&&$("#overlay").length&&hideOverlay()}
function animateArrow(){$("#playingArrow").show()}function hideFeatured(){var b=null;if(featuredSideHeight<190&&isPlaying)b=",li.video2";$("li.video3"+b,$("#featuredSide")).hide()}function openAd(b){window.open(b)}$("a[rel=external]").live("click",function(){window.open($(this).attr("href"));return false});
function loadCalendarMovie(b){if(b=="info"){urlToLoad="http://sebyen.no/#pasiden/1064";location.href=urlToLoad}else $.get("/julekalender/gullkort_episoder.php",{ep:b},function(a){urlToLoad=siteUrl+"/#gullkortet/"+a;location.href=urlToLoad})}jQuery.fn.fadeIn=function(b,a){return this.animate({opacity:"show"},b,function(){jQuery.browser.msie&&this.style.removeAttribute("filter");jQuery.isFunction(a)&&a()})};
jQuery.fn.fadeOut=function(b,a){return this.animate({opacity:"hide"},b,function(){jQuery.browser.msie&&this.style.removeAttribute("filter");jQuery.isFunction(a)&&a()})};jQuery.fn.fadeToggle=function(b,a,c){return this.animate({opacity:"toggle"},b,a,c)};