var str_erreur="";
var ns4 = (document.layers)? true:false;   			//NS 4 
var ie4 = (document.all)? true:false;   			//IE 4 
var dom = (document.getElementById)? true:false;   //DOM

function popup(url,width,height){
    if (height =='')
		height=790;
	if (width =='')
		width=330;   
	open1 = window.open(url,'popup','height='+height+',width='+width+',top=0,left=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=1');
	open1.focus();    
}

function confirmation(message,aller,target){
	if (confirm(message))
		{
		if (target =='')	
			window.document.location.href=aller;
		else
			eval('top.'+target+'.document.location.href="'+aller+'"');
		}
	return true
}

function controle(str,type,champs){
	
	switch(type) {
		case "email":
			re = new RegExp("^([0-9a-zA-Z-_.]+)(@{1})([0-9a-zA-Z-_.]+)([.]{1})([a-zA-Z]{2,4})$")
		break;
		case "numero":
			re = new RegExp("^([0-9]*)$")
		break;
		case "numero+":
			re = new RegExp("^([0-9 ]*)$")
		break;
		case "texte":
			re = new RegExp("^([a-zA-Z' ]*)$")
		break;
		case "alphanum":
			re = new RegExp("^([0-9a-zA-Z_' -]*)$")		
		break;
		case "alphanum+":
			re = new RegExp("^([0-9a-zA-Z_' -\?\&\.\,\*\+àâäòôöèéêëÇçìîïùûü\(\)\"]*)$")		
		break;
		case "lien":
			re = new RegExp("^([0-9a-zA-Z_'./:-]*)$")
		break;
		case "float":
			re = new RegExp("^([0-9]*[.]*[0-9]*)$")
		break
		case "reference":
			re = new RegExp("^([0-9]*[-]*[0-9]*[-]*[0-9]*)$")
		break
	}

	if (!re.test(str) && str != "") {
		str_erreur=str_erreur+champs+' non valide \n';
		
		return false;
	} else
		return true;
}

function calcul_size(size,str_champs,form){
	var iLongueur, iLongueurRestante;
	eval('iLongueur = document.'+form+'.'+str_champs+'.value.length');
	if (iLongueur > size)
		{
			eval('document.'+form+'.'+str_champs+'.value=document.'+form+'.'+str_champs+'.value.substring(0,'+size+')');
  			iLongueurRestante = 0;
		 }
	else
		{
  			iLongueurRestante = size - iLongueur;
 		}
	eval('document.'+form+'.'+str_champs+'_SIZE.value= '+iLongueurRestante);
}


