
function checkEMail(objValue)
{
	apos=objValue.indexOf("@");
	dotpos=objValue.lastIndexOf(".");
	lastpos=objValue.length-1;
	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
	{return false;}
	else {return true;}
}
function mySubmit(msg,msg2){
	document.getElementById('alertMSG').innerHTML = '';
	document.getElementById('Fnome_tbl_contatti').style.backgroundColor='#FFFFFF';
	document.getElementById('Fcognome_tbl_contatti').style.backgroundColor='#FFFFFF';
	document.getElementById('Femail_tbl_contatti').style.backgroundColor='#FFFFFF';
	document.getElementById('Fmessaggio_tbl_contatti').style.backgroundColor='#FFFFFF';
	document.getElementById('autCell').style.backgroundColor='#FFFFFF';
	document.getElementById('validateCode').style.backgroundColor='#FFFFFF';
	if(document.form1.Fnome_tbl_contatti.value == ''){
	   document.getElementById('alertMSG').innerHTML = msg;
	   document.getElementById('Fnome_tbl_contatti').style.backgroundColor='#FF0000';
	   return;
	}
	if(document.form1.Fcognome_tbl_contatti.value == ''){
	   document.getElementById('alertMSG').innerHTML = msg;
	   document.getElementById('Fcognome_tbl_contatti').style.backgroundColor='#FF0000';
	   return;
	}
	if(document.form1.Femail_tbl_contatti.value == ''){
	   document.getElementById('alertMSG').innerHTML = msg;
	   document.getElementById('Femail_tbl_contatti').style.backgroundColor='#FF0000';
	   return;
	}else{
		if(checkEMail(document.form1.Femail_tbl_contatti.value) == false){
		   document.getElementById('alertMSG').innerHTML = msg2;
		   document.getElementById('Femail_tbl_contatti').style.backgroundColor='#FF0000';
		   return;
		}
		}
	if(document.form1.autorizzo.checked == false){
	   document.getElementById('alertMSG').innerHTML = msg;
	   document.getElementById('autCell').style.backgroundColor='#FF0000';
	   return;	   
	 }
	if(document.form1.validateCode.value == ''){
	   document.getElementById('alertMSG').innerHTML = msg;
	   document.getElementById('validateCode').style.backgroundColor='#FF0000';
	   return;	   
	 }
	document.form1.submit();
}
function checkExtWork(fileName){
    $myName =  fileName.toLowerCase()
	if(($myName.lastIndexOf('.pdf') == -1) && ($myName.lastIndexOf('.doc') == -1) && ($myName.lastIndexOf('.docx') == -1)){
		return false;
	   }else{
		return true;
	}
}
function mySubmitWork(mconfirm,msg,msg2){
	if(confirm(mconfirm)){
		document.getElementById('alertMSG').innerHTML = '';
		document.getElementById('Fnome_tbl_workwithus').style.backgroundColor='#FFFFFF';
		document.getElementById('Fcognome_tbl_workwithus').style.backgroundColor='#FFFFFF';
		
		document.getElementById('Fgiornonascita_tbl_workwithus').style.backgroundColor='#FFFFFF';
		document.getElementById('Fmesenascita_tbl_workwithus').style.backgroundColor='#FFFFFF';
		document.getElementById('Fannonascita_tbl_workwithus').style.backgroundColor='#FFFFFF';
		
		document.getElementById('Fluogonascita_tbl_workwithus').style.backgroundColor='#FFFFFF';
		document.getElementById('Fnazionalita_tbl_workwithus').style.backgroundColor='#FFFFFF';
		document.getElementById('Fstatocivile_tbl_workwithus').style.backgroundColor='#FFFFFF';
		
		document.getElementById('Findirizzo_tbl_workwithus').style.backgroundColor='#FFFFFF';
		document.getElementById('Fcap_tbl_workwithus').style.backgroundColor='#FFFFFF';
		document.getElementById('Fcitta_tbl_workwithus').style.backgroundColor='#FFFFFF';
		document.getElementById('Fnazione_tbl_workwithus').style.backgroundColor='#FFFFFF';
		document.getElementById('Femail_tbl_workwithus').style.backgroundColor='#FFFFFF';
		document.getElementById('Ftelefono_tbl_workwithus').style.backgroundColor='#FFFFFF';
		
		document.getElementById('autCell').style.backgroundColor='#FFFFFF';
		document.getElementById('validateCode').style.backgroundColor='#FFFFFF';
		
		if(document.form1.Fnome_tbl_workwithus.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Fnome_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}
		if(document.form1.Fcognome_tbl_workwithus.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Fcognome_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}
		if(document.form1.Fgiornonascita_tbl_workwithus.value == '' || document.form1.Fmesenascita_tbl_workwithus.value == '' || document.form1.Fannonascita_tbl_workwithus.value == '' ){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Fgiornonascita_tbl_workwithus').style.backgroundColor='#FF0000';
		   document.getElementById('Fmesenascita_tbl_workwithus').style.backgroundColor='#FF0000';
		   document.getElementById('Fannonascita_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}
		if(document.form1.Fluogonascita_tbl_workwithus.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Fluogonascita_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}
		if(document.form1.Fnazionalita_tbl_workwithus.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Fnazionalita_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}
		if(document.form1.Fstatocivile_tbl_workwithus.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Fstatocivile_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}
		if(document.form1.Findirizzo_tbl_workwithus.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Findirizzo_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}
		if(document.form1.Fcap_tbl_workwithus.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Fcap_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}
		if(document.form1.Fcitta_tbl_workwithus.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Fcitta_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}
		if(document.form1.Fnazione_tbl_workwithus.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Fnazione_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}
		if(document.form1.Femail_tbl_workwithus.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Femail_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}else{
			if(checkEMail(document.form1.Femail_tbl_workwithus.value) == false){
			   document.getElementById('alertMSG').innerHTML = msg2;
			   document.getElementById('Femail_tbl_workwithus').style.backgroundColor='#FF0000';
			   return;
			}
		}
		if(document.form1.Ftelefono_tbl_workwithus.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('Ftelefono_tbl_workwithus').style.backgroundColor='#FF0000';
		   return;
		}
			
			
		if(document.form1.autorizzo.checked == false){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('autCell').style.backgroundColor='#FF0000';
		   return;	   
		 }
		if(document.form1.validateCode.value == ''){
		   document.getElementById('alertMSG').innerHTML = msg;
		   document.getElementById('validateCode').style.backgroundColor='#FF0000';
		   return;	   
		 }
		 if(document.form1.allegato_tbl_workwithus.value != '' && !checkExtWork(document.form1.allegato_tbl_workwithus.value)){
			document.form1.allegato_tbl_workwithus.value = '';
		 }
		document.form1.submit();
	}
}
