function conferma(testo) {
	return confirm(testo);
}
function cercaCampo(id) {
	return document.forms[0].elements["fields["+id+"]"];
}
function loccaCampo(id,v) {
	
	document.forms[0].elements["fields["+id+"]"].disabled=v;

}
function loccaCampoF(id,v,classForm) {
	var x=document.forms[0].elements["fields["+id+"]"];
	if (v) {
		x.className=classForm+"_locked";
	} else {
		x.className=classForm;
	}
//	document.forms[0].elements["fields["+id+"]"].disabled=v;
	x.disabled=v;

}
function pulisciCampo(id) {
	document.forms[0].elements["fields["+id+"]"].value='';	
}

function attivaCampo(id,v) {
	document.forms[0].elements["fields["+id+"]"].readOnly=v;
}

function chk(id,w,f) {
	switch(w) {
	case 1: // non vuoto
		return (cercaCampo(id).value!="");
		break;
	case 2: // presente un carattere
		return (cercaCampo(id).indexOf(f)>=0);
		break;
	case 3: // deve essere numerico e di f cifre.
		return (cercaCampo(id).parseInt()>0 && cercaCampo(id).length==f);
		break;
	case 4: // deve essere diverso da zero
		return (cercaCampo(id).parseInt()!=0);
		break;
	case 5: // deve essere diverso da zero (e floats 0.00)
		return (cercaCampo(id).parseInt()!=0 && cercaCampo(id).parseInt()!="0.00");
		break;

	}
}
function checkIt(string,detect)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function chkIE() {
	var detect = navigator.userAgent.toLowerCase();
	if (checkIt('msie',detect)) return true;
	return false; 
}
function pad(s,l) {
	s1=new String(s);
	if (s1.length==l) return s1;
	if (s1.length>l) return s1;
	v=l-s1.length;
	x="";

	for (i=0;i<v;i++) x+='0';
	x+=s1;
	return x;	
}
function nf(x,d) {
	q=parseInt(x);
	c=x-q; // 50.2352 -> .2352 -> 23.52 (23) -> 50.23
	k=Math.pow(10,d);	
	c1=c*k;
	c2=Math.abs(Math.round(c1));
	if (c2==0) {
		b="";
		for (i=0;i<d;i++) b+="0";
		c2=b;
	}
	return q+"."+c2;
}
function numbf(obj,d) {
	obj.value=nf(obj.value,d);
}
function getmyYear() {
	// risolvendo il baco di mozilla su getYear... e scoprendo getFullYear()
	var curdate=new Date();
	y=curdate.getYear();
	if (y<2000) {
		if (y<100) 
			y=(y%100)+1900; 
		else
		y=(y%100)+2000;
	}
	return y;

}

function skip_next_field_orig(obj,maxlength,next) {
	if (obj.value.length==maxLength) {
		document.forms[0].elements[next].focus()
	}
}
function skip_next_field(obj,maxLength,next) {
	if (obj.value.length==maxLength) {
		c=cercaCampo(next);
		if ( typeof c != 'undefined' )
			c.focus()
	}
}