
function byId(id)
{return document.getElementById(id);}
function addEvent(element,eventType,lamdaFunction,useCapture)
{if(element.addEventListener)
{element.addEventListener(eventType,lamdaFunction,useCapture);}
else if(element.attachEvent)
{element.attachEvent('on'+eventType,lamdaFunction);}}
function eventTarget(e)
{return(window.event?window.event.srcElement:(e?e.target:null));}
function stopEvent(event){if(event.preventDefault){event.preventDefault();event.stopPropagation();}else{event.returnValue=false;event.cancelBubble=true;}}
function initMsg()
{byId('message').value='';}
function focusMsg()
{byId('message').focus();}
function scrollBottom()
{if(readDirection=='ASC')byId("messages").scrollTop=0;else byId("messages").scrollTop=byId("messages").scrollHeight;}
function addText(myField,myValue){if(document.selection){myField.focus();sel=document.selection.createRange();sel.text=myValue;}
else if(myField.selectionStart||myField.selectionStart=='0'){var startPos=myField.selectionStart;var endPos=myField.selectionEnd;myField.value=myField.value.substring(0,startPos)
+myValue
+myField.value.substring(endPos,myField.value.length);}
else{myField.value+=myValue;}}
function addSmiley(e)
{var target=eventTarget(e);var message=byId('message');addText(message,target.getAttribute('alt'));focusMsg();}
function createItem(element,text,appendTo)
{var itemElement=document.createElement(element);if(text)itemElement.appendChild(document.createTextNode(text));appendTo.appendChild(itemElement);return itemElement;}
function addCookie(name,value)
{var argv=addCookie.arguments;var argc=addCookie.arguments.length;var expires=(argc>2)?argv[2]:null;var path=(argc>3)?argv[3]:null;var domain=(argc>4)?argv[4]:null;var secure=(argc>5)?argv[5]:false;document.cookie=name+"="+escape(value)+
((expires==null)?"":("; expires="+expires.toGMTString()))+
((path==null)?"":("; path="+path))+
((domain==null)?"":("; domain="+domain))+
((secure==true)?"; secure":"");}
function getCookieVal(offset)
{var endstr=document.cookie.indexOf(";",offset);if(endstr==-1)endstr=document.cookie.length;return unescape(document.cookie.substring(offset,endstr));}
function readCookie(name)
{var arg=name+"=";var alen=arg.length;var clen=document.cookie.length;var i=0;while(i<clen)
{var j=i+alen;if(document.cookie.substring(i,j)==arg)return getCookieVal(j);i=document.cookie.indexOf(" ",i)+1;if(i==0)break;}
return null;}
if(typeof window.addEventListener!='undefined')
{window.addEventListener('load',init,false);safari=true;}
else if(typeof document.addEventListener!='undefined')
{document.addEventListener('load',init,false);opera=true;}
else if(typeof window.attachEvent!='undefined')
{window.attachEvent('onload',init);ie=true;}
function sineInOut(t,b,c,d)
{return-c/2*(Math.cos(Math.PI*t/d)-1)+b;}
function positionElement(id)
{var id=byId(id);var pX=0;do{pX+=id.offsetLeft;}while(id=id.offsetParent)
return pX;}
function dec2hex(dec)
{hex=parseInt(dec).toString(16);return((hex.length==1)?0:'')+hex;}
function hex2dec(hex)
{var rgb=new Array();rgb[1]=parseInt(hex.substr(1,2),16);rgb[2]=parseInt(hex.substr(3,2),16);rgb[3]=parseInt(hex.substr(5,2),16);return rgb;}
function getBgValue(selector)
{if(!document.styleSheets)return;else if(document.styleSheets[0].cssRules)rules=document.styleSheets[0].cssRules;else if(document.styleSheets[0].rules)rules=document.styleSheets[0].rules;else return;for(i=0;i<rules.length;i++)
{if(rules[i].selectorText==selector)
{var extracted=rules[i].style.backgroundColor;rgb=extracted.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/i);if(!rgb)rgb=hex2dec(extracted);return rgb;}}}
function reSizeShoutbox()
{var divContent=byId('content');var divMessages=byId('messages');var divExtras=byId('extras');var divLogin=byId('login');if(divContent.offsetWidth>578)
{if(readDirection=='ASC')var classNameBody='shoutboxHorinzontal shoutboxASCHorinzontal';if(readDirection=='DESC')var classNameBody='shoutboxHorinzontal';}
else
{if(readDirection=='ASC')var classNameBody='shoutboxASC';}
var theBody=document.getElementsByTagName('body')[0];if(ie){theBody.setAttribute('className',classNameBody);}
else{theBody.setAttribute('class',classNameBody);}
if(divContent.offsetWidth==0||divContent.offsetHeight==0)return;var widthContent=divContent.offsetWidth-2;var widthShoutbox=widthContent+'px';var heightContent=divContent.offsetHeight-2;var heightShoutbox=heightContent+'px';divMessages.style.width=widthShoutbox;divExtras.style.width=widthShoutbox;divLogin.style.width=widthShoutbox;divMessages.style.height=heightShoutbox;divExtras.style.height=heightShoutbox;divLogin.style.height=heightShoutbox;}
function encodeURL(text)
{text=encodeURIComponent(text);return text;}
function removeLinks(string)
{var regex=/((http|https|ftp|mms|sop|tvu):\/\/[^ ]*)/gi;string=string.replace(regex,"");var regex=/([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+(\.[-a-z0-9]+)*\.[a-z]{2,6})/gi;string=string.replace(regex,"");return string;}
function containLongString(string)
{string=removeLinks(string);var strings=string.split(' ');var answer=false;for(var i=0;i<strings.length;i++)
{if(strings[i].length>18)answer=true;}
return answer;}
function getSound()
{return readCookie('ShoutBoxSoundPref');}
function setSound(number)
{addCookie('ShoutBoxSoundPref',number);sound=number;playSound();}
function playSound()
{try
{if(sound>0)
{window.document.soundBox.GotoFrame(sound);}}
catch(e)
{}}
function toggleView()
{if(translateOn==true)return;if(scrollView=="messages")
{new clScroller('messages','extras');byId('more').value='Extras '+String.fromCharCode(171);scrollView="extras";}
else if(scrollView=="extras")
{new clScroller('extras','messages');byId('more').value='Extras '+String.fromCharCode(187);scrollBottom();scrollView="messages";}
else if(scrollView=="login")
{new clScroller('login','messages');byId('more').value='Extras '+String.fromCharCode(187);scrollView="messages";scrollBottom();}}
function toggleToLogin()
{if(translateOn==true)return;if(scrollView=="login")return;if(scrollView=="messages")
{new clScroller('messages','login');scrollView="login";}
if(scrollView=="extras")
{new clScroller('extras','login');scrollView="login";}
byId('more').value='Extras '+String.fromCharCode(171);}
function addLogin(appendParent)
{if(byId('login'))return;var login=document.createElement('div');login.id='login';createItem('h4','Identification',login);var form=document.createElement('form');var fieldset=document.createElement('fieldset');var label1=document.createElement('label');var input1=document.createElement('input');var label2=document.createElement('label');var input2=document.createElement('input');var input3=document.createElement('input');var input4=document.createElement('input');var linkLost=document.createElement('a');var linkToggle=document.createElement('a');form.setAttribute('action','');form.setAttribute('method','post');label1.setAttribute('for','fieldUsernameLogin');input1.setAttribute('id','fieldUsernameLogin');input1.setAttribute('name','fieldUsernameLogin');input1.setAttribute('type','text');input1.setAttribute('maxlength','20');label2.setAttribute('for','fieldPasswordLogin');input2.setAttribute('id','fieldPasswordLogin');input2.setAttribute('name','fieldPasswordLogin');input2.setAttribute('type','password');input3.setAttribute('name','connectionLogin');input3.setAttribute('type','submit');input4.setAttribute('type','hidden');input4.setAttribute('id','modeSubscribe');input4.setAttribute('value','0');linkToggle.setAttribute('href','javascript:toggleLoginRegister("register")');linkLost.setAttribute('href','javascript:alert("Pour des raisons se s\351curit\351 les mots de passes ne sont pas sauvegard\351s en clair et il est impossible de les restituer. Demandez \340 l\'administrateur de la shoutbox d\'effacer votre compte pour le r\351ouvrir par la suite ou bien d\'ins\351rer un nouveau mot de passe.") ');if(ie)input3.value='Se connecter';else input3.setAttribute('value','Se connecter');label1.appendChild(document.createTextNode('Compte shoutbox :'));label2.appendChild(document.createTextNode('Mot de passe :'));linkLost.appendChild(document.createTextNode('Mot de passe oubli\351'));linkToggle.appendChild(document.createTextNode('Nouveau compte'));login.appendChild(form);form.appendChild(fieldset);fieldset.appendChild(label1);label1.appendChild(input1);fieldset.appendChild(label2);label2.appendChild(input2);form.appendChild(input3);form.appendChild(input4);form.appendChild(linkLost);form.appendChild(linkToggle);addEvent(form,'submit',accountLogin,false);appendParent.appendChild(login);return login;}
function toggleLoginRegister(view)
{if(accessRegistration=='0')
{alert("Les inscriptions sont ferm\351es. Pour ouvrir un compte merci de passer par l'administrateur de la shoutbox.");return;}
if(view=='register')
{var title='Nouveau compte';var button='Cr\351er le compte';var linkLost='none';var linkToggle='login';var linkToggleTitle='Identification';var modeSubscribe=1;}
if(view=='login')
{var title='Identification';var button='Se connecter';var linkLost='block';var linkToggle='register';var linkToggleTitle='Nouveau compte';var modeSubscribe=0;}
var login=byId('login');login.getElementsByTagName('h4')[0].firstChild.nodeValue=title;if(ie)login.getElementsByTagName('input')[2].value=button;else login.getElementsByTagName('input')[2].setAttribute('value',button);login.getElementsByTagName('a')[0].style.display=linkLost;login.getElementsByTagName('a')[1].setAttribute('href','javascript:toggleLoginRegister("'+linkToggle+'")');login.getElementsByTagName('a')[1].firstChild.nodeValue=linkToggleTitle;if(ie)login.getElementsByTagName('input')[3].value=modeSubscribe;else login.getElementsByTagName('input')[3].setAttribute('value',modeSubscribe);}
function addExtras(appendParent)
{if(byId('extras'))return;var extras=document.createElement('div');extras.id='extras';if(smileysPack!="none/")
{smileysArray=[[':rah','mad.gif'],[':-p','razz.gif'],[':-s','bigeek.gif'],['8-]','cool.gif'],['8-)','rolleyes.gif'],[':\'(','cry.gif'],[':-$','shy.gif'],[':-|','none.gif'],[':-o','eek.gif'],[':-/','roll.gif'],[':-(','sad.gif'],[';-)','smilewinkgrin.gif'],[':-)','smile.gif'],['grr','upset.gif'],[':-D','biggrin.gif']];var smileysContent=document.createElement('p');for(var i=0;i<smileysArray.length;i++)
{var curSmiley=createItem('img',false,smileysContent);curSmiley.setAttribute('src',smileysUrl+smileysPack+smileysArray[i][1]);curSmiley.setAttribute('alt',smileysArray[i][0]);curSmiley.setAttribute('title',smileysArray[i][0]);addEvent(curSmiley,'click',addSmiley,false);}}
var smileysPersoContent=document.createElement('p');smileysPersoContent.setAttribute('id','smileysPerso');for(var i=0;i<smileysPersoArray.length;i++)
{if(smileysPersoArray[i][0]=='')break;else smileysPersoIsset=true;var curSmiley=createItem('img',false,smileysPersoContent);curSmiley.setAttribute('src',smileysPersoArray[i][1]);curSmiley.setAttribute('alt',smileysPersoArray[i][0]);curSmiley.setAttribute('title',smileysPersoArray[i][0]);curSmiley.style.display='none';addEvent(curSmiley,'click',addSmiley,false);}
if(smileysPack!="none/"||smileysPersoIsset)createItem('h4','Smileys',extras);if(smileysPack!="none/")extras.appendChild(smileysContent);if(smileysPersoIsset)
{var linkShowSmileysPerso=document.createElement('a');linkShowSmileysPerso.appendChild(document.createTextNode('Voir tous les smileys '+String.fromCharCode(187)));linkShowSmileysPerso.setAttribute('href','javascript:showSmileysPerso()');smileysPersoContent.appendChild(linkShowSmileysPerso);extras.appendChild(smileysPersoContent);}
createItem('h4','Qui est en ligne ?',extras);var pConnected=document.createElement('p');pConnected.setAttribute('id','pConnected');for(var i=0;i<onlineUsersArray.length;i++)
{if(onlineUsersArray[i][0]=='')break;var j=i+2;if(j<onlineUsersArray.length)afterNick=', ';else afterNick='';pConnected.appendChild(document.createTextNode(decodeURIComponent(onlineUsersArray[i])+afterNick));}
extras.appendChild(pConnected);var optionsTitle=document.createElement('h4');extras.appendChild(optionsTitle);optionsTitle.appendChild(document.createTextNode('Options'));var optionsFiles=document.createElement('p');extras.appendChild(optionsFiles);var optionsLinkFiles=document.createElement('a');optionsFiles.appendChild(optionsLinkFiles);optionsLinkFiles.appendChild(document.createTextNode('Voir les archives'));optionsLinkFiles.setAttribute('href','http://www.i-tchat.com/shoutbox/archives.php?idShoutbox='+idShoutbox);optionsLinkFiles.setAttribute('target','_blank');var optionsSound=document.createElement('p');extras.appendChild(optionsSound);var optionsSoundChoice="Sons: ";optionsSoundChoice+="<a href='javascript:setSound(1);'>1</a> - ";optionsSoundChoice+="<a href='javascript:setSound(2);'>2</a> - ";optionsSoundChoice+="<a href='javascript:setSound(3);'>3</a> - ";optionsSoundChoice+="<a href='javascript:setSound(0);'>off</a>";optionsSound.innerHTML=optionsSoundChoice;if(premium==false){var optionsBack=document.createElement('p');extras.appendChild(optionsBack);optionsBack.innerHTML="<a href='http://www.i-tchat.com/feedback-shoutbox' target='_blank'>Cr&eacute;er une shoutbox</a>";}
var loginH4=document.createElement('h4');var loginP=document.createElement('p');var loginBr=document.createElement('br');var loginA=document.createElement('a');var accountDiv=document.createElement('div');loginH4.appendChild(document.createTextNode('R\351servation de pseudo'));loginA.appendChild(document.createTextNode('S\'enregistrer / se connecter'));loginA.setAttribute('href','javascript:toggleToLogin()');loginP.setAttribute('id','loginPSubConnect');accountDiv.setAttribute('id','accountDiv');extras.appendChild(accountDiv);accountDiv.appendChild(loginH4);accountDiv.appendChild(loginP);loginP.appendChild(loginA);appendParent.appendChild(extras);return extras;}
function showSmileysPerso()
{var smileysPerso=byId('smileysPerso');if(!smileysPerso)return;var smileysPersoImg=smileysPerso.getElementsByTagName('img');var linkShow=smileysPerso.getElementsByTagName('a')[0];if(!linkShow)return;for(var i=0;i<smileysPersoImg.length;i++)
{if(smileysPersoImg[i].style.display=='none')
{smileysPersoImg[i].style.display='inline';linkShow.firstChild.nodeValue='Cacher les smileys '+String.fromCharCode(171);addCookie('ShoutBoxSmileysPref','inline');}
else{smileysPersoImg[i].style.display='none';linkShow.firstChild.nodeValue='Voir tous les smileys '+String.fromCharCode(187);addCookie('ShoutBoxSmileysPref','none');}}}
function multiConverter(res)
{var regex=/([^ ]{1,10}:\/\/[^ ]*)/gi;res=res.replace(regex,"<a href=\"$1\" target=\"_blank\">&laquo;lien&raquo;</a>");if(smileysPack!="none/")
{for(var i=0;i<smileysArray.length;i++){if(smileysArray[i][0]=='')break;var regex=smileysArray[i][0].replace(/(\(|\)|\$|\?|\*|\+|\^|\[|\.|\|)/gi,"\\$1");re=new RegExp(regex,'gi');res=res.replace(re,'<img src="'+smileysUrl+smileysPack+smileysArray[i][1]+'" alt="" />');}}
for(var i=0;i<smileysPersoArray.length;i++){if(smileysPersoArray[i][0]=='')break;var regex=smileysPersoArray[i][0].replace(/(\(|\)|\$|\?|\*|\+|\^|\[|\.|\|)/gi,"\\$1");re=new RegExp(regex,'gi');res=res.replace(re,'<img src="'+smileysPersoArray[i][1]+'" alt="" />');}
var regex=/([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+(\.[-a-z0-9]+)*\.[a-z]{2,6})/gi;res=res.replace(regex,"<a href=\"mailto:$1\">&laquo;email&raquo;</a>");return res;}
function addDirectAdmin(e)
{if(statusUser<2)return;var target=eventTarget(e);while(!target.getAttribute('id'))target=target.parentNode;if(target.getElementsByTagName('dl')[0].getElementsByTagName('dd')[2])
{target.getElementsByTagName('dl')[0].removeChild(target.getElementsByTagName('dl')[0].getElementsByTagName('dd')[2]);return;}
var dd=document.createElement('dd');var link1=document.createElement('a');var link2=document.createElement('a');var link3=document.createElement('a');link1.appendChild(document.createTextNode('Supp'));link2.appendChild(document.createTextNode('Ban'));link3.appendChild(document.createTextNode('Spam'));link1.setAttribute('href','javascript:directAdmin()');link2.setAttribute('href','javascript:directAdmin()');link3.setAttribute('href','javascript:directAdmin()');addEvent(link1,'click',directAdmin,false);addEvent(link2,'click',directAdmin,false);addEvent(link3,'click',directAdmin,false);link1.setAttribute('title','Supprimer le message');link2.setAttribute('title','Bannir l\'IP');link3.setAttribute('title','Placer le message dans le filtre anti-spam');link1.setAttribute('name','delete');link2.setAttribute('name','ban');link3.setAttribute('name','spam');dd.appendChild(document.createTextNode('[ '));dd.appendChild(link1);dd.appendChild(document.createTextNode(' - '));dd.appendChild(link2);dd.appendChild(document.createTextNode(' - '));dd.appendChild(link3);dd.appendChild(document.createTextNode(' ]'));dd.setAttribute('class','option');target.getElementsByTagName('dl')[0].appendChild(dd);var contents=byId('messages');var lastPost=contents.lastChild;while(lastPost)
{if(lastPost.nodeType==3)
{lastPost=lastPost.previousSibling;}
else
{break;}}
if(lastPost.id==target.getAttribute('id'))scrollBottom();}
function dynamicConverterInit()
{var postList=byId('messages').getElementsByTagName('li');for(var i=0;i<postList.length;i++)
{var messagePost=postList[i].getElementsByTagName('q')[0].innerHTML;postList[i].getElementsByTagName('q')[0].innerHTML=multiConverter(messagePost);addEvent(postList[i].getElementsByTagName('cite')[0],'click',addDirectAdmin,false);}}
function checkStatusUser()
{if(accessPost<=statusUser)
{byId('form').style.display='block';if(byId('connectField'))byId('main').removeChild(byId('connectField'));}
else
{if(byId('connectField'))return;if(accessPost==1)
{var field=createItem('fieldset','Seuls les membres peuvent poster dans la shoutbox.',byId('main'));}
if(accessPost==2)
{var field=createItem('fieldset','Seuls les admins peuvent poster dans la shoutbox.',byId('main'));}
field.setAttribute('id','connectField');field.style.textAlign='right';byId('form').style.display='none';if(ie){field.innerHTML+='<input type="button" id="connect" />';var connect=byId('connect');}else{var connect=document.createElement('input');connect.setAttribute('id','connect');field.appendChild(connect);connect.setAttribute('type','button');}
connect.setAttribute('value','Connexion '+String.fromCharCode(187));addEvent(connect,'click',toggleToLogin,false);}}
function clFadeSize(id,mode)
{this.obj=byId(id);this.obj.style.overflow='hidden';this.obj.style.display='block';this.heightObj=this.obj.offsetHeight;if(mode=='-')this.setSizeHigher(this.heightObj);if(mode=='+')this.setSizeLower(0);}
clFadeSize.prototype.setSizeHigher=function(size)
{if(size<=1){this.obj.parentNode.removeChild(this.obj);return;}
else{var size=Math.round((size-this.heightObj/10)*10)/10;}
this.obj.style.height=size+'px';var self=this;setTimeout(function(){self.setSizeHigher(size);},30);};clFadeSize.prototype.setSizeLower=function(size)
{if(size>=this.heightObj){return;}
else{var size=Math.round((size+this.heightObj/10)*10)/10;}
this.obj.style.height=size+'px';var self=this;setTimeout(function(){self.setSizeLower(size);},30);};function clScroller(from,to)
{if(opera||accessPost>statusUser)
{byId('messages').style.display='none';byId('extras').style.display='none';byId('login').style.display='none';byId(to).style.display='block';return;}
translateOn=true;fromPosition=positionElement(from);toPosition=positionElement(to);this.start=byId('content').scrollLeft;this.change=toPosition-fromPosition;this.frames=25;this.scrollCycle(0);};clScroller.prototype.scrollCycle=function(currentFrame)
{if(currentFrame>this.frames)
{translateOn=false;return;}
scrollToPosition=sineInOut(currentFrame,this.start,this.change,this.frames);byId('content').scrollLeft=scrollToPosition;currentFrame++;var self=this;setTimeout(function(){self.scrollCycle(currentFrame);},15);};function clFadeColor(id,classFrom,classTo)
{this.obj=byId(id);var rgb=getBgValue(classTo);this.rColor=rgb[1];this.gColor=rgb[2];this.bColor=rgb[3];var rgb=getBgValue(classFrom);this.rColorLight=rgb[1];this.gColorLight=rgb[2];this.bColorLight=rgb[3];this.setColor(1);};clFadeColor.prototype.setColor=function(step)
{if(step<0.74){this.rColorLight=this.rColor;this.gColorLight=this.gColor;this.bColorLight=this.bColor;}
else{stepInvert=1-step;this.rColorLight=Math.floor(this.rColorLight*step+this.rColor*stepInvert);this.gColorLight=Math.floor(this.gColorLight*step+this.gColor*stepInvert);this.bColorLight=Math.floor(this.bColorLight*step+this.bColor*stepInvert);step=Math.round(step*100*0.99)/100;var self=this;setTimeout(function(){self.setColor(step);},70);}
var rColorHex=dec2hex(this.rColorLight);var gColorHex=dec2hex(this.gColorLight);var bColorHex=dec2hex(this.bColorLight);this.obj.style.backgroundColor='#'+rColorHex+gColorHex+bColorHex;};function takeLastPost()
{var contents=byId('messages');var firstPost=contents.firstChild;var lastPost=contents.lastChild;while(firstPost)
{if(firstPost.nodeType==3)
{firstPost=firstPost.nextSibling;}
else
{break;}}
while(lastPost)
{if(lastPost.nodeType==3)
{lastPost=lastPost.previousSibling;}
else
{break;}}
try{var f=parseInt(firstPost.id.replace('p',''));var l=parseInt(lastPost.id.replace('p',''));}
catch(e)
{if(!f)f=0;if(!l)l=0;}
if(f>l)return f;if(l>=f)return l;}
function putMsg(e)
{stopEvent(e);var username=byId('username').value;username=removeLinks(username);if(username.match(/^\s/g)||username.match(/\s$/g)){alert("Merci de supprimer les espaces avant et apres !");return;}
byId('username').value=username;var message=byId('message').value;if(!username)
{byId('username').value='pseudo ?';setTimeout(function(){byId('username').value='';focusMsg();},800);return;}
if(!message)
{byId('message').value='message ?';setTimeout(function(){byId('message').value='';focusMsg();},800);return;}
if(username=='pseudo ?')
{return;}
if(message=='message ?')
{return;}
if(containLongString(message))
{alert('Votre message contient un ou plusieurs mots d\'une longueur excessive.');return;}
if(containLongString(username))
{alert('Votre pseudo est d\'une longueur excessive.');return;}
for(var i=0;i<wordsFilterArray.length;i++)
{if(wordsFilterArray[i]=='')break;while(message.indexOf(wordsFilterArray[i])!=-1)
{alert('Spam d\351tect\351');return;}}
initMsg();clearTimeout(updateCycle);updateCycle=setTimeout(function(){getUpDates();},msgRefresh);var postRequest=Ajax();postRequest.open("POST",ajaxPage+'',true);postRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');postRequest.setRequestHeader("Connection","close");postRequest.send('idShoutbox='+idShoutbox+'&q=PNM&username='+encodeURL(username)+'&m='+encodeURL(message)+'&l='+takeLastPost());postRequest.onreadystatechange=function()
{try
{if(postRequest.readyState==4)
{if(postRequest.status!=200)
{byId('form').submit();return;}
else{var shoutbox=postRequest.responseXML.getElementsByTagName('shoutbox')[0];if(shoutbox.getAttribute('answer')=='ok')
{focusMsg();setUpdates(postRequest.responseXML);}
else if(shoutbox.getAttribute('answer')=='error')alert(shoutbox.getAttribute('alert'));else return;}}}
catch(e)
{return;}}}
function Ajax()
{var ajaxRequest;if(window.XMLHttpRequest)ajaxRequest=new XMLHttpRequest();else ajaxRequest=new ActiveXObject("Microsoft.XMLHTTP");return ajaxRequest;}
function getUpDates(init)
{if(init){return;clearTimeout(updateCycle);updateCycle=setTimeout(function(){getUpDates();},msgRefresh);return;}
var username=byId('username').value;if(!username)
{username='Anonyme';}
clearTimeout(updateCycle);updateCycle=setTimeout(function(){getUpDates();},msgRefresh);var updateRequest=Ajax();updateRequest.open("GET",ajaxPage+'?idShoutbox='+idShoutbox+'&q=UDM&l='+takeLastPost()+'&username='+encodeURL(username),true);updateRequest.setRequestHeader("Connection","close");updateRequest.send(null);updateRequest.onreadystatechange=function()
{try
{if(updateRequest.readyState==4)
{if(updateRequest.status!=200)
{return;}
else{var shoutbox=updateRequest.responseXML.getElementsByTagName('shoutbox')[0];if(shoutbox.getAttribute('answer')=='ok'){setUpdates(updateRequest.responseXML);}
else if(shoutbox.getAttribute('answer')=='error')return;else return;}}}
catch(e)
{return;}}}
function setUpdates(responseXML)
{var shoutbox=responseXML.getElementsByTagName('shoutbox')[0];var shoutboxTime=shoutbox.getAttribute('time');var shoutboxOnline=shoutbox.getAttribute('online');var shoutboxPosts=shoutbox.getElementsByTagName('content')[0].getElementsByTagName('post');var shoutboxUsers=shoutbox.getElementsByTagName('online')[0].getElementsByTagName('user');var contents=byId('messages');var pConnected=byId('pConnected');var postList=new Array();if(shoutboxOnline>1)var connected='connect\351s';else var connected='connect\351';byId('main').getElementsByTagName('h3')[0].firstChild.nodeValue=shoutboxTime+' '+shoutboxOnline+' '+connected;while(pConnected.firstChild)pConnected.removeChild(pConnected.firstChild);for(var i=0;i<shoutboxUsers.length;i++)
{var j=i+1;if(j<shoutboxUsers.length)afterNick=', ';else afterNick='';pConnected.appendChild(document.createTextNode(shoutboxUsers[i].firstChild.nodeValue+afterNick));}
if(shoutbox.getAttribute('reset')=="all")
{while(contents.firstChild)contents.removeChild(contents.firstChild);}
for(var i=0;i<shoutboxPosts.length;i++)
{if(shoutboxPosts[i].getElementsByTagName('user').length>0)
{postList.unshift(i);}}
for(var i=0;i<postList.length;i++)
{playSound();var currentPostNew=postList[i];var nextPostNew=currentPostNew+1;var post=shoutboxPosts[currentPostNew];var postId=post.getAttribute('id');var postTimeS=post.getAttribute('timeSince');var postTimeF=post.getAttribute('timeFormated');var postDelete=post.getElementsByTagName('user')[0].getAttribute('delete');var postNick=post.getElementsByTagName('user')[0].firstChild.nodeValue;var postMessage=post.getElementsByTagName('message')[0].firstChild.nodeValue;if(byId('p'+postId))continue;var li=document.createElement('li');var cite=document.createElement('cite');var q=document.createElement('q');var dl=document.createElement('dl');var dt=document.createElement('dt');var dd1=document.createElement('dd');var dd2=document.createElement('dd');cite.setAttribute('title','Ecrit le '+postTimeF+'');li.setAttribute('id','p'+postId);if(ie)
{dd1.setAttribute('className','date');dd2.setAttribute('className','status');}else{dd1.setAttribute('class','date');dd2.setAttribute('class','status');}
var nick=document.createTextNode(postNick+':');var scape=document.createTextNode(' ');var message=document.createTextNode(postMessage);var dtText=document.createTextNode('Details');var time=document.createTextNode(postTimeS+' ');var status=document.createTextNode('Online');if(postDelete=='agree')
{var deleteLink=document.createElement('a');var commentLink=document.createTextNode('Effacer');deleteLink.appendChild(commentLink);addEvent(deleteLink,'click',deleteLastMessage,false);dd2.appendChild(deleteLink);setTimeout(function()
{dd2.removeChild(deleteLink);dd2.appendChild(status);},10000);}
else
{dd2.appendChild(status);}
cite.appendChild(nick);q.appendChild(message);dt.appendChild(dtText);dd1.appendChild(time);dl.appendChild(dt);dl.appendChild(dd1);dl.appendChild(dd2);li.appendChild(cite);li.appendChild(scape);li.appendChild(q);li.appendChild(dl);var messagePost=li.getElementsByTagName('q')[0].innerHTML;li.getElementsByTagName('q')[0].innerHTML=multiConverter(messagePost);scrollAutorisation=true;if(readDirection=='ASC')
{contents.insertBefore(li,byId('p'+takeLastPost()));}
else
{contents.appendChild(li);}
if(scrollAutorisation)scrollBottom();new clFadeColor('p'+postId,'.fadeFrom','.fadeTo');addEvent(cite,'click',addDirectAdmin,false);}
var postList=byId('messages').getElementsByTagName('li');for(var i=0;i<postList.length;i++)
{var isOnline=false;var isModerator=false;var isDeleted=true;var timeCurrentPost=" ";var usernameCurrentPost=postList[i].getElementsByTagName('cite')[0].firstChild.nodeValue.replace(':','');var idCurrentPost=postList[i].getAttribute('id').replace('p','');for(var j=0;j<shoutboxUsers.length;j++)
{if(shoutboxUsers[j].firstChild.nodeValue.toLowerCase()==usernameCurrentPost.toLowerCase())
{isOnline=true;break;}}
for(var k=0;k<shoutboxPosts.length;k++)
{if(idCurrentPost==shoutboxPosts[k].getAttribute('id'))
{isDeleted=false;timeCurrentPost=shoutboxPosts[k].getAttribute('timeSince')+' ';if(shoutboxPosts[k].getAttribute('status')=='modo')isModerator=true;break;}}
if(isDeleted)
{new clFadeSize('p'+idCurrentPost,'-');scrollBottom();}
else
{if(isOnline)
{postList[i].className="online";}
else
{postList[i].className="offline";}
if(isModerator)
{postList[i].className=postList[i].className+" moderator";}
postList[i].getElementsByTagName('dd')[0].firstChild.nodeValue=timeCurrentPost;}}}
function deleteLastMessage(e)
{clearTimeout(updateCycle);updateCycle=setTimeout(function(){getUpDates();},msgRefresh);var target=eventTarget(e);var postId=target.parentNode.parentNode.parentNode.getAttribute('id').replace('p','');var postRequest=Ajax();postRequest.open("GET",ajaxPage+'?idShoutbox='+idShoutbox+'&q=DLM&postId='+postId,true);postRequest.send(null);postRequest.onreadystatechange=function()
{try
{if(postRequest.readyState==4)
{if(postRequest.status!=200)
{alert("Erreur lors de la suppression du message.");}
else{var shoutbox=postRequest.responseXML.getElementsByTagName('shoutbox')[0];if(shoutbox.getAttribute('answer')=='ok')
{new clFadeSize('p'+postId,'-');return;}
else if(shoutbox.getAttribute('answer')=='error')
{alert(shoutbox.getAttribute('alert'));return;}
else
{return;}}}}
catch(e)
{return;}}}
function accountLogin(e)
{stopEvent(e);var fieldUsernameLogin=byId('fieldUsernameLogin').value;var fieldPasswordLogin=byId('fieldPasswordLogin').value;var modeSubscribe=byId('modeSubscribe').value;if(!fieldUsernameLogin)
{alert("Saisissez votre identifiant shoutbox.");return;}
if(!fieldPasswordLogin)
{if(!confirm("Vous n'avez pas indiqu\351 de mot de passe. Continuer ?"))
return;}
var loginRequest=Ajax();loginRequest.open("GET",ajaxPage+'?idShoutbox='+idShoutbox+'&q=LA&m='+modeSubscribe+'&username='+encodeURL(fieldUsernameLogin)+'&p='+encodeURL(fieldPasswordLogin),true);loginRequest.send(null);loginRequest.onreadystatechange=function()
{try
{if(loginRequest.readyState==4)
{if(loginRequest.status!=200)
{alert("Erreur lors de la connexion.");return;}
else{var shoutbox=loginRequest.responseXML.getElementsByTagName('shoutbox')[0];if(shoutbox.getAttribute('answer')=='ok'){alert(shoutbox.getAttribute('alert'));var fieldUsernameLogin=byId('fieldUsernameLogin').value;byId('username').value=fieldUsernameLogin;usernameMember=fieldUsernameLogin;addEvent(byId('username'),'change',accountDisconnect,false);toggleView();statusUser=shoutbox.getAttribute('statusUser');checkStatusUser();accountLoginOk();getUpDates();}
else if(shoutbox.getAttribute('answer')=='error')alert(shoutbox.getAttribute('alert'));else return;}}}
catch(e)
{return;}}}
function accountDelete()
{if(!confirm("Voulez-vous supprimer votre pseudo r\351serv\351 ?"))
return;var deleteRequest=Ajax();deleteRequest.open("GET",ajaxPage+'?idShoutbox='+idShoutbox+'&q=DA',true);deleteRequest.send(null);deleteRequest.onreadystatechange=function()
{try
{if(deleteRequest.readyState==4)
{if(deleteRequest.status!=200)
{alert("Erreur lors de la suppression de pseudo.");return;}
else{var shoutbox=deleteRequest.responseXML.getElementsByTagName('shoutbox')[0];if(shoutbox.getAttribute('answer')=='ok'){alert(shoutbox.getAttribute('alert'));accountDisconnect(true);toggleView();}
else if(shoutbox.getAttribute('answer')=='error')alert(shoutbox.getAttribute('alert'));else return;}}}
catch(e)
{return;}}}
function accountLoginOk()
{byId('loginPSubConnect').style.display='none';byId('accountDiv').getElementsByTagName('h4')[0].firstChild.nodeValue='Mon compte';if(byId('loginPDisconnectDelete'))
{byId('loginPDisconnectDelete').style.display='block';return;}
var loginP=document.createElement('p');var br=document.createElement('br');var linkDisconnect=document.createElement('a');var linkDeleteAccount=document.createElement('a');loginP.setAttribute('id','loginPDisconnectDelete');br.setAttribute('id','LoginOkBr');linkDeleteAccount.setAttribute('id','LoginOkDel');linkDeleteAccount.setAttribute('href','javascript:accountDelete()');linkDisconnect.setAttribute('id','LoginOkA');linkDisconnect.setAttribute('href','javascript:accountDisconnect()');linkDisconnect.appendChild(document.createTextNode('D\351connexion'));linkDeleteAccount.appendChild(document.createTextNode('Supprimer mon compte'));loginP.appendChild(linkDisconnect);loginP.appendChild(br);loginP.appendChild(linkDeleteAccount);byId('extras').appendChild(loginP);}
function accountDisconnect(force)
{var username=byId('username').value;if(force==true||confirm("Voulez-vous vous d\351connecter pour utiliser un autre pseudo ?"))
{addCookie('ShoutBox'+idShoutbox,username);statusUser=0;checkStatusUser();byId('loginPSubConnect').style.display='block';byId('accountDiv').getElementsByTagName('h4')[0].firstChild.nodeValue='R\351servation de pseudo';byId('loginPDisconnectDelete').style.display='none';}
else
{byId('username').value=usernameMember;focusMsg();}}
function directAdmin(e)
{stopEvent(e);var target=eventTarget(e);var post=target.parentNode.parentNode.parentNode;var postId=post.getAttribute('id').replace('p','');var cmd=target.getAttribute('name');if(cmd=='ban'&&confirm("Voulez-vous vous \351galement supprimer tous les messages de cette personne ?"))
{cmd='ban_delete';}
if(post.getElementsByTagName('dl')[0].getElementsByTagName('dd')[2])
post.getElementsByTagName('dl')[0].removeChild(post.getElementsByTagName('dl')[0].getElementsByTagName('dd')[2]);var postRequest=Ajax();postRequest.open("GET",ajaxPage+'?idShoutbox='+idShoutbox+'&q=DACMD&cmd='+cmd+'&postId='+postId,true);postRequest.send(null);postRequest.onreadystatechange=function()
{try
{if(postRequest.readyState==4)
{if(postRequest.status!=200)
{alert("Erreur lors de la commande d'admin.");return;}
else{var shoutbox=postRequest.responseXML.getElementsByTagName('shoutbox')[0];if(shoutbox.getAttribute('answer')=='ok')
{if(cmd=='delete')new clFadeSize('p'+postId,'-');else if(cmd=='ban'){alert("L'IP est maintenant bannie.");}
else if(cmd=='spam'){alert("Le message est maintenant censur\352.");}
else if(cmd=='ban_delete'){getUpDates();}}
else if(shoutbox.getAttribute('answer')=='error')alert(shoutbox.getAttribute('alert'));else return;}}}
catch(e)
{return;}}}
function init()
{if(navigator.appName=="Microsoft Internet Explorer")ie=true;else ie=false;if(!window.XMLHttpRequest&&!window.ActiveXObject)return;var divContener=document.createElement('div');var divContent=byId('content');var divMessages=byId('messages');divContener.appendChild(divMessages);var divExtras=addExtras(divContener);var divLogin=addLogin(divContener);divContener.setAttribute('id','contener');divContent.appendChild(divContener);setTimeout(reSizeShoutbox,0);setTimeout(reSizeShoutbox,50);setTimeout(reSizeShoutbox,500);setTimeout(reSizeShoutbox,5000);dynamicConverterInit();var form=byId('form');var divButtons=byId('buttons');if(ie){divButtons.innerHTML+='<input type="button" id="more" />';var buttonMore=byId('more');}else{var buttonMore=document.createElement('input');buttonMore.setAttribute('id','more');divButtons.appendChild(buttonMore);buttonMore.setAttribute('type','button');}
buttonMore.setAttribute('value','Extras '+String.fromCharCode(187));addEvent(buttonMore,'click',toggleView,false);addEvent(form,'submit',putMsg,false);byId('reload').style.display='none';checkStatusUser();if(getSound())sound=getSound();var soundBox=document.createElement('div');byId("body").appendChild(soundBox);if(!ie)
{var soundBoxObject=document.createElement('object');soundBoxObject.setAttribute('id','soundBox');soundBoxObject.setAttribute('classid','clsid:D27CDB6E-AE6D-11cf-96B8-444553540000');soundBoxObject.setAttribute('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0');soundBoxObject.setAttribute('width','0');soundBoxObject.setAttribute('height','0');soundBoxObject.setAttribute('title','soundBox');var soundBoxParam1=document.createElement('param');soundBoxParam1.setAttribute('movie','sons/soundBox.swf');var soundBoxParam2=document.createElement('param');soundBoxParam2.setAttribute('quality','high');var soundBoxEmbed=document.createElement('embed');soundBoxEmbed.setAttribute('src','sons/soundBox.swf');soundBoxEmbed.setAttribute('quality','high');soundBoxEmbed.setAttribute('name','soundBox');soundBoxEmbed.setAttribute('swLiveConnect','true');soundBoxEmbed.setAttribute('pluginspage','http://www.macromedia.com/go/getflashplayer');soundBoxEmbed.setAttribute('type','application/x-shockwave-flash');soundBoxEmbed.setAttribute('width','0');soundBoxEmbed.setAttribute('height','0');soundBoxObject.appendChild(soundBoxEmbed);soundBoxObject.appendChild(soundBoxParam1);soundBoxObject.appendChild(soundBoxParam2);soundBox.appendChild(soundBoxObject);}
else
{var soundBoxCode='<object id="soundBox" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';soundBoxCode+='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"';soundBoxCode+='width="0" height="0" title="soundBox">';soundBoxCode+='<param name="movie" value="sons/soundBox.swf" />';soundBoxCode+='<param name="quality" value="high" />';soundBoxCode+='<embed src="sons/soundBox.swf" quality="high" name="soundBox" swLiveConnect="true"';soundBoxCode+='pluginspage="http://www.macromedia.com/go/getflashplayer"';soundBoxCode+='type="application/x-shockwave-flash" width="0" height="0">';soundBoxCode+='</embed>';soundBoxCode+='</object>';soundBox.innerHTML=soundBoxCode;}
if(usernameMember)
{addEvent(byId('username'),'change',accountDisconnect,false);accountLoginOk();}
setTimeout(scrollBottom,15);setTimeout(scrollBottom,500);getUpDates(true);if(readCookie('ShoutBoxSmileysPref')=='inline')showSmileysPerso();}