function ConstantContact(b,a){this.DivID=b;this.RootUrl="http://www.filigranes.be/";this.ImageValide="http://www.filigranes.be/Images/Registration/ok.gif";this.ImageInvalid="http://www.filigranes.be/Images/Registration/attention.gif";this.OnRegistration=(a!=undefined?a:false);var e=document.getElementsByTagName("head")[0];if(e){var c=e.getElementsByTagName("script");var j=e.getElementsByTagName("link");var g=false;for(var d=0;d<c.length;d++){var f=c[d];if(f.src.indexOf("common.js")>0){g=true;break}}if(g==false){var h=document.createElement("script");h.type="text/javascript";h.src=this.RootUrl+"js/methods/common.js";e.appendChild(h)}}}ConstantContact.prototype.Init=function(){var b=this;if(document.getElementById(this.DivID)){if(document.getElementById("txtMail")){document.getElementById("txtMail").value="";if(this.OnRegistration==false){document.getElementById("txtMail").onkeyup=function(c){OnVerifyConstantMail(c,"txtMail","ImgMail",b)}}}var a=document.createElement("div");a.id="ConstantContactList";imgLoad=document.createElement("div");imgLoad.id="loading_"+b.DivID;imgLoad.className="ImageLoading";a.appendChild(imgLoad);document.getElementById(b.DivID).appendChild(a);new Ajax.Request(b.RootUrl+"ConstantContactList.ashx",{method:"get",onSuccess:function(c){b.OnConstantContactListSucceed(c)},onFailure:function(c){b.OnConstantContactListFailed(c)},parameters:{ms:new Date().getTime()}});if(GetCookie("Mail")){document.getElementById("txtMail").value=GetCookie("Mail");OnVerifyConstantMail(null,"txtMail","ImgMail",b)}}};ConstantContact.prototype.OnConstantContactListSucceed=function(e){if(e&&e.responseXML){var k=e.responseXML.getElementsByTagName("ContactList");var d=new Array(k.length);for(var g=0;g<k.length;g++){var h=k[g];var c=0;var a="";var b="";if(h.getElementsByTagName("SortOrder")&&h.getElementsByTagName("SortOrder").length>0&&h.getElementsByTagName("SortOrder")[0]&&h.getElementsByTagName("SortOrder")[0].firstChild&&h.getElementsByTagName("SortOrder")[0].firstChild.nodeValue){c=parseInt(h.getElementsByTagName("SortOrder")[0].firstChild.nodeValue)}if(h.getElementsByTagName("Name")&&h.getElementsByTagName("Name").length>0&&h.getElementsByTagName("Name")[0]&&h.getElementsByTagName("Name")[0].firstChild&&h.getElementsByTagName("Name")[0].firstChild.nodeValue){a=h.getElementsByTagName("Name")[0].firstChild.nodeValue}if(h.attributes.getNamedItem("id")&&h.attributes.getNamedItem("id").nodeValue){b=h.attributes.getNamedItem("id").nodeValue}d[g]=new Array();d[g]["ID"]=b;d[g]["Name"]=a}var m=this;if(document.getElementById("ConstantContactList")){for(var g=0;g<d.length;g++){var l=document.createElement("input");l.id="chk"+g;l.type="checkbox";l.value=d[g]["ID"];document.getElementById("ConstantContactList").appendChild(l);var f=document.createElement("span");f.appendChild(document.createTextNode(d[g]["Name"]));document.getElementById("ConstantContactList").appendChild(f);if(g<d.length-1){var n=document.createElement("br");document.getElementById("ConstantContactList").appendChild(n)}}if(!(this.OnRegistration==true&&!GetCookie("Mail"))){var j=document.getElementById("ConstantContactList").getElementsByTagName("input");for(var g=0;g<j.length;g++){j[g].onclick=function(i){m.OnCheckChange(i)}}}}}if(document.getElementById("loading_"+this.DivID)){document.getElementById("loading_"+this.DivID).style.display="none"}OnVerifyConstantMail(null,"txtMail","ImgMail",m)};ConstantContact.prototype.OnConstantContactListFailed=function(a){if(document.getElementById("loading_"+this.DivID)){document.getElementById("loading_"+this.DivID).style.display="none"}};ConstantContact.prototype.CheckConstantContactList=function(c){var e="";if(document.getElementById(c)){e=document.getElementById(c).value}if(emailValidation(e)){if(document.getElementById("ConstantContactList")){document.getElementById("ConstantContactList").disabled="disabled"}if(this.OnRegistration==true&&!GetCookie("Mail")){var a=document.getElementById("ConstantContactList").getElementsByTagName("input");for(var d=0;d<a.length;d++){a[d].checked=true}document.getElementById("ConstantContactList").disabled=""}else{var b=this;new Ajax.Request(b.RootUrl+"ConstantContactUserList.ashx",{method:"post",onSuccess:function(f){b.OnVerifyConstantMailSucceed(f)},onFailure:function(f){b.OnVerifyConstantMailError(f)},postBody:e})}}};ConstantContact.prototype.GetNewsLetters=function(){var c="";if(document.getElementById("ConstantContactList")){var a=document.getElementById("ConstantContactList").getElementsByTagName("input");for(var b=0;b<a.length;b++){if(a[b].checked==true){if(c!=""){c+="|"}c+=a[b].value}}}return c};ConstantContact.prototype.OnCheckChange=function(d){var b=this;if(document.getElementById("txtMail")){if(emailValidation(document.getElementById("txtMail").value)){var f="<ConstantContact>";f+="<Mail>"+document.getElementById("txtMail").value+"</Mail>";if(document.getElementById("ConstantContactList")){document.getElementById("ConstantContactList").disabled="disabled";var a=document.getElementById("ConstantContactList").getElementsByTagName("input");for(var c=0;c<a.length;c++){if(a[c].checked==true){f+="<List>"+a[c].value+"</List>"}}}f+="</ConstantContact>";new Ajax.Request(b.RootUrl+"ConstantContactModifyUser.ashx",{method:"post",onSuccess:function(e){b.OnModifyUserSucceed(e)},onFailure:function(e){b.OnModifyUserFailed(e)},postBody:f})}}};ConstantContact.prototype.OnModifyUserSucceed=function(a){this.CheckConstantContactList("txtMail")};ConstantContact.prototype.OnModifyUserFailed=function(a){this.CheckConstantContactList("txtMail")};ConstantContact.prototype.OnVerifyConstantMailSucceed=function(f){if(f&&f.responseXML){if(document.getElementById("ConstantContactList")){var b=f.responseXML.getElementsByTagName("ContactList");for(var d=0;d<b.length;d++){var e="";if(b[d].attributes.getNamedItem("id")&&b[d].attributes.getNamedItem("id").nodeValue){e=b[d].attributes.getNamedItem("id").nodeValue}var a=document.getElementById("ConstantContactList").getElementsByTagName("input");for(var c=0;c<a.length;c++){if(a[c].value==e){a[c].checked=true;break}}}document.getElementById("ConstantContactList").disabled=""}}else{if(document.getElementById("ConstantContactList")){var a=document.getElementById("ConstantContactList").getElementsByTagName("input");for(var c=0;c<a.length;c++){a[c].checked=false}document.getElementById("ConstantContactList").disabled=""}}};ConstantContact.prototype.OnVerifyConstantMailError=function(c){if(document.getElementById("ConstantContactList")){var a=document.getElementById("ConstantContactList").getElementsByTagName("input");for(var b=0;b<a.length;b++){a[b].checked=false}document.getElementById("ConstantContactList").disabled=""}};OnVerifyConstantMail=function(h,f,b,c){if(document.getElementById(f)&&document.getElementById(b)){if(document.getElementById(f).value.length>0&&emailValidation(document.getElementById(f).value)){var g=document.getElementById(b);g.className="Valide";g.src=c.ImageValide;g.alt="Valide";c.CheckConstantContactList(f)}else{var g=document.getElementById(b);g.className="Invalid";g.src=c.ImageInvalid;g.alt="Non Valide";if(document.getElementById("ConstantContactList")){var a=document.getElementById("ConstantContactList").getElementsByTagName("input");for(var d=0;d<a.length;d++){a[d].checked=false}document.getElementById("ConstantContactList").disabled="disabled"}}}};