nn = (document.layers)? true : false;
ie = (document.all)? true : false;
ff = (document.getElementById)? true : false;



function ShowLayer(layerName)
{
 swidth=document.body.clientWidth;
 wwidth=(swidth-96)/2;


   if (nn) {
		document.layers[layerName].left = swidth-wwidth-240;
		document.layers[layerName].visibility = "visible";
	   } else
   if (ie) {	
		document.all[layerName].style.left=swidth-wwidth-240;
		document.all[layerName].style.visibility = "visible";
	   } else
   if (ff) {
		document.getElementById(layerName).style.left=swidth-wwidth-240+"px";
		document.getElementById(layerName).style.visibility = "visible";
	   }
};

function HideLayer(layerName)
{

 if (nn) document.layers[layerName].visibility = "hide";
 if (ie) document.all[layerName].style.visibility = "hidden";
 if (ff) document.getElementById(layerName).style.visibility = "hidden";
};

function searchclear()
{
	if ((document.getElementById('topsearch').value =='Поиск по сайту...') || (document.getElementById('topsearch').value =='Search on this site...')) {
    document.getElementById('topsearch').value = '';
  }
}

function check_search_form(form, lang) {
	if (form.str.value.length < 3) {
    if (lang == "ru" || lang == "rus") {
      alert("Введите слово не короче 3 символов!");
    } else {
      alert("Please enter keyword 3 characters or more!");
    }
    return false;
  } else {
    return true;
  }
}

function calc(form, lang) {
  var weight = form.weight.value;
  var count = form.count.value;
  if (weight && count) {
    if (lang == "ru" || lang == "rus") {
      alert("Введите вес ИЛИ количество изделий - что-то ОДНО!");
    } else {
      alert("Please enter weight or item count - not BOTH!");
    }
    return;
  }

  param = form.param2.value;
  if (weight && param) {
    if (!isNumeric(weight)) {
      if (lang == "ru" || lang == "rus") {
        alert("Вес должен быть числом!");
      } else {
        alert("Weight must be a number!");
      }
      return;
    }
    form.count.value = "~" + Math.round(weight * 1000 / param);
  }
  if (count && param) {
    if (!isNumeric(count)) {
      if (lang == "ru" || lang == "rus") {
        alert("Количество должно быть числом!");
      } else {
        alert("Count must be a number!");
      }
      return;
    }
    form.weight.value = "~" + Math.round(param * count / 10) / 100;
  }
}

function isNumeric(sText) {
  var validChars = "0123456789.";
  var isNumber = true;
  var char;

  for (i = 0; i < sText.length; i++) { 
    char = sText.charAt(i); 
    if (validChars.indexOf(char) == -1) {
      isNumber = false;
      break;
    }
  }
  return isNumber;
}

