// function PlaySound(url) {
//   document.all.sound.src = url;
// }
// 
// function MM_preloadImages() { //v3.0
//   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
//     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
//     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
// }
// 
// function MM_swapImgRestore() { //v3.0
//   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
// }
// 
// function MM_findObj(n, d) { //v3.0
//   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
//     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
//   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
//   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
// }
// 
// function MM_swapImage() { //v3.0
//   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
//    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
// }
// 
// function MM_showHideLayers() { //v3.0
//   var i,p,v,obj,args=MM_showHideLayers.arguments;
//   for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
//     if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
//     obj.visibility=v; }
// }
// 
// function MM_openBrWindow(theURL,winName,features) { //v2.0
// 
// 	remote = window.open(theURL,winName,features);
//     	if (remote.opener == null) remote.opener = window;
//     	remote.opener.name = "opener";
// 	return remote;
// }
// 
// function formato (form,field,min,max,type)  {
// 	if (field.value=="") {
// 		return true;
// 	}
// 	if (type=="intero") {
// 		vValue=parseInt(field.value);
// 		vStr="Il valore non  un numero intero"
// 	} else {
// 		vValue=parseFloat(field.value);
// 		vStr="Il valore non  un numero"
// 		}
// 
// 	if (isNaN(vValue)||vValue!=field.value) {
//    		alert(vStr);
// 		field.focus();
// 		field.select();
// 		return false;
// 	} else {
// 		if ((min != -1 && vValue<min)||(max != -1 && vValue>max))  {
// 		alert("Il valore non  nel range corretto");
// 		field.focus();
// 		field.select();
// 		return false;
// 	} else {
// 		return true;
// 		}
// }
// }

var scritto=false;

