function form1_validator(formid){
myform = document.getElementById(formid);
//controllo email
	if(myform.mittente.value == "" || myform.mittente.value.indexOf('@') < 0 || myform.mittente.value.indexOf('.') < 0 || myform.mittente.value.length < 6){
	    alert("Inserire un indirizzo e-mail valido");
	    myform.mittente.focus();
		return false;
  	}
	
	//controllo oggetto
	if (myform.oggetto.value == ""){
		alert("Inserire l'oggetto del messaggio");
		myform.oggetto.focus();
		return false;
	}
	
	//controllo testo
	if (myform.corpo.value == ""){
	    alert("Inserire il testo del messaggio");
	    myform.corpo.focus();
		return false;
	}
	
	myform.submit();
}

/*****************************  FORM REGISTRAZIONE NEWSLETTER VALIDATOR *************************************************/
function formNewsletter(formid){
	myform = document.getElementById(formid);
	//controllo email
	if(myform.email.value == "" || myform.email.value.indexOf('@') < 0 || myform.email.value.indexOf('.') < 0 ){
	    alert("Inserire un indirizzo e-mail valido.");
	    myform.email.focus();
	}else{
		//if(myform.password.value == ""){
		//    alert("Inserire una password per accedere all\'archivio della newsletter.");
		//    myform.password.focus();
		//}else{
			myform.submit();
	  	//}
  	}
}






	function controlaAltezzaElemento(element,action,versione){
		elem = document.getElementById(element)		
		if(action != 'stampa' ){
			if (elem.offsetHeight > 387 || elem.offsetHeight < 250 )
			{
				elem.style.height = 387 + 'px'
				elem.style.overflow = 'auto' 
			}
		}else{
			if(versione != 'eng'){
				strTextConfirm = 'Stai passando ad una visualizzazione Stampa della pagina'
			}else{
				strTextConfirm = 'You are going towards the display of "Print the Page"'				
			}
				if(confirm(strTextConfirm)){
				elem.style.overflow = 'hidden' 			
				elem.style.height = 'auto'
				window.print();
			}
		}	
	}

			
			
	function cambiaContenuto(idElem,contenitore,value)
	{
		var sContenitore = document.getElementById(contenitore)
		var elem = document.getElementById(idElem)
		var sCookie = GetCookie('btAttivo');
		
			sContenitore.innerHTML = value ;		

			if( sCookie != idElem )
			{
				document.getElementById(sCookie).className = 'btNavNoActive';
			}
			
			if (elem.className != 'btNavActive')
			{
				SetCookie ('btAttivo',idElem);
				elem.className = 'btNavActive';
			}
		
	}			
			
			


function getCookieVal (offset) 

{

var endstr = document.cookie.indexOf (";", offset);

if (endstr == -1)

endstr = document.cookie.length;

return unescape(document.cookie.substring(offset, endstr));

}

function GetCookie (name) 

{

var arg = name + "=";

var alen = arg.length;

var clen = document.cookie.length;

var i = 0;

while (i < clen) 

{

var j = i + alen;

if (document.cookie.substring(i, j) == arg)

return getCookieVal (j);

i = document.cookie.indexOf(" ", i) + 1;

if (i == 0) 

break; 

}

return null;

}

function SetCookie (name, value) 

{
var argv = SetCookie.arguments;

var argc = SetCookie.arguments.length;

var expires = (2 < argc) ? argv[2] : null;

var path = (3 < argc) ? argv[3] : null;

var domain = (4 < argc) ? argv[4] : null;

var secure = (5 < argc) ? argv[5] : false;

document.cookie = name + "=" + escape (value) +

((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +

((path == null) ? "" : ("; path=" + path)) +

((domain == null) ? "" : ("; domain=" + domain)) +

((secure == true) ? "; secure" : "");

}

