
/** Renvoie true si le mail est correcte, false sinon
Si le mail est faux une alert est affichée
*/
function isEmailOk( email)
{
if ( isPlacementOk('@',email))
	{
		var domaine = email.substring(email.indexOf('@')+1,email.length);
		if (isPlacementOk('.',domaine))
		{
			var infoPerso = email.substring(0,email.indexOf('@'));
			if (infoPerso.indexOf('.')>-1)
			{
				if (isPlacementOk('.' , infoPerso))
					return true; 
			}
			else
				return true;
		}
	}
	return false;
		
}

/* Utilisée poar isMailOk 
Verifie la présence d'un caractere.Il ne doit ni etre en premiere position ni en derniere*/ 
function isPlacementOk(caract , mot)
{
	var i = mot.indexOf(caract);
	var taille = mot.length;
	
	if (i>0)
	{
		if (mot.charAt(taille-1)!=caract)
			return true;
	}
	return false;
}

	/** Sélectionne automatiquement l'option de la liste 
	 * de la valeur passée en paramètre
	 * @param sel : le select
	 * @param value : la valeur à sélectionner 
	 */
	function selectOption(sel, value){
    for (i=0;i<sel.options.length;i++) { 
      if (sel.options[i].value==value) { 
        sel.options[i].selected=true;
        break;
      }
    } 
	}





/**
 * Ouverture d'une popup sans décoration
 */ 
function openPop(url, nom, largeur, hauteur) {
  newWindow = open(url, nom, "width="+largeur+",height="+hauteur+",toolbar=no,scrollbars=no,resizable=no,titlebar=yes")
  newWindow.moveTo( (parseInt(screen.width)-largeur)/2 ,(parseInt(screen.height)-hauteur)/2 );
  newWindow.focus();
}

/**
 * Ouverture d'une popup avec scroll bars
 */ 
function openPopScroll(url, nom, largeur, hauteur) {
  newWindow = open(url, nom, "width="+largeur+",height="+hauteur+",toolbar=no,scrollbars=yes,resizable=yes,titlebar=yes")
  newWindow.moveTo( (parseInt(screen.width)-largeur)/2 ,(parseInt(screen.height)-hauteur)/2 );
  newWindow.focus();
}

/**
 * Ouverture d'une popup avec scroll bars et une barre d'outil
 */ 
function openPopScrollToolbar(url, nom, largeur, hauteur) {
  newWindow = open(url, nom, "width="+largeur+",height="+hauteur+",toolbar=yes,scrollbars=yes,resizable=yes,titlebar=yes")
  newWindow.moveTo( (parseInt(screen.width)-largeur)/2 ,(parseInt(screen.height)-hauteur)/2 );
  newWindow.focus();
}

/**
 * Popups GénieCube
 */ 


function imgPopup(nomPop,img,fond,txt,css){
   imgPop = window.open("",nomPop,"scrollbars=yes,width=700,height=550,resizable=1");
   imgPop.document.write("<html>\n\n");
   imgPop.document.write("<head><title>Apercu d'image</title></head>\n\n");
   imgPop.document.write("<body bgcolor=\""+fond+"\">\n");
   imgPop.document.write("  <table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"100%\">\n");
   imgPop.document.write("    <tr><td align=\"center\"><img src=\"ressources/"+img+"\"></td></tr>\n");
   imgPop.document.write("    <tr><td align=\"center\">\n");
   imgPop.document.write("      <table border=\"0\" cellpadding=\"0\" cellspacing=\"2\">\n");
   imgPop.document.write("        <tr><td><span style=\""+css+"\">"+txt+"</span></td></tr>\n");
   imgPop.document.write("      </table>\n");
   imgPop.document.write("    </td></tr>\n");
   imgPop.document.write("  </table>\n");
   imgPop.document.write("</body>\n\n");
   imgPop.document.write("</html>");
}

function popup(adr,nompop,larg,haut,res){
window.open(adr,nompop,'width='+larg+',height='+haut+',scrollbars=1,toolbar=0,location=0,status=0,menubar=0,resizable='+res);
}

