
function change_img(img) {
	var file = document.getElementById(img).src.substring(0,document.getElementById(img).src.lastIndexOf("off"));
	document.getElementById(img).src = file + "on.jpg";
}

function restore_img(img) {
	var file = document.getElementById(img).src.substring(0,document.getElementById(img).src.lastIndexOf("on"));
	document.getElementById(img).src = file + "off.jpg";
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/*
window.onscroll = function() {
        resize_masque();
}

 AFFICHAGE POPUP 
function show_article(idArt) {
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		httpRequest = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!httpRequest) {
		alert('Abandon : Impossible de créer une instance XMLHTTP');
	}	

	httpRequest.open('POST','article.php',false);
	httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	httpRequest.send('id=' + idArt);	
	
	document.getElementById('pop_article').innerHTML = httpRequest.responseText;
	document.getElementById('pop_article').style.display = "block";
	document.getElementById('pop_masque').style.display = "block";
}

function hide_article() {
	document.getElementById('pop_article').style.display = "none";
	document.getElementById('pop_masque').style.display = "none";
}

function resize_masque(){
	if (window.innerHeight && window.scrollMaxY) {
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
  	}
	document.getElementById('pop_masque').style.height = yScroll +"px";
	//alert('TB_overlaySize');
}*/

function actionEcheancier(idEcheancier) {
	if(document.getElementById(idEcheancier).style.display == 'block') {					// Cacher l'echeancier
		document.getElementById(idEcheancier).style.display = 'none';
		document.getElementById('lien_' + idEcheancier).title = "Montrer l'échéancier";
		document.getElementById('lien_' + idEcheancier).innerText = "Montrer l'échéancier";
	} else {																				// Montrer l'echeancier
		document.getElementById(idEcheancier).style.display = 'block';
		document.getElementById('lien_' + idEcheancier).title = "Cacher l'échéancier";
		document.getElementById('lien_' + idEcheancier).innerText = "Cacher l'échéancier";
	}
}

function showAllEcheancier(nbEcheanciers) {
	for(idEcheancier = 1; idEcheancier <= nbEcheanciers; idEcheancier++) {
		document.getElementById('echeancier_' + idEcheancier).style.display = 'block';
		document.getElementById('lien_echeancier_' + idEcheancier).title = "Cacher l'échéancier";
		document.getElementById('lien_echeancier_' + idEcheancier).innerText = "Cacher l'échéancier";
	}
}

function hideAllEcheancier(nbEcheanciers) {
	for(idEcheancier = 1; idEcheancier <= nbEcheanciers; idEcheancier++) {
		document.getElementById('echeancier_' + idEcheancier).style.display = 'none';
		document.getElementById('lien_echeancier_' + idEcheancier).title = "Montrer l'échéancier";
		document.getElementById('lien_echeancier_' + idEcheancier).innerText = "Montrer l'échéancier";
	}
}

function verifFormAssurance() {
	var tabInputEmprunteur = new Array('nom_emprunteur','prenom_emprunteur','lieu_naissance_emprunteur','adresse_emprunteur','code_postal_emprunteur','ville_emprunteur','tel_emprunteur','mail_emprunteur','montant_1','duree_1','taux_pret_1');
	
	var tabInputCoEmprunteur = new Array('nom_coemprunteur','prenom_coemprunteur','lieu_naissance_coemprunteur','adresse_coemprunteur','code_postal_coemprunteur','ville_coemprunteur','tel_coemprunteur','mail_coemprunteur');
	
	var tabInput = new Array();
	// On verifie si il y a un coemprunteur
	if(document.getElementById('nom_coemprunteur').value != "")
		tabInput = tabInputEmprunteur.concat(tabInputCoEmprunteur);
	else
		tabInput = tabInputEmprunteur;
		
	var isOK = true;
		
	// On verifie que les champs ne soit pas vide
	for(var i = 0; i < tabInput.length; i++) {
		if(document.getElementById(tabInput[i]).value == "") {
			document.getElementById(tabInput[i]).style.borderColor = "#ff0000";
			isOK = false;
		} else {
			document.getElementById(tabInput[i]).style.borderColor = "#CCCCCC";
		}
	}
	
	if(!isOK)
		document.getElementById("alerte_msg").innerHTML = "<br />Veuillez remplir les champs encadrés en rouge.<br /><br />";
		
	return isOK;
}

function copierAdresse() {
	document.getElementById("adresse_coemprunteur").value = document.getElementById("adresse_emprunteur").value;
	document.getElementById("code_postal_coemprunteur").value = document.getElementById("code_postal_emprunteur").value;
	document.getElementById("ville_coemprunteur").value = document.getElementById("ville_emprunteur").value;
	document.getElementById("tel_coemprunteur").value = document.getElementById("tel_emprunteur").value;
}
