function checkAndSubmitForm(form){
  for (var i=0;i<form.elements.length;i++){ 
    if (form.elements[i].getAttribute("require")=='1' || form.elements[i].className.match(/\bsa_require\b/))
      if (form.elements[i].value==""){ 
        if (form.elements[i].name!="secret")
                 alert("Поле "+form.elements[i].name+" должно быть заполнено"); 
        else alert("Поле секретного кода должно быть заполнено"); 
        return false;
      }
     } 
  return true;
}


function checkForRequiredFields(form,correspondenceArray){
  for (var i=0;i<form.elements.length;i++){
    if (form.elements[i].getAttribute("require")=='1' || form.elements[i].className.match(/\bsa_require\b/))
      if (form.elements[i].value==""){ 
        if (form.elements[i].name!="secret")
                 alert("Поле "+correspondenceArray[form.elements[i].name]+" должно быть заполнено"); 
        else alert("Поле секретного кода должно быть заполнено"); 
        return false;
      }
     } 
  return true;
}

function openPopup(url,w,h){
  win=open(url,
    "popup","toolbar=no,location=no,directories=no,"+
    "status=no,scrollbars=no,resizable=no,"+
    "copyhistory=no,left="+(window.screen.width-w)/2+",top="+
    (window.screen.height-h)/2+",width="+w+",height="+h);
  win.focus();
}

function add2basket(requestUrl){
  var a = jQuery.ajax({
    url : requestUrl,
    type:'post',  
    success: function(msg){
      var response = msg;
      //alert(response);
      //$("debug").innerHTML=response;
      if(response>0){

        if (typeof(korzina_setCount) == "function") { 
          korzina_setCount(response);
          alert("Товар добавлен в корзину!");
        }
      }else{  
        if (typeof(korzina_setCount) == "function") { 
          //alert("Ошибка добавления товара в корзину!");
          korzina_setCount(response);
        }
      }
    },
    error: function(){
      alert('Ошибка доступа!');
    }
  });
}

function PingSession(){
  var a = jQuery.get("/null.php");
}

function smartInput(id)
{
	var el = jQuery('#' + id);
	if (!el[0])
		return;

	el.focus(function()
	{
		if (this.defaultValue == this.value)
			this.value = '';
	});
	el.blur(function()
	{
		if (this.value == '')
			this.value = this.defaultValue;
	});
}

//setInterval("PingSession()", 300000);
