function ResetFilters(){
    f = document.finder;
    f.srcModel.selectedIndex = 0;
    f.srcVariant.selectedIndex = 0;
    f.srcBack.selectedIndex = 0;
    f.srcSize.selectedIndex = 0;
    f.srcFinish.selectedIndex = 0;
    f.srcMaterial.selectedIndex = 0;
    f.srcBorder.selectedIndex = 0;
}
function ResendPassword(clientusername){
  user = prompt("Username",clientusername);
  if(user!=null){
    if(user.length>0){
      window.location="index.php?Mode=send&Command=pwd&user="+user;
    }else{
      ResendPassword();
    }
  }
}

function GoRegister(){
  window.location="index.php?Mode=register";
}

function PopUp(folder,id,width,height){
  loc="popup.php?fold="+folder+"&id="+id;
  props = "toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,status=0,width="+width+",height="+height+",left=50,top=50";
  window.open(loc,"",props);
}

function StaticPopUp(folder,id,width,height){
  loc= folder+"/"+id+".html";
  props = "toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,status=0,width="+width+",height="+height+",left=50,top=50";
  window.open(loc,"",props);
}

function isEmpty(s){
  return (s==null || s.length==0)
}

function isWhitespace(s){
  var i;
  var whitespace;

  whitespace=" \t\n\r";
  for(i=0; i<s.length; i++)
    if(whitespace.indexOf(s.charAt(i))==-1) return false;

    return true;
}

function isEmail(s){
    if (isWhitespace(s)) return false;
    var i = 1;
    var sLength = s.length;
    while (i<sLength && s.charAt(i) != "@")
      i++;

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    while ((i < sLength) && (s.charAt(i) != "."))
      i++;

    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function CheckAddToCart(idProduct,msg){
  myForm = document.forms["Item_"+idProduct];
  if(isNaN(myForm.qty.value)||(parseInt(myForm.qty.value)<=0)){
    alert(msg);
    myForm.qty.focus();
  }else{
    myForm.qty.value = parseInt(myForm.qty.value);
    myForm.submit();
  }
}

function checkCart(then,msg,msgConfirm){
  checked = true;
  myForm = document.forms["cart"];
  for (i=0; i<myForm.elements.length; i++){
    if(myForm.elements[i].name=="qty[]"){
      if(isNaN(myForm.elements[i].value)||myForm.elements[i].value<=0){
        myForm.elements[i].focus();
        alert(msg);
        checked = false;
        break;
      }
    }
  }
  if (checked){
    if(then=="conf"){
      if(confirm(msgConfirm)){
        myForm.Command.value=then;
        myForm.submit();
      }
    }else{
      myForm.Command.value=then;
      myForm.submit();
    }
  }
}

function checktext(testo){
  i=0;
  while (i < testo.length){
    l = testo.substr(i, 1);
    if (l=="\"" || l==" " || l=="&" || l=="?" || l=="=" || l=="." || l=="'" ||
      l=="/" || l=="+" || l=="%" || l=="!" || l=="£" || l=="|" || l=="(" ||
      l==")" || l=="ì" || l=="[" || l=="]" || l==" " || l=="°" || l=="§" ||
      l=="ù" || l=="#" || l=="{" || l=="}" || l=="è" || l=="é" || l=="*" ||
      l==":" || l=="," || l==";" || l=="<" || l==">")
      return false;
    i++;
  }

  return true;
}

function checkquotes(testo){
  i = 0;
  while (i < testo.length){
    if (testo.substr(i, 1) == "\"")
      return false;
    i++;
  }

  return true;
}

//////////

function GalleryPOP(Lang, ID, PHPSESSID){
  loc="gallery.php?Lang="+Lang+"&ID="+ID+"&PHPSESSID="+PHPSESSID;
  window.open(loc,Lang,"toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,status=0,width=500,height=310,left=100,top=100");
}