function Moderate(a){this.DivID=a;this.CommentsXML="";this.OldSelectedValue="";this.AdminValue=1;this.ModeratorValue=2;this.MediaType="";this.TreeNode="";this.Reference="";this.RootUrl="http://www.filigranes.be/";this.wymEditor=null;this.EditorComentID="";this.OldComment=""}Moderate.prototype.Init=function(){if(document.getElementById(this.DivID)){var g=document.getElementsByTagName("head")[0];if(g){var b=g.getElementsByTagName("script");var k=g.getElementsByTagName("link");var d=false;var a=false;for(var f=0;f<b.length;f++){var h=b[f];if(h.src.indexOf("date.js")>0){d=true}if(h.src.indexOf("common.js")>0){d=true}if((a==true)&&(d==true)){break}}if(d==false){var j=document.createElement("script");j.type="text/javascript";j.src=this.RootUrl+"js/methods/date.js";g.appendChild(j)}if(a==false){var j=document.createElement("script");j.type="text/javascript";j.src=this.RootUrl+"js/methods/common.js";g.appendChild(j)}}var e=GetCookie("Mail");var c=GetCookie("UserType");if(e&&c){if(parseInt(c)==this.AdminValue||parseInt(c)==this.ModeratorValue){moderatorTmp=this;LoadCommentsXML(moderatorTmp)}else{document.getElementById(this.DivID).appendChild(document.createTextNode("Vous n'êtes pas autorisé à accéder à ce contenu !"))}}else{document.getElementById(this.DivID).appendChild(document.createTextNode("Veuillez vous connecter !"))}}};LoadCommentsXML=function(a){criteria="<Moderator><UserMail>"+GetCookie("Mail")+"</UserMail></Moderator>";new Ajax.Request(a.RootUrl+"ModeratorGetComment.ashx",{method:"POST",onSuccess:function(b){a.OnLoadCommentsSucceed(b)},onFailure:function(b){a.OnLoadCommentsFailed()},postBody:criteria})};Moderate.prototype.OnLoadCommentsFailed=function(a){this.CommentsXML=undefined;this.BuildModeratorTable("Main",null)};Moderate.prototype.OnLoadCommentsSucceed=function(a){if(a&&a.responseXML){this.CommentsXML=a.responseXML;this.BuildModeratorTable("Main",null)}};Moderate.prototype.AcceptComment=function(c){if(this.EditorComentID!=""){if(confirm("Etes-vous sur de vouloir accepter le commentaire sans l'avoir sauvegarder ?")){this.CancelModification()}else{return}}if(!c){c=window.event}var b=undefined;if(c&&c.srcElement){b=c.srcElement}else{b=c.target}if(b!=undefined){var d="";if(b.id){var a=b.id.substr(7,b.id.length-7);this.SaveComment(a,true,false)}}};Moderate.prototype.DeleteComment=function(c){if(confirm("Etes-vous sur de vouloir supprimer le commentaire ?")){this.CancelModification();if(!c){c=window.event}var b=undefined;if(c&&c.srcElement){b=c.srcElement}else{b=c.target}if(b!=undefined){var d="";if(b.id){var a=b.id.substr(7,b.id.length-7);this.SaveComment(a,false,true)}}}};Moderate.prototype.EditComment=function(c){if(!c){c=window.event}var b=undefined;if(c&&c.srcElement){b=c.srcElement}else{b=c.target}if(b!=undefined){var f="";if(b.id){var d=this;var a=b.id.substr(5,b.id.length-5);if(this.wymEditor==null){textArea=document.createElement("textarea");textArea.id="txtYourComment";textArea.setAttribute("rows","1");if(document.getElementById("comment_"+a)){d.EditorComentID=a;d.OldComment=document.getElementById("comment_"+a).innerHTML;textArea.value=document.getElementById("comment_"+a).innerHTML;document.getElementById("comment_"+a).innerHTML="";document.getElementById("comment_"+a).appendChild(textArea);setTimeout(function(){jQuery(function(){jQuery("#txtYourComment").wymeditor({toolsItems:[{name:"Bold",title:"Strong",css:"wym_tools_strong"},{name:"Italic",title:"Emphasis",css:"wym_tools_emphasis"},{name:"InsertOrderedList",title:"Ordered_List",css:"wym_tools_ordered_list"},{name:"InsertUnorderedList",title:"Unordered_List",css:"wym_tools_unordered_list"},{name:"Indent",title:"Indent",css:"wym_tools_indent"},{name:"Outdent",title:"Outdent",css:"wym_tools_outdent"},{name:"CreateLink",title:"Link",css:"wym_tools_link"},{name:"Unlink",title:"Unlink",css:"wym_tools_unlink"}],boxHtml:"<div class='wym_box'><div class='wym_area_top'>"+WYMeditor.TOOLS+"</div><div class='wym_area_left'></div><div class='wym_area_right'></div><div class='wym_area_main'>"+WYMeditor.HTML+WYMeditor.IFRAME+WYMeditor.STATUS+"</div><div class='wym_area_bottom'></div></div>",postInit:function(g){d.wymEditor=g;var e="<li class='wym_tools_newbutton'><a name='Save' href='#' alt='Envoyer' style='background-image: url(http://www.filigranes.be/Images/WymEditor/envoyer.gif);width:78px'>Sauvegarder votre commentaire</a></li><li class='wym_tools_newbutton_cancel'><a name='Annuler' href='#' alt='Annuler' style='background-image: url(http://www.filigranes.be/Images/WymEditor/annuler.gif);width:78px'>Annuler</a></li>";jQuery(g._box).find(g._options.toolsSelector+g._options.toolsListSelector).append(e);jQuery(g._box).find("li.wym_tools_newbutton a").click(function(){d.SaveModification()});jQuery(g._box).find("li.wym_tools_newbutton_cancel a").click(function(){d.CancelModification();return(false)})}})})},500)}}}}};Moderate.prototype.CancelModification=function(){if(this.EditorComentID){if(document.getElementById("comment_"+this.EditorComentID)){document.getElementById("comment_"+this.EditorComentID).innerHTML=this.OldComment;this.EditorComentID="";this.OldComment="";this.wymEditor=null}}};Moderate.prototype.SaveModification=function(){if(this.EditorComentID&&GetCookie("Mail")){if(document.getElementById("comment_"+this.EditorComentID)){var c=removeHTMLTags(this.wymEditor.html());var a=this;c=c.split(" ").join("").split("&nbsp;").join("").split("\r\n").join("");if(c.length>0){var b="<CommentParam>";b+="<ID>"+a.EditorComentID+"</ID>";b+="<Mail>"+GetCookie("Mail")+"</Mail>";b+="<MediaType>"+a.MediaType+"</MediaType>";b+="<Comment>"+Base64.encode(accentToHTML(this.wymEditor.html()))+"</Comment>";b+="</CommentParam>";b=Base64.encode(b);new Ajax.Request(a.RootUrl+"SaveComment.ashx",{method:"POST",onSuccess:function(d){a.OnSaveModificationSucceed(d)},onFailure:function(d){a.OnSaveModificationError(d)},postBody:b})}}}};Moderate.prototype.OnSaveModificationSucceed=function(a){if(this.EditorComentID){if(document.getElementById("comment_"+this.EditorComentID)){document.getElementById("comment_"+this.EditorComentID).innerHTML=this.wymEditor.html();this.EditorComentID="";this.OldComment="";this.wymEditor=null}}};Moderate.prototype.OnSaveModificationError=function(a){this.wymEditor.status(a.responseText)};Moderate.prototype.SaveComment=function(g,f,a){var c=this;var b=GetCookie("Mail");var e=GetCookie("UserType");if(b&&e){if(parseInt(e)==this.AdminValue||parseInt(e)==this.ModeratorValue){bookDetailTmp=this;var d="<CommentParam>";d+="<ID>"+g+"</ID>";d+="<MediaType>"+c.MediaType+"</MediaType>";d+="<ValidatorMail>"+b+"</ValidatorMail>";d+="<Mail>"+b+"</Mail>";d+="<Validated>"+(f==true?"1":"0")+"</Validated>";d+="<Deleted>"+(a==true?"1":"0")+"</Deleted>";d+="</CommentParam>";d=Base64.encode(d);new Ajax.Request(this.RootUrl+"SaveComment.ashx",{method:"POST",onSuccess:function(h){c.OnSaveCommentSucceed(h,g)},onFailure:function(h){c.OnSaveCommentError(h)},postBody:d})}else{this.Init()}}else{this.Init()}};Moderate.prototype.OnSaveCommentSucceed=function(e,a){if(a){if(document.getElementById("div_"+a)&&document.getElementById("ModeratorContent")){document.getElementById("ModeratorContent").removeChild(document.getElementById("div_"+a));for(var l=0;l<document.getElementById("ModeratorContent").childNodes.length;l++){document.getElementById("ModeratorContent").childNodes[l].className=(l%2==0?"DivEven":"DivOdd")}var f=moderatorTmp.CommentsXML.getElementsByTagName("MediaType");for(var l=0;l<f.length;l++){var d=f[l];if(d.attributes.getNamedItem("Description")){if(d.attributes.getNamedItem("Description").nodeValue==this.MediaType){var c=d.getElementsByTagName("Reference");for(var h=0;h<c.length;h++){var n=c[h];if(n.attributes.getNamedItem("Reference")&&n.attributes.getNamedItem("Reference").nodeValue==moderatorTmp.Reference){var m=n.getElementsByTagName("FiligranauteComment");for(var g=0;g<m.length;g++){var b=m[g];if(b.getElementsByTagName("ID")&&b.getElementsByTagName("ID").length>0&&b.getElementsByTagName("ID")[0].firstChild){commentID=b.getElementsByTagName("ID")[0].firstChild.nodeValue}if(commentID==a){n.removeChild(b);if(n.childNodes.length==0){d.removeChild(n)}break}}break}}break}}}}}};Moderate.prototype.OnSaveCommentError=function(a){};Moderate.prototype.BuildModeratorTable=function(e,b,t){if(this.CommentsXML){if(e.toLowerCase()!=this.TreeNode.toLowerCase()){this.TreeNode==e;this.MediaType=b;this.Reference=t;var v;var c;var p=this;if(document.getElementById("ModeratorHeader")){v=document.getElementById("ModeratorHeader");if(v.hasChildNodes()){while(v.childNodes.length>=1){v.removeChild(v.firstChild)}}}else{v=document.createElement("div");v.id="ModeratorHeader";document.getElementById(this.DivID).appendChild(v)}if(document.getElementById("ModeratorContent")){c=document.getElementById("ModeratorContent");if(c.hasChildNodes()){while(c.childNodes.length>=1){c.removeChild(c.firstChild)}}}else{c=document.createElement("div");c.id="ModeratorContent";document.getElementById(this.DivID).appendChild(c)}var l=document.createElement("a");l.href="#";l.onclick=function(){p.BuildModeratorTable("Main",null,null)};l.appendChild(document.createTextNode("Main"));var s=document.createElement("a");s.href="#";s.onclick=function(){p.BuildModeratorTable("MediaType",this.childNodes[0].nodeValue,null)};s.appendChild(document.createTextNode((p.MediaType?p.MediaType:"")));switch(e){case"Main":var r=p.CommentsXML.getElementsByTagName("MediaType");var E=document.createElement("table");E.style.width="100%";E.className="UserList";c.appendChild(E);theader=document.createElement("thead");E.appendChild(theader);trHeader=document.createElement("tr");theader.appendChild(trHeader);tdMediatypeHeader=document.createElement("td");tdMediatypeHeader.appendChild(document.createTextNode("Media Type"));trHeader.appendChild(tdMediatypeHeader);tBody=document.createElement("tbody");E.appendChild(tBody);for(var B=0;B<r.length;B++){var A=r[B];if(A.childNodes.length>0){if(A.attributes.getNamedItem("Description")){trElement=document.createElement("tr");trElement.className=(B%2==0?"Even":"Odd");tBody.appendChild(trElement);tdMediaType=document.createElement("td");trElement.appendChild(tdMediaType);aMediaType=document.createElement("a");aMediaType.href="#";aMediaType.onclick=function(){p.BuildModeratorTable("MediaType",this.childNodes[0].nodeValue)};aMediaType.appendChild(document.createTextNode(A.attributes.getNamedItem("Description").nodeValue));tdMediaType.appendChild(aMediaType)}}}break;case"MediaType":v.appendChild(l);var r=p.CommentsXML.getElementsByTagName("MediaType");for(var B=0;B<r.length;B++){var A=r[B];if(A.attributes.getNamedItem("Description")){if(A.attributes.getNamedItem("Description").nodeValue==p.MediaType){var E=document.createElement("table");E.style.width="100%";E.className="UserList";c.appendChild(E);theader=document.createElement("thead");E.appendChild(theader);trHeader=document.createElement("tr");theader.appendChild(trHeader);tdRefHeader=document.createElement("td");tdRefHeader.appendChild(document.createTextNode("Reference"));trHeader.appendChild(tdRefHeader);tdNbCommentHeader=document.createElement("td");tdNbCommentHeader.appendChild(document.createTextNode("Nombre de commentaires"));trHeader.appendChild(tdNbCommentHeader);tBody=document.createElement("tbody");E.appendChild(tBody);var w=A.getElementsByTagName("Reference");for(var z=0;z<w.length;z++){var q=w[z];var f="";var G="";if(q.attributes.getNamedItem("Reference")){f=q.attributes.getNamedItem("Reference").nodeValue}if(q.attributes.getNamedItem("NbComment")){G=q.attributes.getNamedItem("NbComment").nodeValue}trElement=document.createElement("tr");trElement.className=(z%2==0?"Even":"Odd");tBody.appendChild(trElement);tdReference=document.createElement("td");tdReference.style.textAlign="center";trElement.appendChild(tdReference);s=document.createElement("a");s.href="#";s.onclick=function(){p.BuildModeratorTable("Comments",p.MediaType,this.childNodes[0].nodeValue)};s.appendChild(document.createTextNode(f));tdReference.appendChild(s);tdReference.appendChild(document.createTextNode(" "));aMoreDetail=document.createElement("a");aMoreDetail.className="snap_shot";aMoreDetail.href=this.RootUrl;if(p.MediaType=="Book"){aMoreDetail.href+="fr/details-livre/index.htm?book="+f}else{if(p.MediaType=="Video"){aMoreDetail.href+="fr/video/index.htm?clip="+f}}aMoreDetail.target="_self";aMoreDetail.appendChild(document.createTextNode("(Plus de détail)"));tdReference.appendChild(aMoreDetail);tdNbComment=document.createElement("td");tdNbComment.style.width="150px";tdNbComment.style.textAlign="right";trElement.appendChild(tdNbComment);tdNbComment.appendChild(document.createTextNode(G))}addSnap();break}}}break;case"Comments":v.appendChild(l);v.appendChild(document.createTextNode(" >> "));v.appendChild(s);var r=p.CommentsXML.getElementsByTagName("MediaType");for(var B=0;B<r.length;B++){var A=r[B];if(A.attributes.getNamedItem("Description")){if(A.attributes.getNamedItem("Description").nodeValue==p.MediaType){var w=A.getElementsByTagName("Reference");for(var z=0;z<w.length;z++){var q=w[z];if(q.attributes.getNamedItem("Reference")&&q.attributes.getNamedItem("Reference").nodeValue==p.Reference){var h=q.getElementsByTagName("FiligranauteComment");divCommentHeader=document.createElement("div");divCommentHeader.className="DivHeader";divCommentHeader.appendChild(document.createTextNode("Commentaires non approuvés"));c.appendChild(divCommentHeader);for(var y=0;y<h.length;y++){var D=h[y];var u="";var F=new Date();var a="";var g="";var C="";var d="";if(D.getElementsByTagName("ID")&&D.getElementsByTagName("ID").length>0&&D.getElementsByTagName("ID")[0].firstChild){u=D.getElementsByTagName("ID")[0].firstChild.nodeValue}if(D.getElementsByTagName("Date")&&D.getElementsByTagName("Date").length>0&&D.getElementsByTagName("Date")[0].firstChild){var o=D.getElementsByTagName("Date")[0].firstChild.nodeValue;year=o.substr(0,4);month=o.substr(5,2);if(month.indexOf("0")=="0"){month=month.substr(1,1)}day=o.substr(8,2);if(day.indexOf("0")=="0"){day=day.substr(1,1)}hour=o.substr(11,2);if(hour.indexOf("0")=="0"){hour=hour.substr(1,1)}minute=o.substr(14,2);if(minute.indexOf("0")=="0"){minute=minute.substr(1,1)}F=new Date(parseInt(year),parseInt(month)-1,parseInt(day),parseInt(hour),parseInt(minute),0,0)}if(D.getElementsByTagName("Comment")&&D.getElementsByTagName("Comment").length>0&&D.getElementsByTagName("Comment")[0].firstChild){a=D.getElementsByTagName("Comment")[0].firstChild.nodeValue}if(D.getElementsByTagName("Mail")&&D.getElementsByTagName("Mail").length>0&&D.getElementsByTagName("Mail")[0].firstChild){g=D.getElementsByTagName("Mail")[0].firstChild.nodeValue}if(D.getElementsByTagName("Avatar")&&D.getElementsByTagName("Avatar").length>0&&D.getElementsByTagName("Avatar")[0].firstChild){C=D.getElementsByTagName("Avatar")[0].firstChild.nodeValue}if(D.getElementsByTagName("Pseudo")&&D.getElementsByTagName("Pseudo").length>0&&D.getElementsByTagName("Pseudo")[0].firstChild){d=D.getElementsByTagName("Pseudo")[0].firstChild.nodeValue}divCommentContent=document.createElement("div");divCommentContent.id="div_"+u;divCommentContent.className=(y%2==0?"CommentContainer DivEven":"CommentContainer DivOdd");c.appendChild(divCommentContent);divUser=document.createElement("div");divComment=document.createElement("div");divComment.id="comment_"+u;if(C!=""){imgAvatar=document.createElement("img");imgAvatar.src=C;divUser.appendChild(imgAvatar)}divUser.appendChild(document.createTextNode("Posté par "+htmlToAccent(d)+", le "+F.format("dd/mm/yyyy")+" à "+F.format("HH:MM")));divComment.innerHTML=a;divUser.appendChild(document.createTextNode(""));var m=document.createElement("a");m.id="accept_"+u;m.href="#";m.appendChild(document.createTextNode("Accepter le commentaire"));m.onclick=function(i){p.AcceptComment(i)};divUser.appendChild(m);divUser.appendChild(document.createTextNode(""));var n=document.createElement("a");n.id="delete_"+u;n.href="#";n.onclick=function(i){p.DeleteComment(i)};n.appendChild(document.createTextNode("Supprimer le commentaire"));divUser.appendChild(n);var x=document.createElement("a");x.id="edit_"+u;x.href="#edit"+u;x.onclick=function(i){p.EditComment(i)};x.appendChild(document.createTextNode("Editer le commentaire"));divUser.appendChild(x);divCommentContent.appendChild(divUser);divCommentContent.appendChild(divComment)}break}}break}}}break}}}};