function affiche_financement()
{
	affiche_masque_transparent("izOverlay2","#000000",0.65);
	$("#div_credit").fadeIn();
	
}
function masque_financement()
{
	$("#izOverlay2").hide();
	$("#div_credit").fadeOut();
}
function affiche_video_hyundai()
{
	affiche_masque_transparent("izOverlay","#000000",0.75);
	$("#video_hyundai").css("display","block");
	
}
function masque_video_hyundai()
{
	$("#izOverlay").hide();
	$("#video_hyundai").css("display","none");
}
function popup_panorama(nom_pano)
{
	
	window.open('panorama/panorama.php?nom_pano='+nom_pano,'','width=600,height=450,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-200)+'');

	return false;

}
function affiche_masque_transparent(idMasque,overlayBackground,overlayTransparency)
{
	$(document.body).append('<div id="'+idMasque+'" />');
	$("#"+idMasque).css("display", "none");
	$("#"+idMasque).css("position", "fixed");
	$("#"+idMasque).css("left", "0px").css("top", "0px");
	$("#"+idMasque).width("100%").height("100%");
	if( $.browser.msie && $.browser.version < 7 ){
		$("#"+idMasque).css({position:"absolute",height:$(document).height(),width:$(document).width()});
	}
	$("#"+idMasque).css("background-color", overlayBackground);
	$("#"+idMasque).css("opacity", overlayTransparency);
	$("#"+idMasque).css("filter", "alpha(opacity=" + overlayTransparency*100 + ")");
	$("#"+idMasque).css("-moz-opacity", overlayTransparency);
	$("#"+idMasque).fadeIn();
}
function ajaxFileUpload()
{
	
	$("#loading")
	.ajaxStart(function(){
		$(this).show();
		$("#bfile").hide();
	})
	.ajaxComplete(function(){
		$(this).hide();
	});

	var id_vh=$("#id_vehicule").attr("value");

	$.ajaxFileUpload
	(
		{
			url:'ajax_upload_image_voiture.php?id_vh='+id_vh,
			secureuri:false,
			fileElementId:'img_to_up',
			dataType: 'json',
			success: function (data, status)
			{
				if(typeof(data.error) != 'undefined')
				{
					if(data.error != ''){
						alert(data.error);
					}
					else{
						$("#id_vehicule").attr("value",data.id_vh);
						reload_image_voiture();
					}
				}
			},
			error: function (data, status, e)
			{
				alert(e);
			}
		}
	)
	
	return false;

}
function reload_image_voiture()
{
	var id_vh=$("#id_vehicule").attr("value");
	var mytime="&ms="+new Date().getTime();
	//alert(mytime);
	
	$("#loading").show();
	
	$.ajax({
	   type: "GET",
	   url: "ajax_affiche_image_vehicule.php",
	   data: "id_vh="+id_vh+mytime+"",
	   success: function(msg){
			//alert(data);
			$("#loading").hide();
			$("#liste_image").html(msg);
	   }
	 });
	
	
	
}

function format_nombre(valeur,decimal,separateur) {
// formate un chiffre avec 'decimal' chiffres après la virgule et un separateur
	var deci=Math.round( Math.pow(10,decimal)*(Math.abs(valeur)-Math.floor(Math.abs(valeur)))) ; 
	var val=Math.floor(Math.abs(valeur));
	if ((decimal==0)||(deci==Math.pow(10,decimal))) {val=Math.floor(Math.abs(valeur)); deci=0;}
	var val_format=val+"";
	var nb=val_format.length;
	for (var i=1;i<4;i++) {
		if (val>=Math.pow(10,(3*i))) {
			val_format=val_format.substring(0,nb-(3*i))+separateur+val_format.substring(nb-(3*i));
		}
	}
	if (decimal>0) {
		var decim=""; 
		for (var j=0;j<(decimal-deci.toString().length);j++) {decim+="0";}
		deci=decim+deci.toString();
		val_format=val_format+"."+deci;
	}
	if (parseFloat(valeur)<0) {val_format="-"+val_format;}
	return val_format;
}



