function onlydec(event,f)

{

if (event.srcElement) {kc = event.keyCode;} else {kc = event.which;}

if ((kc < 48 || kc > 57) && kc != 8 && kc != 0) return false;

return true;

}


function checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,1)=="r") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}
if (!pass) {
shortFieldName=tempobj.name.substring(1,30).toUpperCase();
alert("Prosze wprowadzic: "+shortFieldName);
return false;
}
else
return true;
}









function textCounter(field, countfield, maxlimit) 
{

if (field.value.length > maxlimit) 
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}








function sprawdz(dane) {
	var fieldset = dane.parentNode;
	
	var fieldset = dane.parentNode;
	var txt = dane.value;
	
	if (txt.length > 14) {

var etal = /^[0-9]{15}$/;
sum = 0; mul = 2; l = 14;
  for (i = 0; i < l; i++) {
    digit = txt.substring(l-i-1,l-i);
    tp = parseInt(digit,10)*mul;
    if (tp >= 10)
         sum += (tp % 10) +1;
    else
         sum += tp;
    if (mul == 1)
         mul++;
    else
         mul--;
    }
  chk = ((10 - (sum % 10)) % 10);
if (chk != parseInt(txt.substring(14,15),10))fieldset.className = "";
else
fieldset.className = "welldone";
   		
	}
	else {
		fieldset.className = "";
	}
}






	
// this part is for the form field hints to display
// only on the condition that the text input has focus.
// otherwise, it stays hidden.


function isIMEI (s) {


  if (!etal.test(s))
    return false;
  sum = 0; mul = 2; l = 14;
  for (i = 0; i < l; i++) {
    digit = s.substring(l-i-1,l-i);
    tp = parseInt(digit,10)*mul;
    if (tp >= 10)
         sum += (tp % 10) +1;
    else
         sum += tp;
    if (mul == 1)
         mul++;
    else
         mul--;
    }
  chk = ((10 - (sum % 10)) % 10);
  if (chk != parseInt(s.substring(14,15),10))
    return false;
  return true;
}






function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function prepareInputsForHints() {
  var inputs = document.getElementsByTagName("input");
  for (var i=0; i<inputs.length; i++){
    inputs[i].onfocus = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
    }
    inputs[i].onblur = function () {
      this.parentNode.getElementsByTagName("span")[0].style.display = "none";
    }
  }
}
addLoadEvent(prepareInputsForHints);
