//nbr c 256

var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ 
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}

function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> caractères maximum.'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}

//valid 1

function valid(theForm)
{
  if (theForm.login.value == "")
  {
    alert("Merci d'indiquer votre \"Pseudo\" dans le champ.");
    theForm.login.focus();
    return (false);
  }
  if (theForm.pwd.value == "")
  {
    alert("Merci d'indiquer votre \"Mot de passe\" dans le champ.");
    theForm.pwd.focus();
    return (false);
  }
  return (true);
}

//change case

function changeCase(frmObj)
    {
      var index;
      var tmpStr;
      var tmpChar;
      var preString;
      var postString;
      var strlen;
      tmpStr = frmObj.value.toLowerCase();
      strLen = tmpStr.length;
      if (strLen > 0)  
      {
        for (index = 0; index < strLen; index++)  
        {
          if (index == 0)  
          {
            tmpChar = tmpStr.substring(0,1).toUpperCase();
            postString = tmpStr.substring(1,strLen);
            tmpStr = tmpChar + postString;
          }
          else 
          {
            tmpChar = tmpStr.substring(index, index+1);
            if (tmpChar == " " & index < (strLen-1))  
            {
              tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
              preString = tmpStr.substring(0, index+1);
              postString = tmpStr.substring(index+2,strLen);
              tmpStr = preString + tmpChar + postString;
             }
          }
        }
      }
      frmObj.value = tmpStr;
    }
	
//valid2
	
function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
        result = true;
  }
  return result;
}
function valid2(theForm)
{
  if (theForm.email.value == "")
  {
    alert("Merci d'indiquer votre \"Email\" dans le champ.");
    theForm.email.focus();
    return (false);
  }
  if (!isEmailAddr(theForm.email.value))
  {
    alert("Merci d'indiquer une adresse email valide dans le format: votrenom@undomaine.com");
    theForm.email.focus();
    return (false);
  }  
  if (theForm.prenom.value == "")
  {
    alert("Merci d'indiqué votre \"Prénom\" dans le champ.");
    theForm.prenom.focus();
    return (false);
  }
  if (theForm.pays.value == "")
  {
    alert("Merci de sélectionner votre \"Pays\" dans le menu.");
    theForm.pays.focus();
    return (false);
  }
  if (theForm.pseudo.value == "")
  {
    alert("Merci d'indiquer votre \"Pseudo\" dans le champ.");
    theForm.pseudo.focus();
    return (false);
  }  
  if (theForm.password.value == "")
  {
    alert("Merci d'indiquer votre \"Mot de passe\" dans le champ.");
    theForm.password.focus();
    return (false);
  }
  return (true);
}

//win open

function wo(url, w, h)
{ 
infowin=window.open(url,"infowin","toolbar=no,directories=no,status=no,scrollbars=auto,menubar=no,width="+w+",height="+h);
infowin.window.focus()
}

function wob(url, w, h)
{ 
infowin=window.open(url,"infowin","toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width="+w+",height="+h);
infowin.window.focus()
}

//valid 3

function valid3(theForm)
{
  if (theForm.pardon.value == "")
  {
    alert("Merci d'indiquer votre \"Pardon\" dans le champ.");
    theForm.pardon.focus();
    return (false);
  }
  if (theForm.categorie.value == "")
  {
    alert("Merci de sélectionner une \"Catégorie\" dans le champ.");
    theForm.categorie.focus();
    return (false);
  }
  return (true);
}

//valid 4

function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
        result = true;
  }
  return result;
}
function valid4(theForm)
{
  if (theForm.email.value == "")
  {
    alert("Merci d'indiquer votre \"Email\" dans le champ.");
    theForm.email.focus();
    return (false);
  }
  if (!isEmailAddr(theForm.email.value))
  {
    alert("Merci d'indiquer une adresse email valide dans le format: votrenom@undomaine.com");
    theForm.email.focus();
    return (false);
  }
  return (true);
}

//valid 5

function valid5(theForm)
{
  if (theForm.newpassword.value == "")
  {
    alert("Merci d'indiquer votre \"Nouveau Mot de Passe\" dans le champ.");
    theForm.newpassword.focus();
    return (false);
  }
  return (true);
}

//valid 5

function valid6(theForm)
{
  if (theForm.pseudo.value == "")
  {
    alert("Merci d'indiquer votre \"Nouveau Pseudo\" dans le champ.");
    theForm.pseudo.focus();
    return (false);
  }
  return (true);
}