//include('./scripts/js_smiley.php?js=1');

var seconde = 10;
var uneSeconde = 1000;

function compteRebours()
{
    varHtml_decompte = document.getElementById('comptePub_decompte');
    varHtml = document.getElementById('comptePub');

    if(seconde > 0 && varHtml.style.display != 'none')
    {
        document.getElementById('leJeu').style.display = 'none';
        
        if(seconde > 1) s = 's'; else s = '';

        varHtml_decompte.innerHTML = seconde;

        seconde = seconde-1;
        setTimeout("compteRebours()", uneSeconde)
    }
    else
    {
        supprDecompte();
    }
}

function supprDecompte()
{
    document.getElementById('comptePub').style.display = 'none';
    document.getElementById('leJeu').style.display = 'block';
}

//windowOnload('compteRebours');
window.onload = compteRebours;


// Affichage de l'aide
function formAide (idName, affiche)
{
    if (affiche == 1) {
        document.getElementById(idName).style.display = 'block';
    } else {
        document.getElementById(idName).style.display = 'none';
    }
}

// Confirmation de suppression d'un élément
function supprimer () {
    return confirm('Voulez-vous vraiment supprimer cet élément ?');
}

// Confirmation de suppression d'un élément
function checkLinks() {
    if(!document.getElementsByTagName) {
        return;
    }
    var links = document.getElementsByTagName('A');
    for(var i=links.length-1; i>=0; --i) {
        if(links[i].className.indexOf('doConfirm') != -1) {
            links[i].onclick = function (e) {
                return confirm("Voulez vous réellement effectuer cette action ?" );
            }
        }
    }
}
  
//windowOnload('checkLinks');

// Envoi d'un emoticon à un formulaire
function emoticon(text, idName)
{
	var txtarea = document.getElementById(idName);
	var text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} else {
        var txtareaValue = txtarea.value;
        var Deb = txtareaValue.substring( 0 , txtarea.selectionStart );
        var Fin = txtareaValue.substring( txtarea.selectionEnd , txtarea.textLength );
        txtarea.value = Deb + text + Fin;
	}
}

