function Validacja()
{
	this.G = /^$/;
	this.ww= /[a-zA-Zêó±¶³¿¼æñÊÓ¡¦£¯¬ÆÑ\-\_0-9]/;

	this.trim = function(v) { return v.replace(/^\s+|\s+$/g, ""); }
	
	this.integer = function(v) { 
		this.G=/^\d*$/;
		if ( this.trim(v) && this.G.test(this.trim(v)))
			return true;
		return false;
	}
	this.pesel = function(v) {
		var tab_pesel = (this.trim(v)).split('');
		var w = new Array(1,3,7,9);
		var wk = 0;
		for (var i=0; i<=9; i++)
			wk = (wk + tab_pesel[i]*w[i%4]) % 10;
		var k = (10-wk) % 10;
		if ( tab_pesel[10] != k || !this.trim(v)) 
			return false;
		return true;
	}
	this.email = function(v) {
		this.G=/^[a-zA-Zêó±¶³¿¼æñÊÓ¡¦£¯¬ÆÑ\-\_0-9\.]{1,}@[a-zA-Zêó±¶³¿¼æñÊÓ¡¦£¯¬ÆÑ\-\_0-9\.]{1,}\.\w{2,4}$/;
		if (this.trim(v) && this.G.test(this.trim(v)))
			return true;
		return false;
	}
	this.stringStandard = function(v) {
		this.G=/^[a-zA-Zêó±¶³¿¼æñÊÓ¡¦£¯¬ÆÑ\-\s]+$/;
		if (this.trim(v) && this.G.test(this.trim(v)))
			return true;
		return false;
	}
	this.imie = function(v) { 
		this.G=/^[a-zA-Zêó±¶³¿¼æñÊÓ¡¦£¯¬ÆÑ\-\s]{2,}$/;
		if (this.trim(v) && this.G.test(this.trim(v)))
			return true;
		return false;
	}
	this.nazwisko = function(v) { return this.stringStandard(v) }
	this.miejscowosc = function(v) { return this.stringStandard(v) }
	this.poczta = function(v) { return this.stringStandard(v) }
	this.ulica = function(v) { 
		this.G=/^[a-zA-Zêó±¶³¿¼æñÊÓ¡¦£¯¬ÆÑ\d]+[a-zA-Zêó±¶³¿¼æñÊÓ¡¦£¯¬ÆÑ\-\s\.\d]+$/;
		if (this.trim(v) && this.G.test(this.trim(v)))
			return true;
		return false;
	}
	this.kodPocztowy = function(v) {
		this.G=/^\d\d-\d\d\d$/;
		if (this.trim(v) && this.G.test(this.trim(v)))
			return true;
		return false;
	}
	this.nrLokalu = function(v) {
		this.G=/^\d+[\/\\a-zA-Zêó±¶³¿¼æñÊÓ¡¦£¯¬ÆÑ\-\_0-9\s]*$/;
		if (this.trim(v) && this.G.test(this.trim(v)))
			return true;
		return false;
	}
	this.nrDomu = function(v) {
		this.G=/^\d+[\/\\a-zA-Zêó±¶³¿¼æñÊÓ¡¦£¯¬ÆÑ\-\_0-9\s]*$/;
		if (this.trim(v) && this.G.test(this.trim(v)))
			return true;
		return false;
	}
	this.telefon = function(v)  {
		this.G=/^\+*[0-9\-\(\)\+]{9,20}$/;
		if (this.trim(v) && this.G.test(this.trim(v)))
			return true;
		return false;
	}
	this.minlen = function(v,a) {
		if (!a)
			return;
		if ((this.trim(v)).length < a)
			return false;
		return true;
	}
	this.maxlen = function(v,a) {
		if (!a)
			return;
		if ((this.trim(v)).length > a)
			return false;
		return true;
	}
	this.len = function(v,a) {
		if (!a)
			return;
		if ((this.trim(v)).length != a)
			return false;
		return true;
	}
	// format daty : dd-mm-yyyy
	this.data = function(v,a) {
		this.G=/^\d\d-\d\d-\d\d\d\d$/;
		var mecz=new RegExp("(.{2})-(.{2})-(.{4})");
		var q=mecz.exec(v);
		if (this.trim(v) && this.G.test(this.trim(v)) && parseInt(q[1],10) > 0 && parseInt(q[1],10) < 32 && parseInt(q[2],10) >0 && parseInt(q[2],10) < 13 )
			return true;
		return false;
	}
	this.nrKontaFormat = function(v) {
		this.G=/^[\d\s]*$/;
		if ( this.trim(v) && this.G.test(this.trim(v)) )
			return true;
		return false;
	}
	this.nrKonta = function(v) {
		var v=this.trim(v);
		v=v.replace(/\s/g,'');
		v=v.slice(2,10);
		v=v.split('');
		var wynik=0;
		var wagi=new Array(7,1,3,9,7,11,3);
		for (i=0; i<7; i++) {
			wynik += (parseInt(v[i],10)*wagi[i]);
		}
		wynik%=10;
		if ( wynik == v[7] )
			return true;
		return false;
	}
	this.dowodOsobistyNumer = function(v) { 
		this.G=/^[a-zA-Z]{3}\d{6}$/;
		if ( this.trim(v) && this.G.test(this.trim(v)) )
			return true;
		return false;
	}
	this.dochody = function(v) {
		this.G=/^[0-9]+[0-9\.\,]+$/;
		if ( this.trim(v) && this.G.test(this.trim(v)) && parseInt(this.trim(v))>=850)
			return true;
		return false;
	}
	this.stringPierwszaLitera = function(v) {
		this.G=/^[a-zA-Zêó±¶³¿¼æñÊÓ¡¦£¯¬ÆÑ][a-zA-Zêó±¶³¿¼æñÊÓ¡¦£¯¬ÆÑ\-\s\d]*$/;
		if ( this.trim(v) && this.G.test(this.trim(v)) ) 
			return true;
		return false;
	}

	/* 		dzia³aj±ce globalnie na formularz		*/

	this.validateFormForXmlValue = function(form) {
		var fld=form.elements;
		var fldl=fld.length;
		for(var xxs=0; xxs<fldl; xxs++) {
			if(fld[xxs].value&&fld[xxs].value.indexOf('&')>=0)fld[xxs].value=fld[xxs].value.replace(/&/g,' and ');
			if(fld[xxs].value&&fld[xxs].value.indexOf('<')>=0)fld[xxs].value=fld[xxs].value.replace(/</g,'_');
			if(fld[xxs].value&&fld[xxs].value.indexOf('>')>=0)fld[xxs].value=fld[xxs].value.replace(/>/g,'_');
		}
	}
}


