
var click = "yes";
function resume() {
	click = "yes";
	document.search.templateSearch[0].checked=true;
 	for (i=0;i < 3; i++) document.search.templateSearch[i].disabled=false;	
	var inp = document.getElementById("keywords");
    if (inp!=null) inp.focus();
}

function suspend() {
	click = "no";
	for (i=0;i < 3; i++) {
		document.search.templateSearch[i].checked=false;
		document.search.templateSearch[i].disabled=true;		
	}
    var inp = document.getElementById("keywords");
    if (inp!=null) inp.focus();    
}

function openDialogWindow(url, height, width) {
    url = url + "&" + Math.random();
    var win = window.open(url, "_blank", "height="+height+",width="+width+",status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
    win.focus();
}

function isEmpty(s) {
     if(s == undefined) return true;
         for(var i = 0; i < s.length; i++) {
            if(s.charCodeAt(i) != 32 || s.charCodeAt(i) != '\t') {
            return false;
         }
     }
     return true;
}

function checkFeedbackData(form) {
    if(isEmpty(form.email.value)) {
        alert("Email field is empty");
        return false;
    }
    if (isEmpty(form.name.value)) {
        alert("Name field is empty");
        return false;
    }
    if (isEmpty(form.message.value)) {
        alert("Message field is empty");
        return false;
    }
    return true;
}

function submitForOK() {
    var theForm = document.forms.theForm;
    return checkFeedbackData(theForm);
}


function valid() {
   if (search.keywords.value.length>2) return true;
   else {
      alert("Required min 3 symbols of keyword");
      return false;
   }
}

function addToCart(i, productId){

  var objRegExp  =  new RegExp("^\\d*$");

  if (!(objRegExp.test(document.getElementById("quant"+i).value))){

    alert("quantity should be integer value");
    return false;
  }

  window.location = document.getElementById("add"+i).href + "&id="+productId+"&quantity="+document.getElementById("quant"+i).value;

  return false;
}

function addToOrder(i, productId){

  var objRegExp  =  new RegExp("^\\d*$");

  if (!(objRegExp.test(document.getElementById("quant"+i).value))){

    alert("quantity should be integer value");
    return false;
  }

  window.location = document.getElementById("add"+i).href + "&productID="+productId+"&quantity="+document.getElementById("quant"+i).value;

  return false;
}

