// Fonction qui nettoie puis formate un numéro de téléphone en fonction du pays
// Si c'est un numéro de téléphone mais qui n'a pas le bon nombre de chiffre, on ne change rien mais on affiche en rouge
function Format_Tel(tel,pays){
	var NumTel = tel.value;
	var num_propre = NumTel.replace(/[ ,\\/.-]/g, ""); // On supprime tous les caractères de séparations : espace , \ / . -
	var tel_format="";
	var i = 0;
	if (NumTel!="") {
		if (pays=="fr") {
			if (num_propre.length==10) {
				for (i=0;i<num_propre.length+1;i+=2) {
					if (i!=0 && i!=10) tel_format = tel_format + " ";
					tel_format = tel_format + num_propre.substring(i,i+2);
				}
				tel.value=tel_format;
				//tel.style.color= "#292";
				return true;
			} else {
				if (!isNaN(num_propre)) {
					tel.value = tel.value;
					//tel.style.color="#800";
					return false;
				} else {
					tel.value = tel.value;
					return true;
				}
			}
		} else {
			if (pays=="pt") {
				if (num_propre.length==9) {
					for (i=0;i<num_propre.length+1;i+=3) {
						if (i!=0 && i!=9) tel_format = tel_format + " ";
						tel_format = tel_format + num_propre.substring(i,i+3);
					}
					tel.value=tel_format;
					//tel.style.color= "#292";
					return true;
				} else {
					if (!isNaN(num_propre)) {
						tel.value = tel.value;
						//tel.style.color="#800";
						return false;
					} else {
						tel.value = tel.value;
						return true;
					}
				}
			} 
		}
	} else {
		return true;
	}
} 
function replace(str,find,rep){	
	str=''+str;
	if (find!=rep){
		while(str.indexOf(find) != -1){str = str.replace(find,rep)} 
	}
	return str;
}

function popup(src,width,height,mode){
	
	width=width-10;
	height=height-40;
	
	var left=String((window.screen.Width - width) /2)-10;
	var top=String((window.screen.Height - height)/2)-50;
	if (left<0) left=0;
	if (top<0) top=0;
	if (width<0) width=0;
	if (height<0) height=0;
	
	var fullscreen=0;//plein ecran	
	
	var toolbar=0;//barre d'outils
	var menubar=0;//menu fichier	
	var location=0;//url	
	var status=1;// barre de status pour les eeruer javascript
	
	var scrollbars=1;//scrollbars
	var resizable=0;//peut ce redimensionner
	var copyhistory=0;
	
	var channelmode=0;//laisser à 0
	var directories=0;//laisser à 0 ajouter la barre des liens	
	var titlebar=0;//non utilisé
	
	if (mode=='vide'){
		scrollbars=0;
		status=0;
	}
	
	if (mode=='light'){
		
		
	}
	if (mode=='lightresize'){		
		resizable=1;
	}
	if (mode=='full'){
		toolbar=1;
		location=1;
		menubar=1;
		resizable=1;	
	}
	if (mode=='fullscreen'){
		fullscreen=1;		
	}
	
	
	return window.open(src,'_blank','left='+left+',top='+top+',width='+width+', height='+height+',fullscreen='+fullscreen+',channelmode='+channelmode+',directories='+directories+',  toolbar='+toolbar+',  menubar='+menubar+',titlebar='+titlebar+',location='+location+', status='+status+', scrollbars='+scrollbars+' , resizable='+resizable+',copyhistory='+copyhistory);
}

