/*  ------------------------------------------------*
 *			    Javascript test navigateurs         *
 *  ------------------------------------------------*/
 
// Version de navigateur
var browser = navigator.appName;
var version = parseInt(navigator.appVersion);
var version2 = navigator.appVersion;

// Javascript enable
var jvsenable = false;
if ( browser == "Microsoft Internet Explorer" && version > 3 ) jvsenable = true;
if ( browser == "Netscape" && version >= 3 ) jvsenable = true;

// print enable
var printenable = false;
if ( browser == "Microsoft Internet Explorer" && version > 3 && version2.indexOf("MSIE 4") < 0 ) printenable = true;
if ( browser == "Netscape" && version >= 3 ) printenable = true;

// detecte IE
var iedetect = true;
if ( browser == "Netscape") iedetect = false;


function printmail(lhs,rhs,tlhs,trhs)
{
   document.write ("<A HREF='mailto:"+lhs);
   document.write ("@");
   document.write (rhs+"'>");
   document.write (tlhs);
   if (trhs != "")
      document.write ("@" + trhs);
   document.write ("</A>");
}


/*  ----------------------------------------------------------------------------------------------------------	*
 *	popupall																									*
 *	se redimensione par raport a l'ecran																		*
 *	<a href="xxxxx" onclick="popupall(this.href,'popupall','no','yes','60','80','10','40'); return(false);">	*
 *  <a href="fichier.htm" onclick="window.open(this.href);return false;">										*
 *  ----------------------------------------------------------------------------------------------------------	*/

	function popupall(URL,FRAME,SCROLLBARS,RESIZABLE,WIDTH,HEIGHT,TOP,LEFT)
	{
		var param = "menubar=no,location=yes,directories=yes,status=yes,toolbar=yes,scrollbars="+SCROLLBARS+",resizable="+RESIZABLE+",width="+((screen.width)-WIDTH)+",height="+((screen.height)-HEIGHT)+",top="+TOP+",left="+LEFT;
		window.open(URL,FRAME,param); 
	}


/*  ----------------------------------------------------------------------------------------------------------	*
 *	Popup fenêtre javascript																					*
 *	<a href="xxxxx" onclick="popupwin('xxxxx','Popupwin','yes','yes','550','370','20','40');return(false);">	*
 *	<a href="xxxxx" onclick="popupwin(this.href,'popupwin','no','yes','100','100','20','60'); return(false);">	*
 *  ----------------------------------------------------------------------------------------------------------	*/

	function popupwin(URL,FRAME,SCROLLBARS,RESIZABLE,WIDTH,HEIGHT,TOP,LEFT)
	{
		var param = "menubar=no,location=no,directories=no,status=no,toolbar=no,scrollbars="+SCROLLBARS+",resizable="+RESIZABLE+",width="+WIDTH+",height="+HEIGHT+",top="+TOP+",left="+LEFT;
		window.open(URL,FRAME,param); 
	}


	
/*  -----------------------------------------------------------------*
 *			    			test email  					         *
 *  -----------------------------------------------------------------*/

	function testmail(mail)
	{
		var cpt=0;
		if( mail.length==0)
			return false;
		
		var taille=mail.length;
		
		if(mail.charAt(taille-2)!='.')
			{
			//window.alert(mail.charAt(mail.length-1));
			var pos=0;	
			for( i=0; i<mail.length; i++)
				{
				var verif=mail.charAt(i);

				if(verif=='@' && i>=1)
					{
					cpt++;
					pos=i;
					}
				//window.alert(pos);
				if(pos<=i && pos!=0)
					{
					if(verif=='.') cpt++;
					}
				}
				
			}
				
		if (cpt<2)
			return false;

		return true;
	}



/*  -----------------------------------------------------------------*
 *			    			test formulaire 				         *
 *  -----------------------------------------------------------------*/
 
	function testform()
	{
		var erreur="";
				
		if(document.F1.Téléphone.value.length<10 && !testmail(document.F1.eMail.value))
		{
			erreur+="\n Nous n'avons aucun moyen de vous contacter ... \n\n Veuillez remplir SVP le champ Téléphone ou le champ eMail     \n\n";
		}
		
		if(erreur.length>0)
			{
			window.alert(erreur);
			return false;
			}

		return true;

	}


/*  -----------------------------------------------------------------*
 *			    print	<a href="javascript:imprimer();">            *
 *  -----------------------------------------------------------------*/

	// fonction print

	function imprimer()
	{

		if (printenable)
		{
			window.print();
		}
		else
		{
			alert("Votre navigateur n'est pas compatible.\nCliquez sur ok, puis faire clic droit sur la souris\nenfin cliquez sur \"Imprimer\" dans menu contextuel.\nOu Appuyez sur les touches CTRL + P sur PC.")
		}

	}
