function showMCE(id,linkObj) {
    if (tinyMCE.getInstanceById(id) == null) {
        linkObj.innerHTML = "hide editor";
        tinyMCE.execCommand('mceAddControl', false, id);
    }
    else {
        linkObj.innerHTML = "show editor";
        tinyMCE.execCommand('mceRemoveControl', false, id);
    }
}

/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object   the table row
 * @param   string   the action calling this script (over, out or click)
 * @param   string   the default background color
 * @param   string   the color to use for mouseover
 * @param   string   the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()) {
        if (theAction == 'out') {
            newColor = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor = (thePointerColor != '')
                     ? thePointerColor
                     : theDefaultColor;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function





function emoticon(text) {
	if (document.form_item.message.createTextRange && document.form_item.message.caretPos) {
		var caretPos = document.form_item.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
		document.form_item.message.focus();
	} else {
	document.form_item.message.value  += text;
	document.form_item.message.focus();
	}
}

function caract(text) {
	var val = prompt("Tapez la valeur","");
	if (text == "- Pouvoir : ")
	{
		fin = '% de la réserve mana.\r\n';
	}
	else
	{
		fin = ' pts\r\n';
	}
	var text = text + val + fin;
	if (document.form_item.message.createTextRange && document.form_item.message.caretPos) {
		var caretPos = document.form_item.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
		document.form_item.message.focus();
	} else {
	document.form_item.message.value  += text;
	document.form_item.message.focus();
	}
}
function resist(text) {
	var val = prompt("Tapez la valeur","");
	if (text == "- Réduction des Coûts d'Endurance des Styles de Combat : ")
	{
		fin = ' pts (PvE uniquement)';
	}
	else
	{
		fin = '%';
	}
	if (text == "- Réduction de la Durée des Effets Négatifs : " || text == "- Absorption Partielle : " || text == "- Bonus aux Dégats des Styles Réactifs : " || text == "- Bonus de Défense : " || text == "- Fortification de Bulle Protectrice : " || text == "- Bonus au Toucher : " || text == "- Esquive : " || text == "- Blocage : " || text == "- Parade : " || text == "- Reduction de Coûts de Mana pour Sort : ")
	{
		fin2 = ' (PvE uniquement)';
	}
	else
	{
		fin2 = '';
	}
	var text = text + val + fin + fin2 + '\r\n';
	if (document.form_item.message.createTextRange && document.form_item.message.caretPos) {
		var caretPos = document.form_item.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
		document.form_item.message.focus();
	} else {
	document.form_item.message.value  += text;
	document.form_item.message.focus();
	}
}
function cap(text) {
	var val = prompt("Tapez la valeur","");
	var text = text + val + '\r\n';
	if (document.form_item.message.createTextRange && document.form_item.message.caretPos) {
		var caretPos = document.form_item.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
		document.form_item.message.focus();
	} else {
	document.form_item.message.value  += text;
	document.form_item.message.focus();
	}
}



function foc(text) {
	var val = prompt("Tapez la valeur","");
	var text = text + val + ' nivs\r\n';
	if (document.form_item.message.createTextRange && document.form_item.message.caretPos) {
		var caretPos = document.form_item.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
		document.form_item.message.focus();
	} else {
	document.form_item.message.value  += text;
	document.form_item.message.focus();
	}
}

function Cond_vs(text) {
	var vs = prompt("Condition : vs ??","");
	var text = '- Condition : vs ' + vs + '\r\n';
	if (document.form_item.message.createTextRange && document.form_item.message.caretPos) {
		var caretPos = document.form_item.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
		document.form_item.message.focus();
	} else {
	document.form_item.message.value  += text;
	document.form_item.message.focus();
	}
}

function pouv(text) {
	var vs = prompt("Pouvoir : ?? % de la réserve mana.","");
	var text = '- Pouvoir : ' + vs + '% de la réserve mana.\r\n';
	if (document.form_item.message.createTextRange && document.form_item.message.caretPos) {
		var caretPos = document.form_item.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
		document.form_item.message.focus();
	} else {
	document.form_item.message.value  += text;
	document.form_item.message.focus();
	}
}

function Cond_niv(text) {
	var niv = prompt("Le niveau ?","");
	var text = '\r\nCondition de Niveau : Niveau ' + niv + '\r\n\r\n';
	if (document.form_item.message.createTextRange && document.form_item.message.caretPos) {
		var caretPos = document.form_item.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
		document.form_item.message.focus();
	} else {
	document.form_item.message.value  += text;
	document.form_item.message.focus();
	}
}


function charge(text) {
	var nb = prompt("Le nombre de charges ?","");
	var text = 'Capacité de Charges Magiques :\r\n- ' + nb + ' Charges\r\n- ' + nb + ' Max\r\n';
	if (document.form_item.message.createTextRange && document.form_item.message.caretPos) {
		var caretPos = document.form_item.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
		document.form_item.message.focus();
	} else {
	document.form_item.message.value  += text;
	document.form_item.message.focus();
	}
}

function charge2(text) {
	var nb = prompt("Le nombre de charges ?","");
	var text = 'Objet Magique à Charges Secondaires :\r\n- ' + nb + ' Charges\r\n- ' + nb + ' Max\r\n';
	if (document.form_item.message.createTextRange && document.form_item.message.caretPos) {
		var caretPos = document.form_item.message.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text;
		document.form_item.message.focus();
	} else {
	document.form_item.message.value  += text;
	document.form_item.message.focus();
	}
}



// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}




var N = (self.document.all) ? 0 : 1;
var sDocRoot = (N) ? "self.document." : "self.document.all.";
var obDocRoot = (N) ? self.document : self.document.all;
var clslst = new Array("c1","c2","c3","c4","c5","c6","c7","c8","c9","c10","c11","c12","c13","c14");

function setallclasses()
{
 for(var i=0 ; i<clslst.length ; i++)
 {
  chkbx = eval(sDocRoot+clslst[i]);
  if ( chkbx )
   chkbx.checked = 1;
 }
}


  chk = 1; 
  function setall() 
  { 
     for(var i=0 ; i<40 ; i++) 
     { 
      var e = document.forms["form_item"].tab_cl[i];  
       e.checked = chk;  
     } 
  }


var N = (self.document.all) ? 0 : 1;
var obDocRoot = (N) ? self.document : self.document.all;
var sDocRoot = (N) ? "self.document." : "self.document.all.";
var mapWindow = null;


function launch(newURL, newName, newFeatures, orgName)
{
  var remote = open(newURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  return remote;
}


function launchMapWindow(value,value2)
{
value2 = value2-1;
  window.open('search_loc.php?zone='+value + '&etage=' + value2 , 'BdoDaoc', 'directories=no , location=no , menubar=no, resizable=no , scrollbars=no , width=720 , height=600');
}

function launchsearchWindow(value)
{
  targeturl = "search.php?zone=" + value;
  window.open(targeturl, "search", "height=250,width=400,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0");
}

function launchMapWindow2(valeur)
{
  targeturl = "search_loc.php?zone=" + valeur;
  mapWindow = launch(targeturl, "souris", "height=600,width=720,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0");
}

function updateMapWindow()
{
  if ( mapWindow && !mapWindow.closed )
    launchMapWindow();
}

function storeCaret (textEl) {
    if (textEl.createTextRange) 
	textEl.caretPos = document.selection.createRange().duplicate();
}

function insertAtCaret (textEl, text) {
    if (textEl.createTextRange && textEl.caretPos) {
	var caretPos = textEl.caretPos;
	caretPos.text =  caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
    }  else {
	textEl.value = textEl.value + text;
    }
}

function doMod (tag,dest){
    var t;
    if (document.selection) {
	t = document.selection.createRange().text;
    } else {
	t = document.getSelection();
    }	
    var newval = new String;
    if (tag == "B") {
	newval = "[b]" + t + "[/b]";
    }
    if (tag == "I") newval = "[i]" + t + "[/i]";
    if (tag == "U") newval = "[u]" + t + "[/u]";
    if (tag == "Sm") newval = "[sm]" + t + "[/sm]";
    if (tag == "Li") newval = "[li]" + t + "[/li]";
    if (tag == "Lg") newval = "[lg]" + t + "[/lg]";
    if (tag == "Qu") newval = "[quote]" + t + "[/quote]";
    if (tag == "Pre") newval = "[pre]" + t + "[/pre]";
    if (tag == "URL") {
	var href = prompt("Tapez l'url ici","http://");
	var t = prompt("Tapez le descriptif","lien");
	newval = "[url=" + href + "]" + t + "[/url]";
    }
    if (tag == "IMG") {
	var href = prompt("Tapez l'url ici","http://");
	newval = "[img]" + href + "[/img]";
    }
    if (tag == "Color") {
	var color = document.getElementById('color')[document.getElementById('color').selectedIndex].value;
	newval = "[" + color + "]" + t + "[/" + color + "]";
    }
    if (newval == "") return;
    insertAtCaret(dest,newval); 
}



function loadHelp(helpURL) {
    window.open(helpURL,'help','width=400,height=400,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
}
function CheckIt() {
    if (document.form_item.subject.value == ""){
	alert('You Need to Enter a Subject');
	return false;
    }
    document.form_item.submit();
}


function confirmSubmit()
{
var agree=confirm("Vous êtes vraiment sur?");
if (agree)
	return true ;
else
	return false ;
}

function checkall(nb)
{
	var i = 0;
	
	while (i < nb)
	{
		a = 'tab_cl[' + i + ']';
		document.form_item.elements[a].checked = true;
		i = i+1;
	}
	
}

function decheckall(nb)
{
	var i = 0;

	while (i < nb)
	{
		a = 'tab_cl[' + i + ']';
		document.form_item.elements[a].checked = false;
		i = i+1;
	}

}

function toggle (i,n) 
{
	e = document.getElementById(n);
	if (e.style.display != 'block') 
	{
		e.style.display = 'block';
		i.src = 'images/hide_content.gif';
	}
	else
	{
		e.style.display = 'none';
		i.src = 'images/show_content.gif';
	}
}





function ClipBoard(intext) 
{ 

   window.clipboardData.setData("Text", intext); 
   alert("L'url est copié dans le presse papier.\nVous pouvez la coller via le raccourci Ctrl+V où vous voulez.");
   return false;
}

function sendData(param, page)
{
	if(document.all)
	{
		//Internet Explorer
		var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
	}//fin if
	else
	{
	    //Mozilla
		var XhrObj = new XMLHttpRequest();
	}//fin else

		//définition de l'endroit d'affichage:

	var content = document.getElementById("contenu");
	
	XhrObj.open("POST", page);

		//Ok pour la page cible

	XhrObj.onreadystatechange = function()
	{
		if (XhrObj.readyState == 4 && XhrObj.status == 200)
		content.innerHTML = XhrObj.responseText ;
	}
	XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	XhrObj.send(param);
}
