function Valider()
{	
	if(window.event.keyCode == 13)
	{
		document.form1.submit();		
	}
}

function OuvrePopUp(URL)
{
var hauteur = 25;
var largeur = 270;
var winl = (screen.width - largeur) / 2;
var wint = (screen.height - hauteur) / 2;
var	winprops = 'height='+hauteur+',width='+largeur+',top='+wint+',left='+winl+'resizable=no, location=no, menubar=no, status=no, scrollbars=no, menubar=no'
window.open(URL,"", winprops);	
}

function OuvrePopUp2(URL)
{
var hauteur = 500;
var largeur = 400;
var winl = (screen.width - largeur) / 2;
var wint = (screen.height - hauteur) / 2;
var	winprops = 'height='+hauteur+',width='+largeur+',top='+wint+',left='+winl+'resizable=no, location=no, menubar=no, status=no, scrollbars=no, menubar=no'
window.open(URL,"", winprops);	
}

function OuvrePopUpGrand(img) {
	titre="My Pairopals";
	w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=yes');	
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+50); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY bgcolor='#FFFFFF' text='#000000' onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0>");
	w.document.write("");
	w.document.write("<BR><center><a href='javascript:close();'><font color='#000000'>Close the window</font></a></center>");
	w.document.write("</BODY></HTML>");
	w.document.close();
}


function VerificationQuantite(formulaire)
{
var compteurNaN = 0;
	
	for (champ=0; champ<formulaire.elements.length; champ++)
		{
		if(formulaire.elements[champ].type == "text" && (formulaire.elements[champ].value))
			{
			nombre = parseInt(formulaire.elements[champ].value, 10);
			if(isNaN(nombre) || nombre < 0)
				{
				compteurNaN++;
				}
			else formulaire.elements[champ].value = nombre;
			}
		else if(!(formulaire.elements[champ].value))
			{
			compteurNaN++;
			}
		}
	if(compteurNaN > 0)
		{			
		OuvrePopUp('warningQuantity.html');		
		return false;
		}
	else return true;
}

function VerificationStock(formulaire)
{
if(formulaire.size)
{
if(formulaire.size.options[formulaire.size.options.selectedIndex].value != 0 && formulaire.size.options[formulaire.size.options.selectedIndex].value!=1)
	{	
	return true;
	}
else if(formulaire.size.options[formulaire.size.options.selectedIndex].value == 1)
	{
	OuvrePopUp('warningSelectSize.htm');	
	return false;
	}
}	

return true;
}

function VerificationAnimals(formulaire)
{
if(formulaire.face1.options[formulaire.face1.options.selectedIndex].value != 0 && formulaire.face2.options[formulaire.face2.options.selectedIndex].value!=0)
	{	
	return true;
	}
else 
	{
	OuvrePopUp('warnigSlectAnimal.htm');	
	return false;
	}
}

function Verificationcoche(formulaire)
{
	if(formulaire.accept.checked)
		return true;
	
	OuvrePopUp('warningcoche.htm');
	return false;
}

function Affiche_forms() {
  // Fonction qui affiche le nom de tous les formulaires
  // et de tous les les éléments d'un document HTML
  // Boucle tous les formulaire
  for (var i = 0; i < document.forms.length; i++) {

    // Affiche le nom ou la propriété name du formulaire i
    document.write(document.forms[i].name+"<br />");

    // Boucle tous les éléments du formulaire i
    for (var l = 0; l < document.forms[i].elements.length; l++) {

      // Affiche le nom ou la propriété name de l'élément l
      document.write("- "+document.forms[i].elements[l].name+"<br />");
	  document.write("_ "+document.forms[i].elements[l].value+"<br />");
    }
  }
}
