function caricaFoto(img){
	w=200;
	h=120;
	var left = Math.floor((screen.width-w)/2);
	var top = Math.floor((screen.height-h)/2);
	var setting="location=no,menubar=no,resizable=no,scrollbars=yes,toolbar=no,width="+w+",height="+h+",top="+top+",left="+left;
	newWin=window.open("openimg.php?img="+img, 'popUp', setting);
	newWin.focus();
}

function gId(id){
	return document.getElementById(id);
}



function caricaFotoPhotoGallery(url) {
	wid = window.open(url, "popupimmagine", 'toolbar=no,directories=no,resizable=NO,menubar=no,scrollbars=NO,width=100,height=100');
	wid.focus();
}

function APG(URL,width,height) {

var left = (screen.width/2) - width/2;
var top = (screen.height/2) - height/2;
var styleStr = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;

window.open(URL,"", styleStr);
}

function resize(){


var scrResHeight = document.getElementById('divBoxFucsiaMiddle').offsetHeight;
var h = Number(scrResHeight);
document.getElementById("divBoxFogliaOffertaMiddleDescrizioneOfferta").style.height = h;
document.getElementById("divBoxFucsiaMiddle").style.height = h;


}



function gId(id){
	return document.getElementById(id);
}

function getItem(id)
 {
     var itm = false;
     if(document.getElementById)
         itm = document.getElementById(id);
     else if(document.all)
         itm = document.all[id];
     else if(document.layers)
         itm = document.layers[id];

     return itm;
 }

 function toggleItem(id)
 {
     itm = getItem(id);

     if(!itm)
         return false;

     if(itm.style.display == 'none')
         itm.style.display = '';
     else
         itm.style.display = 'none';

     return false;
 }
 
 
 
 
 function checkFormNewsLetterHome(){
 	msgError="";
 
 
 	if(gId("email_home").value!=""){
 		var email=gId("email_home").value;
 		var filter=/^([a-zA-Z0-9_\-])+([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{2,4})$/;
 		if(!filter.test(email)){
 			msgError+="L'indirizzo di posta non è corretto\n";
 		}
 	}
 
 	if(gId("email_home").value==""){
 		msgError+="L'indirizzo di posta non è corretto\n";
 	}
 
 
 if(gId("accetta_privacy")){
 	if(gId("accetta_privacy").checked != true){
 		msgError+="Accetta i termini della privacy\n";
 	}
}
 
 
 	if(msgError!=""){
 		alert(msgError);
 		return false;
 	}
 	return true;
 }
 
 
 function submitNewsLetterHome(op){
 	if(checkFormNewsLetterHome()){
 		document.newsletter_home.operazione_newsletter_home.value=op;
 		document.newsletter_home.submit();
 	}
}