// Javascript pour le script de gestion de news

// Ouvre une fenêtre centrée de la taille spécifiée
function OpenWindow(url, width, height)
{
	posX = screen.width / 2  - width / 2;
	posY = screen.height / 2 - height / 2;
	
	window.open(url, 'popup', 'toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=1, copyhistory=0, menuBar=0, width=' + width + ', height=' + height + ', left=' + posX + ', top=' + posY);
}

function OnMailFocus()
{
	oField = document.forms['newsletterform'].elements['email'];
	
	if(oField.value == 'nom@domaine.com')
		oField.value = '';
}

function OnMailBlur()
{
	oField = document.forms['newsletterform'].elements['email'];
	
	if(oField.value == '')
		oField.value = 'nom@domaine.com';
}

// Détermine le navigateur
var isMozilla = (navigator.userAgent.toLowerCase().indexOf('gecko') != -1) ? true : false;

// Ajoute un smiley dans la zone de texte des messages
function PutSmiley(strSmiley)
{
	textArea = document.getElementById('message');

	if(isMozilla)
	{
		objectValue = textArea.value;

		objectValueDeb = objectValue.substring(0 , textArea.selectionStart);
		objectValueFin = objectValue.substring(textArea.selectionEnd , textArea.textLength);
		textArea.value = objectValueDeb + strSmiley + objectValueFin;
		
		textArea.focus();
		posSelected = objectValueDeb.length + strSmiley.length;
		textArea.setSelectionRange(posSelected, posSelected);
	}
	else
	{
		
		textArea.focus(textArea.caretPos);
		textArea.focus(textArea.value.length);
		textArea.caretPos = document.selection.createRange().duplicate();
		textArea.caretPos.text = strSmiley;
		textArea.focus();
	}
}
