function initForms(){
	aInput = document.getElementsByTagName("input")
	aTextAreas = document.getElementsByTagName("textarea")
	aButtons = [];
	aText = [];
	
	for (var i=0; i<aInput.length; i++){
		switch(aInput[i].type){
			case 'text':
				aText[aText.length] = aInput[i];
				break;
			case 'password':
				aText[aText.length] = aInput[i];
				break;	
			case 'button':
				aButtons[aButtons.length] = aInput[i];
				break;
		}
	}
	
	for (var i=0; i<aButtons.length; i++){
		aButtons[i].onmouseover = function(){
			this.className = 'buttonhover'
		}
		aButtons[i].onmouseout = function(){
			this.className = 'button'
		}
	}
	
	for (var i=0; i<aText.length; i++){
		aText[i].onfocus = function(){
			this.className = 'textfocus'
		}
		aText[i].onblur = function(){
			this.className = 'text'
		}
	}

	for (var i=0; i<aTextAreas.length; i++){
		aTextAreas[i].onfocus = function(){
			this.className = 'textfocus'
		}
		aTextAreas[i].onblur = function(){
			this.className = 'text'
		}
	}		

}

//form validator
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("Please, type a valid email address!");
	    myform.mittente.focus();
		return;
  	}
	if(myform.destinatari.value == "" || myform.destinatari.value.indexOf('@') < 0 || 

myform.destinatari.value.indexOf('.') < 0 || myform.destinatari.value.length < 6){
	    alert("Please, type a valid email address!");
	    myform.destinatari.focus();
		return;
  	}
	
	//controllo oggetto
	if (myform.oggetto.value == ""){
		alert("Please, type something into the field \'By\'!");
		myform.oggetto.focus();
		return;
	}
	
	//controllo testo
	if (myform.corpo.value == ""){
	    alert("Please, type something into the textarea \'Message\'!");
	    myform.corpo.focus();
		return;
	}
	
	myform.submit();
}






//alert('ao che stai a fa')
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(NameOfCookie, value, expiredays) 
{ var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + escape(value) + 	((expiredays == null) ? ";PATH=/" : ";PATH=/; expires=" + ExpireDate.toGMTString());
}

function checkInfoCookie(previewMode){
	if (getCookie('cInfo')== null){ 
		if (previewMode != '1'){
			document.location.href = '/servizio/1375/infopage.asp'	
			}else{
			document.location.href = '../bin/browse.asp?csite=sovraintendenza2004&template=infopage%2esmt&id=info'
		}	
	}else{
		if (previewMode != '1'){
			document.location.href = '/schede/ricercamonumenti.asp'	
			}else{
			document.location.href = '../bin/browse.asp?csite=sovraintendenza2004&template=ricercamonumenti%2esmt&id=schede'		
		}
	}	
}


function delCookie (NameOfCookie) 
{ if (getCookie(NameOfCookie)) {
	document.cookie = NameOfCookie + "=" +
	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

}


function addToCart(url){
	var cookieContent = getCookie('printCart');
	if ((cookieContent == null) || (cookieContent == ";" )) cookieContent = '';
	if (cookieContent.indexOf(url) == -1){
		setCookie('printCart', cookieContent + url + ';');
		alert('la pagina ' + url.split('|')[0] + ' è stata aggiunta correttamente a "il mio Archivio"');
	}else{
		alert('la pagina ' + url.split('|')[0] + ' è già presente ne "il mio Archivio"');
	}
}

function fullScreen(theURL) {

window.open(theURL, '', 'fullscreen=yes, scrollbars=yes, width=' + screen.width + ', height='+ screen.height);
}