function inputFocusBlur(input, txt)
{
	input
	.focus(function()
	{
		if ($(this).val()==txt)
			$(this).val('');
	})
	.blur(function()
	{
		if ($(this).val()=='')
			$(this).val(txt);
	});
}

function frmSubmit(frm, file, action)
{
	frm.submit(function()
	{
		return submit_form($(this), file, action, 0);
	})
}

function submit_form(form, fichier, action, id)
{//v2.1
	var params=	'action='+action+'&id='+id;
	var valeur=	"";
	
	$(":input", form).not("select[multiple]").not($("radio", form)).each(function()
	{
		valeur	= $(this).val();
		var id	= $(this).attr('id');
		var name= $(this).attr('name');
		
		if (this.type=='checkbox')
		{
			valeur	= this.checked ? 1 : 0;
		}
		else
		if (this.type=='radio')
		{
			valeur	= $($(this)+":checked").val();
		}
		else
		{		
			valeur= valeur.replace(/€/g, "&euro;");
			valeur= valeur.replace(/™/g, "&trade;");
			valeur= valeur.replace(/’/g, "'");
			valeur= valeur.replace(/œ/g, "oe");
		}
		
		params+="&"+encodeURIComponent(name)+"="+encodeURIComponent(valeur);
	})
	
	ajax_post(fichier, params);

	return false;
}

function ajax_post2(url, params, fct)
{
	$.get(url, params,
	function(data)
	{
		fct(data);
	});
}

function ajax_post(url, params)
{
	$.post(url, params,
	function(data)
	{
		eval(data);
	});
}

function ajax_get(url, params)
{
	$.get(url, params,
	function(data)
	{
		eval(data);
	});
}

function format_nbre( number, decimals )
{//number_format
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://crestidg.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57     
 
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = ',';
    var t = '.';
		var s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}

function emails()
{
	$(".email")
	.each(function()
	{
		var email = $(this).text();
		email= email.replace(" [@] ", "@");
		email= email.replace(" [.] ", ".");
		
		$(this).replaceWith("<a href=\"mailto:"+email+"\">"+email+"</a>");
	});
}

function email(nom, domaine, sujet)
{
	document.location.href="mailto:"+nom+"@"+domaine+"?subject="+encodeURIComponent(sujet);
}

function mouseGoesOver()
{
	this.src=mouseOvers[this.number].src
}

function mouseGoesOut()
{
	this.src=mouseOuts[this.number].src
}


var mouseOvers=new Array();
var mouseOuts=new Array();

function images_survol()
{
	var Img= $(".bouton");


	for(var i=0, T=Img.length; i<T; i++)
	{
		var src= 		Img[i].src;
		var suffix=	src.substring(src.lastIndexOf('.'));

		Img[i].onmouseover=mouseGoesOver;
		Img[i].onmouseout=mouseGoesOut;

		mouseOuts[i]=			new Image();
		mouseOuts[i].src=	src;

		mouseOvers[i]=		new Image();
		mouseOvers[i].src=src.substring(0,src.lastIndexOf('.'))+'-hover'+suffix;

		Img[i].number=i
	}
}

function images_survolori()
{
	$(".bouton").each(function()
	{
		var src= 		$(this).attr('src');
		var suffix=	src.substring(src.lastIndexOf('.'));
		
		$(this)
		.mouseover(function()
		{
			var img = src.replace('-hover', '');
			img = img.replace(suffix, '-hover'+suffix);
			
			$(this).attr('src', img);
		})
		.mouseout(function()
		{
			var img = src.replace('-hover', '');

			$(this).attr('src', img);
		})
	})
}

function images_survol_affiche(images)
{//ajoute le -hover
	$(images).each(function()
	{
		var src= 		$(this).attr('src');
		var suffix=	src.substring(src.lastIndexOf('.'));
		
		var img = src.replace('-hover', '').replace(suffix, '-hover'+suffix);

		$(this).removeClass('bouton').unbind().attr('src', img);
	})
}

function images_survol_retire(images)
{//retire le -hover
	$(images).each(function()
	{
		var img = $(this).attr('src').replace('-hover', '');
		
		$(this).addClass('bouton').attr('src', img);
	})
}