// JavaScript Document
function aller_a(id){
     	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}
function masquer_class(ma_class) {
	$('.'+ma_class+'').fadeOut();
}
function masquer_tout_error() {
	$('.input_box_error').fadeOut();
}

function supprimer(id,table,debut) {
		$('#loading_block_'+id+'').fadeIn();
		$.ajax({
			url : './'+table+'/act.php',
			cache : false,
			type : 'POST',
			data : 'act=supprimer_'+table+'&id='+id+'&debut='+debut+'',
			success :	function(data){									
							$('#'+table+'_resultat').html(data);
						}
		});	
}
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,no_timeout) {
	if(no_timeout) {
		$('#' + id_ok).html('<div style="color: #000000;background-color: #00FF00;padding:10px;margin-top:10px;margin-bottom:10px;font-weight: bold;">' + message + '</div>').fadeIn();
	}
	else {
		$('#' + id_ok).html('<div style="color: #000000;background-color: #00FF00;padding:10px;margin-top:10px;margin-bottom:10px;font-weight: bold;">' + message + '</div>').fadeIn();
		setTimeout(function() { $('#' + id_ok).fadeOut(); },5000);
	}
}

function afficher_ko(id_ko,message) {
	$('#' + id_ko).html('<div style="color: #FFF;background-color: #FF7171;padding:10px;border:1px solid #8A0000;margin-top:10px;margin-bottom:10px;font-weight: bold;">' + message + '</div>').fadeIn();
}

function masquer_ok(id_ok) {
	$('#' + id_ok).fadeOut();
}

function masquer(id_masquer) {
	$('#' + id_masquer).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);
}

function append_html(id_html,le_html) {
	$('#'+id_html).append(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(table,id,url_jquery,valide) {
	$.ajax({
		url : './'+ url_jquery +'',
		cache : false,
		type : 'POST',
		data : 'act=valider_'+table+'&url_jquery='+url_jquery+'&id='+id+'&valide='+valide+'',
		success : function(data){									
			$('#valider_'+ id +'').html(data).fadeIn();
 		}
	});
}
function jquerize(f_name,url,f_data,res) {
	if(f_data == "formulaire") {
		f_data = $("#f_"+f_name+"").serialize();
	}
	$("#loading_"+ f_name +"").fadeIn();
	$.ajax({
		url : ""+url+"",
		cache : false,
		type : "POST",
		data : ""+f_data+"",
		success : function(data){
			if(res) {
				$("#"+ res +"").html(data).fadeIn();
			}
			else {
				$("#res_"+ f_name +"").html(data).fadeIn();
			}
			$("#loading_"+ f_name +"").fadeOut();
		}
	});
}


