se.aftonbladet.snack=new function(){};
se.aftonbladet.snack.RESULT_CODE_OK=1;
se.aftonbladet.snack.RESULT_CODE_ACCESS_DENIED=2;
se.aftonbladet.snack.RESULT_CODE_CLOSED=3;
se.aftonbladet.snack.RESULT_CODE_ERROR_UNKNOWN=4;
se.aftonbladet.snack.RESULT_CODE_TIME_CHECK=5;
se.aftonbladet.snack.RESULT_CODE_EXPIRED=6;
se.aftonbladet.snack.GET_COMMENTS_TIMEOUT=5000;
se.aftonbladet.snack.POST_COMMENT_TIMEOUT=5000;
se.aftonbladet.snack.SERVICE_URL="";
se.aftonbladet.snack.ABUSE_URL="http://snack.aftonbladet.se/reportAbuse.action";
se.aftonbladet.snack.PROFILE_URL="http://snack.aftonbladet.se/publicPage.action";
se.aftonbladet.snack.IMAGE_MALE_URL="http://www.aftonbladet.se/template/ver1-0/gfx/snack/humanmale50x50.png";
se.aftonbladet.snack.IMAGE_FEMALE_URL="http://www.aftonbladet.se/template/ver1-0/gfx/snack/humanfemale50x50.png";
se.aftonbladet.snack.comments=new Array();
se.aftonbladet.snack.groups=new Array();
se.aftonbladet.snack.commentsGroupId=null;
se.aftonbladet.snack.commentsGroupName=null;
se.aftonbladet.snack.commentsCount=0;
se.aftonbladet.snack.commentsWritten=0;
se.aftonbladet.snack.page=0;
se.aftonbladet.snack.perPage=3;
se.aftonbladet.snack.maxPerPageHistory=se.aftonbladet.snack.perPage;
se.aftonbladet.snack.batchSize=20;
se.aftonbladet.snack.lastBatch=null;
se.aftonbladet.snack.comments.open=null;
se.aftonbladet.snack.comments.expired=null;
se.aftonbladet.snack.groupMembershipChecked=false;
se.aftonbladet.snack.joiningGroup=false;
se.aftonbladet.snack.getCommentsCount=function(){return this.commentsCount+this.commentsWritten
};
YAHOO.namespace("articleComment.container");
se.aftonbladet.snack.addCommentCallback={success:function(A){var B=se.aftonbladet.snack.parseJson(A.responseText);
if(se.aftonbladet.snack.checkResponse(B)){if(!B.view.open){if(B.view.expired){se.aftonbladet.snack.renderErrorMessage(se.aftonbladet.snack.RESULT_CODE_EXPIRED)
}else{se.aftonbladet.snack.renderErrorMessage(se.aftonbladet.snack.RESULT_CODE_CLOSED)
}}if(!YAHOO.lang.isUndefined(B.view.comments)&&B.view.comments.length==1){se.aftonbladet.snack.comments.reverse();
se.aftonbladet.snack.comments.push(B.view.comments[0]);
se.aftonbladet.snack.comments.reverse();
se.aftonbladet.snack.commentsWritten++;
se.aftonbladet.snack.navigate(0);
se.aftonbladet.snack.clearTextarea(YAHOO.util.Dom.get("abArtCommentTextarea"));
se.aftonbladet.snack.hideModule("abArtError");
se.aftonbladet.snack.hideModule("abArtLinksGroupMember")
}else{se.aftonbladet.snack.renderErrorMessage(se.aftonbladet.snack.RESULT_CODE_ERROR_UNKNOWN)
}}},failure:function(A){YAHOO.articleComment.container.commentFormModule.hide();
YAHOO.articleComment.container.commentFormFailModule.show();
se.aftonbladet.snack.renderErrorMessage(se.aftonbladet.snack.RESULT_CODE_ERROR_UNKNOWN)
},timeout:se.aftonbladet.snack.POST_COMMENT_TIMEOUT,argument:[]};
se.aftonbladet.snack.addComment=function(){var B=document.getElementById("commentForm");
if(YAHOO.lang.isUndefined(B.text)||YAHOO.lang.trim(B.text.value).length==0){return 
}YAHOO.util.Connect.setForm(B);
var C="articleId="+this.articleId;
if(this.joiningGroup){C+="&joinGroup=true"
}var A=YAHOO.util.Connect.asyncRequest("POST",B.action,this.addCommentCallback,C)
};
se.aftonbladet.snack.getCommentsCallback={success:function(A){se.aftonbladet.snack.parseCommentsJson(A.responseText)
},failure:function(A){YAHOO.articleComment.container.commentFormModule.hide();
YAHOO.articleComment.container.commentFormFailModule.show();
se.aftonbladet.snack.renderErrorMessage(se.aftonbladet.snack.RESULT_CODE_ERROR_UNKNOWN)
},timeout:se.aftonbladet.snack.GET_COMMENTS_TIMEOUT,argument:[]};
se.aftonbladet.snack.parseJson=function(B){var C=[];
try{C=YAHOO.lang.JSON.parse(B)
}catch(A){this.renderErrorMessage(this.RESULT_CODE_ERROR_UNKNOWN);
return C
}return C
};
se.aftonbladet.snack.checkResponse=function(A){if(YAHOO.lang.isUndefined(A.resultCode)){this.renderErrorMessage(this.RESULT_CODE_ERROR_UNKNOWN);
return false
}else{if(A.resultCode==this.RESULT_CODE_OK){if(YAHOO.lang.isUndefined(A.view.open)){this.renderErrorMessage(this.RESULT_CODE_ERROR_UNKNOWN);
return false
}return true
}else{if(A.resultCode==this.RESULT_CODE_ACCESS_DENIED){this.renderErrorMessage(this.RESULT_CODE_ACCESS_DENIED);
return false
}else{if(A.resultCode==this.RESULT_CODE_CLOSED){this.renderErrorMessage(this.RESULT_CODE_CLOSED);
return false
}else{if(A.resultCode==this.RESULT_CODE_TIME_CHECK){this.renderErrorMessage(this.RESULT_CODE_TIME_CHECK,true);
return false
}else{this.renderErrorMessage(this.RESULT_CODE_ERROR_UNKNOWN);
return false
}}}}}};
se.aftonbladet.snack.parseCommentsJson=function(C){var D=this.parseJson(C);
if(!this.checkResponse(D)){return 
}var E=D.startBatch*D.batchSize;
for(var B=E,A=0;
A<D.view.comments.length;
B++,A++){var F=D.view.comments[A];
this.comments[B]=F
}this.commentsGroupId=D.view.commentsGroupId;
this.commentsGroupName=D.view.commentsGroupName;
this.commentsCount=D.view.commentsCount;
this.commentsWritten=0;
this.batchSize=D.batchSize;
this.lastBatch=D.endBatch;
this.comments.open=D.view.open  && !se.aftonbladet.snack.articleCommentsClosed;
this.comments.expired=D.view.expired || se.aftonbladet.snack.articleCommentsClosed;
this.navigate(this.page);
this.articleLoadedModules();
this.renderCommentsCount()
};
se.aftonbladet.snack.getComments=function(D,C,A){if(A&&this.preFetchedComments!=undefined){this.parseCommentsJson(this.preFetchedComments)
}else{var B=YAHOO.util.Connect.asyncRequest("GET",this.SERVICE_URL+"?articleId="+this.articleId+"&startBatch="+D+"&endBatch="+C,this.getCommentsCallback,null)
}};
se.aftonbladet.snack.showJoinGroupMessage=function(C){if(YAHOO.lang.isObject(C)){if(YAHOO.lang.isArray(C.groups)){for(var A=0;
A<C.groups.length;
A++){if(C.groups[A].id==this.commentsGroupId){return false
}}this.renderJoinGroupMessage();
return true
}return false
}if(se.aftonbladet.snack.commentsGroupName==null||se.aftonbladet.snack.commentsGroupId==null||se.aftonbladet.snack.commentsGroupId<=0){return false
}if(typeof se.aftonbladet.plus!="undefined"&&typeof se.aftonbladet.plus.menuInfo!="undefined"&&YAHOO.lang.isValue(se.aftonbladet.plus.menuInfo)){return this.showJoinGroupMessage(se.aftonbladet.plus.menuInfo)
}var B=YAHOO.util.Get.script(se.aftonbladet.snack.GROUPINFO_URL)
};
se.aftonbladet.snack.showComment=function(divName,text,userName,imageURL,abuseLink,profileURL){YAHOO.widget.Module.CSS_MODULE="abArtItem";
var abuseLink='<a href="#" onClick="abWindowOpen(\''+this.ABUSE_URL+"?abuseLink="+abuseLink+"','700','600');return false;\">";
abuseLink+='<img src="http://www.aftonbladet.se/template/ver1-0/gfx/misc/v1/rep_abuse.gif" width="49" height="17" alt="anm&auml;l" class="abArtAbuse" /></a>';
var c=eval("YAHOO.articleComment.container.newComment"+divName);
c=new YAHOO.widget.Module("newComment"+divName,{visible:false});
var h="";
if(profileURL!=null){h='<a href="'+profileURL+'">'
}if(se.aftonbladet.snack.BOX_DESIGN=="narrow"){h+='<img src="'+imageURL+'" width="50" height="50" alt="profilbild" class="abArtComPicLeftNarrow" />'
}else{h+='<img src="'+imageURL+'" width="50" height="50" alt="profilbild" class="abArtComPicBorder" />'
}if(profileURL!=null){h+="</a>"
}if(se.aftonbladet.snack.BOX_DESIGN=="narrow"){c.setHeader("");
c.setBody(h+"<p>"+abuseLink+'<span class="abArtPresent">'+userName+'</span><span class="abArtSpeech" title="Artikel kommentarer">&#0160;</span>'+this.truncateText(text,"short",divName)+"</p>");
c.setFooter("<span></span>")
}else{c.setHeader(h);
c.setBody("<p>"+abuseLink+'<span class="abArtPresent">'+userName+'</span><span class="abArtSpeech" title="Artikel kommentarer">&#0160;</span>'+this.truncateText(text,"short",divName)+"</p>");
c.setFooter("<span></span>")
}c.render(YAHOO.util.Dom.get("abArtCB"));
c.show();
YAHOO.widget.Module.CSS_MODULE="yui-module"
};
se.aftonbladet.snack.hideComment=function(divName){var c=eval("YAHOO.articleComment.container.newComment"+divName);
c=new YAHOO.widget.Module("newComment"+divName,{visible:false});
c.render(document.body)
};
se.aftonbladet.snack.renderComments=function(F){for(var C=0;
C<this.maxPerPageHistory;
C++){if(C<F.length&&F[C]!=undefined){var A=F[C].writer;
var G=F[C].comment;
var E="";
var D=null;
if(A.profileUrl!=null){D=this.PROFILE_URL+"?userId="+A.profileUrl
}if(A.gender=="2"){E+='<span class="abArtSexMaleS"></span>'
}else{E+='<span class="abArtSexFemaleS"></span>'
}E+=D!=null?'<a href="'+D+'">'+A.displayName+"</a>":A.displayName;
if(A.age!=null){E+=", "+A.age+" &aring;r"
}if(A.city!=null){E+=", "+A.city
}if(G.created!=null){E+=", "+G.created
}var B;
if(A.imageUrl!=null){B=A.imageUrl
}else{if(A.gender=="2"){B=this.IMAGE_MALE_URL
}else{B=this.IMAGE_FEMALE_URL
}}this.showComment("comment"+C,G.text,E,B,G.abuseLink,D)
}else{this.hideComment("comment"+C)
}}};
se.aftonbladet.snack.renderPagination=function(){var B=Math.ceil(this.getCommentsCount()/this.perPage);
var D="";
if(this.page!=0){D+='<a href="javascript:se.aftonbladet.snack.navigate('+(this.page-1)+');">&#171;</a> '
}else{D+='<span class="abArtCountAct">&#171;</span> '
}var F=0;
var E=Math.floor(this.SHOW_PAGINATION_PAGES/2);
if(this.page>E&&B>this.SHOW_PAGINATION_PAGES){F=this.page-E
}if(F>B-this.SHOW_PAGINATION_PAGES-1&&B>this.SHOW_PAGINATION_PAGES){F=B-this.SHOW_PAGINATION_PAGES
}for(var C=F;
C<B+F&&C<this.SHOW_PAGINATION_PAGES+F;
C++){if(C==this.page){D+='<span class="abArtCountAct">'+(C+1)+"</span> "
}else{D+='<a href="javascript:se.aftonbladet.snack.navigate('+C+');">'+(C+1)+"</a> "
}}if(this.page<B-1){D+='<a href="javascript:se.aftonbladet.snack.navigate('+(this.page+1)+');">&#187;</a>'
}else{D+='<span class="abArtCountAct">&#187;</span>'
}var A=YAHOO.util.Dom.get("abArtCountPagination");
if(A!=null&&A!=undefined){A.innerHTML=D
}};
se.aftonbladet.snack.renderCommentsCount=function(){this.renderArticleHeadlineText();
if(this.getCommentsCount()>0){this.renderCommentsCountSpans(this.getCommentsCount()+" kommentar"+(this.getCommentsCount()>1?"er":""));
this.showModule("abArtCount")
}else{this.noCommentsAddedModules()
}};
se.aftonbladet.snack.renderCommentsCountSpans=function(C){var B=YAHOO.util.Dom.getElementsByClassName("abArtCommentsCount","span","abArtikelytaContainer");
for(var A=0;
A<B.length;
A++){B[A].innerHTML=C;
B[A].style.visibility="visible"
}};
se.aftonbladet.snack.clearTextarea=function(A){A.value=""
};
se.aftonbladet.snack.truncateText=function(C,B,D){if(C.length<this.NUMBER_OF_CHARACTERS){return C
}else{if(B=="short"){var A='<span id="abArtCommentShort'+D+'">'+C.substring(0,this.NUMBER_OF_CHARACTERS)+"</span>";
A+='<span id="abArtCommentLong'+D+'" style="display: none;">';
A+=C.substring(this.NUMBER_OF_CHARACTERS,C.length)+'&#160;<a href="" onClick="se.aftonbladet.snack.toggleCommentDisplay(\''+D+"', 'short'); return false;\">d&ouml;lj</a></span>";
A+='<span id="abArtCommentDisplayLink'+D+'">... <a href="" onClick="se.aftonbladet.snack.toggleCommentDisplay(\''+D+"', 'long'); return false;\">visa</a></span>";
return A
}else{return C+'<a href="" onClick="se.aftonbladet.snack.toggleCommentDisplay(text, \'short\'); return false;">d&ouml;lj</a>'
}}};
se.aftonbladet.snack.toggleCommentDisplay=function(B,A){if(A=="long"){YAHOO.util.Dom.setStyle("abArtCommentLong"+B,"display","inline");
YAHOO.util.Dom.setStyle("abArtCommentDisplayLink"+B,"display","none")
}else{YAHOO.util.Dom.setStyle("abArtCommentLong"+B,"display","none");
YAHOO.util.Dom.setStyle("abArtCommentDisplayLink"+B,"display","inline")
}};
se.aftonbladet.snack.renderErrorMessage=function(D,A){var B=YAHOO.util.Dom.get("abArtError");
var C="";
if(D==this.RESULT_CODE_ACCESS_DENIED){C="Du m&aring;ste vara registrerad anv&auml;ndare f&ouml;r att skriva en kommentar."
}else{if(D==this.RESULT_CODE_CLOSED){C="Kommentarsfunktionen &auml;r avst&auml;ngd mellan midnatt och 06:00. V&auml;lkommen &aring;ter!"
}else{if(D==this.RESULT_CODE_EXPIRED){C="Funktionen f&ouml;r att skriva kommentarer &auml;r avst&auml;ngd."
}else{if(D==this.RESULT_CODE_TIME_CHECK){C="Du m&aring;ste v&auml;nta 30 sekunder f&ouml;r att kunna skriva en kommentar igen."
}else{if(D==this.RESULT_CODE_ERROR_UNKNOWN){C="Ett problem har intr&auml;ffat"
}else{C="Ett problem har intr&auml;ffat"
}}}}}B.innerHTML=C;
if(!A){this.hideModule("abArtCount");
this.hideModule("abArtTB");
this.hideModule("abArtSubmitButton")
}if(!abIsSnackMember()){this.showModule("abArtLinksLogin")
}this.showModule("abArtError")
};
se.aftonbladet.snack.renderJoinGroupMessage=function(){var A=YAHOO.util.Dom.get("abArtJoinGroupName");
A.innerHTML="G&aring; med i "+se.aftonbladet.snack.commentsGroupName;
this.showModule("abArtLinksGroupMember");
YAHOO.util.Dom.setStyle("abArtSubmitButton","opacity",1);
myTooltip=new YAHOO.widget.Tooltip("abArtLinksGroupMemberTooltop",{context:"abArtLinksGroupMember",text:"Som medlem i en Snackgrupp kan du hitta likasinnade att diskutera med och f&aring; tips av. H&auml;r kan du ladda upp dina foton och hitta de b&auml;sta bloggarna inom just ditt intresseomr&aring;de. G&aring; med nu!",showDelay:500,autodismissdelay:8000})
};
se.aftonbladet.snack.renderArticleHeadlineText=function(){var A=YAHOO.util.Dom.get("abArtHBHeadline");
if(!YAHOO.lang.isUndefined(se.aftonbladet.snack.HEADLINE_TEXT)&&YAHOO.lang.trim(se.aftonbladet.snack.HEADLINE_TEXT).length>0){A.innerHTML=se.aftonbladet.snack.HEADLINE_TEXT
}};
se.aftonbladet.snack.setPageSize=function(A){if(this.maxPerPageHistory<A){this.maxPerPageHistory=A
}this.perPage=A;
this.navigate(0)
};
se.aftonbladet.snack.navigate=function(F){this.page=F>0?F:0;
var H=this.page*this.perPage;
var A=H+this.perPage;
if(A>this.getCommentsCount()){A=this.getCommentsCount()
}if(A>this.comments.length){var G=this.lastBatch+1;
var E=Math.floor(A/this.batchSize);
this.getComments(G,E);
return 
}var D=[];
var B=0;
for(var C=H;
C<A;
C++){D[B++]=this.comments[C]
}this.renderComments(D);
this.renderPagination();
this.renderCommentsCount()
};
se.aftonbladet.snack.showLoginModules=function(){this.showModule("abArtLogin");
this.hideModule("abArtTB");
this.hideModule("abArtCount");
this.showModule("abArtLinksBack");
this.hideModule("abArtLinksLogin");
this.hideModule("abArtError");
if(this.getCommentsCount()<=0){this.showModule("abArtCBDivider")
}YAHOO.util.Dom.replaceClass("abArtBoxInner","abArtBoxNormalInner","abArtBoxLoginInner")
};
se.aftonbladet.snack.goBackModules=function(){this.hideModule("abArtLogin");
this.showModule("abArtTB");
this.showModule("abArtCount");
this.hideModule("abArtLinksBack");
this.showModule("abArtLinksLogin");
this.hideModule("abArtCBDivider");
this.hideModule("abArtError");
YAHOO.util.Dom.replaceClass("abArtBoxInner","abArtBoxLoginInner","abArtBoxNormalInner")
};
se.aftonbladet.snack.articleLoadedModules=function(){this.showModule("abArtHB");
this.showModule("abArtCB");
this.showModule("abArtTB");
this.hideModule("abArtLoadBox");
if(abIsSnackMember()){this.showModule("abArtCommentLoggedInMember");
this.hideModule("abArtCommentLoggedOutMember");
this.hideModule("abArtCommentNotSnackMember");
this.hideModule("abArtCommentClosed");
this.hideModule("abArtCommentExpired");
this.showModule("abArtSubmitButton");
this.hideModule("abArtLinksLogin");
this.hideModule("abArtLinksSnackMember");
YAHOO.util.Dom.addClass("abArtLogo","abArtLogoButtonMode")
}else{if(abIsLoggedIn()){this.showModule("abArtLinksSnackMember");
this.showModule("abArtCommentNotSnackMember")
}else{this.showModule("abArtLinksLogin");
this.showModule("abArtCommentLoggedOutMember")
}}this.commentsClosed()
};
se.aftonbladet.snack.noCommentsAddedModules=function(){YAHOO.util.Dom.get("abArtCommentTextareaLoggedOut").value=this.FIRST_COMMENT_TEXT;
this.renderCommentsCountSpans("inga kommentarer");
this.commentsClosed()
};
se.aftonbladet.snack.commentsClosed=function(){if(!this.comments.open){if(this.comments.expired){this.showModule("abArtCommentExpired");
this.hideModule("abArtCommentClosed")
}else{this.showModule("abArtCommentClosed");
this.hideModule("abArtCommentExpired")
}this.hideModule("abArtCommentLoggedInMember");
this.hideModule("abArtCommentLoggedOutMember");
this.hideModule("abArtCommentNotSnackMember");
this.hideModule("abArtSubmitButton")
}};
se.aftonbladet.snack.checkGroupMembership=function(A){if(!this.groupMembershipChecked){YAHOO.util.Dom.setStyle("abArtSubmitButton","opacity",1);
this.showJoinGroupMessage();
this.groupMembershipChecked=true
}};
se.aftonbladet.snack.joinGroup=function(A){this.joiningGroup=A
};
se.aftonbladet.snack.modules=[];
se.aftonbladet.snack.commentModulesInit=function(){this.initModule("abArtHB",false);
this.initModule("abArtCB",false);
this.initModule("abArtCount",false);
this.initModule("abArtTB",false);
this.initModule("abArtLoadBox",false);
this.initModule("abArtLogin",false);
this.initModule("abArtBB",false);
this.initModule("abArtBox",false);
this.initModule("abArtCommentLoggedInMember",false);
this.initModule("abArtCommentLoggedOutMember",false);
this.initModule("abArtCommentNotSnackMember",false);
this.initModule("abArtCommentClosed",false);
this.initModule("abArtCommentExpired",false);
this.initModule("abArtLinksLogin",false);
this.initModule("abArtLinksSnackMember",false);
this.initModule("abArtLinksBack",false);
this.initModule("abArtLinksGroupMember",false);
this.initModule("abArtSubmitButton",false);
this.initModule("abArtCBDivider",false);
this.initModule("abArtError",false);
this.hideModule("abArtHB");
this.hideModule("abArtCB");
this.hideModule("abArtCount");
this.hideModule("abArtTB");
this.showModule("abArtLoadBox");
this.hideModule("abArtLogin");
this.showModule("abArtBB");
this.showModule("abArtBox");
this.hideModule("abArtCommentLoggedInMember");
this.hideModule("abArtCommentClosed");
this.hideModule("abArtCommentExpired");
this.hideModule("abArtCommentLoggedOutMember");
this.hideModule("abArtCommentNotSnackMember");
this.hideModule("abArtLinksLogin");
this.hideModule("abArtLinksBack");
this.hideModule("abArtLinksGroupMember");
this.hideModule("abArtSubmitButton");
this.hideModule("abArtCommentClosed");
this.hideModule("abArtCommentExpired");
this.hideModule("abArtError")
};
se.aftonbladet.snack.initModule=function(C,A){var B=new YAHOO.widget.Module(C,{visible:A});
B.render();
this.modules[C]=B
};
se.aftonbladet.snack.hideModule=function(B){var A=this.modules[B];
if(!YAHOO.lang.isUndefined(A)&&!YAHOO.lang.isNull(A)){A.hide();
A.render()
}};
se.aftonbladet.snack.showModule=function(B){var A=this.modules[B];
if(!YAHOO.lang.isUndefined(A)&&!YAHOO.lang.isNull(A)){A.show();
A.render()
}};
se.aftonbladet.snack.removeModule=function(B){var A=this.modules[B];
if(!YAHOO.lang.isUndefined(A)&&!YAHOO.lang.isNull(A)){A.destroy()
}};
se.aftonbladet.snack.becomeSnackMember=function(){location.href="http://snack.aftonbladet.se"
};
var scriptLoaded=true;