config={facebox:{loadingImage:'/componada/resources/web/gfx/facebox/loading.gif',closeImage:'/componada/resources/web/gfx/facebox/closelabel.png',fconfig:'id="auth_iframe" frameBorder="0" scrolling="no" border="0" marginWidth="0" marginHeight="0"',faceboxHtml:'\
    <div id="facebox" style="display:none;"> \
      <div class="popup"> \
        <div class="message"></div> \
        <div class="content"></div> \
        <a href="#" class="close">\
        <img src="/componada/resources/web/gfx/facebox/closelabel.png" title="close" class="close_image" /></a> \
      </div> \
    </div>'},auth:{tokenCookie:'apit',tokenUrl:'apir',userCookie:'apiu',cookies:{delimiter:{part:"&",pair:"="},expire:365},iframe:{width:500,height:400},logout:{iframe:{id:"logoutFrame",url:"/springLogout.html",config:'style="width: 0px; height: 0px; border: none;" '+'scrolling="no" width="0" height="0" border="0" '+'marginheight="0" marginwidth="0" frameBorder="0"'}},janus:{url:{context:'/API/janus',login:'/auth/login/',validation:'/auth/validatetoken/'}}},markup:{action:{login:'apiUserActionLogin',logout:'apiUserActionLogout',expand:'apiUserActionExpand',list:'apiUserActionList'},favourites:'apiFavouriteList',favourite:'apiFavourite',nodetype:'a'}}
