var ns4 = (document.layers)? true:false;   			//NS 4 
var ie4 = (document.all)? true:false;   			//IE 4 
var dom = (document.getElementById)? true:false;   //DOM
var PreloadFlag = false;

function SetToXY(DivId,Coordinates)
/*********************************************
Fonction permettant de positionner un DIV.
Paramètres : 
			DivId 		->	propriété ID du <DIV>
			Coordinates	->	tableau (X,Y)
**********************************************/
    {
    if (dom)
        {
        document.getElementById(DivId).style.left = Coordinates[0];
        document.getElementById(DivId).style.top = Coordinates[1];
        }
    if (ie4) 
        {
        document.all[DivId].style.posLeft = Coordinates[0];
        document.all[DivId].style.posTop = Coordinates[1];
        }
    if (ns4)
        {
        document.layers[DivId].pageX = Coordinates[0];
        document.layers[DivId].pageY = Coordinates[1];
        }
    }

function SlideToX(DivId,PositionX,PasMvt)
/*********************************************
Fonction permettant de positionner un DIV.
Paramètres : 
			DivId 		->	propriété ID du <DIV>
			Coordinates	->	position en X
			PasMvt -> pas du mouvement
**********************************************/
    {
    if (dom)
        {
        document.getElementById(DivId).style.left = PositionX;
        }
    if (ie4) 
        {
			//if (from < to) {
  			//  document.all.texte2.style.left = (from += 20);


		//MvtLeft = PositionX -  document.all[DivId].style.posLeft;
		
		document.all[DivId].style.posLeft = PositionX
		//setTimeout('SlideToX(' + DivId + ',' + PositionX + ','+ PasMvt+')', 75);

        }
    if (ns4)
        {
        document.layers[DivId].pageX = PositionX;
        }
    }
	

function Show(DivId)
/*********************************************
Fonction permettant de rendre visible un DIV.
Paramètres : 
			DivId 		->	propriété ID du <DIV>
**********************************************/
	{
	if (dom)
		{
		document.getElementById(DivId).style.visibility = "visible";
		}
	else if (ie4) 
		{
		document.all[DivId].style.visibility = "visible";
		}
	else if (ns4)
		{
		document.layers[DivId].visibility = "show";
		}
	}


function Hide(DivId)
/*********************************************
Fonction permettant de rendre invisible un DIV.
Paramètres : 
			DivId 		->	propriété ID du <DIV>
**********************************************/
	{
	
	if (dom)
		{
		document.getElementById(DivId).style.visibility = "hidden";
		}
	else if (ie4) 
		{
		document.all[DivId].style.visibility = "hidden";
		}
	else if (ns4)
		{
		document.layers[DivId].visibility = "hide";
		}
	}

function Opacity(DivId,opaciteInitiale,opaciteFinale,vitesse) 
//function SetOpacity(elmt, opacity){
/*********************************************
Fonction permettant de jouer avec l'opacite d'un div.
Paramètres : 
			DivId 		->	propriété ID du <DIV>
			opacityInitiale ->	opacite de base
			opacityFinale ->	opacite finale
			vitesse ->	vitesse de changement
**********************************************/
//pour IE filter:alpha(opacity=50); 
//pour Mozilla et Firefox  -moz-opacity: 0.5; 
//Pour les navigateurs supportant CSS3 opacity: 0.5;
	{
		if (dom)
			{
			elmt = document.getElementById(DivId);
			}
		else if (ie4) 
			{
			elmt = document.all[DivId];
			}
		else if (ns4)
			{
			elmt = document.layers[DivId];
			}
		
	  if (elmt.filters) {
	  	elmt.filters.alpha.opacity=opaciteInitiale;
	  } else {
	    elmt.style.setProperty("-moz-opacity", opaciteInitiale/100, "");
	    elmt.style.setProperty("-khtml-opacity", opaciteInitiale/100, "");
	    elmt.style.setProperty("opacity", opaciteInitiale/100, "");
	  }
	  
	  if (opaciteInitiale < opaciteFinale){
	  	setTimeout("Opacity('"+DivId+"',"+(opaciteInitiale+1)+","+opaciteFinale+","+vitesse+")",vitesse);
	  } else if (opaciteInitiale > opaciteFinale){
		setTimeout("Opacity('"+DivId+"',"+(opaciteInitiale-1)+","+opaciteFinale+","+vitesse+")",vitesse);
	  }
		  
	}
	


	
	
function PreloadImages()
/*********************************************
Préchargement des images passées en paramètre,
pour rendre fluide les rollover
**********************************************/

	{
	var MyArguments = PreloadImages.arguments;
	var MyImages = new Array();
	if (document.images)
		{
		for(var i=0; i<MyArguments.length; i++)
			{
			MyImages[i]= new Image();
			MyImages[i].src = MyArguments[i];
			}
		PreloadFlag = true;
		}
	}


function ChangeImages()
/*********************************************
Change la source d'une image.
Paramètres :
	Premier argument	->	Attribut NAME de l'image
	Deuxième argument	->	nouvelle valeur de l'attribut SRC
**********************************************/
	{
	var MyArguments = ChangeImages.arguments;
	var ImgName;
	for(var i=0; i<MyArguments.length; i+=2)
		{
		ImgName = MyArguments[i];
		//alert(document.images[ImgName].src);
		document.images[ImgName].src = MyArguments[i+1];
		}
	}
//-->

function controle(str,type,champs){
/*********************************************
Check si au moins un des boutons radio de la
liste est coch&eacute; :
	Premier argument	->	le contenu du champs
	Second argument		->	le type de champs
	Troisi&egrave;me argument 	->  nom du 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
	}

	if (!re.test(str)) {
		str_erreur= str_erreur+ champs + " " + str_non_valide + " \n";
		return false;
	} else if (str == '') {
		str_erreur= str_erreur+ champs + " " + str_incomplet + " \n";
		return false;
	} else
		return true;
}

function radiotest(node,champs) {
/*********************************************
Check si au moins un des boutons radio de la
liste est coch&eacute; :
	Premier argument	->	liste de boutons
	Second argument 	->  nom du champs radio
**********************************************/ 
	for (var i=0; i<node.length;i++) { 
		if( node.item(i).checked ) { 
			var select = node.item(i).value; 
			break; 
		} 
	} 
	if(select)
		return true; 
	else {
		str_erreur=str_erreur+champs+' non valide \n';
		return false; 
	}
} 


function picsview(name) { 	
/*********************************************
Ouvre un popup a la taille de l'image.
Paramètres :
	Premier argument	->	Nom du fichier
**********************************************/
	var nomSite="Idrac-associes.com";
	var couleurFond="#FFFFFF";
	var cheminLoading="images/";
	if (ie4)   {	
		// ie4/5, netscape6
		//Copyright Enigmera.com
		thenewWin = window.open("",'thenewWin','width=214,height=200,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='214' height='200' 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(); 
	}
} 


