Number.prototype.formatMoney = function(c, d, t){
var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", 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 nl2br (str, is_xhtml) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Philip Peterson
    // +   improved by: Onno Marsman
    // +   improved by: Atli Þór
    // +   bugfixed by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   improved by: Maximusya
    // *     example 1: nl2br('Kevin\nvan\nZonneveld');
    // *     returns 1: 'Kevin<br />\nvan<br />\nZonneveld'
    // *     example 2: nl2br("\nOne\nTwo\n\nThree\n", false);
    // *     returns 2: '<br>\nOne<br>\nTwo<br>\n<br>\nThree<br>\n'
    // *     example 3: nl2br("\nOne\nTwo\n\nThree\n", true);
    // *     returns 3: '<br />\nOne<br />\nTwo<br />\n<br />\nThree<br />\n'
    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';

    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}



var etapeEncours=null;
function supprimerAvis(ida,idf,verif)
{	
	if(verif=="oui")
	{
		

$.ajax({
   type: "POST",
   url: "suppression_avis.php",
   data: "ida="+ida+"&idf="+idf,
   success: function(msg){
 // alert( "Data Saved: " );
	//$("#sptreponsable_composante").html(""+msg);
	//alert("le fichier a été supprimé");
	$("a#fa"+ida+"_"+idf).remove();
	$("a#sa"+ida+"_"+idf).remove();
   }
 });
	}
	
	else
	{
	jQuery('#inline1_val').html("Êtes vous sûr de vouloir supprimer ce fichier ?<br/><br/><input name=\"fffffff\" type=\"button\" value=\"Oui\" onclick=\"javascript:supprimerAvis('"+ida+"','"+idf+"','oui');$.fancybox.close();\" />&nbsp;&nbsp;&nbsp;<input name=\"fffffff\" type=\"button\" value=\"Non\" onclick=\"javascript:$.fancybox.close();\" />"); $("#amsgbox_val").click();	
		
	}
}

function majFieldAnnee(an)
{
	var anneefield=parseInt(an);
	$('font.fieldsuite').html(anneefield);
	$('span.fieldsuite1').html(anneefield+'/'+(anneefield+1));
	$('span.fieldsuite2').html((anneefield+1)+'/'+(anneefield+2));
	$('span.fieldsuite3').html((anneefield+2)+'/'+(anneefield+3));
	
}


function supprimerFichier(ida,idf,verif)
{
	if(verif=="oui")
	{
$.ajax({
   type: "POST",
   url: "suppression_fichier.php",
   data: "ida="+ida+"&idf="+idf,
   success: function(msg){
     // alert( "Data Saved: " + msg );
	//$("#sptreponsable_composante").html(""+msg);
	//alert("le fichier a été supprimé");
	$("a#fa"+ida+"_"+idf).remove();
	$("a#sa"+ida+"_"+idf).remove();
   }
 });
	}
	
	else
	{
	jQuery('#inline1_val').html("Êtes vous sûr de vouloir supprimer ce fichier ?<br/><br/><input name=\"fffffff\" type=\"button\" value=\"Oui\" onclick=\"javascript:supprimerFichier('"+ida+"','"+idf+"','oui');$.fancybox.close();\" />&nbsp;&nbsp;&nbsp;<input name=\"fffffff\" type=\"button\" value=\"Non\" onclick=\"javascript:$.fancybox.close();\" />"); $("#amsgbox_val").click();	
		
	}
}

function changerInputapp()
{
	var nbrmois=12*$("#theureannuel input[type='radio'][value='oui']:checked").not(":hidden").length;
	$("#test_apprentissage").val(nbrmois);
//alert("le nombre d'années est :"+nbrmois);	
}

function changerResponsable(idc,ide)
{
	
	//
	$.ajax({
   type: "POST",
   url: "code_rne.php",
   data: "idc="+idc+"&ide="+ide,
   success: function(msg){
     // alert( "Data Saved: " + msg );
	$("#tcode_rne_composante_new").val(msg);
   }
 });
	
	
	
	/*$("#sptreponsable_composante").html('<img src="images/ajax-loader.gif" width="16" height="16" />');
$.ajax({
   type: "POST",
   url: "resp_composante.php",
   data: "idc="+idc+"&ide="+ide,
   success: function(msg){
     // alert( "Data Saved: " + msg );
	$("#sptreponsable_composante").html(""+msg);
   }
 });*/
}

function lireAnnotation(ida)
{
	
$.ajax({
   type: "POST",
   url: "lire_annotation.php",
   data: "ida="+ida,
   success: function(msg){
     //alert( "Data Saved: " + msg );
	location.reload();
   }
 });
}


function calculerminvtot()
{ 
	var total=0;
	$("#tfluxsol .minv").each(function(i){
		
		if( IsNumeric($(this).val() ) ) total=total+parseFloat($(this).val()); else $(this).val(0);
	});
	$("#tfluxsol #minvtot").val(total);
	//alert("test ca apsse"+total);
}

function calculermaxvtot()
{
var total=0;
		$("#tfluxsol .maxv").each(function(i){
		
		if( IsNumeric($(this).val() ) ) total=total+parseFloat($(this).val()); else $(this).val(0);
	});
	$("#tfluxsol #maxvtot").val(total);
	//alert("test ca apsse"+total);
}

function champsTotal()
{
	var nbrspan=$("span.total").size();
	
	$("span.total").each(function(i){
		var valeur=$(this).html();
		var id=$(this).attr("id");
		$(this).replaceWith('<input type="text" name="'+id+'" id="'+id+'" class="znvaleur" value="'+valeur+'"/>');
		
	
		
	});
	return true;
}

