function SHL(layerID) {
  if (document.getElementById(layerID).style.display=="block") {
    document.getElementById(layerID).style.display = "none";
    document.getElementById(layerID).style.visibility = "hidden";
  } else {
    document.getElementById(layerID).style.display = "block";
    document.getElementById(layerID).style.visibility = "visible";
  }
}
function CheckMainForm(Lang) {
  var errorMessage = "";
  if (Lang==1) errorMessage = "שגיאה: לא הוזן פרמטר חיפוש.";
  else errorMessage = "Error: No search parameter was assigned.";
  if (document.getElementById("MainSearchForm").MainSearch.value == "" || document.getElementById("MainSearchForm").MainSearch.value == "חיפוש חופשי"  || document.getElementById("MainSearchForm").MainSearch.value == "Free Search") alert(errorMessage);
  else document.getElementById("MainSearchForm").submit();
}

function GoToCat(id) {
  location.href = "Products.asp?SearchType=Cat&Cat="+id;
}

function GoToCatEng(id) {
  location.href = "ProductsEng.asp?SearchType=Cat&Cat="+id;
}
function ShowLayer(layerID) {
  SHL("Details"+layerID);
  SHL("HideHref"+layerID);
  SHL("ShowHref"+layerID);
}

function HideLayer(layerID) {
  SHL("Details"+layerID);
  SHL("HideHref"+layerID);
  SHL("ShowHref"+layerID);
}

function CreateFlashObject(source,width,height) {
  document.writeln("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+width+"' height='"+height+"' align='middle'>");
//  document.writeln("  <param name='allowScriptAccess' value='sameDomain' /><param NAME='wmode' VALUE='transparent' />");
  document.writeln("  <param name='allowScriptAccess' value='sameDomain' />");
  document.writeln("  <param name='movie' value='"+source+"' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' />");
  document.writeln("  <embed src='"+source+"' quality='high' bgcolor='#ffffff' width='"+width+"' height='"+height+"' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
  document.writeln("</object>");
}

function Trim(str) { if(str) return( str.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') ); else return ""; }
function RetFalse(obj,msg) { alert(msg);obj.focus();obj.select();return false; }

function CheckContactUs(TheForm) {
  TheForm.FullName.value=Trim(TheForm.FullName.value);
  if (TheForm.FullName.value == "") return RetFalse(TheForm.FullName, "שגיאה: אתה חייב להכניס שם מלא.");
  if (!(/^[A-Za-zא-ת\'\-\'_ ]+$/.test(TheForm.FullName.value))) return RetFalse(TheForm.FullName, "שגיאה: שם מלא אינו תקין.");
  TheForm.EMail.value=Trim(TheForm.EMail.value);
  if (TheForm.EMail.value == "") return RetFalse(TheForm.EMail, "שגיאה: אתה חייב להכניס דואל.");
  if (TheForm.EMail.value.indexOf("@") == -1) return RetFalse(TheForm.EMail, "שגיאה: דואל אינו תקין.");
  TheForm.Phone.value=Trim(TheForm.Phone.value);
  if (TheForm.Phone.value == "") return RetFalse(TheForm.Phone, "שגיאה: אתה חייב להכניס טלפון.");
  return true;
}

function CheckContactUsE(TheForm) {
  TheForm.FullName.value=Trim(TheForm.FullName.value);
  if (TheForm.FullName.value == "") return RetFalse(TheForm.FullName, "Error: You must fill fullname.");
  if (!(/^[A-Za-zא-ת\'\-\'_ ]+$/.test(TheForm.FullName.value))) return RetFalse(TheForm.FullName, "Error: Fullname is invalid.");
  TheForm.EMail.value=Trim(TheForm.EMail.value);
  if (TheForm.EMail.value == "") return RetFalse(TheForm.EMail, "Error: You must fill EMail.");
  if (TheForm.EMail.value.indexOf("@") == -1) return RetFalse(TheForm.EMail, "Error: EMail is invalid.");
  TheForm.Phone.value=Trim(TheForm.Phone.value);
  if (TheForm.Phone.value == "") return RetFalse(TheForm.Phone, "Error: You must fill phone number.");
  return true;
}

function CheckUpForm() {
  var TheForm = document.getElementById("UpSearchForm");
  TheForm.UpSearch.value=Trim(TheForm.UpSearch.value);
  if (TheForm.UpSearch.value == "") return RetFalse(TheForm.UpSearch, "שגיאה: אתה חייב להכניס ביטוי חיפוש.");
  if (!(/^[A-Za-zא-ת\'\-\'_ ]+$/.test(TheForm.UpSearch.value))) return RetFalse(TheForm.UpSearch, "שגיאה: ביטוי חיפוש אינו תקין.");
  TheForm.submit();
}
var isNeedShowCats=false;
var checkShowCatsVar=null
function CheckNeedClose() {
  if (!isNeedShowCats) {
    document.getElementById("SearchCats").style.display = "none";
    document.getElementById("SearchCats").style.visibility = "hidden";
    clearInterval(checkShowCatsVar);
    checkShowCatsVar=null;
  } else checkShowCatsVar=setInterval("CheckNeedClose()",2000);
}
