function PokazObrazek(src, w, h, src2, w2, h2)
{
  if (!w2)
    w2 = 0;
  if (!h2)
    h2 = 0;

  var aw = screen.availWidth - 20;
  var ah = screen.availHeight - 60;
  var s_w = w+w2+17>aw?true:false;
  var s_h = Math.max(h,h2)>ah?true:false;
  w_ = s_w?aw:w+w2+(s_h?17:0);
  h_ = s_h?ah-20:Math.max(h,h2);
  var left = (screen.availWidth - w_) / 2;
  var top = (screen.availHeight - h_) / 2;
  var win = window.open('', 'Obrazek_duzy', 'left='+left+',top='+top+',width='+w_+',height='+h_+',scrollbars='+((s_w)||(s_h)?1:0));
  win.document.open();
  win.document.writeln('<html><head><title>Podgląd</title><meta http-equiv="Content-type" content="text/html; charset=ISO-8859-2"></head>');
  win.document.writeln('<body bgcolor="#FDCA3F" leftmargin="0" topmargin="0" onclick="window.close()" title="Zamknij">');
  win.document.writeln('<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr>');
  win.document.writeln('<td><img src="'+src+'" width="'+w+'" height="'+h+'" alt="Zamknij" border="0"></td>');
  if (w2)
    win.document.writeln('<td><img src="'+src2+'" width="'+w2+'" height="'+h2+'" alt="Zamknij" border="0"></td>');
  win.document.writeln('</tr></table>');
  win.document.writeln('</body></html>');
  win.document.close();
  win.focus();
}

function PokazObjekty(nameOn, nameOff)
 {
 Tab = document.getElementsByName(nameOn);
  for (i=0; i<Tab.length; i++)
   Tab[i].style.display = 'block';
 Tab = document.getElementsByName(nameOff);
  for (i=0; i<Tab.length; i++)
   Tab[i].style.display = 'none';
 }

function PodmienImg(id, src, w, h)
 {
 obj = document.getElementById(id);
 obj.src = src;
 obj.width = w;
 obj.height = h;
 }

function zmienModele(obj)
 {
 tab = tablica[obj.value];
 lista = document.getElementById('id_wkladu');
 lista.options.length = 0;
  for (i=0; i<tab.length; i++)
   {
   var opt = new Option(tab[i][1], tab[i][0]);
   opt.selected = false;
   opt.defaultSelected = false;
   lista.options[i] = opt;
   }
 }

function zmienWklad(stan)
 {
 document.getElementById('inny_wklad').disabled = !stan;
 document.getElementById('firma_').disabled = stan;
 document.getElementById('id_wkladu').disabled = stan;
 }

function obudowy_ZaznaczWszystko(stan)
 {
 document.getElementById('o_marmur').disabled = stan;
 document.getElementById('o_piaskowiec').disabled = stan;
 document.getElementById('o_granit').disabled = stan;
 document.getElementById('o_kafle').disabled = stan;
 document.getElementById('o_cegla').disabled = stan;
 document.getElementById('o_gladzie').disabled = stan;
 document.getElementById('o_stal').disabled = stan;
 document.getElementById('o_inne').disabled = stan;
 }

function obudowy_sprawdz()
 {
 zaznaczone = true;
 puste = false;

 zaznaczone&= document.getElementById('o_marmur').checked;
 zaznaczone&= document.getElementById('o_piaskowiec').checked;
 zaznaczone&= document.getElementById('o_granit').checked;
 zaznaczone&= document.getElementById('o_kafle').checked;
 zaznaczone&= document.getElementById('o_cegla').checked;
 zaznaczone&= document.getElementById('o_gladzie').checked;
 zaznaczone&= document.getElementById('o_stal').checked;
 zaznaczone&= document.getElementById('o_inne').checked;

 puste|= document.getElementById('o_marmur').checked;
 puste|= document.getElementById('o_piaskowiec').checked;
 puste|= document.getElementById('o_granit').checked;
 puste|= document.getElementById('o_kafle').checked;
 puste|= document.getElementById('o_cegla').checked;
 puste|= document.getElementById('o_gladzie').checked;
 puste|= document.getElementById('o_stal').checked;
 puste|= document.getElementById('o_inne').checked;

 document.getElementById('obudowy_zaznacz').checked = zaznaczone;
 document.getElementById('obudowy_zaznacz').indeterminate = !((!puste)||(zaznaczone));
 }


function Alert(text)
 {
 alert(text);
 return false;
 }

ValidateCheck = true;

function ValidateObudowy()
 {
  if (!ValidateCheck) return true;
 f = document.getElementById('FormName0');
  if (f)
   {
    if (f['nazwa'].value=='') return Alert('Pole "nazwa" nie może pozostać puste.');
    if (f['inne'].innerHTML=='') return Alert('Pole "inne" nie może pozostać puste.');
    if ((f['inny_chk'].checked)&&(f['inny_wklad'].innerHTML=='')) return Alert('Proszę wpisać nazwę innego wkładu.');
   tmp = 0;
   id_ = new Array('o_marmur', 'o_piaskowiec', 'o_granit', 'o_kafle', 'o_cegla', 'o_gladzie', 'o_stal', 'o_inne');
    for (i=0;i<id_.length;i++)
     if (f[id_[i]].checked) tmp++;
    if (!tmp) return Alert('Proszę wybrać przynajmniej jeden materiał.');
   }
 return true;
 }

function ValidateWklady()
{
  if (!ValidateCheck) return true;
  f = document.getElementById('FormName1');
  if (f)
  {
    if (f['nazwa'].value=='') return Alert('Musisz podać nazwe wkładu!');
    if (f['moc_nominalna'].value=='') return Alert('Proszę podać moc nominalną.');
    if (f['moc_maksymalna'].value=='') return Alert('Proszę podać moc maksymalną.');
    if (f['przekroj_rury'].value=='') return Alert('Proszę podać przekrój rury dymnej.');
    if (f['waga'].value=='') return Alert('Proszę podać wagę.');
    if (f['gwarancja'].value=='') return Alert('Proszę podać gwarancję.');
    if ((f['wysokosc'].value=='')||(f['szerokosc'].value=='')||(f['glebokosc'].value=='')) return Alert('Proszę wpisać wszystkie wymiary.');
    if ((f['o_norma_din'].checked=='')&&(f['o_norma_iso'].checked=='')&&(f['o_norma_npo'].checked=='')) return Alert('Proszę podać przynajmniej jedną normę.');
   }
 return true;
 }
