/**
 * lors du click sur bonton faite votre demande
 */
$(function() {
	$('#bouton-validation-simulateur').click(function(event) {
		event.preventDefault();
		var href = $(this).attr('href');
		var montant = $("#MontantInp").val();
		if (montant == ""){
			montant = 4000;
		}
		var duree = $("#DureeInp").val();
		if( duree == ""){
			duree=12;
		}
		var mensualite = $("#MensuInp").val();
		if(mensualite == ""){
			mensualite = 345.54;
		}
		//alert("montant =>"+montant+" duree =>"+duree+" mensu =>"+mensualite);
		if ($("#typePack").get(0)){
			$.loader();
			$.ajax({
				type:"GET",
				url:"simulationAjax.do?method=simul&typeCredit="+$("#typeCredit").val()+"&calculer=MENSUALITE&montant="+montant+"&duree="+duree+"&mensualite=",
				dataType: "xml",
				success:function(){
					$.postdatas( {
						url : href,
						datas : [ {
							name : 'montant',
							value : montant
						}, {
							name : 'duree',
							value : duree
						}, {
							name : 'mensualite',
							value : mensualite
						},{name:"typePack", value:$("#typePack").val()},
						{name:"typeCredit", value:$("#typeCredit").val()},
						{name:"ppc", value:$("#ppc").val()}
						
						]
					});
				}
			});
		}else{
			$.postdatas( {
				url : $(this).attr('href'),
				datas : [ {
					name : 'montant',
					value : montant
				}, {
					name : 'duree',
					value : duree
				}]
			});
		};
	});
	
	
	$("#mlMixtPPC").click(function(event){
		event.preventDefault();
		$("#mlPPC").dialog({
			close:function(event, ui){
				$(this).dialog('destroy');
				$("embed").each(function(){
					$(this).show();
				});
			},
			open: function(event, ui) {
				$("embed").each(function(){
					$(this).hide();
				});
			},
			width:450,
			title:"Mentions légales",
			modal:true,
			resizable:false,
			draggable:false
		});
	});
	$("#mlMixtPPR").click(function(event){
		event.preventDefault();
		$("#mlPPR").dialog({
			close:function(event, ui){
				$(this).dialog('destroy');
				$("embed").each(function(){
					$(this).show();
				});
			},
			open: function(event, ui) {
				$("embed").each(function(){
					$(this).hide();
				});
			},
			width:450,
			title:"Mentions légales",
			modal:true,
			resizable:false,
			draggable:false
		});
	});
});