function openWin(){
    par = 'width=335, height=270, menubar=no, location=no,resizable=no,scrollbars=no';
	window.open('http://stelmas-d.ru/video/lq.html','newWin', par);
}
function openBonus(){
    par = 'width=20, height=20, menubar=no, location=no,resizable=no,scrollbars=no,status=no';
	window.open('./bonuses.php','newWin', par);
}
function openBook(){   widt=(screen.width)*0.9; hei=(screen.height)*0.9;
    par = 'width='+widt+', height='+hei+', menubar=yes, location=no,resizable=yes,scrollbars=yes';
	window.open('../book.php','newBook', par)

}



	function bonus(){
	        proc = document.getElementById("disc").innerHTML;
	        if(document.getElementById("sumItem"))
	        sum =  document.getElementById("sumItem").value;
	        else sum = 0;
	        Bonus = Math.round(proc*sum*0.01);
	         document.getElementById("bon").innerHTML = Bonus;

	}

  window.onerror=null;
  window.status="";
   function basket(id) {

    var act = "add";
    qqt =  "qtt_"+id ;
   	qty =  document.getElementById(qqt).value;

  	    JsHttpRequest.query(
            './backend.php',
            {
                "id": id ,
                "qty" : qty ,
                "ssid": ssid ,
                "act" : act
 },
            function(result, errors) { document.getElementById("topCart").innerHTML = errors;
                 if (result) {
                    innerHTML = document.getElementById("topCart").innerHTML =
                    	result["str"] ;
                         focus(document.getElementById("topCart"));
                        document.getElementById("mainCart").innerHTML =
                        result["bask"];
                        document.getElementById("path").style.display = 'none';

                        bonus();
                }
            },
            true
        );
    }

     function _clear(){
       JsHttpRequest.query(
            './backend.php',
            {
                "act": "cls",
                "ssid": ssid
 },
            function(result, errors) { document.getElementById("topCart").innerHTML = errors;
                 if (result) {
                    document.getElementById("topCart").innerHTML =
                         result["str"] ;
                         focus(document.getElementById("topCart"));

                         document.getElementById("mainCart").innerHTML =
                        result["bask"];
                         bonus();
                }
            },
            true
        );

    }


  function newCount(i,id){

      qqt = "c"+i  ;
      	   _item =  document.getElementById(qqt).innerHTML;


      JsHttpRequest.query(
            './backnc.php',
            {   "id"  : id,
                "qty"  : _item,
                "ssid" : ssid
 				},
            function(result, errors) { document.getElementById("topCart").innerHTML = errors;
                 if (result) {
                    document.getElementById("topCart").innerHTML =
                         result["str"] ;
                         focus(document.getElementById("topCart"));
                          document.getElementById("mainCart").innerHTML =
                        result["bask"];
                        document.getElementById("path").style.display = 'none';
						 bonus();

                }
            },
            true
        )
   }

    function basketNo(){
    document.getElementById("basketTo").style.display="none";
    }

    function basketYes(){
    document.getElementById("basketTo").style.left= (screen.width/2-250);
    document.getElementById("basketTo").style.top= (screen.height/2-100);
    document.getElementById("basketTo").style.display="";
    }

    function closeLay() {

	if ( trigger == "close")
	{
    wid-=5;
    if ( wid > 0 ) setTimeout("closeLay()",10);

 	else  {  trigger ="open";
 	document.getElementById("button-r").innerHTML = '<img src="../shop/imgs/b-left.gif">';
 			}
 	}
 	else {
    wid+=5;
    if ( wid < 220 ) setTimeout("closeLay()",10);

 	else  {   trigger ="close";
 	document.getElementById("button-r").innerHTML = '<img src="../shop/imgs/b-right.gif">';}
 			}
    document.getElementById('cart').style.width = wid +'px';
    document.getElementById('fade').style.height = document.body.scrollHeight ;

}


function openBook(){   widt=(screen.width)*0.9; hei=(screen.heght)*0.9;
    par = 'width='+widt+', height='+hei+', menubar=yes, location=no,resizable=yes,scrollbars=yes';
	window.open('../book.php','newBook', par)

}
function openCart(){
	document.getElementById('fade').style.display='block';
	document.getElementById('fade').style.height = document.body.scrollHeight ;


}

function iter(who,id,gid){
     elem = eval("c"+id);
    Pr =  eval("pr"+id);
   	sUm = eval("s"+id);

 	val = document.getElementById("c"+id).innerHTML;
    if (who == "up") Val = (1*val+1);
    else if(val>0)   Val = (1*val-1);
    document.getElementById("c"+id).innerHTML = Val;

    document.getElementById("s"+id).innerHTML =  Val * document.getElementById("pr"+id).innerHTML ;
    document.getElementById("path").style.display='block';
    newCount(id,gid) ;

 }

  setTimeout('closeLay()',1000) ;
