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.bind('submit', function(event)
	{
		event.stopPropagation();
		
		return submit_form($(this), file, action, 0);
	})
}

function frmSubmitOld(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()
	$(":input", form).not("select[multiple]").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')
		{
			var radio=$("input:radio[name="+name+"]");
			
			for (var j=0, Tradio=radio.length; j<Tradio; j++)
			{
				if (radio[j].checked)
				{
					valeur=radio[j].value;
				}
			}
		}
		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_post(url, params)
{
	$.post(url, params,
	function(data)
	{
		eval(data);
	});
}

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

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

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) : "");
}