function checkemail(str){
  //var str=document.validation.emailcheck.value
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;
  if (filter.test(str))
    return true;
  else{
    alert("Entrez une adresse mail valide. Merci.");
    //alert("Please input a valid email address!")
    return false;
  }
}

function placerEscargot(params){
  for (i=0; i<params.nbPets; i++){
  document.getElementById('divItems').innerHTML += '<div style="position:relative"><img style="cursor:pointer;position:absolute;top:' + Math.round(Math.random()*600) + 'px;left:-17px" src="../img/esh.gif" onmouseover="if(this.style.top == \'8px\') this.style.top=\'600px\' ;this.style.top=this.style.top.substring(0,this.style.top.length-2)-1 + \'px\'"/></div>';
  }
}

function sleep(millisecondi)
{
    var now = new Date();
    var exitTime = now.getTime() + millisecondi;

    while(true)
    {
        now = new Date();
        if(now.getTime() > exitTime) return;
    }
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


/*
* Debugging functions
*/
function debug(msg){
  if(DEBUG=='true'){
    var date = new Date();
    var h = date.getHours();
    var m = date.getMinutes();
    var s = date.getSeconds();
    if(m<10) m = "0"+m;
    if(s<10) s = "0"+s;
                getById('divDebug').innerHTML+="["+h+":"+m+":"+s+"] "+msg+"<br/>" ;
                DEBUG_LINE++;
                if(DEBUG_LINE>DEBUG_MAX){
                        DEBUG_LINE = 0;
                        getById('divDebug').innerHTML = "";
                }
  }
}

function debugIE(msg){
  if(DEBUG=='true' && BROWSER == "IE5+") debug(msg);
}

/* Utils functions  */
/*****************************************************************************/
/*
* Several Javascript functions alias
*/
function getById(id){ return document.getElementById(id); }
function wln(elt){ document.writeln(elt); }

/*
 * Brower detecting functions
 */
function detectBrowser(){
  if (navigator.userAgent.search(/Firefox/) != -1){
    BROWSER = "Firefox"; return;}
  if (navigator.userAgent.search(/Safari/) != -1){
    BROWSER = "Safari"; return;}
  if (navigator.userAgent.search(/MSIE/) != -1){
    BROWSER = "IE5+"; return;}
  else {
    BROWSER = "Autre"; return;}
 /* if(document.getElementById && !document.all){
    BROWSER = "Firefox"; EXT=".png"; return;
  }
  if(document.all && document.getElementById){
    BROWSER = "IE5+";    EXT=".png"; return;
  }*/
}

/*
 * Create a new HTTPRequest object : browser dependance
 */
httpRequest = function(){
    if(window.XMLHttpRequest) return new XMLHttpRequest();
    else{
      if(window.ActiveXObject)
        return new ActiveXObject("Microsoft.XMLHTTP");
      else{
        debug("browser don't support HttpResquet Object");
        return null;
      }
    }
  };