$.fn.serializeObject=function(){var o={};var a=this.serializeArray();$.each(a,function(){if(o[this.name]){if(!o[this.name].push){o[this.name]=[o[this.name]];}
o[this.name].push(this.value||'');}else{o[this.name]=this.value||'';}});return o;};var auth={render:new Array(),postLogin:new Array(),isFavourite:function(){},janusUrl:"",janusUseSSL:false,localJanus:"",publicationId:false,initLogin:function(renderLogin,renderLoggedIn,localJanus,janusUrl,janusUseSSL,publicationId){this.render['logIn']=renderLogin;this.render['loggedIn']=renderLoggedIn;this.janusUrl=janusUrl
this.localJanus=localJanus
this.janusUseSSL=(janusUseSSL.toLowerCase()==='true');this.publicationId=publicationId;},initFavourite:function(advertId,message,renderFavourite,renderNotFavourite,isFavourite){this.render['activeFavourite']=renderFavourite;this.render['inactiveFavourite']=renderNotFavourite;this.isFavourite=isFavourite;if(auth.isLoggedIn()){this.renderFavourite(advertId);}
var favourites="#"+config.markup.favourites;$(favourites).click(function(e){e.preventDefault();if(e.target&&e.target.nodeName.toLowerCase()==config.markup.nodetype){if(auth.isLoggedIn()){auth.toggleFavourite(advertId,this.publicationId);}else{auth.postLogin['addFavourite']={fname:auth.toggleFavourite,args:[advertId,this.publicationId]};auth.displayLogin(message);}}});},isFavourite:function(id){$.get('/API/janus/auth/favourite/'+id+"/",function(data){if(data.advertId===id&&data.status==="SUCCESS"){return true;}else{return false;}});},renderFavourite:function(id){$.get('/API/janus/auth/favourite/'+id+"/",function(data){if(data.advertId===id&&data.status==="SUCCESS"){auth.renderActiveFavourite(id);}else{auth.renderInActiveFavourite(id);}});},toggleFavourite:function(id,publicationId){if(auth.isFavourite(id)){auth.delFavourite(id);}else{auth.addFavourite(id,publicationId);}},addFavourite:function(id,publicationId){jQuery.ajax({type:'POST',url:'/API/janus/auth/favourite/',contentType:'application/json',data:JSON.stringify({id:id,publicationId:publicationId}),dataType:'json',success:function(response){if(response.status==="SUCCESS"){auth.renderActiveFavourite(id);}}});},delFavourite:function(id){jQuery.ajax({type:'DELETE',url:'/API/janus/auth/favourite/',contentType:'application/json',data:JSON.stringify({id:id}),dataType:'json',success:function(response){if(response.status==="SUCCESS"){auth.renderInActiveFavourite(id);}}});},renderActiveFavourite:function(id){this.render['activeFavourite'](id);},renderInActiveFavourite:function(id){this.render['inactiveFavourite'](id);},renderLogin:function(){this.render['logIn']();},renderLoggedIn:function(){var user=auth.userFromCookie();this.render['loggedIn'](user.email);},getTokenCookie:function(){return($.cookie(config.auth.tokenCookie));},isLoggedIn:function(){if(this.getTokenCookie()){return true;}
return false;},serializeObject:function(obj,delPart,delPair){var key,i=0,serialized='';if(!delPart){delPart=config.auth.cookies.delimiter.part;}
if(!delPair){delPair=config.auth.cookies.delimiter.pair;}
for(key in obj){if(obj.hasOwnProperty(key)&&typeof obj[key]!=='function'){if(i>0){serialized+=delPart;}
serialized+=key+delPair+obj[key];i+=1;}}
return serialized;},deserializeObject:function(str,delPart,delPair){if(!delPart){delPart=config.auth.cookies.delimiter.part;}
if(!delPair){delPair=config.auth.cookies.delimiter.pair;}
var obj={},arr=str.split(delPart);for(i in arr){var p=arr[i].split(delPair);obj[p[0]]=p[1].replace('"','');}
return obj},queryStringValue:function(key){var qa=this.queryStringToArr();if(qa&&qa[key]){return qa[key];}},queryStringToArr:function(){var res,pairs=window.location.search.substring(1).split('&');if(pairs){res=new Array()}
var i;for(i in pairs){var pair=pairs[i].split('=');if(pair[1]){res[pair[0]]=decodeURIComponent(pair[1]);}}
return res;},userFromCookie:function(){if($.cookie(config.auth.tokenCookie)){return this.deserializeObject($.cookie(config.auth.userCookie));}
return false;},validateLogin:function(callback){var token=this.getTokenCookie();if(token){$.get('/API/janus/auth/validate/'+token+"/",function(data){if(data.token===token&&data.status==="SUCCESS"){callback();}});}},getLocation:function(){var protocol,host,port,context,location;port=window.location.port;protocol=window.location.protocol;host=window.location.host;context=config.auth.janus.url.context;if(port>=9000){return this.localJanus;}
if(this.janusUrl!==''){location=this.janusUrl;}
else{if(this.janusUseSSL===true){location='https://'+host+context;}else{location=protocol+'//'+host+context;}}
return location;},getLoginServiceUrl:function(){var path=config.auth.janus.url.login;return this.getLocation()+path+"?pid="+this.publicationId;},getLogoutUrl:function(){var path=config.auth.logout.iframe.url;return this.getLocation()+path+"?pid="+this.publicationId;},getValidationServiceUrl:function(token){var path=config.auth.janus.url.validation;return this.getLocation()+path+token+'/';},displayLogin:function(msg){var frame='<iframe src='+this.getLoginServiceUrl()+' '+config.facebox.fconfig+'></iframe>';$.facebox.settings.loadingImage=config.facebox.loadingImage;$.facebox.settings.closeImage=config.facebox.closeImage;$.facebox.settings.faceboxHtml=config.facebox.faceboxHtml;$.facebox(frame);$("#facebox .popup").removeClass("notabs");if(msg){$("#facebox .popup").addClass("heading");$("#facebox .message").html(msg);}else{$("#facebox .popup").removeClass("heading");$("#facebox .message").html("");}
return this;},displayValidation:function(token,msg){var frame='<iframe src='+this.getValidationServiceUrl(token)+' '+config.facebox.fconfig+'></iframe>';$.facebox.settings.loadingImage=config.facebox.loadingImage;$.facebox.settings.closeImage=config.facebox.closeImage;$.facebox.settings.faceboxHtml=config.facebox.faceboxHtml;$.facebox(frame);$("#facebox .popup").addClass("notabs");$("#facebox .message").html(msg);return this;},logOut:function logOut(){var frame='<iframe id='+config.auth.logout.iframe.id+' src='+this.getLogoutUrl()+' '
+config.auth.logout.iframe.config+'></iframe>';$('.apiFavouriteList').append(frame);},handleAuthenticated:function(){$.facebox.close();this.renderLoggedIn();var functions=this.postLogin;for(obj in functions){functions[obj].fname.apply(auth,functions[obj].args)}
this.postLogin=new Array();},handleLogout:function(){$("#"+config.auth.logout.iframe.id).remove();this.renderLogin();},closeFacebox:function closeFacebox(){$.facebox.close();}}
var api={};api.core={decodemailto:function(e){var href=e.getAttribute('href');var address=href.replace(/\[at\]/gmi,'@');address=address.replace(/\[dot\]/gmi,'.');if(href!=address){e.setAttribute('href',address);}}};api.$=function(x){if(typeof x=="string"){x=document.getElementById(x);}
return x;};api.getElementsByClassName=function(e,c,t){e=e||document;t=t||"*";var arrRet=[];var els=e.getElementsByTagName(t);var re=new RegExp("\\b"+c+"\\b");for(var i=0;i<els.length;i++){if(re.test(els[i].className)){arrRet.push(els[i]);}}
return arrRet;};api.bh=function(n,a){var o;if(n!="text"){o=document.createElement(n);for(var i in a){if(i=="class"||i=="className"||i=="cl"){o.className=a[i];}else if(i=="innerHTML"||i=="ih"){o.innerHTML=a[i];}else if(i.indexOf("style.")>-1){var iS=i.split(".");o[iS[0]][iS[1]]=a[i];}else if(i=="style"&&typeof a[i]=="object"){for(var y in a[i])o[i][y]=a[i][y];}else{o.setAttribute(i,a[i]);}}}else{o=document.createTextNode(a);}
return o;};api.parseStringToXml=function(s){var xmlDoc=null;try{xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async="false";xmlDoc.loadXML(s);}catch(errI){try{parser=new DOMParser();xmlDoc=parser.parseFromString(s,"text/xml");}
catch(errII){}}
return xmlDoc;};api.toggleClassName=function(e,oc,rc){if(e.className==oc){e.className=rc;}else if(e.className==rc){e.className=oc;}};api.getLastStreamNode=function(node){var nL=document.getElementsByTagName(node);return nL[nL.length-1];};api.ajax=function(param){for(var i in param){this[i]=param[i];}
var transport=function(){var t=false;if(window.XMLHttpRequest){t=new XMLHttpRequest();}else if(window.ActiveXObject){try{t=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{t=new ActiveXObject("Microsoft.XMLHTTP");}catch(E){t=false;}}}
return t;};var $=function(e){if(typeof e=='string'){e=document.getElementById(e);return e;}};if(!this.method){this.method='GET';}
if(!this.args){this.args=null;}
if(typeof this.async!="boolean"){this.async=true;}
if(!!this.update){var e=$(this.update);this.onsuccess=function(r){e.innerHTML=r.responseText;};}
this.xh=new transport();};api.ajax.prototype.send=function(){var x=this.xh;var f=this.onsuccess;var e=this.onfailure;var a=this.args;x.open(this.method,this.url,this.async);if(this.method=='POST'){x.setRequestHeader("Content-type","application/x-www-form-urlencoded");x.setRequestHeader("Content-length",a.length);x.setRequestHeader("Connection","close");}
if(this.async){x.onreadystatechange=function(){if(x.readyState==4){if(x.status==200)f(x);else if(!!e)e(x);}};}
x.send(a);if(!this.async){this.response=x;}};api.ajax.prototype.start=function(x){this.send();var t=this;var executer=function(t){t.send();};this.timer=setInterval(function(){executer(t);},x*1000);};api.ajax.prototype.stop=function(){if(!this.timer){return;}
clearInterval(this.timer);this.timer=null;};if(!this.JSON){this.JSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());api.cookie={set:function(name,value,expires,path,domain,secure){var fDate=new Date();var exDate=fDate.getTime();exDate+=1000*3600*24*expires;fDate.setTime(exDate);name+="="+escape(value)+((expires)?"; expires="+fDate.toGMTString():"");name+=((path)?"; path="+path:"");name+=((domain)?"; domain="+domain:"");name+=((secure)?"; secure":"");document.cookie=name;},get:function(name){var dc=document.cookie;if(dc===""){return false;}
var prefix=name+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!==0){return null;}}else{begin+=2;}
var end=document.cookie.indexOf(";",begin);if(end==-1){end=dc.length;}
return(unescape(dc.substring(begin+prefix.length,end))||"");},del:function(name,path,domain){var cookie=name+"="+((path)?";path="+path:"");cookie+=((domain)?";domain="+domain:"");cookie+=";expires=Thu, 01-Jan-1970 00:00:01 GMT";if(this.get(name)){document.cookie=cookie;}},isOn:function(){this.set("apiCookiesOnCheck","true",365);return(this.get("apiCookiesOnCheck")=="true");}};api.imageForSale=function(p){var self=this;for(var i in p)this[i]=p[i];this.imageJson={id:this.id,url:this.url,title:this.title,btnTitle:this.euroFotoBtnTitle,btnTxt:this.euroFotoBtnText,btnDesc:this.euroFotoBtnDesc,backUrl:document.location.toString(),shop:this.photopartner,fotoByline:this.euroFotoByline};this.element.onclick=function(){self.showLightbox()};api.imagesForSale.push(this);}
api.imagesForSale=[];api.imageForSale.prototype={showLightbox:function(){var self=this;$.colorbox({html:$("<div/>").prepend($("<div/>",{className:"euroFotoThumbnail"}).prepend($("<img/>",{src:this.thumbnail.url,css:{width:this.thumbnail.width+"px",height:this.thumbnail.height+"px"}})),$("<h1/>",{html:"Bestill bildeprodukter"}),$("<p/>",{html:this.imageJson.btnDesc}),$("<div/>",{html:this.imageJson.btnTitle,className:"apiOrderImageBtn tostore"}).bind("click",function(){self.buyImage()})),width:"600px",scrolling:false})},buyImage:function()
{$.ajax({url:"/ajax/eurofoto/buyimage.json",type:"POST",data:{"imageJson":JSON.stringify(this.imageJson)},dataType:"json",cache:false,async:false,success:function(data)
{document.location=data.url;},error:function(error)
{}});}};api.effects={};api.effects.scale={animTimer:null,currentTarget:null,originalHeight:null,targetHeight:null,time:0,targetDuration:2,setHeight:function(target,newHeight){target.style.height=newHeight+"px;";},startScale:function(target,newHeight){this.time=0;this.currentTarget=document.getElementById(target);this.targetHeight=newHeight;this.originalHeight=Number(this.currentTarget.offsetHeight);this.animTimer=window.setInterval("api.effects.scale.animate()",30);},stopScale:function(){clearInterval(this.animTimer);},animate:function(){this.time+=0.1;if(this.time<this.targetDuration){var difference=this.targetHeight-this.originalHeight;var newHeight=this.easeInOut(this.time,this.originalHeight,difference,this.targetDuration);this.currentTarget.style.height=newHeight+"px";}else{this.currentTarget.style.height=this.targetHeight+"px";this.stopScale();}},easeInOut:function(t,b,c,d){if(t===0){return b;}
if(t==d){return b+c;}
if((t/=d/2)<1){return c/2*Math.pow(2,10*(t-1))+b;}
return c/2*(-Math.pow(2,-10*--t)+2)+b;}};api.map=function(){};api.map.loadScript=function(callbackScript,googleMapKey){var script=document.createElement("script");script.setAttribute("src","http://maps.google.com/maps?file=api&v=2.x&key="+googleMapKey+"&c&async=2&callback="+callbackScript);script.setAttribute("type","text/javascript");document.documentElement.firstChild.appendChild(script);};api.map.writeScript=function(callbackScript,googleMapKey){document.write("<scr"+"ipt type='text/javascript' src='http://maps.google.com/maps?file=api&v=2.x&key="+googleMapKey+"&c&async=2.x&callback="+callbackScript+"'></scr"+"ipt>")}
api.map.createMarker=function(longitude,latitude,comment,staticurls){var position=new GLatLng(longitude,latitude);var defaultApiIcon=new GIcon();defaultApiIcon.image=staticurls+"/resources/web/gfx/maps/marker-blue.png";defaultApiIcon.shadow=staticurls+"/resources/web/gfx/maps/marker-blue-shadow.png";defaultApiIcon.iconSize=new GSize(35,35);defaultApiIcon.shadowSize=new GSize(53,35);defaultApiIcon.iconAnchor=new GPoint(18,35);defaultApiIcon.infoWindowAnchor=new GPoint(30,0);markerOptions={icon:defaultApiIcon};var markerMaxWidth={maxWidth:"300"};var marker=new GMarker(position,markerOptions);if(!(comment===null||comment==="")){GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml(comment,markerMaxWidth);});}
return marker;};api.map.createMap=function(elementIdToAttachMapTo,centerOfMapLatitude,centerOfMapLongitude,mapZoom,markersOnMap){if(GBrowserIsCompatible()){var map=new GMap2(document.getElementById(elementIdToAttachMapTo));map.setCenter(new GLatLng(centerOfMapLatitude,centerOfMapLongitude),mapZoom);map.addControl(new GSmallMapControl());if(!(markersOnMap===0||markersOnMap===null)){for(i=0;i<markersOnMap.length;i++){map.addOverlay(markersOnMap[i]);}}}};api.video=function(vTitle,vFile,vThumb,tagetID,pWidth,pHeight,nedstatSiteId,instreamAdUrl,playerFileName){var vp=new api.video.player();vp.setVideoPlayerWidth(pWidth);vp.getVideoPlayerHeight(pHeight);vp.setPlayer(globalstaticurl+'common/flash/videoplayer/'+playerFileName)
var vf=new api.video.file();vf.setTitle(vTitle);vf.setFile(vFile);vf.setThumb(vThumb);var flashvars={autoplay:"false",debug:"false",playlist:vf.getPlaylist(),instreamAdUrl:instreamAdUrl+new Date().getTime(),reportURL:'http://int.sitestat.com/a-pi/'+nedstatSiteId+'/s?as3.nsPlayer'};var params={menu:"false",allowfullscreen:"true",allowScriptAccess:"always"};var attributes={};swfobject.embedSWF(vp.getPlayer()+"?sc="+now,tagetID,"100%","100%","9.0.0",vp.getFlashInstallURL(),flashvars,params,attributes);};api.video.player=function(){this.videoPlayer=globalstaticurl+'common/flash/videoplayer/APIVideoPlayer2.swf';this.flashInstallURL=globalstaticurl+'common/flash/videoplayer/expressInstall.swf';this.videoPlayerId='apiVideoPlayer';this.videoPlayerHeight=442;this.videoPlayerWidth=512;};api.video.player.prototype.setPlayer=function(playerUrl){this.videoPlayer=playerUrl;};api.video.player.prototype.setFlashInstallURL=function(flashUrl){this.flashInstallURL=flashUrl;};api.video.player.prototype.setVideoPlayerId=function(v){this.videoPlayerId=v;};api.video.player.prototype.setVideoPlayerHeight=function(v){this.videoPlayerHeight=v;};api.video.player.prototype.setVideoPlayerWidth=function(v){this.videoPlayerWidth=v;};api.video.player.prototype.getPlayer=function(){return this.videoPlayer;};api.video.player.prototype.getFlashInstallURL=function(){return this.flashInstallURL;};api.video.player.prototype.getVideoPlayerId=function(){return this.videoPlayerId;};api.video.player.prototype.getVideoPlayerHeight=function(){return this.videoPlayerHeight;};api.video.player.prototype.getVideoPlayerWidth=function(){return this.videoPlayerWidth;};api.video.file=function(){this.videoTitle="";this.videoFile="";this.videoThumb="";this.autoplay=false;};api.video.file.prototype.setTitle=function(vTitle){this.videoTitle=escape(vTitle);};api.video.file.prototype.setFile=function(vFile){this.videoFile=vFile;};api.video.file.prototype.setThumb=function(vThumb){this.videoThumb=vThumb;};api.video.file.prototype.setDisplayTime=function(dTime){this.displayTime=dTime;};api.video.file.prototype.getPlaylist=function(){return'autoplay='+this.autoplay+'&playlist='+'<data><video>'+'<title>'+this.videoTitle+'</title>'+'<fileurl>'+this.videoFile+'</fileurl>'+'<thumburl>'+this.videoThumb+'</thumburl>'+'</video></data>';};api.form=function(){};api.form.restore=function(){this.formFields=new Array();};api.form.restore.prototype.preAction=function(e){if(!this.formFields[e.name]||this.formFields[e.name]==e.value){this.formFields[e.name]=e.value;e.value='';}};api.form.restore.prototype.postAction=function(e){if(e.value===''){e.value=this.formFields[e.name];}};api.form.validate=function(){};api.form.validate.prototype.email=function(e,c){var emailExp=/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;if(e.value.match(emailExp)){api.callback(c(e,true));return true;}else{api.callback(c(e,false));return false;}};api.poll=function(id,pubId,results,closed){this.form=document.forms[document.forms.length-1];this.returnGfx="/componada/resources/web/gfx/pix_fff.gif"
this.ajaxPrefix="/apiajax/";this.cookieName="apiPoll6";this.id=id;this.publicationId=pubId;this.results=results;this.closed=closed;this.fixResult=!(this.results.length>0);if(!api.polls[id])api.polls[id]=[this];else api.polls[id].push(this);this.checked=false;this.output=[];var opts=api.getElementsByClassName(this.form,"apiOption","div");for(var i=0;i<opts.length;i++){var percentDiv=api.bh("div",{cl:"apiResult"});opts[i].insertBefore(percentDiv,opts[i].firstChild);var barWrap=api.bh("div",{cl:"apiPollBarWrap"});;opts[i].appendChild(barWrap);var bar=api.bh("div",{cl:"apiPollBar"});;barWrap.appendChild(bar);this.output.push({per:percentDiv,bar:bar});if(this.fixResult)this.results.push(0);};this.chk();this.updateResults();if(this.closed)this.showResult();};api.poll.prototype.updateResults=function(){var This=this;var foo=new api.ajax({url:this.ajaxPrefix+this.id,onsuccess:function(req){This.updateCallback(req)}});foo.send();};api.poll.prototype.updateCallback=function(req){var result=JSON.parse(req.responseText);if(!!result.results){this.results=result.results;this.chk();}};api.poll.prototype.send=function(o){var ins=o.parentNode.parentNode.getElementsByTagName("input");var c=null;for(var i=0;i<ins.length;i++){if(ins[i].checked){c=ins[i].value;}};if(!c){return false;}
var coo=api.cookie.get(this.cookieName)||"|";coo+=this.id+":"+c+"|";api.cookie.set(this.cookieName,coo,30);var url='/do/test?mentometerId='+escape(this.id)+'&publicationId='+escape(this.publicationId)+'&redirectTo='+escape(this.returnGfx)+'&vote=svar'+escape(c);var image=new Image();image.src=url;this.showResult(c);};api.poll.prototype.chk=function(){var coo=api.cookie.get(this.cookieName)||"";var re=new RegExp("\\|"+this.id+"\\:(\\d+)\\|");if(re.test(coo)){this.showResult(RegExp.$1)}
else{var total=0;for(var i=0;i<this.results.length;i++){total+=this.results[i];}
api.getElementsByClassName(this.form,"apiCountTotal","span")[0].innerHTML=total;var This=this;api.getElementsByClassName(this.form,"apiPollSubmitBut","input")[0].onclick=function(){This.send(this)};}};api.poll.prototype.showResult=function(c){for(y=0;y<api.polls[this.id].length;y++){var cPoll=api.polls[this.id][y];var totout=api.getElementsByClassName(cPoll.form,"apiCountTotal","span")[0];var total=0;for(var i=0;i<cPoll.results.length;i++){if((i+1)==c)cPoll.results[i]++;total+=cPoll.results[i];};var ins=api.getElementsByClassName(cPoll.form,"apiPollOptIn","input");for(var i=0;i<ins.length;i++){if(c==ins[i].value){ins[i].checked="checked";};ins[i].disabled="disabled";var percent=(Math.round((cPoll.results[i]*1000)/total)/10);cPoll.output[i].per.innerHTML=percent+"%";cPoll.output[i].bar.style.width=percent+"%";};totout.innerHTML=total;cPoll.form.className="apiPollIsSubmited";if(this.closed)cPoll.form.className="apiPollIsClosed";cPoll.checked=true;};};api.polls=[];api.netmeeting=function(){};api.netmeeting.send=function(){document.getElementById("errorFieldTitle").innerHTML=''
document.getElementById("errorFieldBody").innerHTML=''
document.getElementById("errorFieldName").innerHTML=''
var title=document.getElementById("formTitle").value;var body=document.getElementById("formBody").value;var name=document.getElementById("formName").value;if(title==''||body==''||name==''){if(title==''){document.getElementById("errorFieldTitle").innerHTML=" - Tittel m&#229; fylles ut";}
if(body==''){document.getElementById("errorFieldBody").innerHTML=" - Sp&#248;rsm&#229;l m&#229; fylles ut";}
if(name==''){document.getElementById("errorFieldName").innerHTML=" - Navn m&#229; fylles ut";}
return false;}else{return true;}}
api.brokerguide_changeCounty=function(selectedChoice,defaultMunicipality,defaultDistrict,geographies){api.brokerguide_clearSelect($('#municipalities'),defaultMunicipality);api.brokerguide_clearSelect($('#districts'),defaultDistrict);if(selectedChoice!=''){$.each(geographies[selectedChoice]['municipalities'],function(index,value){$('#municipalities').append(api.brokerguide_createOptionHTML(value['name'],value['name']+" ("+value['count']+")"));});}
if($('#counties').children('option:selected').index()!=0){$('#municipalities').removeAttr('disabled');if($('#municipalities').children().size()==2){$('#municipalities').children('option:nth-child(2)').attr('selected','selected');api.brokerguide_changeMunicipality($('#municipalities').children('option:selected').val(),defaultDistrict,geographies);}
else{$('#districts').attr('disabled','disabled');}}
else{$('#municipalities').attr('disabled','disabled');$('#districts').attr('disabled','disabled');}}
api.brokerguide_changeMunicipality=function(selectedChoice,defaultDistrict,geographies){api.brokerguide_clearSelect($('#districts'),defaultDistrict);if(selectedChoice!=''){var municipalityEntry=api.brokerguide_getMuniciaplityEntry(selectedChoice,geographies[$('#counties').children('option:selected').val()]['municipalities'])
$.each(municipalityEntry['districts'],function(index,value){$('#districts').append(api.brokerguide_createOptionHTML(value['name'],value['name']+" ("+value['count']+")"));});}
if($('#municipalities').children('option:selected').index()!=0){$('#districts').removeAttr('disabled');if($('#districts').children().size()==2){$('#districts').children('option:nth-child(2)').attr('selected','selected');}}
else{$('#districts').attr('disabled','disabled');}}
api.brokerguide_clearSelect=function(selectObj,defaultLabel){selectObj.children().remove();selectObj.append(api.brokerguide_createOptionHTML("",defaultLabel));selectObj.children('option:first').attr('selected','selected');}
api.brokerguide_createOptionHTML=function(value,label){return'<option value="'+value+'">'+label+'</option>';}
api.brokerguide_getMuniciaplityEntry=function(name,municipalityList){var entry={};$.each(municipalityList,function(key,value){if(value['name']==name){entry=value;}});return entry}
function Classified(){this.expandedFasettDiv=null;this.fasettPopup=null;}
Classified.prototype.updateFasettLinks=function(event){var leftColDiv=document.getElementById("apiLandingLeft");var links=leftColDiv.getElementsByTagName("div");for(linkCnt=0;linkCnt<links.length;linkCnt++){if(links[linkCnt].className=='item'){maxWidth=100;clippingStep=1;this.ellipsify(links[linkCnt],"item",maxWidth,clippingStep);}}}
Classified.prototype.addPopupEvent=function(elem){elem.onmouseover=function(event){if(!classified.fasettPopup){classified.fasettPopup=document.createElement("div");classified.fasettPopup.className='apiFasettPopup';classified.fasettPopup.onmouseout=function(event){if(!event)event=window.event;var relatedTarget=(event.relatedTarget)?event.relatedTarget:event.toElement;while(relatedTarget&&relatedTarget.tagName!='BODY'){if(relatedTarget==classified.fasettPopup){return;}
relatedTarget=relatedTarget.parentNode;}
classified.fasettPopup.style.display='none';}
document.getElementById("apiContent").appendChild(classified.fasettPopup);}
classified.fasettPopup.innerHTML=elem.innerHTML;for(linkCnt=0;linkCnt<classified.fasettPopup.childNodes.length;linkCnt++){if(classified.fasettPopup.childNodes[linkCnt].className=='item'||classified.fasettPopup.childNodes[linkCnt].className=='selected'){classified.fasettPopup.childNodes[linkCnt].innerHTML=elem.childNodes[linkCnt].title;}}
var divposition=classified.getAbsolutePosition(elem,document.getElementById("apiLandingLeft"));classified.fasettPopup.style.top=divposition.top+"px";classified.fasettPopup.style.display='block';};elem.onmouseout=function(event){if(!event)event=window.event;var relatedTarget=(event.relatedTarget)?event.relatedTarget:event.toElement;while(relatedTarget&&relatedTarget.tagName!='BODY'){if(relatedTarget==classified.fasettPopup){return;}
relatedTarget=relatedTarget.parentNode;}
classified.fasettPopup.style.display='none';}}
Classified.prototype.getAbsolutePosition=function(elem,absoluteTo){var offsetTrail=elem;var offsetLeft=0;var offsetTop=0;while(offsetTrail){offsetLeft+=offsetTrail.offsetLeft;offsetTop+=offsetTrail.offsetTop;if(offsetTrail.id==absoluteTo.id){offsetTrail=null;}else{offsetTrail=offsetTrail.offsetParent;}}
if(navigator.userAgent.indexOf('Mac')!=-1&&typeof document.body.leftMargin!='undefined'){offsetLeft+=document.body.leftMargin;offsetTop+=document.body.topMargin;}
return{left:offsetLeft,top:offsetTop};}
Classified.prototype.ellipsify=function(container,linkClassName,maxWidth,clippingStep){var links=container.getElementsByTagName("a");var y;for(y=0;y<links.length;y++){if(links[y].className==linkClassName){var linkobj=links[y];linkobj.title=linkobj.innerHTML;var clipping=false;while(linkobj.offsetWidth>maxWidth){clipping=true;linkobj.innerHTML=linkobj.innerHTML.substring(0,linkobj.innerHTML.length-clippingStep);}
if(clipping){linkobj.innerHTML=linkobj.innerHTML.substring(0,linkobj.innerHTML.length-3)+'...';this.addPopupEvent(container);}
return;}}}
api.streaming={};api.streaming.formatLiveVideoDate=function(date,fmt){function pad(value){return(value.toString().length<2)?'0'+value:value;}
return fmt.replace(/%([a-zA-Z])/g,function(_,fmtCode){switch(fmtCode){case'Y':return date.getUTCFullYear();case'M':return pad(date.getUTCMonth()+1);case'd':return pad(date.getUTCDate());case'H':return pad(date.getUTCHours());case'm':return pad(date.getUTCMinutes());case's':return pad(date.getUTCSeconds());default:throw new Error('Unsupported format code: '+fmtCode);}});}
api.streaming.showLiveNotification=function(divid,content,height){var div=document.getElementById(divid);div.innerHTML='<div style="width: 100%; height: 100%; text-align: center; line-height: '+height+'px; '+'background: #000; color: #FFF">'+content+'</div>';}
var api=api||{};api.classified={tipAFriend:function(_settings,_texts){var settings=_settings;var texts=_texts;function toggleButtons(){$('.tipAFriendButton').each(function(){if($(this).attr('disabled')){$(this).removeAttr('disabled');}
else{$(this).attr('disabled','disabled');}});}
function tipAFriendDetectedSvg(){$('.tipAFriendButton').removeClass('tipAFriendButtonFallback');}
function tipAFriendDetectSvg(){var testImg='data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D';var img=document.createElement('img');img.setAttribute('src',testImg);img.onload=tipAFriendDetectedSvg;}
function prospectTipAFriendConfirmation(message,statistics){$("#apiTipAFriendDiv").removeClass("apiTipAFriendWaiting");$("#apiTipAFriendDiv").removeClass("apiTipAFriendExpanded");$("#apiTipAFriendConfirmation").addClass("apiTipAFriendConfirmationExpanded");$(".apiTipAFriendSentMessage").html(message+statistics);}
this.validate=function validate(){tipAFriendDetectSvg();$("#tipAFriendForm").validate({rules:{comment:{maxlength:settings.maxMsgLength}},groups:{tipAFriend:"recipient comment"},errorPlacement:function(error,element){$(".apiValidationMessage").html(error);},submitHandler:function(form){var recipient=document.getElementById("apiTipFormEmailTo").value;var action=form.action;var formData=$(form).serialize();$.ajax({type:'POST',url:action,data:formData,beforeSend:function(){$("#apiTipAFriendDiv").addClass("apiTipAFriendWaiting");toggleButtons();},success:function(data){if(data.errorMessage==""){prospectTipAFriendConfirmation(texts.message_sent+' '+recipient,texts.statistics);}else{$(".apiValidationMessage").html(texts.message_not_sent+': '+data.result);$("#apiTipAFriendDiv").removeClass("apiTipAFriendWaiting");}
toggleButtons();},error:function(request,status,exception){$("#apiTipAFriendDiv").removeClass("apiTipAFriendWaiting");$(".apiValidationMessage").html(texts.message_not_sent);toggleButtons();},timeout:10000,dataType:'json'});}});}}}
