function openGame(){
	var iWidth  = screen.availWidth;
	var iHeight = screen.availHeight;
	window.open("jeu/game.php", "game", "location=no, resizable=yes, status=no, toolbar=no, scrollbars=no, menubar=no, width="+iWidth+", height="+iHeight+", top=0, left=0");
}
function initMouseWheel(){
	if (window.addEventListener){
		/** DOMMouseScroll is for mozilla. */
		window.addEventListener('DOMMouseScroll', wheel, false);
	}
	/** IE/Opera. */
	window.onmousewheel = document.onmousewheel = wheel;

}
function displayBubble(id_bubble, id_target){
	
	var eBubble = $(id_bubble);
	var height  = eBubble.getStyle("height").toInt();
	var width   = eBubble.getStyle("width").toInt();
	var eTarget = $(id_target);
	var x = getOffsetLeft(eTarget) - 30;
	var y = getOffsetTop(eTarget) - height - 10;
	
	if (eBubble.getStyle("opacity") != 0){
		eBubble.setStyle("opacity", 0);
		
	}
	
	eBubble.setStyles({
				left : x + "px",
				top : y + "px"
				});

	var fadein = new Fx.Morph(id_bubble, {duration : 1000, wait : false, transition : Fx.Transitions.linear});
	fadein.start({'opacity': 1});
}
function hideBubble(id_bubble){
	
	var fadeout = new Fx.Morph(id_bubble, {duration : 1000, wait : false, transition : Fx.Transitions.linear});
	fadeout.start({'opacity': 0});
}
function getOffsetLeft(e)
{
	var x = e.offsetLeft;
	while ((e = e.offsetParent) != null){
		x += e.offsetLeft;
	}
	return x;
}
function getOffsetTop(e)
{
	var y = e.offsetTop;
	while ((e = e.offsetParent) != null){
		y += e.offsetTop;
	}
	return y;
}
function _isAlphabetic(str) // Boolean
{
	var result = true;
	var len    = str.length;
	for (var i = 0; i < len; i++)
	{
		var charCode = str.charCodeAt(i);
		if ((charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 122))
		{
			result = false;
			break;
		}
	}
	return result;
}
function _checkMail(email) //Boolean
{
	var aEmail  = [];
	var aDomain = [];
	
	if (email.length < 1) // moins d'un caractère
		return false;
	
	aEmail = email.split("@");
	
	if (aEmail.length != 2) // seulement un @ autorisé
		return false;

	var aDomain = aEmail[1].split(".");
	
	if (aDomain.length < 2) // au moins un point 
	{
		return false;
	}
	
	if (aDomain[aDomain.length - 1].length < 2 || aDomain[aDomain.length - 1].length > 4)
		return false; // un . est permis et entre 2 et 4 caractères après le .
	
	if(!_checkString (aEmail[0].toString()) || !_checkString (aEmail[1].toString()))
		return false;	// il y a un caractère invalide
	
	return true;
}
function _checkString (str) // Boolean
{
	var len	= str.length; // longueur de la chaine
	// je parcours la chaine
	for (var i = 0; i < len; i++)
		if (!_checkChar(str.charCodeAt(i)))
			return false; // la chaine contient au moins un caractère invalide
	return true;
}
function _checkChar (charCode) // Boolean
{
	var ASCII_ALLOWED = [[38,39],[42,43],[45,57],[61,61],[63,63],[65,90],[94,95],[97,123],[125,126]];
	// je parcours les caractères invalide
	for (var j = 0; j < ASCII_ALLOWED.length; j++)
	{
		if (charCode >= ASCII_ALLOWED[j][0] && charCode <= ASCII_ALLOWED[j][1])
		{
			return true;	// le caractère est dans l'intervalle des caractères permis
		}
	}
	return false;
}
