// JavaScript Document
/*function popup(page,width,height) {
	// ouvre une fenetre sans barre d'etat, ni d'ascenceur. Vous pouvez modifier la largeur (width)
	// la hauteur (height). Vous pouvez ajouter la barre d'outils (Toolbar=yes)
    // ou les ascenseurs (scrollbars)yes)
    var top=0;
	var left=0;
	window.open(page,"","top="+top+",left="+left+",width="+width+",height="+height+",toolbar=no,scrollbars=yes,resizable=no");        
}*/

function popupCenter(page,width,height) {
	// ouvre une fenetre sans barre d'etat, avec ascenceur et redimensionnable. Vous pouvez modifier la largeur (width)
	// la hauteur (height). Vous pouvez ajouter la barre d'outils (Toolbar=yes)
    // ou les ascenseurs (scrollbars)yes)
    var top=(screen.height-height)/2;
    var left=(screen.width-width)/2;
	window.open(page,"","top="+top+",left="+left+",width="+width+",height="+height+",toolbar=no,scrollbars=yes,resizable=no");        
}

function popupCenterResize(page,width,height) {
	// ouvre une fenetre sans barre d'etat, avec ascenceur et redimensionnable. Vous pouvez modifier la largeur (width)
	// la hauteur (height). Vous pouvez ajouter la barre d'outils (Toolbar=yes)
    // ou les ascenseurs (scrollbars)yes)
    var top=(screen.height-height)/2;
    var left=(screen.width-width)/2;
	window.open(page,"","top="+top+",left="+left+",width="+width+",height="+height+",toolbar=no,scrollbars=yes,resizable=yes");        
}

function PopupImage(img,title) {
	w=open("",'image','width=400,height=400,toolbar=no,scrollbars=yes,resizable=yes');	
	w.document.write("<HTML><HEAD><TITLE>"+title+"</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+30); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><a href=\"#\" onMouseDown='javascript:window.close()'><IMG src='"+img+"' alt=\"Cliquez sur l'image pour fermer la fenêtre\" border=0></a>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
	
	//<a href="#" onMouseDown="'javascript:window.close()')">
}

function modifier_id_cont(form,valeur)
{
	//alert('Nouvelle valeur: '+valeur+', Ancienne valeur: '+document.forms[index].id_cont.value);
	form.id_cont.value = valeur;
}

function verifier_matiere(form,thing)
{
	var len = form.elements.length;
	var passed =  false;
	var i = 0;
	var save = 0;
	
	for(i=0;i<len;i++) {
		if (form.elements[i].checked == true)
		{
			passed = true;
			save = i;
		}
	}
	if (passed == false)
		alert("Vous devez d'abord sélectionner la matière du contenant, Verre ou Plastique");
	else
	{
		if (thing == true)
		{
			if (form.elements[save].value == "plastique")
				form.couleur.value = 'blanc';
		}
		if (thing == false)
		{
			if (form.elements[save].value == "verre")
			{
				//alert (form.forme.value);
				if (form.forme.value == '')
				{
					form.forme.value = 'rond';
					form.couleur.value = '';
				}
			}
		}
	}

	return passed;
}

function verifier_matiere_sachet(form)
{
	var len = form.elements.length;
	var passed =  false;
	var i = 0;
	var save = 0;
	
	for(i=0;i<len;i++) {
		if (form.elements[i].checked == true)
		{
			passed = true;
			save = i;
		}
	}
	if (passed == false)
		alert("Vous devez d'abord sélectionner la matière du sachet, Plastique, Coton Uni ou Coton Imprimé");

	return passed;
}

function verifier_contact(form)
{
	var cpt = 0;
	for (cpt = 0; cpt <4; cpt++)
	{
		mt=form.elements[cpt].value;
		if ((mt.length<1)||(mt.substring(0,6)=="******"))
		{
			alert("Le champ comprenant le curseur n'a pas été complété !");
			form.elements[cpt].focus();
			return false;
		}
	}
	return true;
}
