// JavaScript Document
function afficher_loading(id_loading) {
	$('#' + id_loading).fadeIn();
}

function masquer_loading(id_loading) {
	$('#' + id_loading).fadeOut();
}

function afficher_error(id_error,message) {
	$('#' + id_error).html('<span class="error">' + message + '</span>').fadeIn();
}

function masquer_error(id_error) {
	$('#' + id_error).fadeOut();
}

function afficher_ok(id_ok,message) {
	$('#' + id_ok).html('<span class="message_ok">' + message + '</span>').fadeIn();
}

function masquer_ok(id_ok) {
	$('#' + id_ok).fadeOut();
}

function afficher_html(id_html,le_html) {
	$('#' + id_html).html(le_html).fadeIn();
}

function prepend_html(id_html,le_html) {
	$('#' + id_html).prepend(le_html);
}


$.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
			return $(':input',this).clearForm();
			if (type == 'text' || type == 'password' || tag == 'textarea' || type == 'file')
				this.value = '';
				else if (type == 'checkbox' || type == 'radio')
					this.checked = false;
					else if (tag == 'select')
 						this.selectedIndex = -1;
	});
};

function reset_form(id_form) {
	$('#'+ id_form).each(function(){
		this.reset();
	});
}

function supprimer_image(id_table,id_img,champ,url_jquery) {
		$.ajax({
					url : './'+ url_jquery +'',
					cache : false,
					type : 'POST',
					data : 'act=supprimer_image&id_table=' + id_table + '&id_img=' + id_img + '&champ=' + champ + '',
					success : function(data){									
								$('#image_' + champ + '_' + id_img + '').fadeOut();
							}
				});
}
function f_jquery_valider(id_jquery,id,url_jquery,valide) {
	$.ajax({
				url : './'+ url_jquery +'',
				cache : false,
				type : 'POST',
				data : 'act=valider&url_jquery=' + url_jquery + '&id_table=' + id_jquery + '&id=' + id + '&valide=' + valide + '',
				success : function(data){									
							$('#valider_'+ id +'').html(data).fadeIn();
						}
			});
}
