//  MODULI
function OG_ImgAlert(form) {
 	var email = document[form].email.value;
 	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if (email!="") {
  
  if (!email_reg_exp.test(email)) {
           document.alertimg.src="img/alert.gif";
        }
	 else {
 		   document.alertimg.src="img/trasp2.gif";
        }
	}
	 else {
 		   document.alertimg.src="img/trasp2.gif";
        }
}
function OG_noMail(input) {
	var el=document.getElementById(input);
 	var email = el.value;
 	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if (email!="") {
  
  if (!email_reg_exp.test(email)) {
           alert("indirizzo e-mail non corretto");
		   el.focus();
        }
	}
	/* else {
 		   document.alertimg.src="imgs/trasp2.gif";
        }*/
}
function getRadioButtonValue(radio) {
	if(radio==null)
	return "";
	if(radio.checked)
	return radio.value;
	for (var i = 0; i < radio.length; i++)
		if (radio[i].checked)	
	return radio[i].value;
	return ""
}

function OG_ComtrolloInformativa(form) {
	returnVal_1 = getRadioButtonValue(document[form].accetto);
	if (returnVal_1 == '' || returnVal_1 == -1) {
		document.alertimg3.src="img/alert_accettoA.gif";
	} else {
		document.alertimg3.src="img/trasp2.gif";
	}
}

function OG_ControlloModulo(form) {
	if (document[form].nome.value != "") {
		var nome= "ok";	  
	}
	if (document[form].cognome.value != "") {
  		var cognome= "ok";	  
	}
  	
	switch (form) {
	case 'f_info':
		if (document[form].tel.value != "") {
  			var tel= "ok";	  
  		}
		if (document[form].posizione.value != "") {
	  		var posizione= "ok";	  
		}
		if (document[form].email.value != "") {
	  		var email= "ok";	  
		}
		if (nome=="ok" && cognome=="ok" && posizione=="ok" && tel=="ok" && email=="ok"){
	  		document.alertimg3.src="img/trasp2.gif";
        	document[form].submit();
     	} else {
	  		document.alertimg3.src="img/alert_form.gif";
  		}
		break
	case 'f_acq':
		if (document[form].azienda.value != "") {
			var azienda= "ok";	  
		}
		if (document[form].posizione.value != "") {
			var posizione= "ok";	  
		}
		if (document[form].email.value != "") {
	  		var email= "ok";	  
  		}
		if (nome=="ok" && cognome=="ok" && azienda=="ok" && posizione=="ok" && email=="ok"){
  			document.alertimg3.src="img/trasp2.gif";
       		document[form].submit();
   	 	} else {
  			document.alertimg3.src="img/alert_form.gif";
		}
		break	
	}
}

function OG_validate(field) {
	var valid = "0123456789"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}

	if (ok == "no") {
		document.alertimg2.src="img/alert_cap.gif";
		field.focus();
		field.select();
	} else {
 	   document.alertimg2.src="img/trasp2.gif";
	}
}
//  End Moduli
