function conferma(messaggio, url){
	if(confirm(messaggio))
		window.location.href = url;
}

function chk_txt(o,v){
	if(o.value.search('[a-zA-Z0-9]') == -1){
		if(arguments.length==1) alert('Campo ' + o.name + ' errato');
		else if(arguments.length==2) alert(v);
		o.focus();
		return false;
	}
	return true;
}
function chk_float(o,m){
	//alert(o.value+ o.value.search('[^0-9]+\.[^0-9]+\,[^0-9]'));
        if(!o.value || o.value.search('[^0-9]+\,[^0-9]' ) != -1 || o.value == "0,00"){
		if(arguments.length==1) alert('Campo ' + o.name + ' errato');
		else if(arguments.length==2) alert(m);	
		o.focus();
		return false;
	}
	return true;
}
function chk_int(o,m){
	if(!o.value || o.value == 0 || o.value.search('[^0-9]+\.[^0-9]') != -1){
		if(arguments.length==1) alert('Campo ' + o.name + ' errato');
		else if(arguments.length==2) alert(m);	
		o.focus();
		return false;
	}
	return true;
}
//togliere http!!!
function chk_url(o){
	if(o.value.search('[a-z]+://[a-zA-Z0-9]+\.[a-zA-Z0-9]+') == -1){
		alert('Campo ' + o.name + ' errato');
		o.focus();
		return false;
	}
	return true;
}
function chk_url1(o,m){
	if(o.value.search('[a-zA-Z0-9]+\.[a-zA-Z0-9]+') == -1){
		if(arguments.length==2){
			alert(m);
			o.focus();
		}
		return false;
	}
	return true;
}

function chk_len(o,m,len){
	var len = parseInt(len);
	var strlen = parseInt(o.value.length);
	
	if( strlen !== len ){
	
		if( arguments.length == 3 ){
			alert(m);
			o.focus();
		}
		return false;
	}
	return true;
	
}


function azzera(url){
	window.location.href = url;
}
function chk_email(o,d){
	if(o.value.search("^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-.]?[0-9a-zA-Z])*\\.[a-zA-Z]{2,4}$") == -1){
		alert(d);
		o.focus();
		return false;
	}
	return true;
}

function chk_select(o,d){
	if(!o[o.selectedIndex].value  ){
		alert(d);
		o.focus();
		return false;
	}
	return true;
}

function chk_date_form(o,v){
	var l = o.value.length;

	var f1 = o.value.slice(2,3);
	var f2 = o.value.slice(5,6);
	if( f1=='/' && f2=='/' && l==10 ){
		return true;
	}else{
		if(arguments.length==2){
			alert(v);
		}else{
			alert("il formato deve essere gg/mm/aaaa");
		}
		o.focus();
		return false;
	} 

}


function block_virgola(o){
	var regexp=/\,/;
	if(o.value.search(regexp)>0){
		alert("il valore  "+o.value+"  inserito non è consentito ");
		o.focus();
		return false;
	}
	else return true;
}

