var edoc,ewin,rng; function SB_initZoneSaisie()
{ if(IE) {edoc = window.frames['editeur'].document;ewin = window.frames['editeur'];}
if(MOZ) {edoc = document.getElementById('editeur').contentDocument;ewin = document.getElementById('editeur').contentWindow;}
if(!IE && !MOZ){ alert('Votre navigateur n\'est pas compatible avec les ShootBox !'); return;}
if(edoc.designMode != 'On') edoc.designMode = 'On'; if(!edoc.body){ setTimeout('SB_initZoneSaisie()',20); return;}
if(MOZ) { edoc.addEventListener("keypress", SB_bloquerTouchesSpeciales, true); edoc.addEventListener("keyup", SB_detecterSmiley, true); edoc.addEventListener("click", SB_cacherTouteBoite, true);}
if(IE) { edoc.attachEvent("onkeypress", SB_bloquerTouchesSpeciales); edoc.attachEvent("onkeyup", SB_detecterSmiley); edoc.attachEvent("onclick", SB_cacherTouteBoite); edoc.body.ondrop = SB_copierCollerInterdit;}
SB_reinitZoneSaisie(); SB_initPalette(); SB_initEmoticons();}
function SB_reinitZoneSaisie() { var zone_messages_active = document.getElementById('connexion_invite').style.display == 'none'; if (zone_messages_active) { if(IE) { window.frames['editeur'].focus(); window.frames['editeur'].document.body.innerHTML = ''; SB_setRng();}
else if(MOZ) {document.getElementById('editeur').contentDocument.body.innerHTML = '<span></span>';document.getElementById('editeur').contentWindow.focus();}
}
SB_executerCommande('removeformat',null); if(glob_is_bold) SB_executerCommande('bold',null); if(glob_is_italic) {SB_executerCommande('italic',null);}
SB_executerCommande('forecolor',glob_couleur_forecolor); SB_executerCommande('backcolor',glob_couleur_backcolor);}
function SB_copierCollerInterdit() { alert(trans['copier_coller_interdit']); return false;}
function SB_initPalette() { var x = document.getElementsByName('color'); for (var i=0; i < x.length; i++) { x[i].onmouseover = function () {this.style.border = '1px dotted white';}
x[i].onmouseout = function () {this.style.border = '1px solid gray';}
x[i].onclick = SB_clickCp;}
}
function SB_clickCp() { var couleur = '#' + this.id.substring(4); if((glob_commande == 'forecolor' && couleur == glob_couleur_backcolor) || (glob_commande == 'backcolor' && couleur == glob_couleur_forecolor)) { couleur = InverseColor(this.id.substring(4));}
SB_executerCommande(glob_commande,couleur); if(glob_commande == 'forecolor') glob_couleur_forecolor = couleur; else glob_couleur_backcolor = couleur; document.getElementById('cp').style.display = 'none'; this.style.border = '1px solid gray';}
function SB_initEmoticons() { var x = document.getElementsByName('emoticon'); var raccourci; for (var i=0; i < x.length; i++) { x[i].onclick=SB_insererEmoticon; x[i].onmouseover=function () {this.style.border='1px solid gray';}
x[i].onmouseout=function () {this.style.border='1px solid white';}
raccourci = x[i].alt.replace(/(\(|\)|\||\&|\+|\^|\*|\?|\$|\.|\[|\]|\{|\})/g,'\\$1'); if(raccourci.match(/ou/)) { raccourci = raccourci.split(' ou '); for(var j=0;j < raccourci.length; j++) { glob_str_smileys += '(' + raccourci[j] + ')|'; glob_assoc_smileys[x[i].alt.split(' ou ')[j]] = x[i].src;}
}
else { glob_str_smileys += '(' + raccourci + ')|'; glob_assoc_smileys[x[i].alt] = x[i].src;}
}
glob_str_smileys = glob_str_smileys.substr(0,glob_str_smileys.length - 1);}
function SB_getOffsetTop(elm) { var mOffsetTop = elm.offsetTop; var mOffsetParent = elm.offsetParent; var parents_up = 2; while(parents_up > 0) { mOffsetTop += mOffsetParent.offsetTop; mOffsetParent = mOffsetParent.offsetParent; parents_up--;}
return mOffsetTop;}
function SB_getOffsetLeft(elm) { var mOffsetLeft = elm.offsetLeft; var mOffsetParent = elm.offsetParent; var parents_up = 2; while(parents_up > 0) { mOffsetLeft += mOffsetParent.offsetLeft; mOffsetParent = mOffsetParent.offsetParent; parents_up--;}
return mOffsetLeft;}
function SB_setRng() { if(IE) { var sel = document.getElementById('editeur').contentWindow.document.selection; if (sel!=null) { rng = sel.createRange();}
}
}
function SB_afficherCacherMasque(etat) { if(!etat) {document.getElementById('masque').style.display = 'none';return;}
else document.getElementById('masque').style.display = 'inline';}
function SB_jouer(son,forcer) { if(forcer || glob_options_sons) { if(MOZ) document.getElementById('lecteur_sons').innerHTML='<object hidden="true" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="0" height="0" id="dewplayer" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="dewplayer.swf?son=sons/'+son+'.mp3&amp;autostart=1&amp;bgcolor=FFFFFF" /><param name="quality" value="high" /><param name="bgcolor" value="FFFFFF" /><embed hidden="true" src="dewplayer.swf?son=sons/'+son+'.mp3&amp;autostart=1&amp;bgcolor=FFFFFF" quality="high" bgcolor="FFFFFF" width="200" height="20" name="dewplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>'; if(IE) document.getElementById('lecteur_sons').innerHTML="<embed type='audio/x-wav' src='sons/"+son+".mp3' hidden='true' height='50' width='50' autostart='true' loop='false'>";}
}
function SB_descendreScrollMessages() { if(glob_options_defil_auto) document.getElementById('zone_messages').scrollTop = document.getElementById('zone_messages').scrollHeight;}
function SB_afficherCacher(objet) { if (objet.style.display == 'none' || objet.style.display == '') objet.style.display = 'inline'; else objet.style.display = 'none'; ewin.focus();}
function SB_afficherCacherConnexion(div_connexion,pseudo,mdp) { if (div_connexion.style.display == 'none') { document.getElementById('connexion_invite').style.display = 'none'; div_connexion.style.display = 'inline'; pseudo.focus();}
else { document.getElementById('connexion_invite').style.display = 'inline'; document.getElementById('pseudo_connexion_invite').focus(); div_connexion.style.display = 'none'; mdp.value = ''; pseudo.value = '';}
}
function SB_cacherTouteBoite() { document.getElementById('cp').style.display = 'none'; document.getElementById('emoticons').style.display = 'none'; if (ewin) ewin.focus();}
function SB_afficherPalette(bouton) { var oDialog = document.getElementById('cp'); var buttonElement = document.getElementById(bouton); var iLeftPos = SB_getOffsetLeft(buttonElement) - 45; var iTopPos = SB_getOffsetTop(buttonElement) - 136; oDialog.style.left = (iLeftPos) + 'px'; oDialog.style.top = (iTopPos) + 'px'; if(document.getElementById('emoticons').style.display == 'inline') document.getElementById('emoticons').style.display = 'none'; SB_afficherCacher(oDialog); SB_setRng(); glob_commande = bouton;}
function SB_afficherEmoticons() { var oDialog = document.getElementById('emoticons'); var buttonElement = document.getElementById('smileys'); var iLeftPos = SB_getOffsetLeft(buttonElement) - 5; var iTopPos = SB_getOffsetTop(buttonElement) - 176; oDialog.style.left = (iLeftPos) + 'px'; oDialog.style.top = (iTopPos) + 'px'; if(document.getElementById('cp').style.display == 'inline') document.getElementById('cp').style.display = 'none'; SB_afficherCacher(oDialog);}
function SB_insererEmoticon() { if(MOZ) { SB_executerCommande('insertimage',this.src);}
if(IE) { ewin.focus(); var insert = edoc.selection.createRange(); insert.pasteHTML(SB_creerSmiley(this.src));}
this.style.border = '1px solid white'; document.getElementById('emoticons').style.display = 'none';}
function SB_executerCommande(action,valeur){ if(MOZ){ if(action == 'backcolor') action = 'hilitecolor';}
if (typeof edoc != 'undefined') edoc.execCommand(action, false, valeur);}
function SB_stopperToucheMoz(evt) { evt.preventDefault(); evt.stopPropagation();}
function SB_bloquerTouchesSpeciales(evt) { var key = String.fromCharCode(evt.charCode).toLowerCase(); if (evt.ctrlKey && MOZ) { var cmd = ''; switch (key) { case 'b': cmd = "bold"; glob_is_bold = !glob_is_bold; break; case 'i': cmd = "italic"; glob_is_italic = !glob_is_italic; break;}; if (cmd) { SB_executerCommande(cmd, null); SB_stopperToucheMoz(evt);}
}
if (evt.keyCode == 13) { SB_posterMessage(glob_idshootbox); if(MOZ) SB_stopperToucheMoz(evt); return false;}
if (evt.keyCode == 9) { document.getElementById('bouton_envoyer').focus(); if(MOZ) SB_stopperToucheMoz(evt); return false;}
SB_cacherTouteBoite();}
function SB_creerSmiley(source) { return " <img src='" + source + "' style='background-color:transparent' alt='chat gratuit shootbox' title='Smiley mini chat shootbox' width='19' height='19' />";}
function SB_detecterSmiley() { var expr = new RegExp(glob_str_smileys,'g'); var str_editeur = new String(edoc.body.innerHTML); if(expr.test(str_editeur)) { str_editeur = str_editeur.replace(expr,function ($0) {return SB_creerSmiley(glob_assoc_smileys[$0]);}); if(IE) edoc.body.innerHTML = str_editeur; if(MOZ) {edoc.body.innerHTML = ''; SB_executerCommande('inserthtml',str_editeur);}
if(glob_is_bold) {SB_executerCommande('bold',null);}
if(glob_is_italic) {SB_executerCommande('italic',null);}
SB_executerCommande('forecolor',glob_couleur_forecolor); SB_executerCommande('backcolor',glob_couleur_backcolor);}
}
function SB_connexion_invite_etape1 () { var pseudo = document.getElementById('pseudo_connexion_invite').value; var regPseudo = new RegExp ( "^[a-z0-9]{4,15}$", "g" ); if(pseudo == '') {alert(trans['champ_pseudo_manquant']);document.getElementById('pseudo_connexion_invite').focus(); return}
if(pseudo.length < 4) {alert(trans['pseudo_longueur_insuffisante']); document.getElementById('pseudo_connexion_invite').focus(); return}
if(pseudo.search ( regPseudo ) == -1 ) {alert(trans['champ_pseudo_incorrect']);document.getElementById('pseudo_connexion_invite').focus(); return}
SB_connexion_invite();}

