var contextRoot="http://widgets.ne.se";
function replaceAllSpecialCharacters(B){var A=B;
A=A.replace(/\\\\/g,"\\");
A=A.replace(/\\\"/g,'"');
A=A.replace(/\\{/g,"{");
A=A.replace(/\\}/g,"}");
A=A.replace(/\\]/g,"]");
A=A.replace(/\\\[/g,"[");
A=A.replace(/\\\//g,"/");
A=A.replace(/\\:/g,":");
A=A.replace(/\\,/g,",");
A=A.replace(/\\=/g,"=");
A=A.replace(/\\;/g,";");
A=A.replace(/\\#/g,"#");
return A;
}document.write('<link rel="stylesheet" type="text/css" href="'+contextRoot+'/bubbla/css/nebubbla-min.css" media="all">');
var NEBubbla={mouseOutDelay:400,getExplanationUrl:"http://www.ne.se/ArticleExplanation",showSearch:false,cache:{},init:function(){var A=$(document.createElement("div")).addClass("d1");
NEBubbla.container=$(document.createElement("div")).attr("id","neBubble");
NEBubbla.arrow=$(document.createElement("div")).attr("id","neArrow");
NEBubbla.content=$(document.createElement("div")).attr("id","neContent");
NEBubbla.container.append(A.append(NEBubbla.content).append(NEBubbla.arrow));
$("body").append(NEBubbla.container);
$("a[href^=http://ne.se],a[href^=http://www.ne.se]").each(function(){$(this).attr("href",$(this).attr("href").replace(/http:\/\/ne\./gi,"http://www.ne."));
var C=$(this).attr("href").toString().replace(/http:\/\/(www\.)?ne\.se/gi,"");
var E=C;
E=decodeURIComponent(E);
var B=encodeURIComponent(E);
var D=NEBubbla.getExplanationUrl+"?url="+B+"&callback=?";
$.getJSON(D,function(F){F.title=replaceAllSpecialCharacters(F.title);
F.explanation=replaceAllSpecialCharacters(F.explanation);
NEBubbla.cache[C]=F;
$("a[href=http://www.ne.se"+C+"]").addClass("ne_markup").hover(function(){$("a.ne_bubbleup").each(function(){NEBubbla.hide(this);
});
$(this).addClass("ne_active");
NEBubbla.show(this);
},function(){$(this).removeClass("ne_active");
});
});
});
},show:function(A){$(document).mouseover(function(C){var B=$(C.target);
if(!(B.parents("#neBubble").length||B.is("#neBubble")||B.is(".ne_markup"))){$(document).unbind("mouseover");
NEBubbla.timer=window.setTimeout("NEBubbla.hide()",NEBubbla.mouseOutDelay);
}});
$(A).addClass("ne_bubbleup");
NEBubbla.doShow($(A),$(A).attr("href").toString().replace(/http:\/\/www\.ne\.se/gi,""));
},doShow:function(A,D){var N=new Date();
var K=N.getFullYear();
var O=NEBubbla.cache[D].title;
var C=NEBubbla.cache[D].explanation;
var B="";
if(NEBubbla.showSearch){B='<form id="neSearch" method="get"><fieldset><legend>S\u00F6k i Encyklopedin</legend><div><span class="neSearchField"><input type="text" name="query" autocomplete="off" value="S\u00F6k p\u00E5 fria NE"><span></span></span><span class="neSearchBtn"><a class="submit_anchor" target="_blank" href="#">s\u00F6k</a></span></div></fieldset></form>';
}NEBubbla.content.html(C+'<p class="readfull"><a target="_blank" href="'+A.attr("href")+'">L\u00E4s hela artikeln p\u00E5 NE</a></p>'+B+'<p class="footer">\u00A9 '+K+' Nationalencyklopedin <span class="sep">|</span> <a target="_blank" href="http://www.ne.se/static/tools/bubbla.jsp">OM NE:S FAKTABUBBLA</a></p>');
NEBubbla.content.prepend("<h2>"+O+"</h2>");
NEBubbla.content.prepend('<div class="neLink"><a target="_blank" href="http://www.ne.se">NE</a></div>');
var M=A.offset();
var L=NEBubbla.viewport();
var I=M.top-NEBubbla.container.height()-28;
var H=M.left+A.width()/2-NEBubbla.container.width()/3;
var E=H;
if(H+NEBubbla.container.width()>L.cx){H=L.cx-NEBubbla.container.width()-8;
}if(H<8){H=8;
NEBubbla.container.addClass("noleft");
}if(I<L.y){I=M.top+A.height();
NEBubbla.container.addClass("viewbottom");
NEBubbla.arrow.addClass("bottom");
}var J=NEBubbla.container.width()/3-11+(E-H);
NEBubbla.arrow.css("margin-left",J+"px");
NEBubbla.container.css({left:H+"px",top:I+"px",display:"block"});
var G=$("#neSearch .neSearchField input");
var F=G.attr("value");
G.focus(function(){$(this).addClass("focus").attr("value","");
}).blur(function(){$(this).removeClass("focus");
if($(this).attr("value")==""){$(this).attr("value",F);
}});
$("#neSearch .neSearchBtn a").click(function(){var P=G.attr("value");
if(P!=F&&P){$(this).attr("href","http://www.ne.se/sok/"+encodeURIComponent(P));
}});
jQuery("#neSearch").submit(function(){var P=G.attr("value");
window.open("http://www.ne.se/sok/"+encodeURIComponent(P),"_blank");
return false;
});
},hide:function(A){window.clearTimeout(NEBubbla.timer);
$("a.ne_bubbleup").removeClass("ne_bubbleup");
NEBubbla.container.removeClass("noleft").removeClass("viewbottom");
NEBubbla.arrow.removeClass("bottom");
NEBubbla.container.css("display","none");
$(NEBubbla.content).empty();
},viewport:function(){return{x:$(window).scrollLeft(),y:$(window).scrollTop(),cx:$(window).width(),cy:$(window).height()};
}};
jQuery(function(){NEBubbla.init();
});
