$(function(){jQuery.ajax({url:window.headerLink,dataType:"html",cache:true,ifModified:true,success:function(data){jQuery(".topMenuItem",data).each(function(){jQuery("#"+$(this).attr("id")).replaceWith(this);});}});function switchImg(el,type,callback){var $el=$(el);$el.each(function(){var $el=$(this);if(type===undefined){type="switch";}if(type==="switch"){$el.attr("src",$el.attr("src")===$el.data("hoverimg")?$el.data("img"):$el.data("hoverimg"));}else{if($el.data(type)){$el.attr("src",$el.data(type));}}(callback||$.noop)($el);});}function mouseInsideElement(mouse,element){var getDxy=function(xy,el){var dxy={};dxy.left=xy.left+el.outerWidth(true);dxy.top=xy.top+el.outerHeight(true);return dxy;},xy=$(element).offset(),dxy=getDxy(xy,$(element));if(mouse.left>xy.left&&mouse.top>xy.top&&mouse.left<dxy.left&&mouse.top<dxy.top){return true;}else{return false;}}$(".toggleTopMenu").live("mouseover",function(e){if(!$(this).data("hoverIntentInit")){$(this).data("hoverIntentInit",true);$(this).hoverIntent({over:function(){var $this=$(this);$menuDiv=$(this).parent().children(".topMenuContainerBar");$thisImg=$this.find("img");switchImg($(".toggleTopMenu img").not($thisImg),"img",function($el){$el.css("z-index",80);});switchImg($thisImg,"hoverimg",function($el){$el.css("z-index",120);});if($menuDiv.is(":visible")){return;}$(".topMenuContainerBar").fadeOut("fast");$elemMiddle=$this.offset().left+($this.outerWidth(true)/2);var top=$this.closest("#top-menu-wrapper").css("top");$menuDiv.css({height:$(document).height(),top:(top!==undefined?"-"+top:"0"),left:$elemMiddle-($menuDiv.outerWidth(true)/2)});$menuDiv.data("menuelement",$this);$menuDiv.fadeIn("fast");},out:$.noop,timeout:100});$(this).trigger(e);}});$(".topMenuLevel-0, topMenuLevel-1").live("mouseleave",function(e){var $this=$(this),insideMenuElement=false;if($this.data("menuelement")){insideMenuElement=mouseInsideElement({left:e.pageX,top:e.pageY},$this.data("menuelement"));}if(!insideMenuElement){$this.fadeOut("fast");if($this.data("rightEl")){$this.data("rightEl").fadeOut("fast");}$img=$this.closest("li:has(> a.toggleTopMenu)").find("a.toggleTopMenu img");switchImg($img,"img",function($el){$el.css("z-index",80);});}});$(".topMenuLevel-0 > .menuList > .hasRightMenu > a").live("mouseover",function(e){if(!$(this).data("hoverIntentInit")){$(this).data("hoverIntentInit",true);$(this).hoverIntent({out:$.noop,over:function(e){var $this=$(this),parentMenuDiv=$this.closest(".topMenuContainerBar"),rightEl=$(this).parent().children(".topMenuContainerBar"),allRightBars=$(".topMenuLevel-1");parentMenuDiv.find(".hasRightMenu a").removeClass("active");$this.addClass("active");if(rightEl.length>0){if(rightEl.is(".topMenuLevel-1")){if(rightEl.is(":visible")){}else{rightEl.css({height:$(document).height(),left:parentMenuDiv.outerWidth(true)});if(allRightBars.filter(":visible").not(rightEl).length>0){allRightBars.fadeOut("fast");rightEl.fadeIn("fast");}else{rightEl.fadeIn("fast");}}}}else{if(rightEl.length==0){allRightBars.fadeOut("fast");}}},timeout:250,interval:200});$(this).trigger(e);}});$(".topMenuLevel-1 .hasRightMenu").live("click",function(e){var $this=$(this),$list=$this.find(".menuList").parent();if($list.is(":visible")){if($(e.target).parent().is(".hasRightMenu")){$list.slideUp();$this.find("> a").removeClass("active");}}else{$(".topMenuLevel-2").slideUp().closest(".hasRightMenu").find("> a").removeClass("active");$this.find("> a").addClass("active");$list.slideDown();}});$(".openFormArticleLink").click(function(e){e.preventDefault();window.open($(this).attr("href"),"articleFormWindow","height=800,width=620,left=250,scrollbars=yes");return false;});$(".contentSeparator:last",$("#midInnerColumn")).removeClass("contentSeparator");$("a[rel='lightbox']").colorbox({transition:"elastic"});$(".expandSearchLink").bind("click",function(e){e.preventDefault();var expandEl=$("#"+$(this).data("divtoexpand"));if(expandEl.is(":visible")){expandEl.animate({height:0},500,function(){$(this).hide();});}else{expandEl.height(0);expandEl.css("display","").animate({height:expandEl.data("calculatedHeight")},500);}$(this).parent().toggleClass("avanceradSokOpen avanceradSokClose");return false;});$("#advanced_search :input").change(function(){$("#advSearch").val("true");$("#utbFormAdvSearch").show();});$("#resetUgglanSearch").bind("click",function(){$("#advSearch").val("false");$("#utbFormAdvSearch").hide();});(function(){if(top.window.location.search.indexOf("advSearch=true")!==-1){$("#advSearch").val("true");}})();(function(){if($("#advSearch").val()==="true"){$("#utbFormAdvSearch").css("display","");$(".expandSearchLink").parent().removeClass("avanceradSokOpen").addClass("avanceradSokClose");}else{$("#utbFormAdvSearch").hide();$(".expandSearchLink").parent().addClass("avanceradSokOpen").removeClass("avanceradSokClose");}})();$(".cboxElement").each(function(){var $this=$(this),img=$this.find("img"),src=img.attr("src");if(src!==undefined){$this.attr("href",src.replace(/\/derivatives\/(.+?)\//,"/derivatives/landscape_800/"));}});$("#advanced_search").each(function(){$(this).data("calculatedHeight",$(this).height());if($("#advSearch").val()!=="true"){$(this).hide();}});$("#resetUgglanSearch").bind("click",function(e){var $form=$(this).closest("form");$("select option:first-child",$form).attr("selected",true);$('#us_matchTermin option[value="L"]',$form).attr("selected",true);$(":checkbox",$form).attr("checked",false);$(":text",$form).val("");e.preventDefault();return false;});$(".news a, #fake-news-link").live("focus",function(){this.blur();});$.fn.corner.defaults.useNative=false;$(".bildContainerCornerBox").corner("cc:#fff dogfold tr 40px");$("span.utb_tillfalle_underrubrik:contains('Öppen för sen ansökan via Studera.nu')").css("color","#C80025");$("div.center-column-wrapper p:contains('Antal träffar:')").css("margin-bottom","5px");$("div.center-column-wrapper td:contains('Sortera:')").css("padding","0px");$('select[name="kursplanId"]').css("margin-right","30px");jQuery(".bildGalleri").jcarousel({auto:0,visible:4});if(window.afterAppInit&&window.afterAppInit.length){for(var i=0;i<window.afterAppInit.length;i++){window.afterAppInit[i]();}}});
