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

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 popImage(imageURL, ttl, width, height){
  if(!width) width=100;
  if(!height) height=100;
  if(!ttl) ttl="...";
        var opt='scrollbars=no,width='+width+',height='+height+',left='+(window.screen.width-width)/2+',top='+(window.screen.height-height)/2+',status=yes';
        imgWin = window.open('','',opt);
        with (imgWin.document) {
                writeln('<html><head><title>'+ttl+'</title><style type="text/javascript">body {overflow: auto; margin: auto; margin:0; padding: 0;}</style>');
                writeln('<sc'+'ript type="text/javascript">');
                writeln('function resizePopup() {');
                writeln('width = document.images[0].width + 10; ');
                writeln('height = document.images[0].height + 50; ');
                writeln('window.resizeTo(width,height); ');
                writeln('if (window.innerWidth) { window.innerWidth = width - 10; window.innerHeight = height - 30; }');
                writeln('}');
                writeln('</s' + 'cript>');
    writeln('</head><body bgcolor="#FFFFFF" onload="resizePopup();">')
                writeln('<img src="'+imageURL+'" alt="Закрыть" onclick="window.close();" border="0" style="position: absolute; left: 0px; top: 0px; cursor: pointer;"/></body></html>');
                close();
        }
}
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);