var zIndexCourant=10000;
var scrollToInfoBulle=false;

function YAP_isEmail(who) {
	var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
	return(email.test(who));
}

function ajouteInfobulle(id,texte,positionnement){
	if(!positionnement){
		var positionnement="SE";
	}
	switch(positionnement){
		case "O":
			offsetX=-10;
			offsetY=10
			break;
		default:
			offsetX=10;
			offsetY=10;
			break;
	}
	zIndexCourant=zIndexCourant-1;
	var idInfobulle="infob" + encodeID(id);
	if(!$("#" + idInfobulle).size()){
		var offset = $('#' + id).offset();
		if(!texte){
			var texte = $('#' + id).attr("alt");
		}
		var x = offset.left;
		var y = offset.top;
		$("body").append('<p class="infoBulle" rel="' + id + '" id="' + idInfobulle + '" style="z-index:' + (zIndexCourant-1) + ';"><a name="hash' + idInfobulle + '"></a>' + texte + '<span class="fermer"><img src="/medias/general/bouton_fermer.gif"></span></p>');
		$("#" + idInfobulle).css("top",(y+offsetY));
		$("#" + idInfobulle).css("left",(x+offsetX));
		$("#" + idInfobulle).fadeIn("slow");
		$("#" + idInfobulle).click(function(){
			$(this).fadeOut("fast",function(){
				$(this).remove();
			});
		});
		$('#' + id).focus(function(){
			oteInfobulle($('#' + id).attr("id"));
			$('#' + id).unbind('click');
			$('#' + id).removeClass("enAttente");
		});
	}else{
		$("#" + idInfobulle).fadeOut("fast",function(){
			$(this).fadeIn("slow");
		});

	}
	if(!scrollToInfoBulle){
		$.scrollTo("#" + idInfobulle);
		scrollToInfoBulle=true;
	}
	return false;
}
function oteInfobulle(id){
	var idInfobulle="infob" + encodeID(id);
	$("#" + idInfobulle).remove();
}
function encodeID(id){
	//return(hex_md5(id));
	return(id);
}
function oteInfosBulles(){
	$("[id^='infob']").remove();
}
function echappeSelecteurJquery(chaine){
	var reg=new RegExp("(\\[)", "g");
	chaine=chaine.replace(reg,"\\\\[");
	var reg=new RegExp("(\\])", "g");
	chaine=chaine.replace(reg,"\\\\]");
	var reg=new RegExp("(\\.)", "g");
	chaine=chaine.replace(reg,"\\\\.");
	return chaine;
}
