// Common functions

function popitup(name,url,w,h,scrollbars,dirs) {
	var newwindow = '';
	if (!newwindow.closed && newwindow.location) {
		newwindow.location.href = url;
		}
	else {
		newwindow=window.open(url,name,'scrollbars='+scrollbars+',resizable=yes,directories='+dirs+',location='+dirs+',status='+dirs+',titlebar='+dirs+',toolbar='+dirs+',menubar='+dirs+',width='+w+',height='+h+',left=20,top=0');
		if (!newwindow.opener) newwindow.opener = self;
		}
	if (window.focus) {newwindow.focus()}
	return false;
	}

function conferma_eliminazione() {
	return confirm("ATTENZIONE! Confermi la cancellazione? Questa operazione è irreversibile.");
	}

function validatenews(form) {
	var ret=true;
	var emptytext="<p>&nbsp;<\/p>";
	var filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if (form.nome.value=="" || !filtro.test(form.email.value)) {
		alert ("Per iscriverti alla newsletter, riempi entrambi i campi nome ed email e riprova.");
		form.nome.focus();
		ret=false;
		}
	if (form.nome.value!="" && form.email.value!="" && !form.consenso.checked) {
		alert ("Senza il consenso al trattamento dei dati personali non è possibile portare a termine l'iscrizione. Leggi l'informativa sulla privacy e fai clic su accetto per effettuare l'iscrizione.");
		form.consenso.focus();
		ret=false;
		}
	return ret
	}
	
//
// Almanacco
//
function almanacco (year,month,day,legale,S) {
var tz=1; // TIMEZONE: GMT+1
var lat=41.6;
var lon=12.3;
var sign_name = ['','ARIETE','TORO','GEMELLI','CANCRO','LEONE','VERGINE','BILANCIA','SCORPIONE','SAGITTARIO','CAPRICORNO','ACQUARIO','PESCI'];
var tresh = [0,19,20,21,22,22,22,22,21,21,19,18,20];
var sign = month-3; // segno: 1=ariete
if (sign<=0) sign += 12; 
if (day>=tresh[month]) sign += 1;
if (sign>12) sign -= 12; 

sunRiseSet(year, month, day, lat, lon);
var sris_h = Math.floor(sRiseT);
var sris_m = "00" + Math.floor((sRiseT - sris_h)*60);
var sset_h = Math.floor(sSetT);
var sset_m = "00" + Math.floor((sSetT - sset_h)*60);
sset_m = sset_m.substr(sset_m.length-2);
sris_m = sris_m.substr(sris_m.length-2);
var dur_h = sset_h-sris_h; // durata del giorno in ore
var dur_m = sset_m-sris_m; // durata del giorno in minuti
if (dur_m < 0) {
	dur_m += 60;
	dur_h -= 1;
	}
document.write ('Il Sole sorge alle ');
document.write (sris_h + tz + legale + ":" + sris_m);
document.write ("<br \/>tramonta alle ");
document.write (sset_h + tz + legale + ":" + sset_m);
document.write ('<br \/><strong>Durata del giorno:<\/strong><br \/>');
document.write (dur_h + " h " + dur_m + " min");					
document.write ('<br \/><strong>Segno zodiacale:<br \/><\/strong> ' + sign_name[sign] +'<img src="' + S + 'img\/segno' + sign + '.gif" hspace="5" vspace="0" align="top" alt="" \/>');
}
