/*******************************************************************************
* Program:    Skladanie zamowien  -  JOKER                                     *
* Author:     Jerzy Primke                                                     *
* Data:       2009                                                             *
* License:    Ten program NIE JEST freeware. Nie wolno go uzywac, kopiowac,    *
*             modyfikowac, redystrybuowac itp. bez zgody autora.               *
*                                                                              *
*             This software IS NOT a freeware. You may not use, copy, modify,  *
*             redistribute it etc. without a permission.                       *
*******************************************************************************/

var suma=0;
var element=0;
function potwierdz(){
  if (confirm('Czy chcesz zaakceptować zamówienie?')) return true;
  else return false;
}
function podstaw(val){
  element=val;
}
function sumuj(val,l1,l2){
  if (isEmpty(val)) {
    val = 0;
  }
  if (!isInteger(val)) {
    alert('błędna wartość w polu ilość!');
    indeks = 'il['+l1+']['+l2+']';
    document.getElementById(indeks).value = element;
  }
  else {
    if (isEmpty(element)) {
      element = 0;
    }
    suma = suma + parseInt(val) - parseInt(element);
    document.getElementById('suma').value = suma;
  }
}
function sumuj1(val,ind){
  if (isEmpty(val)) {
    val = 0;
  }
  if (!isInteger(val)) {
    alert('błędna wartość w polu ilość!');
    indeks = 'il_nie_'+ind;
    document.getElementById(indeks).value = element;
  }
  else {
    if (isEmpty(element)) {
      element = 0;
    }
    suma = suma + parseInt(val) - parseInt(element);
    document.getElementById('suma').value = suma;
  }
}
function isInteger (s)
{
  var i;
  if (isEmpty(s))
  if (isInteger.arguments.length == 1) return 0;
  else return (isInteger.arguments[1] == true);
  for (i = 0; i < s.length; i++)
  {
    var c = s.charAt(i);
    if (!isDigit(c)) return false;
  }
  return true;
}
function isEmpty(s)
{
  return ((s == null) || (s.length == 0))
}

function isDigit (c)
{
  return ((c >= "0") && (c <= "9"))
}


