
//************** FONCTIONS PERSO *****************\\

// ouvre un popup au centre de l'écran
function popupCentree(page, largeur, hauteur, opt){
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;

	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+opt);
}


// teste si les fichiers à uploader sont des images jpg ou jpeg ou des docs pdf.
//	--> Sont passés en paramètres les noms des éléments à tester.
function testFichier(){
	var tab = testFichier.arguments;
	if(tab.length==0){
		return true;
	}
	else{
		var i = 0, err = false, ch;
		while(i < tab.length && !err){
			ch = document.getElementsByName(tab[i])[0].value;
			if(ch != "")
				err = ((ch.substring(ch.length-3).toLowerCase() != "jpg") && (ch.substring(ch.length-4).toLowerCase() != "jpeg"));

			i = i+1;
		}
		if(err){
			alert("Certains fichiers indiqués ne sont pas des images jpg ou jpeg.");
			return false;
		}
		return true;
	}
}

function testPlan(){
	var tab = testPlan.arguments;
	if(tab.length==0){
		return true;
	}
	else{
		var i = 0, err = false, ch;
		while(i < tab.length && !err){
			ch = document.getElementsByName(tab[i])[0].value;
			if(ch != "")
				err = (ch.substring(ch.length-3).toLowerCase() != "pdf");

			i = i+1;
		}
		if(err){
			alert("Certains fichiers indiqués ne sont pas des documents pdf.");
			return false;
		}
		return true;
	}
}


// Demande de confirmation
//	--> Affiche le texte txt
//	--> Si l'utilisateur répond 'oui', redirige vers le lien
function confirmation(txt, lien){
	if(confirm(txt))
		window.location.href = lien;
}


// Met à jour la grande photo du descriptif de biens.
/*	function affichephoto2(p1, p2, p3, p4, p5){
		document.getElementById( p1 ).style.visibility = "visible";
		document.getElementById( p1 ).style.display = "block";
		document.getElementById( p2 ).style.visibility = "hidden";
		document.getElementById( p2 ).style.display = "none";
		document.getElementById( p3 ).style.visibility = "hidden";
		document.getElementById( p3 ).style.display = "none";
		document.getElementById( p4 ).style.visibility = "hidden";
		document.getElementById( p4 ).style.display = "none";
		document.getElementById( p5 ).style.visibility = "hidden";
		document.getElementById( p5 ).style.display = "none";
	}
*/
	
// Fonction optimisée
	function affichephoto(p1)
	{

		document.getElementById( p1 ).style.visibility = "visible";
		document.getElementById( p1 ).style.display = "block";

		var t_args = affichephoto.arguments;
		if( t_args.length > 1 )
		{
			var i = 1;
			while( i < t_args.length )
			{
				document.getElementById( t_args[i] ).style.visibility = "hidden";
				document.getElementById( t_args[i] ).style.display = "none";
				i++;
			}
		}
	}


