function centragePopup(width,height) {
	
	window.resizeTo(width,height);
	
	var screenWidth= window.screen.availWidth;
	var screenHeight= window.screen.availHeight;
	
	var xOrigine = parseInt(screenWidth / 2) - parseInt(width / 2);
	var yOrigine = parseInt(screenHeight / 2) - parseInt(height / 2);
	
	window.moveTo(xOrigine,yOrigine);
	
}

function decimal(nombre) {
	if ( isNaN(nombre) )
		return nombre;
	else {
		nombre = new String(Math.round(Number(nombre) * 100) / 100);
		if ( nombre.indexOf('.') == -1 )
			nombre += '.00'
		else {
			if ( nombre.indexOf('.') == nombre.length - 1 )
				nombre += '00';
			else if ( nombre.indexOf('.') == nombre.length - 2 )
				nombre += '0';
		}
		return nombre;
	}
}

function popup(cible,name) {
	var width = 750;
	var height = window.screen.availHeight - 150;
	var locationWidth = parseInt((window.screen.availWidth - width) / 2);
	var locationHeight = parseInt((window.screen.availHeight - height) / 3);
	window.open(cible,name,'status,resizable,scrollbars,alwaysRaised,hotkeys,dependent,width=' + width + ',height=' + height + ',left=' + locationWidth + ',top=' + locationHeight + ',screenX=' + locationWidth + ',screenY=' + locationHeight);
}

function ancre(name, nomClass) {
	if ( document.anchors[name] )/* syntaxe pour Netscape */
		document.anchors[name].className = nomClass;
	else/* syntaxe pour IE */
		document.anchors(name).className = nomClass;
}

function verif_format(fichier) {
	fichier = fichier.value.toLowerCase() ;
	composants = fichier.split('.') ;
	type_fichier = composants[composants.length-1] ;
	if (type_fichier != "gif" && type_fichier != "jpeg" && type_fichier != "jpg") {
		alert("Le type de fichier " + type_fichier + " est invalide !") ;
		return false ;
	}
	else
		return true ;
}

// Fonction vérifiant le format de date jj/mm/aaaa 
function test_date(date) {
	// Test si le champs contient bien 10 caractères 
	if (date.value.length != 10) {
		return false ; 
	} 
	else { 
	// Test si les barres de séparation sont au bon endroit 
		if ( date.value.charAt(2)!= "/" || date.value.charAt(5)!= "/") { 
			return false ; 
		} 
		else { 
			annee = date.value.substring(6,10) ; 
			mois = date.value.substring(3,5) ; 
			jour = date.value.substring(0,2) ;
			
			// Test si l'année , le mois et le jour sont bien des nombres (via la fonction chaine_nombre) 
			if ((! chaine_nombre(annee)) || (! chaine_nombre(mois)) || (! chaine_nombre(jour))) { 
				return false ; 
			} 
			else { 
				annee = eval(annee) ; 
				mois = eval(mois) ; 
				jour = eval(jour) ; 
				// Test le nombre de jour du mois de Février selon l'année 
				if ((annee % 4 == 0) && (annee % 100 != 0) || (annee % 400 == 0)) { 
					tab_mois = new Array (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) ; 
				} 
				else { 
					tab_mois = new Array (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) ; 
				} 
				// Test si le numéro du mois existe 
				if ((mois < 1) || (mois > 12)) {
					return false ; 
				} 
				// Test le jour est compris entre 1 et le maximum du mois 
				else if ((jour < 1) || (jour > tab_mois[mois-1])) {
					return false ; 
				} 
				else
					return true ;
			} 
		} 
	} 
} 

// Fonction qui vérifie si une chaine est bien un nombre :
function chaine_nombre(chaine) {
	for (var i = 0; i < chaine.length; i ++) {
		for (var j = 0; j < 10; j ++) {
			if (chaine.charAt(i) == j.toString())
				break ;
		}
		if (j == 10)
			return false ;
	}
	return true ;
}

// Fonction qui vérifie la validité d'une adresse e-mail :
function verif_email(adresse) {
	if ((adresse == "")	|| (adresse.indexOf ('@') == -1) || (adresse.indexOf ('.') == -1))
		return false ;
	return true ;
}

// Fonction qui permet d'ajouter un effet de pixélisation à une image : (uniquement IE v 5 et plus)
function pixelisation(img){	
	if (img && img.filters && img.filters[0]){
		img.filters[0].apply() ;
		img.filters[0].play() ;
	}
}