function picsview(name) { 	
/*********************************************
Ouvre un popup a la taille de l'image.
Paramètres :
	Premier argument	->	Nom du fichier
**********************************************/
	var nomSite="Vallana.com";
	var couleurFond="#535353";
	var cheminLoading="images/divers/";
	if (ie4)   {	
		// ie4/5, netscape6
		//Copyright Enigmera.com
		thenewWin = window.open("",'thenewWin','width=214,height=118,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,top=0,left=0');
		thenewWin.document.open("text/html");
		thenewWin.document.write("<html><head><title>" + nomSite + "</title>");
		
		thenewWin.document.write("<script language=\"JavaScript\" type=\"text/javascript\">");
		thenewWin.document.write("img2=new Image;");
		thenewWin.document.write("img2.src=\"" + name+ "\";");
		thenewWin.document.write("function checksize(){");
		thenewWin.document.write("	if (img2.complete) {");
		thenewWin.document.write("		document.img.src=img2.src;");
		thenewWin.document.write("		document.img.width = img2.width;");
		thenewWin.document.write("		document.img.height = img2.height;");
		
		thenewWin.document.write("		var tmpWidth, tmpHeight;");
		thenewWin.document.write("		if ((document.img.width+10) > screen.width)");
		thenewWin.document.write("			tmpWidth = screen.width;");
		thenewWin.document.write("		else");
		thenewWin.document.write("			tmpWidth = document.img.width+10;");

		thenewWin.document.write("		if ((document.img.height+60) > screen.height) {");
		thenewWin.document.write("			tmpHeight = screen.height;");
		thenewWin.document.write("		} else ");
		thenewWin.document.write("			tmpHeight = document.img.height+60;");

		thenewWin.document.write("		window.resizeTo(tmpWidth, tmpHeight)");
		thenewWin.document.write(" 	} else {");
		thenewWin.document.write("		setTimeout('checksize()',250);");
		thenewWin.document.write("	}");
		thenewWin.document.write("}");
		thenewWin.document.write("</script>");
		
		thenewWin.document.write("</head><body BGCOLOR=\""+couleurFond+"\" LEFTMARGIN=\"0\" TOPMARGIN=\"0\" MARGINWIDTH=\"0\" MARGINHEIGHT=\"0\" onload=\"checksize()\">"); 
		thenewWin.document.write("<a href=\"javascript:self.close()\"><img src=\""+cheminLoading+"loading.gif\" border='0' width='200' height='100' name=\"img\" alt=\"Cliquez sur l\'image pour fermer le popup\"></a>");
		thenewWin.document.write("</body></html>"); 
		thenewWin.document.close();
		thenewWin.focus();
	} else if (ns4 || dom){
		//Netscape4/6
	   	//Copyright Enigmera.com
		thenewWin = window.open("",'thenewWin','width=800,height=600,scrollbars=no,resizable=yes,menubar=no,status=no,toolbar=no,location=no,directories=no,top=0,left=0');
		thenewWin.document.open("text/html");
		thenewWin.document.write("<html><head><title>" + nomSite + "</title>");
		
		thenewWin.document.write("<script language=\"JavaScript\" type=\"text/javascript\">");
		thenewWin.document.write("function checksize(){");
		thenewWin.document.write("	if (document.img.complete) {");
		thenewWin.document.write("		window.resizeTo(document.img.width+12, document.img.height+30);");
		thenewWin.document.write("		window.status = \"" + nomSite + "\";");
		thenewWin.document.write(" 	} else {");
		thenewWin.document.write("		setTimeout('checksize()',250);");
		thenewWin.document.write("		window.status = \"Chargement de l'image en cours...\";"); 
		thenewWin.document.write("	}");
		thenewWin.document.write("}");	
		thenewWin.document.write("</script>");		

		thenewWin.document.write("</head><body BGCOLOR=\""+couleurFond+"\" LEFTMARGIN=\"0\" TOPMARGIN=\"0\" MARGINWIDTH=\"0\" MARGINHEIGHT=\"0\">"); 
		thenewWin.document.write("<div align=\"center\"><a href=\"javascript:self.close()\"><img src=\"" + name + "\" border='0' name=\"img\" alt=\"Cliquez sur l\'image pour fermer le popup\" onload=\"checksize()\"></a></div>");
		thenewWin.document.write("</body></html>"); 
		thenewWin.document.close();
		thenewWin.focus();
	} else {
		//Autres navigateurs
	   	//Copyright Enigmera.com
		thenewWin = window.open("",'thenewWin','width=800,height=600,scrollbars=no,resizable=yes,menubar=no,status=no,toolbar=no,location=no,directories=no,top=0,left=0');
		thenewWin.document.open("text/html");
		thenewWin.document.write("<html><head><title>" + nomSite + "</title>");

		thenewWin.document.write("</head><body BGCOLOR=\""+couleurFond+"\" LEFTMARGIN=\"0\" TOPMARGIN=\"0\" MARGINWIDTH=\"0\" MARGINHEIGHT=\"0\">"); 
		thenewWin.document.write("<div align=\"center\"><a href=\"javascript:self.close()\"><img src=\"" + name + "\" border='0' name=\"img\" alt=\"Cliquez sur l\'image pour fermer le popup\"></a></div>");
		thenewWin.document.write("</body></html>"); 
		thenewWin.document.close();
		thenewWin.focus(); 
	}
} 