function calculerBudget(id)
{
	var mt=0;
	var op1=0;
	var op2=0;
	//liste des calcul
	
	//a1nbhptot
	if(id=="a1nbhptot")
	{  mt=parseFloat($("#a11nbhp").html())+parseFloat($("#a12nbhp").html())+parseFloat($("#a13nbhp").html())+parseFloat($("#a14nbhp").html());
	$("#"+id).html(""+mt);
	$("#total_charges").click();
	}
	
	//a11nbhp
	if(id=="a11nbhp")
	{   
	    if(IsNumeric($("#a11_heures").val())) op1=parseFloat($("#a11_heures").val());
		if(IsNumeric($("#a11_nb_gr").val()))  op2=parseFloat($("#a11_nb_gr").val());
		
		mt=op1*op2;
		$("#"+id).html(""+mt);
		$("#a11_ch").click(); //correctif bug blur $("#a11_ch").blur();
		$("#a1nbhptot").click();
		
	}
	//a12nbhp
	if(id=="a12nbhp")
	{   
	    if(IsNumeric($("#a12_heures").val())) op1=parseFloat($("#a12_heures").val());
		if(IsNumeric($("#a12_nb_gr").val()))  op2=parseFloat($("#a12_nb_gr").val());
		
		mt=op1*op2;
		$("#"+id).html(""+mt);
		$("#a12_ch").click(); //correctif bug blur  $("#a12_ch").blur();
		$("#a1nbhptot").click();
	}
	//a13nbhp
	if(id=="a13nbhp")
	{   
	    if(IsNumeric($("#a13_heures").val())) op1=parseFloat($("#a13_heures").val());
		if(IsNumeric($("#a13_nb_gr").val()))  op2=parseFloat($("#a13_nb_gr").val());
		
		mt=op1*op2;
		$("#"+id).html(""+mt);
		$("#a13_ch").click(); //correctif bug blur $("#a13_ch").blur();
		$("#a1nbhptot").click();
	}
	//a14nbhp
	if(id=="a14nbhp")
	{   
	    if(IsNumeric($("#a14_heures").val())) op1=parseFloat($("#a14_heures").val());
		if(IsNumeric($("#a14_nb_gr").val()))  op2=parseFloat($("#a14_nb_gr").val());
		
		mt=op1*op2;
		$("#"+id).html(""+mt);
		$("#a14_ch").click(); //correctif bug blur $("#a14_ch").blur();
		$("#a1nbhptot").click();
	}
		//a31nbhp
	if(id=="a31nbhp")
	{   
	    if(IsNumeric($("#a31_heures").val())) op1=parseFloat($("#a31_heures").val());
		if(IsNumeric($("#a31_nb_gr").val()))  op2=parseFloat($("#a31_nb_gr").val());
		
		mt=op1*op2*parseFloat($("#fpa").val());
		$("#"+id).html(""+mt);
		$("#a31_ch").click(); //correctif bug blur  $("#a31_ch").blur();
		//$("#a1nbhptot").click();
	}
			//a32nbhp
	if(id=="a32nbhp")
	{   
	    if(IsNumeric($("#a32_heures").val())) op1=parseFloat($("#a32_heures").val());
				
		mt=op1*parseFloat($("#fpa").val());
		$("#"+id).html(""+mt);
	   
		$("#a32_ch").click(); //correctif bug blur $("#a32_ch").blur(); 
		//$("#a1nbhptot").click();
	}
				//a32nbhp
	if(id=="a33nbhp")
	{   
	    if(IsNumeric($("#a33_heures").val())) op1=parseFloat($("#a33_heures").val());
		if(IsNumeric($("#a33_nb_gr").val()))  op2=parseFloat($("#a33_nb_gr").val());
		
		mt=op1*op2
		$("#"+id).html(""+mt);
		$("#a33_ch").click();  //correctif bug blur $("#a33_ch").blur();
		//$("#a1nbhptot").click();
	}
	
	//a1fia
	if(id=="a1fiatot")
	{  mt=parseFloat($("#a11fia").html())+parseFloat($("#a12fia").html())+parseFloat($("#a13fia").html())+parseFloat($("#a14fia").html());
	$("#"+id).html(""+mt);
	$("#total_charges").click();
	}
	//a11fia
	if(id=="a11fia")
	{   
	    if(IsNumeric($("#a11_ch").val())) op1=parseFloat($("#a11_ch").val());
		if(IsNumeric($("#a11nbhp").html()))  op2=parseFloat($("#a11nbhp").html());
		
		mt=op1*op2;
		$("#"+id).html(""+mt);
		$("#a1fiatot").click();
		$("#a11fiapp").click();
		
	}
	
	//a12fia
	if(id=="a12fia")
	{   
	    if(IsNumeric($("#a12_ch").val())) op1=parseFloat($("#a12_ch").val());
		if(IsNumeric($("#a12nbhp").html()))  op2=parseFloat($("#a12nbhp").html());
		
		mt=op1*op2;
		$("#"+id).html(""+mt);
		$("#a1fiatot").click();
		$("#a12fiapp").click();
	}
	
	//a13fia
	if(id=="a13fia")
	{   
	    if(IsNumeric($("#a13_ch").val())) op1=parseFloat($("#a13_ch").val());
		if(IsNumeric($("#a13nbhp").html()))  op2=parseFloat($("#a13nbhp").html());
		
		mt=op1*op2;
		$("#"+id).html(""+mt);
		$("#a1fiatot").click();
		$("#a13fiapp").click();
	}
	//a13fia
	if(id=="a14fia")
	{   
	    if(IsNumeric($("#a14_ch").val())) op1=parseFloat($("#a14_ch").val());
		if(IsNumeric($("#a14nbhp").html()))  op2=parseFloat($("#a14nbhp").html());
		
		mt=op1*op2;
		$("#"+id).html(""+mt);
		$("#a1fiatot").click();
		$("#a14fiapp").click();
	}
		//a21fia
	if(id=="a21fia")
	{   
	    if(IsNumeric($("#a21_ch").val())) op1=parseFloat($("#a21_ch").val());
		if(IsNumeric($("#a21_heures_payees").val()))  op2=parseFloat($("#a21_heures_payees").val());
		
		mt=op1*op2;
		$("#"+id).html(""+Math.round(mt));
		$("#a21fiapp").click();
	}
		//a41fia
	if(id=="a41fia")
	{   
	    if(IsNumeric($("#a41_ch").val())) op1=parseFloat($("#a41_ch").val());
		if(IsNumeric($("#a41_heures_payees").val()))  op2=parseFloat($("#a41_heures_payees").val());
		
		mt=op1*op2;
		$("#"+id).html(""+Math.round(mt));
		$("#a41fiapp").click();
	}
	
	//a1fiapptot
	if(id=="a1fiapptot")
	{  mt=parseFloat($("#a11fiapp").html())+parseFloat($("#a12fiapp").html())+parseFloat($("#a13fiapp").html())+parseFloat($("#a14fiapp").html());
	$("#"+id).html(""+mt);
	$("#total_charges").click();
	}

	//a11fiapp
		if(id=="a11fiapp")
	{   
	    if(IsNumeric($("#a11fia").html())) op1=parseFloat($("#a11fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a1fiapptot").click();
	}
	//a12fiapp
		if(id=="a12fiapp")
	{   
	    if(IsNumeric($("#a12fia").html())) op1=parseFloat($("#a12fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a1fiapptot").click();
	}
	//a13fiapp
		if(id=="a13fiapp")
	{   
	    if(IsNumeric($("#a13fia").html())) op1=parseFloat($("#a13fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a1fiapptot").click();
	}
	//a14fiapp
		if(id=="a14fiapp")
	{   
	    if(IsNumeric($("#a14fia").html())) op1=parseFloat($("#a14fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a1fiapptot").click();
	}
	
	//a34_frais_imputes_apprentis
		if(id=="a34_frais_imputes_apprentis")
	{ 
	if(IsNumeric($("#a31_nb_gr").val())) op1=parseFloat($("#a31_nb_gr").val()); 
	if(IsNumeric($("#fpa").val())) op2=parseFloat($("#fpa").val()); 
	mt=op1*op2*50;
	$("#"+id).val(""+Math.round(mt));
	$("#a3fiapptot").click();
	}
	
		//a3fiapptot
	if(id=="a3fiapptot")
	{
		if(IsNumeric($("#a34_frais_imputes_apprentis").val())) op1=parseFloat($("#a34_frais_imputes_apprentis").val());  
	mt=parseFloat($("#a31fiapp").html())+parseFloat($("#a32fiapp").html())+parseFloat($("#a33fiapp").html())+op1;
	$("#"+id).html(""+mt);
	$("#total_charges").click();
	}

		//a31fiapp
		if(id=="a31fiapp")
	{   
	    
	    if(IsNumeric($("#a31_ch").val())) op1=parseFloat($("#a31_ch").val());
		if(IsNumeric($("#a31nbhp").html()))  op2=parseFloat($("#a31nbhp").html());
				
		mt=op1*op2;
		$("#"+id).html(""+Math.round(mt));
		$("#a3fiapptot").click();
	}
			//a32fiapp
		if(id=="a32fiapp")
	{   
	    
	    if(IsNumeric($("#a32_ch").val())) op1=parseFloat($("#a32_ch").val());
		if(IsNumeric($("#a32nbhp").html()))  op2=parseFloat($("#a32nbhp").html());
				
		mt=op1*op2;
		$("#"+id).html(""+Math.round(mt));
		$("#a3fiapptot").click();
	}
	
			//a33fiapp
		if(id=="a33fiapp")
	{   
	    
	    if(IsNumeric($("#a33_ch").val())) op1=parseFloat($("#a33_ch").val());
		if(IsNumeric($("#a33nbhp").html()))  op2=parseFloat($("#a33nbhp").html());
				
		mt=op1*op2;
		$("#"+id).html(""+Math.round(mt));
		$("#a3fiapptot").click();
	}
	
		//a2fiapptot
	if(id=="a2fiapptot")
	{  mt=parseFloat($("#a21fiapp").html());
	$("#"+id).html(""+mt);
	$("#total_charges").click();
	}

	
		//a21fiapp
		if(id=="a21fiapp")
	{   
	    if(IsNumeric($("#a21fia").html())) op1=parseFloat($("#a21fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a2fiapptot").click();
	}
	
	
		//a4fiapptot
	if(id=="a4fiapptot")
	{  mt=parseFloat($("#a41fiapp").html())+parseFloat($("#a42fiapp").html());
	$("#"+id).html(""+mt);
	$("#total_charges").click();
	}

		//a41fiapp
		if(id=="a41fiapp")
	{   
	    if(IsNumeric($("#a41fia").html())) op1=parseFloat($("#a41fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a4fiapptot").click();
	}
		//a42fiapp
		if(id=="a42fiapp")
	{   
	
	    if(IsNumeric($("#a42_frais_imputes_apprenants").val())) op1=parseFloat($("#a42_frais_imputes_apprenants").val());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a4fiapptot").click();
	}
	
		//a5fiapptot
	if(id=="a5fiapptot")
	{   if(IsNumeric($("#a52_frais_imputes_apprentis").val())) op1=parseFloat($("#a52_frais_imputes_apprentis").val());
	mt=parseFloat($("#a51fiapp").html())+op1+parseFloat($("#a53fiapp").html());
	$("#"+id).html(""+mt);
	$("#total_charges").click();
	}
		//a51fiapp
		if(id=="a51fiapp")
	{   
	
	    if(IsNumeric($("#a51_frais_imputes_apprenants").val())) op1=parseFloat($("#a51_frais_imputes_apprenants").val());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a5fiapptot").click();
	}
		//a53fiapp
		if(id=="a53fiapp")
	{   
	
	    if(IsNumeric($("#a53_frais_imputes_apprenants").val())) op1=parseFloat($("#a53_frais_imputes_apprenants").val());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a5fiapptot").click();
	}
	
		//a6fiapptot
	if(id=="a6fiapptot")
	{   
	mt=parseFloat($("#a660fiapp").html())+parseFloat($("#a661fiapp").html())+parseFloat($("#a662fiapp").html())+parseFloat($("#a663fiapp").html())+parseFloat($("#a664fiapp").html())+parseFloat($("#a665fiapp").html())+parseFloat($("#a668fiapp").html());
	$("#"+id).html(""+mt);
	$("#total_charges").click();
	}
	
	//a660fiapp
		if(id=="a660fiapp")
	{   
	
	    if(IsNumeric($("#a660_frais_imputes_apprenants").val())) op1=parseFloat($("#a660_frais_imputes_apprenants").val());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a6fiapptot").click();
	}
	//a661fiapp
		if(id=="a661fiapp")
	{   
	
	    if(IsNumeric($("#a661_frais_imputes_apprenants").val())) op1=parseFloat($("#a661_frais_imputes_apprenants").val());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a6fiapptot").click();
	}
	//a662fiapp
		if(id=="a662fiapp")
	{   
	
	    if(IsNumeric($("#a662_frais_imputes_apprenants").val())) op1=parseFloat($("#a662_frais_imputes_apprenants").val());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a6fiapptot").click();
	}
	//a663fiapp
		if(id=="a663fiapp")
	{   
	
	    if(IsNumeric($("#a663_frais_imputes_apprenants").val())) op1=parseFloat($("#a663_frais_imputes_apprenants").val());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a6fiapptot").click();
	}
	//a664fiapp
		if(id=="a664fiapp")
	{   
	
	    if(IsNumeric($("#a664_frais_imputes_apprenants").val())) op1=parseFloat($("#a664_frais_imputes_apprenants").val());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a6fiapptot").click();
	}
	//a665fiapp
		if(id=="a665fiapp")
	{   
	
	    if(IsNumeric($("#a665_frais_imputes_apprenants").val())) op1=parseFloat($("#a665_frais_imputes_apprenants").val());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a6fiapptot").click();
	}
		//a668fiapp
		if(id=="a668fiapp")
	{   
	
	    if(IsNumeric($("#a668_frais_imputes_apprenants").val())) op1=parseFloat($("#a668_frais_imputes_apprenants").val());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#a6fiapptot").click();
	}
	
	
		//b1fiapptot
	if(id=="b1fiapptot")
	{   
	mt=parseFloat($("#b11fiapp").html())+parseFloat($("#b12fiapp").html())+parseFloat($("#b13fiapp").html());
	
	if(($("#b14fiapp").length>0)&&($("#b15fiapp").length>0))
	mt=mt+parseFloat($("#b14fiapp").html())+parseFloat($("#b15fiapp").html());
	
	
	$("#"+id).html(""+mt);
	$("#total_charges").click();
	}
			//b11fia
		if(id=="b11fia")
	{   
	 
	    if(IsNumeric($("#b11_cout_etudiant").val())) op1=parseFloat($("#b11_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b11fiapp").click();
	}
	
		//b11fiapp
		if(id=="b11fiapp")
	{   
	
	    if(IsNumeric($("#b11fia").html())) op1=parseFloat($("#b11fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b1fiapptot").click();
	}
	
	//b12fia
		if(id=="b12fia")
	{   
	 
	    if(IsNumeric($("#b12_cout_etudiant").val())) op1=parseFloat($("#b12_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b12fiapp").click();
	}
	
		//b12fiapp
		if(id=="b12fiapp")
	{   
	
	    if(IsNumeric($("#b12fia").html())) op1=parseFloat($("#b12fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b1fiapptot").click();
	}
	//b13fia
		if(id=="b13fia")
	{   
	 
	    if(IsNumeric($("#b13_cout_etudiant").val())) op1=parseFloat($("#b13_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b13fiapp").click();
	}
	
		//b13fiapp
		if(id=="b13fiapp")
	{   
	
	    if(IsNumeric($("#b13fia").html())) op1=parseFloat($("#b13fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b1fiapptot").click();
	}
	
		//b14fia
		if(id=="b14fia")
	{   
	 
	    if(IsNumeric($("#b14_cout_etudiant").val())) op1=parseFloat($("#b14_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b14fiapp").click();
	}
	
		//b14fiapp
		if(id=="b14fiapp")
	{   
	
	    if(IsNumeric($("#b14fia").html())) op1=parseFloat($("#b14fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b1fiapptot").click();
	}
	
			//b15fia
		if(id=="b15fia")
	{   
	 
	    if(IsNumeric($("#b15_cout_etudiant").val())) op1=parseFloat($("#b15_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b15fiapp").click();
	}
	
		//b15fiapp
		if(id=="b15fiapp")
	{   
	
	    if(IsNumeric($("#b15fia").html())) op1=parseFloat($("#b15fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b1fiapptot").click();
	}
	
		//b2fiapptot
	if(id=="b2fiapptot")
	{   
	mt=parseFloat($("#b260fiapp").html())+parseFloat($("#b261fiapp").html())+parseFloat($("#b262fiapp").html())+parseFloat($("#b263fiapp").html())+parseFloat($("#b265fiapp").html())+parseFloat($("#b266fiapp").html())+parseFloat($("#b267fiapp").html())+parseFloat($("#b268fiapp").html());
	$("#"+id).html(""+mt);
	$("#total_charges").click();
	}
			//b260fia
		if(id=="b260fia")
	{   
	 
	    if(IsNumeric($("#b260_cout_etudiant").val())) op1=parseFloat($("#b260_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b260fiapp").click();
	}
	
			//b261fia
		if(id=="b261fia")
	{   
	 
	    if(IsNumeric($("#b261_cout_etudiant").val())) op1=parseFloat($("#b261_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b261fiapp").click();
	}
			//b262fia
		if(id=="b262fia")
	{   
	 
	    if(IsNumeric($("#b262_cout_etudiant").val())) op1=parseFloat($("#b262_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b262fiapp").click();
	}
	
			//b263fia
		if(id=="b263fia")
	{   
	 
	    if(IsNumeric($("#b263_cout_etudiant").val())) op1=parseFloat($("#b263_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b263fiapp").click();
	}
	
			//b265fia
		if(id=="b265fia")
	{   
	 
	    if(IsNumeric($("#b265_cout_etudiant").val())) op1=parseFloat($("#b265_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b265fiapp").click();
	}
			//b266fia
		if(id=="b266fia")
	{   
	 
	    if(IsNumeric($("#b266_cout_etudiant").val())) op1=parseFloat($("#b266_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b266fiapp").click();
	}
	
			//b266fia
		if(id=="b266fia")
	{   
	 
	    if(IsNumeric($("#b266_cout_etudiant").val())) op1=parseFloat($("#b266_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b266fiapp").click();
	}
	
			//b267fia
		if(id=="b267fia")
	{   
	 
	    if(IsNumeric($("#b267_cout_etudiant").val())) op1=parseFloat($("#b267_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b267fiapp").click();
	}
		//b268fia
		if(id=="b268fia")
	{   
	 
	    if(IsNumeric($("#b268_cout_etudiant").val())) op1=parseFloat($("#b268_cout_etudiant").val());
				
		mt=(op1*parseFloat($("#fpapr").val()));
		$("#"+id).html(""+Math.round(mt));
		$("#b268fiapp").click();
	}
	
	//b260fiapp
		if(id=="b260fiapp")
	{   
	
	    if(IsNumeric($("#b260fia").html())) op1=parseFloat($("#b260fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b2fiapptot").click();
	}
	//b261fiapp
		if(id=="b261fiapp")
	{   
	
	    if(IsNumeric($("#b261fia").html())) op1=parseFloat($("#b261fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b2fiapptot").click();
	}
	//b262fiapp
		if(id=="b262fiapp")
	{   
	
	    if(IsNumeric($("#b262fia").html())) op1=parseFloat($("#b262fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b2fiapptot").click();
	}
	//b263fiapp
		if(id=="b263fiapp")
	{   
	
	    if(IsNumeric($("#b263fia").html())) op1=parseFloat($("#b263fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b2fiapptot").click();
	}
	//b265fiapp
		if(id=="b265fiapp")
	{   
	
	    if(IsNumeric($("#b265fia").html())) op1=parseFloat($("#b265fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b2fiapptot").click();
	}
	//b266fiapp
		if(id=="b266fiapp")
	{   
	
	    if(IsNumeric($("#b266fia").html())) op1=parseFloat($("#b266fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b2fiapptot").click();
	}
	//b267fiapp
		if(id=="b267fiapp")
	{   
	
	    if(IsNumeric($("#b267fia").html())) op1=parseFloat($("#b267fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b2fiapptot").click();
	}
	
		//b268fiapp
		if(id=="b268fiapp")
	{   
	
	    if(IsNumeric($("#b268fia").html())) op1=parseFloat($("#b268fia").html());
				
		mt=(op1/parseFloat($("#fpapr").val()))*parseFloat($("#fpa").val());
		$("#"+id).html(""+Math.round(mt));
		$("#b2fiapptot").click();
	}
	
		//total des charges
	if(id=="total_charges")
	{   
	mt=parseFloat($("#b2fiapptot").html())+parseFloat($("#b1fiapptot").html())+parseFloat($("#a6fiapptot").html())+parseFloat($("#a5fiapptot").html())+parseFloat($("#a4fiapptot").html())+parseFloat($("#a3fiapptot").html())+parseFloat($("#a2fiapptot").html())+parseFloat($("#a1fiapptot").html());
	$("#"+id).html(""+mt);
	$("#charges_cfa").click();
		}
	
	if(id=="ressources_assurer")
	{
		  if(IsNumeric($("#dotations_salaires").val())) op1=parseFloat($("#dotations_salaires").val());
		  if(IsNumeric($("#part_apprentis").val())) op2=parseFloat($("#part_apprentis").val());
		mt=op1+op2;
		$("#"+id).html(""+mt);
		$("#charges_cfa").click();
		$("#autres_ressources").click();
		$("#contribution_total").click();
		$("#contribution_autres").click();
		$("#total_recettes").click();
	}
	if(id=="charges_cfa")
	{
		
		 if(IsNumeric($("#total_charges").html())) op1=parseFloat($("#total_charges").html());
		  if(IsNumeric($("#ressources_assurer").html())) op2=parseFloat($("#ressources_assurer").html());
		  
		  mt=Math.round((op1-op2)/9);
		$("#"+id).html(""+mt);
		$("#charges_structure_cfa").val(""+mt);
		
		$("#total_despenses_2an").click();
		$("#charges_structure_cfa_apprenti").click();
		
	}
	
		if(id=="total_despenses_2an")
	{
		
		 if(IsNumeric($("#total_charges").html())) op1=parseFloat($("#total_charges").html());
		  if(IsNumeric($("#charges_cfa").html())) op2=parseFloat($("#charges_cfa").html());
		  
		  mt=op1+op2;
		$("#"+id).html(""+mt);
		$("#rappel_depenses").html(""+mt);
		$("#total_despenses_1").click();
		$("#total_despenses_2").click();
		$("#rappel_depenses").click();
	}
	
		if(id=="total_despenses_1")
	{
		
			 if(IsNumeric($("#total_despenses_2an").html())) op1=parseFloat($("#total_despenses_2an").html());
		  if(IsNumeric($("#contribution_1").val())) op2=parseFloat($("#contribution_1").val());
		   mt=op1*op2;
		 
		$("#"+id).html(""+Math.round(mt/100));
	}
		if(id=="total_despenses_2")
	{
		
		
		 if(IsNumeric($("#total_despenses_2an").html())) op1=parseFloat($("#total_despenses_2an").html());
		  if(IsNumeric($("#contribution_2").val())) op2=parseFloat($("#contribution_2").val());
		   mt=op1*op2;
		$("#"+id).html(""+Math.round(mt/100));
	}
		if(id=="rappel_depenses")
	{
	
			/* if(IsNumeric($("#total_despenses_2an").html())) op1=parseFloat($("#total_despenses_2an").html());
		  if(IsNumeric($("#contribution_1").val())) op2=parseFloat($("#contribution_1").val());
		   mt=op1*op2;
		 
		$("#"+id).html(""+Math.round(mt/100));*/
		$("#autres_ressources").click();
		$("#ratio_cout_apprenti").click();
		
	
	}
	
		if(id=="autres_ressources")
	{
	
			 if(IsNumeric($("#rappel_depenses").html())) op1=parseFloat($("#rappel_depenses").html());
		  if(IsNumeric($("#ressources_assurer").html())) op2=parseFloat($("#ressources_assurer").html());
		   mt=op1-op2;
		 
		$("#"+id).html(""+mt);
		$("#contribution_total").click();
		$("#autres_ressources_1").click();
		$("#autres_ressources_2").click();
		$("#total_recettes").click();
		$("#tarif_apprenti_hors_charges").click();
		$("#recettes_ufa").click();		
		
		
	
	}
	
		if(id=="contribution_total")
	{
	
			 if(IsNumeric($("#ressources_assurer").html())) op1=parseFloat($("#ressources_assurer").html());
		  if(IsNumeric($("#autres_ressources").html())) op2=parseFloat($("#autres_ressources").html());
		   mt=(op1/(op1+op2))*100;
		 
		$("#"+id).html(""+Math.round(mt));
		$("#txttaux_parti").html(""+Math.round(mt));
	
	}
	
		if(id=="contribution_autres")
	{
	
			 if(IsNumeric($("#autres_ressources").html())) op1=parseFloat($("#autres_ressources").html());
		  if(IsNumeric($("#ressources_assurer").html())) op2=parseFloat($("#ressources_assurer").html());
		   mt=(op1/(op1+op2))*100;
		 
		$("#"+id).html(""+Math.round(mt));
	
	}
	
	if(id=="autres_ressources_1")
	{
	 if(IsNumeric($("#autres_ressources").html())) op1=parseFloat($("#autres_ressources").html());
	mt=(op1/3);
	$("#"+id).html(""+Math.round(mt));
	}
	
	if(id=="autres_ressources_2")
	{
	 if(IsNumeric($("#autres_ressources").html())) op1=parseFloat($("#autres_ressources").html());
	mt=(op1*2/3);
	$("#"+id).html(""+Math.round(mt));
	}
	
	if(id=="total_recettes")
	{
	 if(IsNumeric($("#ressources_assurer").html())) op1=parseFloat($("#ressources_assurer").html());
	 if(IsNumeric($("#autres_ressources").html())) op2=parseFloat($("#autres_ressources").html());
	mt=op1+op2;
	$("#"+id).html(""+Math.round(mt));
	}


if(id=="charges_structure_cfa")
	{

	}
	
	if(id=="charges_structure_cfa_apprenti")
	{
 if(IsNumeric($("#charges_structure_cfa").val())) op1=parseFloat($("#charges_structure_cfa").val());
	 if(IsNumeric($("#fpa").val())) op2=parseFloat($("#fpa").val());
	mt=op1/op2;
	$("#"+id).html(""+Math.round(mt));
	$("#tarif_apprenti_hors_charges").click();
	$("#recettes_ufa").click();		
	}
	
	if(id=="tarif_apprenti_hors_charges")
	{
		 if(IsNumeric($("#autres_ressources").html())) op1=parseFloat($("#autres_ressources").html());
	 if(IsNumeric($("#charges_structure_cfa_apprenti").html())) op2=parseFloat($("#charges_structure_cfa_apprenti").html());
	mt=(op1/parseFloat($("#fpa").val()))-op2;
		
	$("#"+id).html(""+Math.round(mt));
	$("#charges_apprenti_cfa").click();
	$("#tarif_heures_pr_apprenti").click();			
	
	}
	
		if(id=="charges_apprenti_cfa")
	{
		 if(IsNumeric($("#charges_structure_cfa_apprenti").html())) op1=parseFloat($("#charges_structure_cfa_apprenti").html());
	 if(IsNumeric($("#tarif_apprenti_hors_charges").html())) op2=parseFloat($("#tarif_apprenti_hors_charges").html());
	mt=op1+op2;
		
	$("#"+id).html(""+Math.round(mt));
	$("#charges_horaires_apprenti_cfa").click();		
	}
	
			if(id=="charges_horaires_apprenti_cfa")
	{
		 if(IsNumeric($("#charges_apprenti_cfa").html())) op1=parseFloat($("#charges_apprenti_cfa").html());
	 if(IsNumeric($("#hpr").val())) op2=parseFloat($("#hpr").val());
	mt=op1/op2;
		
	$("#"+id).html(""+Math.round(mt*100)/100);	
	}
	
	
		if(id=="recettes_ufa")
	{
		 if(IsNumeric($("#autres_ressources").html())) op1=parseFloat($("#autres_ressources").html());
	 if(IsNumeric($("#charges_structure_cfa").val())) op2=parseFloat($("#charges_structure_cfa").val());
	mt=op1-op2;
		
	$("#"+id).html(""+Math.round(mt));
	
	}
	
		if(id=="ratio_cout_apprenti")
	{
		 if(IsNumeric($("#rappel_depenses").html())) op1=parseFloat($("#rappel_depenses").html());
	     mt=(op1/parseFloat($("#fpa").val()))
		
	$("#"+id).html(""+Math.round(mt));
	$("#ratio_cout_heure_apprenti").click();	
	
	}
	
if(id=="ratio_cout_heure_apprenti")
	{
		 if(IsNumeric($("#ratio_cout_apprenti").html())) op1=parseFloat($("#ratio_cout_apprenti").html());
	
	mt=(op1/parseFloat($("#hpr").val()));
		
	$("#"+id).html(""+Math.round(mt*100)/100);
	
	}	
	if(id=="tarif_heures_pr_apprenti")
	{
		 if(IsNumeric($("#tarif_apprenti_hors_charges").html())) op1=parseFloat($("#tarif_apprenti_hors_charges").html());
	
	mt=(op1/parseFloat($("#hpr").val()));
		
	$("#"+id).html(""+Math.round(mt*100)/100);
	
	}	

	
	
	
	
	
}



function IsNumeric(input)
{
   return (input - 0) == input && input.length > 0;
}


function selectionDuree(n)
{
	if(n=='12')
	{
	$(".ligne_2an input").attr("disabled",true);
	$(".ligne_3an input").attr("disabled",true);
	$(".ligne_2an").hide();
	$(".ligne_3an").hide();

	}
	if(n=='24')
	{
	$(".ligne_2an input").attr("disabled",false);
	$(".ligne_3an input").attr("disabled",true);
	$(".ligne_2an").show();
	$(".ligne_3an").hide();

	}
	if(n=='36')
	{
	$(".ligne_2an input").attr("disabled",false);
	$(".ligne_3an input").attr("disabled",false);
	$(".ligne_2an").show();
	$(".ligne_3an").show();
	
	}
}

function vraiVisible(elem)
{
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();

    var elemTop = $(elem).offset().top;
    var elemBottom = elemTop + $(elem).height();

    return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom));
}


function switcherZone(val)
{
	if(val!="")
$("#fz21 input").attr("disabled",true);
else
$("#fz21 input").attr("disabled",false);
}

function switcherEtape(lib,ind)
{
		$('#site #contenu fieldset.etape2 #cadreform').scrollTo( $('img.navig'+ind+'').parents("div.zone_etape"), 800 );
				etapeEncours=$('img.navig'+ind+'').parents("div.zone_etape");
	
/*	var pas=-1*820*ind;
  $('#site #contenu fieldset.etape2 #cadrescroll').not(":animated").animate({
     top: ''+pas+'px'    
  }, 500, function() {
    // Animation complete.
  });*/
	
}


function changerDocs(idz, cn, nbr)
{
$("."+cn+"").not("."+cn+":first").remove();
for(var i=1;i<=parseInt(nbr);i++)
{
$("."+cn+":first").clone().appendTo($("#"+idz+"")).removeClass("abstract_ajax").show().find("span.indice").html(""+i);
}
}

function selectionGrille(nbr,act,id)
{
	//if($("#zntableur .cbid:checked").length!=1)
	if(false)		
	{jQuery('#inline1').html( "Vous devez selectionner un dossier."); $("#amsgbox").click();}
		else
		{ //act+="?id="+$("#zntableur .cbid:checked").val();
			$("#formGrille").attr("action",act+"?cb="+id);
			$("#formGrille").submit();
		
		}
}

function allerPartie()
{

}

//desactiver tous touche entrer 

function DesactiverEntrer_complet(idFormulaire){
	$('#'+idFormulaire).bind("keypress",
		function(e){
			if(e.keyCode == 13)
				return false;
		}
	);
}

//desactiver tous touche entrer que dans les input
function DesactiverEntrer_input(idFormulaire){
	$('#'+idFormulaire+' input').bind("keypress",
		function(e){
			//alert('ok');
			if(e.keyCode == 13)
				return false;
		}
	);
}


$(document).ready(function() {
	
	DesactiverEntrer_input('fcontact');
	DesactiverEntrer_input('fetapeformu');
	DesactiverEntrer_input('fbudget');
	//DesactiverEntrer_input('');
	 
//evenement click nvigation	 
if($("div.znavig a").length>0)
{
$("div.znavig a").click(function(){
	var indzone=$(this).attr("ind");
	
	if($(this).hasClass("selected"))
	{
			$('#site #contenu fieldset.etape2 #cadreform').scrollTo( $("#site #contenu fieldset.etape2 #cadreform div.zone_etape:nth-child("+indzone+")"), 800, function(){
				
				$(document).scrollTo( $("#site #contenu fieldset.etape2 #cadreform div.zone_etape:nth-child("+indzone+")"),200);
				
				});
			etapeEncours=$("#site #contenu fieldset.etape2 #cadreform div.zone_etape:nth-child("+indzone+")");
		
		}
	
	
			
			
	});	
	
	}

	 
//initialistaion de l'etape encours
if($("div.zone_etape").length>0)
etapeEncours=$("div.zone_etape:first");	 
	 
//calcul total part

$(".partcout1").blur(function(){
	var total=0;
	$(".partcout1").each(function(i){
		
		if( IsNumeric($(this).val() ) ) total=total+parseFloat($(this).val()); else $(this).val(0);
	});
	$(".parttotal1").val(total);
	$(".parttotal1").change();
	//alert("test ca apsse"+total);
	
	}); 
	
$(".partcout2").blur(function(){
	var total=0;
	$(".partcout2").each(function(i){
		
		if( IsNumeric($(this).val() ) ) total=total+parseFloat($(this).val()); else $(this).val(0);
	});
	$(".parttotal2").val(total);
	$(".parttotal2").change();
	//alert("test ca apsse"+total);
	
	});
$(".partcout3").blur(function(){
	var total=0;
	$(".partcout3").each(function(i){
		
		if( IsNumeric($(this).val() ) ) total=total+parseFloat($(this).val()); else $(this).val(0);
	});
	$(".parttotal3").val(total);
	$(".parttotal3").change();
	//alert("test ca apsse"+total);
	
	});

	 
	 
//calcult des flux automatique
$("#tfluxapp .flx").blur(function(){
	var total=0;
	$(".flx").each(function(i){
		
		if( IsNumeric($(this).val() ) ) total=total+parseFloat($(this).val()); else $(this).val(0);
	});
	$("#tflux_entrant_total").val(total);
	//alert("test ca apsse"+total);
	
	}); 
	 
//desactiver les années
if($(".ligne_2an").length>0)
{
$(".ligne_2an input").attr("disabled",true);
$(".ligne_2an").hide();
}
if($(".ligne_3an").length>0)
{
	$(".ligne_3an input").attr("disabled",true);
	$(".ligne_3an").hide();
}

//clonage des zones ajax
$(".abstract_ajax").each(function(i){
//alert("test aj"+$(this).html());
	$(this).clone().appendTo($(this).parent()).removeClass("abstract_ajax");
//this.clone().appendTo($(this).parent());
 });
 $(".abstract_ajax").hide();	 
	 
//datagrid checkbox global
$("#zntableur #cb_global").click(function(){ if($(this).is(":checked")) {$("#zntableur .cbid").attr("checked",true);}else{$("#zntableur .cbid").attr("checked",false);} });	


//fancybox
if($("#amsgbox").length>0)
{
$("#amsgbox").fancybox({
	'showCloseButton': false,
				'padding'			: 0,
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});
}
//fancybox
if($("#amsgbox_val").length>0)
{
$("#amsgbox_val").fancybox({
	'showCloseButton': false,
				'padding'			: 0,
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});
}
			
	$('input.qtekey').keypress(function (event){ return event.keyCode == 13 ? false : true; });		
	
	// validation formulaire de contact
	$("#fbudget").validate({
		onfocusout: false,
		onkeyup: false,
		meta: "validate",					   
		submitHandler: function(form) {
			//alert("test soummettre contact");
			if(champsTotal())
			form.submit();
		},					  
		showErrors: function(errorMap, errorList){ 
			if (errorList.length > 0) {
				//alert("erreur");
				jQuery('#inline1').html( errorList[0].message); $("#amsgbox").click();
			}
		}
	});
			
// validation formulaire de contact
	$("#fcontact").validate({
		onfocusout: false,
		onkeyup: false,
		meta: "validate",					   
		submitHandler: function(form) {
			//alert("test soummettre contact");
			form.submit();	
		},					  
		showErrors: function(errorMap, errorList){ 
			if (errorList.length > 0) {
				//alert("erreur");
				jQuery('#inline1').html( errorList[0].message); $("#amsgbox").click();
			}
		}
	}); 
	
//validation du formulaire des etapes 
$.validator.methods.equal = function(value, element, param) {
		return value == param;
	};

	$("#fetapeformu").validate({
		onfocusout: false,
		onkeyup: false,
		meta: "validate",					   
		submitHandler: function(form) {
			if(vraiVisible($("#btvalider")))
			form.submit();	
			else			
			{
			$('#site #contenu fieldset.etape2 #cadreform').scrollTo( $(etapeEncours).next("div.zone_etape:first"), 800,function(){
				
				$(document).scrollTo( $('#site #contenu fieldset.etape2 #cadreform'), 200);
				/*alert("recadrer la page");*/} );
			etapeEncours=$(etapeEncours).next("div.zone_etape:first");
			
			$("div.znavig a:nth-child("+(parseInt(etapeEncours.index())+1)+")").addClass("selected");
			
			
			}
			//
		},					  
		showErrors: function(errorMap, errorList){ 
			if (errorList.length > 0) {
				
				//if($("#t1anne").is(":visible"))
				
				//errorList[0].element.val("chems");
				//if(vraiVisible(errorList[0].element))
				indexetapeencours=$(etapeEncours).index();
				indexetapeerreur=$(errorList[0].element).parents("div.zone_etape").index();
				
				
				if(parseFloat(indexetapeerreur)>parseFloat($("#tindice_fouverture_new").val()))
				{$("#tindice_fouverture_new").val(indexetapeerreur);
				$("#tindice_fmodification_new").val(indexetapeerreur);
				}
				
					
				if(indexetapeencours==indexetapeerreur)					
				{jQuery('#inline1').html( errorList[0].message); $("#amsgbox").click(); }
				else
				{//
				if($(errorList[0].element).parents("div.zone_etape").is($(etapeEncours).next("div.zone_etape")))
				{$('#site #contenu fieldset.etape2 #cadreform').scrollTo( $(errorList[0].element).parents("div.zone_etape"), 800 );
				etapeEncours=$(errorList[0].element).parents("div.zone_etape");
				$("div.znavig a:nth-child("+(parseInt(etapeEncours.index())+1)+")").addClass("selected");
				}
				else
				{$('#site #contenu fieldset.etape2 #cadreform').scrollTo( $(etapeEncours).next("div.zone_etape"), 800 );
				etapeEncours=$(etapeEncours).next("div.zone_etape");	
				$("div.znavig a:nth-child("+(parseInt(etapeEncours.index())+1)+")").addClass("selected");
				}
				//alert("Test "+$(errorList[0].element).parents("div.zone_etape"));
				}
				
			}
		}
	}); 
	
	
	//
	$( "#date_derniere_habilitation" ).datepicker({
			showOn: "button",
			buttonImage: "images/ico_calendrier.gif",
			dateFormat: 'dd/mm/yy',
			buttonImageOnly: true
		});
	$("#date_derniere_habilitation").datepicker('option', 'dayNamesMin', ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa']);
		$("#date_derniere_habilitation").datepicker('option', 'monthNames', ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Decembre']);
		
		$( "#date_derniere_fin" ).datepicker({
			showOn: "button",
			buttonImage: "images/ico_calendrier.gif",
			dateFormat: 'dd/mm/yy',
			buttonImageOnly: true
		});
	$("#date_derniere_fin").datepicker('option', 'dayNamesMin', ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa']);
		$("#date_derniere_fin").datepicker('option', 'monthNames', ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Decembre']);
 
	 
	 
 });
