function ouvre_pub(page,nom_win,largeur,hauteur)
{
var deja_saisie = "";
var l = largeur;
var h = hauteur;

for (var i=0 ; i<document.calcul_form.length ; i++)
    {
    deja_saisie += "&" + document.calcul_form.elements[i].name + "=" + document.calcul_form.elements[i].value;
    }
ouvre_win = window.open(page+deja_saisie,nom_win,"toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+l+",height="+h);
ouvre_win.focus();
}



function ouvre(page,nom_win,largeur,hauteur)
{
var l = largeur;
var h = hauteur;
ouvre_win = window.open(page,nom_win,"toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=no,resizable=yes,width="+l+",height="+h);
ouvre_win.focus();
}

function plus(monform,mazone,val_plus,val_max,val_min)
{
nb = document[monform][mazone].value;
nb = parseInt(nb) + parseInt(val_plus);
if (nb < val_min)
    {
    nb = val_min;
    }
document[monform][mazone].value = nb;	
if ((val_max != '') && (nb > val_max))
    {
    alert ("Il n'est pas possible de mettre plus de " + val_max + " !");
    document[monform][mazone].value = val_max;
    }
}

function AfficheMsg(champ,msg)
{
if (champ.value == "")
    {
    champ.value = msg;
    }
}

function DeleteMsg(champ,msg)
{
if (champ.value == msg)
    {
    champ.value = "";
    }
}

function ChampsVide(champs,strNomChamps)
{
var intLongueur, strChaine
strChaine=champs.value
intLongueur=strChaine.length
	
while ((strChaine.substring(intLongueur-1,intLongueur)==' ') && (intLongueur!=0))
    {
    intLongueur -= 1;
    }

if (intLongueur<1)
    {
	alert("La saisie du champ "+strNomChamps+" est obligatoire !");
	champs.focus();
	champs.select();
	champs.value="";
	return 0;
	}
return 1;
}

function Chiffres_Validator(champ)
{
var chiffre_ok = "0123456789";
var checkStr = champ.value;
var allValid = 1;
var allNum = "";
for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < chiffre_ok.length;  j++)
		{
		if (ch == chiffre_ok.charAt(j))
			{
			break;
			}
		}
	if (j == chiffre_ok.length)
		{
		allValid = 0;
		break;
		}
	allNum += ch;
	}
if (!allValid)
	{
	alert('La valeur de ce champ doit être un entier !');
    champ.focus();
    champ.select();
	return false;
	}
return true;
}

function IsValid()
{
flag = false;
// verif des pub[xx] (tous les champs sauf les 2 derniers)
for (var i=0 ; i<document.calcul_form.length-2 ; i++)
    {
    if (!Chiffres_Validator(document.calcul_form.elements[i]))
        {
        return false;
        }
    if (document.calcul_form.elements[i].value > 0)
        flag = true;
    }
// verif du nb de postes
if (!ChampsVide(document.calcul_form.nbarticles,"[Nombre d'articles]"))
    return false;
if (!Chiffres_Validator(document.calcul_form.nbarticles))
    return false;
// verif du nb d'articles
if (!ChampsVide(document.calcul_form.nbpostes,"[Nombre de postes]"))
    return false;
if (!Chiffres_Validator(document.calcul_form.nbpostes))
    return false;

if (flag == false)
    {
    alert("Vous devez saisir un nombre d'articles pour au moins une publication !");
    return false;
    }

document.calcul_form.submit();
}
