function swap(swapname)
{
document.getElementById(lastswapname).style.display = 'none';
document.getElementById(swapname).style.display = '';
if (swapname!=lastswapname)
{
lastswapname=swapname;
}
}

function mostra(name)
{
lastnamex = lastname + "x";
document.getElementById(lastname).style.display = 'none';
document.getElementById(lastnamex).style.display = '';
if (name!=lastname)
{
namex = name + "x";
vai = "a" + name;
document.getElementById(namex).style.display = 'none';
document.getElementById(name).style.display = '';
// self.location.hash = vai;
lastname=name;
}
else
{
lastname='top';
}

}

function HeureCheck()
{
krucial = new Date;
heure = krucial.getHours();
min = krucial.getMinutes();
sec = krucial.getSeconds();
jour = krucial.getDate();
mois = krucial.getMonth()+1;
annee = krucial.getFullYear();
if (sec < 10)
{
sec0 = "0";
}
else
{
sec0 = "";
}
if (min < 10)
{
min0 = "0";
}
else
{
min0 = "";
}
if (heure < 10)
{
heure0 = "0";
}
else
{
heure0 = "";
}
if (mois < 10)
{
mois0 = "0";
}
else
{
mois0 = "";
}
if (jour < 10)
{
jour0 = "0";
}
else
{
jour0 = "";
}
if (annee < 10)
{
annee0 = "0";
}
else
{
annee0 = "";
}
DinaDate = "" + jour0 + jour + "/" +  mois0 + mois + "/" + annee0 + annee;
total = DinaDate
DinaHeure = heure0 + heure + ":" + min0 + min + ":" + sec0 + sec;
total = DinaHeure
total = DinaDate + " - " + DinaHeure;
document.time.timebox.value = total;
tempo = setTimeout("HeureCheck()", 1000)
}
window.onload = HeureCheck;


function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}


function StripSpacesFromEnds(s)
{
	while((s.indexOf(' ',0) == 0) && (s.length > 1))
	{
		s = s.substring(1,s.length);
	}
	while((s.lastIndexOf(' ') == (s.length - 1) && (s.length > 1)))
	{
		s = s.substring(0,(s.length - 1));
	}
	if((s.indexOf(' ',0) == 0) && (s.length == 1)) s = '';
	return s;
}


function IsItPresent(s,explanation)
{
	s = StripSpacesFromEnds(s);
	if(s.length) return s;
	alert('Per favore inserisci ' + explanation + '.');
	return '';
}


function checkEmail(s_email)
{
	if ((s_email=="") || (s_email=="Indirizzo email")) return true;
	var i = s_email.indexOf(' ',0);
	while(i > -1)
	{
		s_email = s_email.substring(0,i) + 
			s_email.substring((i + 1),s_email.length);
		i = s_email.indexOf(' ',0);
	}
	document.mailing.email.value = s_email;
	if((s_email.length < 6) ||
	   (s_email.indexOf('@',0) < 1) ||
	   (s_email.lastIndexOf('@') != s_email.indexOf('@',0)) ||
	   (s_email.lastIndexOf('@') > (s_email.length - 5)) ||
	   (s_email.lastIndexOf('.') > (s_email.length - 3)) ||
	   (s_email.lastIndexOf('.') < (s_email.length - 4)) ||
	   (s_email.indexOf('..',0) > -1) ||
	   (s_email.indexOf('@.',0) > -1) ||
	   (s_email.indexOf('.@',0) > -1) ||
	   (s_email.indexOf(',',0) > -1))
	{
		alert("L\'indirizzo email \'" + s_email + "\' non e\' valido.\nInseriscine uno corretto!");
		document.mailing.email.value = "Indirizzo email";
		document.mailing.email.focus();
		document.mailing.email.select();
		return false;
	}
}
function checkForm()
{
	s = document.mailing.email.value;
	if ( (s=="") || (s=="Indirizzo email")) 
	{
	alert("Inserisci un indirizzo email!");
	document.mailing.email.value="Indirizzo email";
	document.mailing.email.focus();
	document.mailing.email.select();
	return false;
	}

	s = document.mailing.name.value;
	if ( (s=="") || (s=="Nome e Cognome")) 
	{
	alert("Inserisci il tuo Nome e Cognome!");
	document.mailing.name.value="Nome e Cognome";
	document.mailing.name.focus();
	document.mailing.name.select();
	return false;
	}

	s = document.mailing.city.value;
	if ( (s=="") || (s=="Citta'")) 
	{
	alert("Inserisci la Citta'!");
	document.mailing.city.value="Citta'";
	document.mailing.city.focus();
	document.mailing.city.select();
	return false;
	}
}

function votazione() {
	var cnt = -1;
	for (var i=vota.voto.length-1; i > -1; i--) {
		if (vota.voto[i].checked) {cnt = i; i = -1;}
	}
	if (cnt == -1) alert("Prima esprimi il tuo giudizio scegliendo dall'elenco di sinistra, poi premi il bottone 'vota!'");
	if (cnt > -1) return true;
	else return false;
}

function checkCommento()
{
	s = document.vota.comment.value;
	if ( (s=="") || (s=="scrivi qui il tuo commento...") ) 
	{
	alert("Prima inserisci un commento, poi clicca 'invia'!");
	document.vota.comment.focus();
	document.vota.comment.select();
	return false;
	}
}