function validaForm_check(form, message_o, message_s)
{
	fatal=false;
	if (spedisci(form, message_o, message_s)){
		//Se tutto e' ok, rinomina nome campi
		for (i=0;i<form.length;i++)
			{
				var tempobj=form.elements[i];
				if((tempobj.name.substring(0,2)=="s_")||
				    (tempobj.name.substring(0,2)=="r_"))
				{
					tempobj.name = tempobj.name.substring(2,tempobj.name.length);
				}			
			}
		form.submit();
		
		return true;
	}
	else
		return false;
}
// function spedisci(form, message_o, message_s)
// {
// 	var tmpstr_o='Il campo seguente  obbligatorio: \n';
// 	var tmpstr_s='Occorre compilare almeno uno dei campi seguenti: \n';
// 	if (message_o.length > 0)
// 		tmpstr_o = message_o;
// 	if (message_s.length > 0)
// 		tmpstr_s = message_s;	
// 	var ret=convalida(form, tmpstr_o);
// 	if(ret)
// 	{
// 		scritto=false;
// 	}
// 	else
// 		if (!fatal){
// 		var cnt=0;
// 		for (i=0;i<form.length;i++)
// 			{
// 				var tempobj=form.elements[i];		
// 				if(tempobj.name.substring(0,2)=="s_"){
// 					cnt++;
// 					tmpstr_s = tmpstr_s + '"' + tempobj.name.substring(2,tempobj.name.length) + '"\n';
// 				}
// 			}
// 			if (cnt!=0)
// 				alert(tmpstr_s);
// 			else
// 				ret=true;
// 		}
// 	return ret;
// }
// 	
// 
// function convalida(form, message_o)
// {
// 	for (i=0;i<form.length;i++)
// 	{
// 		var tempobj=form.elements[i]
// 		
// 		switch(tempobj.type)
// 		{
// 			case 'checkbox':
// 			{	
// 				if((tempobj.checked=="1")&&(tempobj.name.substring(0,2)=="s_")){				
// 					scritto=true;
// 					pass=true;
// 				}
// 				if((tempobj.checked!="1")&&(tempobj.name.substring(0,2)=="r_"))
// 				{
// 					alert(message_o + ' "' + tempobj.name.substring(2,tempobj.name.length) + '".');
// 					fatal=true;
// 					return false;
// 				}
// 									
// 				break;
// 			}
// 			case 'radio':
// 			{
// 				if((tempobj.checked=="1")&&(tempobj.name.substring(0,2)=="s_"))
// 					scritto=true;
// 			
// 				if((tempobj.checked=="1")&&(tempobj.name.substring(0,2)=="r_"))
// 				{	
// 					pass=true;
// 				}
// 								
// 				break;
// 			}			
// 			default:
// 			{
// 				if((tempobj.value!='')&&(tempobj.name.substring(0,2)=="s_")){				
// 					scritto=true;
// 					pass=true;
// 				}
// 				if((tempobj.value=='')&&(tempobj.name.substring(0,2)=="r_"))
// 				{
// 					alert(message_o + ' "' + tempobj.name.substring(2,tempobj.name.length) + '".');
// 					fatal=true;
// 					return false;
// 				}
// 				
// 				break;
// 			}
// 		}
// 	}			
// 	if(scritto==false || pass==false) {
// 		return false
// 	}
// 	else
// 		return true;
// }
// 
// function validaForm2 (form, button)  {
// 	var pass=false
// 	var passchek=false
// 	var numchek=0
// 	for (i=0;i<form.length;i++){
// 	var tempobj=form.elements[i]
// 	if (tempobj.name.substring(0,2)=="r_") {
// 		if (tempobj.type=="text"||tempobj.type=="textarea" ||tempobj.type=="password" || tempobj.type=="select-one") {
// 			if (tempobj.value=='')  {
// 			alert("Dati incompleti");
// 			return false;
// 			}
// 			}
// 		else {
// 			if ((tempobj.type=="radio")&&tempobj.checked=="1")  {
// 			passchek=true;
// 			}
// 			numchek++;
// 			}
// 		}
// 	}
// 	if (passchek || numchek==0) {
// 		for (i=0;i<form.length;i++){
// 			var tempobj=form.elements[i]
// 			if (tempobj.name.substring(0,2)=="r_") {
// 				tempobj.name=tempobj.name.substring(2,tempobj.name.length);
// 			}
// 		}
// 		return true;
// 		}
// 	else
// 		alert("Dati incompleti");
// 	return false;
// }
// function validaForm (form, button)  {
// 	var ret=validaForm2 (form, button);
// 	if (ret) {
// 		form.submit();
// 		return true;
// 	}
// 	else
// 		return false;
// 	}
// 
// function checkdate(objName) {
// var datefield = objName;
// if (chkdate(objName) == false) {
// datefield.select();
// alert('Attenzione, formato data non corretto');
// datefield.focus();
// return false;
// }
// else {
// return true;
//    }
// }
// function chkdate(objName) {
// var strDatestyle = "EU";
// var strDate;
// var strDateArray;
// var strDay="";
// var strMonth="";
// var strYear="";
// var intday;
// var intMonth;
// var intYear;
// var booFound = false;
// var datefield = objName;
// //var strSeparatorArray = new Array("-"," ","/",".");
// //unico separatore ammesso
// var strSeparatorArray = new Array("/");
// var intElementNr;
// var err = 0;
// strDate = datefield.value;
// if (strDate.length < 1) {
// return true;
// }
// 
// for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
// if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
// strDateArray = strDate.split(strSeparatorArray[intElementNr]);
// if (strDateArray.length != 3) {
// err = 1;
// return false;
// }
// else {
// strDay = strDateArray[0];
// strMonth = strDateArray[1];
// strYear = strDateArray[2];
// }
// booFound = true;
//    }
// else
// return false;
// }
// if (booFound == false) {
// if (strDate.length>5) {
// strDay = strDate.substr(0, 2);
// strMonth = strDate.substr(2, 2);
// strYear = strDate.substr(4);
//    }
// }
// if (strYear.length == 2) {
// strYear = '20' + strYear;
// }
// // US style
// intday = parseInt(strDay, 10);
// if (isNaN(intday)) {
// err = 2;
// return false;
// }
// intMonth = parseInt(strMonth, 10);
// if (isNaN(intMonth)) {
// err = 3;
// return false;
// }
// intYear = parseInt(strYear, 10);
// if (isNaN(intYear)) {
// err = 4;
// return false;
// }
// if (intMonth>12 || intMonth<1) {
// err = 5;
// return false;
// }
// if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
// err = 6;
// return false;
// }
// if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
// err = 7;
// return false;
// }
// if (intMonth == 2) {
// if (intday < 1) {
// err = 8;
// return false;
// }
// if (LeapYear(intYear) == true) {
// if (intday > 29) {
// err = 9;
// return false;
// }
// }
// else {
// if (intday > 28) {
// err = 10;
// return false;
// }
// }
// }
// //datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
// return true;
// }
// function LeapYear(intYear) {
// if (intYear % 100 == 0) {
// if (intYear % 400 == 0) { return true; }
// }
// else {
// if ((intYear % 4) == 0) { return true; }
// }
// return false;
// }
// 
// function formato (form,field,min,max,type)  {
// 	if (field.value=="") {
// 		return true;
// 	}
// 	if (type=="intero") {
// 		vValue=parseInt(field.value);
// 		vStr="Il valore non  un numero intero"
// 	} else {
// 		vValue=parseFloat(field.value);
// 		vStr="Il valore non  un numero"
// 		}
// 
// 	if (isNaN(vValue)||vValue!=field.value) {
//    		alert(vStr);
// 		field.focus();
// 		field.select();
// 		return false;
// 	} else {
// 		if ((min != -1 && vValue<min)||(max != -1 && vValue>max))  {
// 		alert("Il valore non  nel range corretto");
// 		field.focus();
// 		field.select();
// 		return false;
// 	} else {
// 		return true;
// 		}
// }
// }
