function confirmLink(theLink, Type)
{
    if (typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm('Veux tu vraiment supprimer ceci ?\n -->  ' + Type);
    if (is_confirmed) {
        theLink.href += '&confirm=1';
    }

    return is_confirmed;
}

function checkOk(theForm) {
	theForm.action += '?confirm=1';
}

function openpopup() {
	var timer = setTimeout("window.open('popups/messages.php?action=recept', 'refus', 'toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=yes, copyhistory=no, width=544, height=500, left=200, top=50')",500);
}

function insertTewcode(theTextarea, theBalise)
{
	if (document.selection)
	{
		theTextarea.focus();
		sel = document.selection.createRange();
		var a = sel.text.length;
		sel.text = '!' + theBalise + ':' + sel.text + ':' + theBalise + '!';
		sel.select();
		if(a>0)
			sel.collapse(false);
		else
		{
			sel.collapse(true);
			sel.move("character",theBalise.length+2);
		}
	}
	else if (theTextarea.selectionStart || theTextarea.selectionStart == '0')
	{
		var startPos = theTextarea.selectionStart;
		var endPos = theTextarea.selectionEnd;
		var chaine = theTextarea.value;
		var chaineAj = '!' + theBalise + ':' + chaine.substring(startPos,endPos) + ':' + theBalise + '!';
		theTextarea.value = chaine.substring(0, startPos) + chaineAj + chaine.substring(endPos, chaine.length);
		if(chaine.substring(startPos,endPos).length>0)
			endPos = startPos + chaineAj.length;
		else
			endPos = startPos + theBalise.length+2;
		theTextarea.selectionStart = endPos;
		theTextarea.selectionEnd = endPos;
	}
	else
	{
		theTextarea.value += '!' + theBalise + ':' + sel.text + ':' + theBalise + '!';
	}
	theTextarea.focus();
}

function insertElement(theTextarea, theElement)
{
	if (document.selection) {
		theTextarea.focus();
		sel = document.selection.createRange();
		sel.text = theElement;
		sel.select();
		sel.collapse();
	}
	else if (theTextarea.selectionStart || theTextarea.selectionStart == '0') {
		var startPos = theTextarea.selectionStart;
		var endPos = theTextarea.selectionEnd;
		var chaine = theTextarea.value;
		theTextarea.value = chaine.substring(0, startPos) + theElement + chaine.substring(endPos, chaine.length);
		endPos = startPos + theElement.length;
		theTextarea.selectionStart = endPos;
		theTextarea.selectionEnd = endPos;
	} else {
		theTextarea.value += chaineAj;
	}
	theTextarea.focus();
}