// JavaScript Document
function get_price() 
  {
  var price,skupina,podkarta,arrBuf,mnozstvi,price_varianta,cena_doplnek, id_doplnek;
  price=0;
  arrBuf
  if (document.getElementById('latky_id')==null)
    {
      if (document.getElementById('podkarta_id')==null)
        {
        price=document.getElementById('tovar_cena').value;
        }else
        {
        podkarta=document.getElementById('podkarta_id').value;
        price=document.getElementById('podkarta_cena_'+podkarta).value;
        }
    } else
    {
    skupina=document.getElementById('skupina_latky_id_'+document.getElementById('latky_id').value).value;
      if (document.getElementById('podkarta_id')==null)
      {
      price=document.getElementById('latky_cena_'+document.getElementById('latky_id').value).value;
      }
      else 
      {
      podkarta=document.getElementById('podkarta_id').value;
      price=document.getElementById('latky_cena_podkarty_'+podkarta+'_'+skupina).value;
      }
    }
price=parseFloat(price);
    var y=0
    for(y=0; y < 100; y++){
    if(document.getElementById('addons_'+y)==null){
    break;
    } 
    if(document.getElementById('addons_'+y).checked)
    {
 
    id_doplnek=document.getElementById('addons_'+y).value;
    cena_doplnek=parseFloat(document.getElementById('addon_'+id_doplnek).value);
    price+=cena_doplnek;
    }
 
    }    

var i=0;
for (i=0;i<=15;i++)
{
  if(document.getElementById('variace'+i) != null){
          value_variace=document.getElementById('variace'+i).value;
          price_varianta =parseFloat(document.getElementById('polozky_cena[variace'+i+'][' + value_variace + ']').value);
     	    price += price_varianta;
     	    }
}    

      	    
     
mnozstvi=document.getElementById('mnozstvi').value;
price=price*mnozstvi;
arrBuf = String(price).split(".");

if (!arrBuf[1])
  {
  cena_pro_zapis=price+',00 Kč';
  }
  else 
  {
   if (arrBuf[1].length<2)
    {
    arrBuf[1]=arrBuf[1]+'0';
    } else
    {
    arrBuf[1]=arrBuf[1].substring(0,2)
    }
  cena_pro_zapis=arrBuf[0]+','+arrBuf[1]+' Kč';
  }

document.getElementById('cena_celkem').innerHTML=cena_pro_zapis;
} 
