function syncsum (obj) {
  //обновление общей выбранной суммы на странице продукта
  if (document.getElementById("totalprice").innerHTML == '') {
    //если вначале загрузке страницы
    document.getElementById("totalprice").innerHTML = document.getElementById("productcena").innerHTML
  }else{
if(obj){

    //если общая цена уже была установлена
    oldtotalprice = parseFloat(document.getElementById("totalprice").innerHTML)
    checkedprice = parseFloat(obj.id)

    if (obj.checked) {
//      alert(oldtotalprice+" + "+ checkedprice)
      newprice = oldtotalprice + checkedprice
    } else {
      //если передумали брать продукт
//      alert(oldtotalprice+" - "+ checkedprice)
      newprice = (oldtotalprice*100 - checkedprice*100)/100

    }
    document.getElementById("totalprice").innerHTML = newprice;
  }}
}

function openpage(pagenumber) {
  //отправляет постом номер выводимой страницы
  document.getElementById("startelement").value = pagenumber;
  a=document.getElementById("ProdPage");
  a.submit();
}
function openBasket(addr)
{
    var str=id_prod_arr[0]+'='+document.getElementsByName(id_prod_arr[0])[0].value;
    var j=1
    for(var i=1;id_prod_arr[i];i++)
    {

        if(document.getElementsByName(id_prod_arr[i])[0].checked)
        {
            str=str+'&'+id_prod_arr[i]+'='+document.getElementsByName(id_prod_arr[i])[0].value;
        }
    }

    new_window = window.open(addr+"?"+str,"new_window", "resizable=yes,scrollbars=yes,toolbar=yes,userbar=yes,location=yes,status=yes,menubar=yes");
}
function getDims(winWidth, winHeight) {
        var dims = new Object();
        if (winWidth) {
                dims.width = winWidth;
                dims.scrollbars = false;
                if (screen.width < dims.width + 70) {
                        dims.width = screen.width - 70;
                        dims.scrollbars = true;
                }
        }

        if (winHeight) {
                dims.height = winHeight;
                if (screen.height < dims.height + 100) {
                        dims.height = screen.height - 100;
                        dims.scrollbars = true;
                }
        }
        dims.heightStr = (winHeight)? ',height=' + dims.height : '';
        dims.scrollbarsStr = (dims.scrollbars)? ',scrollbars=yes' : ',scrollbars=no';
        dims.width=(dims.scrollbars)? dims.width+17 : dims.width;
        dims.widthStr = (winWidth)? ',width=' + dims.width : '';
        dims.posX = Math.round((screen.width - dims.width) / 2);
        dims.posY = Math.round((screen.height - winHeight) / 2);
        dims.posCode = (document.all)? ',left=' + dims.posX + ',top=' + dims.posY : ',screenX=' + dims.posX + ',screenY=' + dims.posY;
        return dims;
}
function popupImg(imgSrc, winName, imgWidth, imgHeight, winTitle) {

        winWidth = (imgWidth)? imgWidth +0 : null;
        winHeight = (imgHeight)? imgHeight + 0 : null;
        var dims = getDims(winWidth, winHeight);
        var popupWin = window.open('', winName, 'menubar=no,toolbar=no,resizable=yes,status=yes' + dims.scrollbarsStr + dims.widthStr + dims.heightStr + dims.posCode);
        if (popupWin) {
                popupWin.document.open();
                popupWin.document.write('<html><head><title>' + winTitle + '</title></head><body bgcolor="white" style="margin: 0px 0px; padding: 0px;">')
                popupWin.document.write('<img src="' + imgSrc + '" width="' + imgWidth + '" height="' + imgHeight + '" />')
                popupWin.document.write('</body></html>')
                popupWin.document.close();
        }
        return false;
}
function openNoDialog(href,winName) {
window.open(href, winName, 'menubar=no,toolbar=no,resizable=yes,status=yes');
}