var vco_pesel = new Class.create(vc,{
	type : 'vco_pesel',
	valid : function (){
		alert('nie uzywalne');
		return true; 
		
        if (this.e.value=='') return true;
        if (this.e.value.length != 11 || parseInt(this.e.value).toString()!=this.e.value) return false;
        var weights = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3]; 
        var s = 0;
        //for (var x=0; x<10; x++) s = s + weights[x] * parseInt(substr(this.e.value.substr(x,1)));
        for (var x=0; x<10; x++) s = s + weights[x] * parseInt(this.e.value.substr(x,1));
        s = 10 - (s % 10);
        if (s == 10) s = 0;
        if (s == parseInt(this.e.value.substr(10,1))) {
        	this.ok();
        	return true;
        }
        this.msg('Bledny numer pesel');
        return false;
	}
});
var vco_nip = new Class.create(vc,{
	type : 'vco_nip',
	valid : function (){
		d('[[new VCO_nip]]');


		this.e.value = this.e.value.replace(',','.');

        if (this.e.value=='' && this.p.allow_null) return true;
		
        var weights = [6, 5, 7, 2, 3, 4, 5, 6, 7];
        nip=this.e.value.replace(/[ -]/g, ''); 
        if (nip.substring(0,2).toUpperCase() == 'PL') nip = nip.substring(2,nip.length);
        if (nip.length != 10){
        	this.msg('Bledna dlugosc, spodziewam sie 10 znaków');
        } 
        var s = 0; 
        for (var x=0; x<9; x++) {
        	s = s + weights[x] * parseInt(nip.substr(x,1)); 
        }
        s = s % 11; 
        if (s == parseInt(nip.substr(9,1))){
        	this.ok();
        	return true;
        }
        this.msg('Nieprawidłowy numer NIP');
        return false;
	}	
});
 		
 
