
function flash(id, text, kolor, czas, kolor2, czas2)
{
  var t = document.getElementById(id);
  if (t)
  {
    t.innerHTML = '<font class="clsFontBlack" style="color: '+kolor+'">'+text+'</font>';
    setTimeout('flash("' +  id + '","'+text+'","' + kolor2 + '",' + czas2 + ',"' + kolor + '",' + czas + ')', czas);
  }

}


function koszyk_add(prid, kategoria, producent, nazwa)	{
	 var choice= confirm("Kategoria: "+kategoria+"\nProducent: "+producent+"\nNazwa: "+nazwa+"\n\nDodać pozycję do koszyka?");
	 if (choice== true)
	{
		window.location = "koszyk/koszyk_dodaj.php?prid="+prid;
	} 	
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
   return IsNumber;  
}


function formatCurrency(num) {
	num = num.toString().replace(',','.');
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num)) num = "0";
	//sign = (num == (num = Math.abs(num)));
	sign = true;
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+
	num.substring(num.length-(4*i+3));
	num = Math.abs(num);
	return (num + '.' + cents);
}


<!-- Integer functions -->
   
   function isEmpty(s)   {
      return ((s == null) || (s.length == 0))
   }
   
   function isDigit (c)
   {
      return ((c >= "0") && (c <= "9"))
   }   
   
   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 isSignedInteger (s)   {
      if (isEmpty(s))
      if (isSignedInteger.arguments.length == 1) return false;
      else return (isSignedInteger.arguments[1] == true);

      else {
         var startPos = 0;
         var secondArg = false;

         if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

         // skip leading + or -
         if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
            startPos = 1;
         return (isInteger(s.substring(startPos, s.length), secondArg))
      }
   }
   
   function isPositiveInteger (s)   {
      var secondArg = false;

       if (isPositiveInteger.arguments.length > 1)
          secondArg = isPositiveInteger.arguments[1];

       // The next line is a bit byzantine.  What it means is:
       // a) s must be a signed integer, AND
       // b) one of the following must be true:
       //    i)  s is empty and we are supposed to return true for
       //        empty strings
       //    ii) this is a positive, not negative, number

       return (isSignedInteger(s, secondArg)
          && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
   }
   
   function isNonnegativeInteger (s)   {
      var secondArg = false;

       if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

       // The next line is a bit byzantine.  What it means is:
       // a) s must be a signed integer, AND
       // b) one of the following must be true:
       //    i)  s is empty and we are supposed to return true for
       //        empty strings
       //    ii) this is a number >= 0

       return (isSignedInteger(s, secondArg)
            && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
   }
   //...Plus isSignedInteger, isInteger, isEmpty, isDigit   
   
   function checkInteger(p) {

	//alert(p.value);
	if (isNonnegativeInteger(p.value)) {
		if (p.value>0) {
			return true;
		} else {
			p.value = 1;
			return false;
		}
	} else {
		p.value = 1;
		return false;
	}

}
   