// Prévisualisation
function  previsualiser(texte)
{
    var timer=0;
	var textVisu = document.getElementById(texte).value;
	textVisu = code_to_html(textVisu);
	if (document.getElementById) {
        document.getElementById('previsualiser_' + texte).innerHTML = textVisu;
        document.getElementById('previsualiser_' + texte).style.border = '1px dashed #34425F';
        document.getElementById('previsualiser_' + texte).style.padding = '4px';
        document.getElementById('previsualiser_' + texte).style.margin = '4px';
    }
	timer=setTimeout('previsualiser("'+texte+'")',1000);
}
function code_to_html(t)
{
	t=nl2khol(t);
    // balise Gras
	t=deblaie(/(\[\/b\])/g,t);
	t=remplace_tag(/\[b\](.+)\[\/b\]/g,'<b>$1</b>',t);
	t=remblaie(t);
    // balise Italique
	t=deblaie(/(\[\/i\])/g,t);
	t=remplace_tag(/\[i\](.+)\[\/i\]/g,'<i>$1</i>',t);
	t=remblaie(t);
    // balise Underline
	t=deblaie(/(\[\/u\])/g,t);
	t=remplace_tag(/\[u\](.+)\[\/u\]/g,'<u>$1</u>',t);
	t=remblaie(t);
    // balise quote
	t=deblaie(/(\[\/quote\])/g,t);
	t=remplace_tag(/\[quote=([^\s<>]+)\](.+)\[\/quote\]/g,'<div class="quoteBloc"><strong>$1 a écrit</strong> :<br/><div class="quote">$2</div></div>',t);
	t=remblaie(t);
    // balise quote
	t=deblaie(/(\[\/quote\])/g,t);
	t=remplace_tag(/\[quote\](.+)\[\/quote\]/g,'<div class="quoteBloc"><div class="quote">$1</div></div>',t);
	t=remblaie(t);
    // balise code
	t=remplace_tag(/\[code\](.+)\[\/code\]/g,'<code>$1</code>',t);
    // balise Img
	t=deblaie(/(\[\/img\])/g,t);
	t=remplace_tag(/\[img\](.+)\[\/img\]/g,'<img src="$1" alt="" />',t);
	t=remplace_tag(/\[img=(.+)\](.+)\[\/img\]/g,'<img src="$1" alt="$2"/>',t);
	t=remblaie(t);
    // balise Smiley
    t = remplace_smiley(t);
    // balise URL
	t=remplace_tag(/\[url=([^\s<>]+)\](.+)\[\/url\]/g,'<a href="$1" target="_blank">$2</a>',t);
    // balise Color
	t=deblaie(/(\[\/color\])/g,t);
	t=remplace_tag(/\[color=(#[a-fA-F0-9]{6})\](.+)\[\/color\]/g,'<font color="$1">$2</font>',t);
	t=remblaie(t);
    // balise size
	t=deblaie(/(\[\/size\])/g,t);
	t=remplace_tag(/\[size=([+-]?[0-9])\](.+)\[\/size\]/g,'<font size="$1">$2</font>',t);
	t=remblaie(t);
	t=unkhol(t);
	t=nl2br(t);
	return t;
}
function deblaie(reg,t) {
	texte=new String(t);
	return texte.replace(reg,'$1\n');
}
function remblaie(t) {
	texte=new String(t);
	return texte.replace(/\n/g,'');
}
function remplace_tag(reg,rep,t) {
	texte=new String(t);
	return texte.replace(reg,rep);
}
function nl2br(t) {
	texte=new String(t);
	return texte.replace(/\n/g,'<br/>');
}
function nl2khol(t) {
    var ptag=String.fromCharCode(5,6,7);
	texte=new String(t);
	return texte.replace(/\n/g,ptag);
}
function unkhol(t) {
    var ptag=String.fromCharCode(5,6,7);
	texte=new String(t);
	return texte.replace(new RegExp(ptag,'g'),'\n');
}
function remplace_smiley(t) {
	t=remplace_tag(/\:D/g,'<img src="http://www.genaisse.com/forums/images/smiles/icon_biggrin.gif"/>',t);
}
function include( filename ) {
    // http://kevin.vanzonneveld.net
    // +   original by: mdsjack (http://www.mdsjack.bo.it)
    // +   improved by: Legaev Andrey
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: include('/js/imaginary1.js');
    // *     returns 1: 1

    var js = document.createElement('script');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', filename);
    js.setAttribute('defer', 'defer');
    document.getElementsByTagName('HEAD')[0].appendChild(js);

    // save include state for reference by include_once
    if (!window.php_js) window.php_js = {};
    if (!window.php_js.includes) window.php_js.includes = {};
    if (!window.php_js.includes[filename]) {
        window.php_js.includes[filename] = 1;
    } else {
        window.php_js.includes[filename]++;
    }

    return window.php_js.includes[filename];

}

/* Onload multiple */
function windowOnload(func)
{
   var oldonload = window.onload;

   if(typeof window.onload != 'function')
   {
      window.onload = func;
   }
   else
   {
      window.onload = function()
      {
         oldonload();
         func();
      }
   }
}

function favoris_fr() {
    if ( navigator.appName != 'Microsoft Internet Explorer' )
    { window.sidebar.addPanel("Boojeux","http://www.boojeux.com",""); }
    else { window.external.AddFavorite("http://www.boojeux.com","Boojeux"); }
}
function favoris_es() {
    if ( navigator.appName != 'Microsoft Internet Explorer' )
    { window.sidebar.addPanel("Boojeux","http://games.boojeux.com",""); }
    else { window.external.AddFavorite("http://games.boojeux.com","Boojeux"); }
}
function favoris_en() {
    if ( navigator.appName != 'Microsoft Internet Explorer' )
    { window.sidebar.addPanel("Boojeux","http://juegos.boojeux.com",""); }
    else { window.external.AddFavorite("http://juegos.boojeux.com","Boojeux"); }
}

