function get(sid){

	if (document.all) {
	return document.all[sid];
	}
	else if (document.layers) {
	return document.layers[sid];
	}
	else if (document.getElementById) {
	return document.getElementById(sid);
	}
}

// Data e ora
	var vecchio = "";
	var update = 1;
	var giorno_della_sett = new Array(7);
		giorno_della_sett[0] = "Dom";
		giorno_della_sett[1] = "Lun";
		giorno_della_sett[2] = "Mar";
		giorno_della_sett[3] = "Mer";
		giorno_della_sett[4] = "Gio";
		giorno_della_sett[5] = "Ven";
		giorno_della_sett[6] = "Sab";

	var mese_del_anno = new Array(12);
		mese_del_anno[0] = "1";
		mese_del_anno[1] = "2";
		mese_del_anno[2] = "3";
		mese_del_anno[3] = "4";
		mese_del_anno[4] = "5";
		mese_del_anno[5] = "6";
		mese_del_anno[6] = "7";
		mese_del_anno[7] = "8";
		mese_del_anno[8] = "9";
		mese_del_anno[9] = "10";
		mese_del_anno[10] = "11";
		mese_del_anno[11] = "12";

	var ricarica_ora = new Array(3);
		ricarica_ora[0] = 0;
		ricarica_ora[1] = 1000;
		ricarica_ora[2] = 60000;

	function visualizza_orologio() {
		if (vecchio == "die") { return; }
	
		var Digitale = new Date();
		var giorno = Digitale.getDay();
		var mese_anno = Digitale.getDate();
		var mese = Digitale.getMonth();
		var anno = Digitale.getFullYear();
		var ore = Digitale.getHours();
		var minuti = Digitale.getMinutes();
		var secondi = Digitale.getSeconds();

		if (minuti <= 9) { minuti = "0"+minuti; }
		if (secondi <= 9) { secondi = "0"+secondi; }

	// Struttura sintattica e grafica dell'orologio
		orologio = '';
	
		orologio += '<span class="orologio">'+giorno_della_sett[giorno]+' '+mese_anno+'.'+mese_del_anno[mese]+'.'+anno+' ore '+ore+':'+minuti+'</span>';

		get("stampa_orologio").innerHTML = orologio;

		setTimeout("visualizza_orologio()",ricarica_ora[update]);
}


function fotofade(obj,which)	{
	if(document.getElementById){
		if (which==true){
			if(document.all){
				obj.filters.alpha.opacity=100
				}
			else{
				obj.style.setProperty("-moz-opacity", 1, "");
				}
			}
		else
			{
			if(document.all){
				obj.filters.alpha.opacity=40
				}
							else{
				obj.style.setProperty("-moz-opacity", .4, "");
				}
			}
		}
	}


function giocatoreselect(url){
if(url != "nogo"){
location.href=url;
}
}




function control() {
  if (get('_nome').value == "") {
     alert('Obbligatorio il nome');
     get('_nome').focus();
    }
    else  if (get('_testo').value == "") {
      alert('Obbligatorio il testo');
      get('_testo').focus();
    }
     else  if (get('_antispam').value == "") {
      alert('Inserisci il codice');
      get('_antispam').focus();
    }
    else{
    get('formreg').submit();
    }
    
}

function addemote(icon){
var text = get('_testo').value;
get('_testo').value = text+icon+" ";
get('_testo').focus();
}

function addemotemp(icon){
var text = get('testomp').value;
get('testomp').value = text+icon+" ";
get('testomp').focus();
}


function leggendicon() {
if (get('leggendicon').className == "hidden"){
get('leggendicon').className = "";
get('leggendicontxt').innerHTML = "nascondi leggenda icone";
}
else{
get('leggendicon').className = "hidden";
get('leggendicontxt').innerHTML = "vedi leggenda icone";
}

}


function impocontrol(){
var passa = get('pass1reg').value;
var passb = get('pass2reg').value;

if (passa != ""){

if ((passa.length < 5) || (passa.length > 15)){
alert('La password deve essere minimo 5 lettere e massimo 15');
get('pass1reg').focus();
}
else if (passa != passb){
alert('Le due password non coincidono');
get('pass2reg').focus();
}
else{
get('formreg').submit();
}
}
else{
get('formreg').submit();
}
}

function regcontrol(){
var nick = get('nickreg').value;
var user = get('userreg').value;
var passa = get('pass1reg').value;
var passb = get('pass2reg').value;
var email = get('emailreg').value;
var filtro  =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

if (nick == ""){
alert('Non hai inserito un nick');
get('nickreg').focus();
}
else if ((nick.length < 3) || (nick.length >15)){
alert('Il nick non rispetta la lunghezza minima o massima di lettere');
get('nickreg').focus();
}
else if (user == ""){
alert('Manca un user');
get('userreg').focus();
}
else if ((user.length < 3) || (user.length > 10)){
alert('Il campo user non ha minimo 3 lettere o sorpassa le 10');
get('userreg').focus();
}
else if (passa == ""){
alert('Devi scegliere una password');
get('pass1reg').focus();
}
else if ((passa.length < 5) || (passa.length > 15)){
alert('La password deve essere minimo 5 lettere e massimo 15');
get('pass1reg').focus();
}
else if (passa != passb){
alert('Le due password non coincidono');
get('pass2reg').focus();
}
else if (email == ""){
alert('Email obbligatoria per accertare il proprietario');
get('emailreg').focus();
}
else if (!filtro.test(email)) {
alert('Email inserita non valida, deve essere valida');
get('emailreg').focus();
}
else{
get('formreg').submit();
}
}

function passlostcontrol(){
var email = get('email').value;
var user = get('user').value;
var filtro  =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

if (email == ""){
alert('Devi pur inserire un email per ricevere la password');
get('email').focus();
}
else if (!filtro.test(email)) {
alert('Email non corretta, controlla di nuovo che sia giusta');
get('email').focus();
}
else if (user == ""){
alert('Devi inserire anche user');
get('user').focus();
}
else if ((user.length < 3) || (user.length > 10)){
alert('Il campo user deve avere minimo 3 e massimo 10 lettere');
get('user').focus();
}
else{
get('formreg').submit();
}
}

function passlostcontro_reply(){
var pass = get('pass').value;
var passb = get('passb').value;

if (pass == ""){
alert('Scegliere una nuova password');
get('pass').focus();
}
else if ((pass.length < 3) || (pass.length > 10)){
alert('La password deve avere un minimo di 5 lettere e un massimo di 15');
get('pass').focus();
}
else if (pass != passb){
alert('Le due password non coincidono');
get('passb').focus();
}
else{
get('formreg').submit();
}
}



function controlsendmp(){
var oggettomp = get('oggettomp').value;
var testomp = get('testomp').value;


if (oggettomp == ""){
alert('Hai dimenticato di inserire un oggetto');
get('oggettomp').focus();
}
else if (oggettomp.length > 100 ){
alert('Oggetto troppo lungo, masismo 100 caratteri');
get('oggettomp').focus();
}

else if (testomp == ""){
alert('Non hai inserito alcun testo');
get('testomp').focus();
}
else if (testomp.length > 2000 ){
alert('Il testo supera i caratteri consentiti');
get('testomp').focus();
}

else{
get('formreg').submit();
}
}

function deletemp(id){
  if (confirm("Sicuro di voler eliminare questo messaggio?")) {
    location.href="deletemp.php?id="+id;
    }
}

function deleteall(){
  if (confirm("Sicuro di voler eliminare tutti i messaggi selezionati?")) {
    get('leggimp_id').submit();
    }
}


function checkallcheckbox(checkbox){
if(get('checkall').value == "off"){
var Value = true;
    var obj_checkbox = get('leggimp_id').elements[checkbox];
    var conta_checkbox = obj_checkbox.length;
    for(var i = 0; i < conta_checkbox; i++)
        obj_checkbox[i].checked = Value;
        get('checkall').value="on";
}
else{
var Value = false;
    var obj_checkbox = get('leggimp_id').elements[checkbox];
    var conta_checkbox = obj_checkbox.length;
    for(var i = 0; i < conta_checkbox; i++)
        obj_checkbox[i].checked = Value;
        get('checkall').value="off";
}

}

function webcontact(){
var nome_contact = get('nome_contact').value;
var email_contact = get('email_contact').value;
var contatto_contact = get('contatto_contact').value;
var testo_contact = get('testo_contact').value;
var filtro  =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

if (nome_contact == ""){
alert('Non hai inserito un nome e cognome');
get('nome_contact').focus();
}
else if ((nome_contact.length < 5) || (nome_contact.length >40)){
alert('Un nome e cognome di meno di 5 lettere non viene considerato tale');
get('nome_contact').focus();
}
else if (testo_contact == ""){
alert('Manca il testo descrittivo');
get('testo_contact').focus();
}
else if ((testo_contact.length < 10) || (testo_contact.length > 1000)){
alert('Il testo deve essere descrittivo, meno di 10 lettere non lo sono');
get('testo_contact').focus();
}
else if ((email_contact == "") && (contatto_contact == "")){
alert('Devi inserire un email oppure un contatto telefonico o indirizzo per poter ricevere una risposta');
get('email_contact').focus();
}
else if ((email_contact != "") && (!filtro.test(email_contact)) ){
alert('Email inserita non valida, deve essere valida');
get('email_contact').focus();
}
else{
get('formreg').submit();
}
}


function aprigb() {


if(get('scrivigb').className== "hidden"){
get('scrivigb').className = ""
get('tip').innerHTML = "<b>Chiudi modulo per scrivere</b>";
}
else{
get('scrivigb').className = "hidden"
get('tip').innerHTML = "<b>Scrivi un commento</b>";
}
}

 
 function showfoto(nr, alte, larghe, desc) {
var img = nr;
var maxalt = 550;
var maxlarghe = 940;
if(desc != ""){
desc = desc+"<br />";
var maxalt = 530;
}

if(alte >= maxalt){
nalte = maxalt;
var nlarghe = larghe * maxalt;
var olarghe = nlarghe / alte;

if(olarghe >=maxlarghe){
olarghe = maxlarghe;
nalte = maxlarghe * alte;
nalte = nalte / larghe;
}
}
else{
olarghe = larghe;
nalte = alte;
}

var maltezza = nalte / 2;
maltezza = maltezza + 10;
var mlarghezza = olarghe / 2;
var margini = "margin-left: -"+mlarghezza+"px; margin-top: -"+maltezza+"px;";
var maxwh = "width: "+olarghe+"px; height: "+nalte+"px;";
var margininav = "width: "+olarghe+"px; margin-left: -"+mlarghezza+"px; margin-top: -"+maltezza+"px;";get('top').className ="top";
get('top').innerHTML="<div class='topwhite' style='"+margini+"' >"+desc+"<img  onclick='zaam();' src='"+img+"' style='"+maxwh+"' alr='' /></div>";
get('back').innerHTML ="<div class='back' onclick='zaam();'>&nbsp;</div>";

var objs = get('back');
if(document.getElementById){

			if(document.all){
				objs.filters.alpha.opacity=65
				}
			else{
				objs.style.setProperty("-moz-opacity", 0.65, "");
				}
			}
		else{
			if(document.all){
				objs.filters.alpha.opacity=65
				}
							else{
				objs.style.setProperty("-moz-opacity", 0.65, "");
				}
			
		}

}


function setavanti (numero){
get(numero).className = "navrighton";
}
function setindietro (numero){
get(numero).className = "navlefton";
}
function setindietronull (numero){
get(numero).innerHTML = "&nbsp;";
get(numero).className = "navleft";
}
function setavantinull (numero){
get(numero).innerHTML = "&nbsp;";
get(numero).className = "navright";
}
function setcloseon(){
get('close').className = "clearbothfotoon";
}
function setcloseoff(){
get('close').className = "clearbothfoto";
}

function shawfoto(nr, alte, larghe, desc, nav) {
var end = get('end').value;
if(nav == "1"){
showfoto(nr, alte, larghe, desc);
}
var img = nr;
var maxalt = 550;
var maxlarghe = 940;
if(desc != ""){
desc = desc+"<br />";
var maxalt = 530;
}

if(alte >= maxalt){
nalte = maxalt;
var nlarghe = larghe * maxalt;
var olarghe = nlarghe / alte;

if(olarghe >=maxlarghe){
olarghe = maxlarghe;
nalte = maxlarghe * alte;
nalte = nalte / larghe;
}
}
else{
olarghe = larghe;
nalte = alte;
}

var idnav = nav;
var status = "indifferente";


if(nav == end){
status = "ultima";
navprec = --nav;


var navpiupre = "idnav"+navprec;
var nexidfotopre = get(navpiupre).value;

var imgfilepiupre= "imgfile"+navprec;
var imgfilepre = get(imgfilepiupre).value;

var altezzapiupre= "altezza"+navprec;
var altezzapre = get(altezzapiupre).value;

var larghezzapiupre = "larghezza"+navprec;
var larghezzapre = get(larghezzapiupre).value;

var nomepiupre= "nome"+navprec;
var nomepre = get(nomepiupre).value;
}
else if (nav == "1"){
status = "prima";
navprox = ++nav;

var navpiu = "idnav"+navprox;
var nexidfoto = get(navpiu).value;

var imgfilepiu= "imgfile"+navprox;
var imgfile = get(imgfilepiu).value;

var altezzapiu= "altezza"+navprox;
var altezza = get(altezzapiu).value;

var larghezzapiu= "larghezza"+navprox;
var larghezza = get(larghezzapiu).value;

var nomepiu= "nome"+navprox;
var nome = get(nomepiu).value;
}
else{

navprox = ++nav;
navprec = --nav;
navprec = --navprec;

var navpiupre = "idnav"+navprec;
var nexidfotopre = get(navpiupre).value;

var imgfilepiupre= "imgfile"+navprec;
var imgfilepre = get(imgfilepiupre).value;

var altezzapiupre= "altezza"+navprec;
var altezzapre = get(altezzapiupre).value;

var larghezzapiupre = "larghezza"+navprec;
var larghezzapre = get(larghezzapiupre).value;

var nomepiupre= "nome"+navprec;
var nomepre = get(nomepiupre).value;



var navpiu = "idnav"+navprox;
var nexidfoto = get(navpiu).value;

var imgfilepiu= "imgfile"+navprox;
var imgfile = get(imgfilepiu).value;

var altezzapiu= "altezza"+navprox;
var altezza = get(altezzapiu).value;

var larghezzapiu= "larghezza"+navprox;
var larghezza = get(larghezzapiu).value;

var nomepiu= "nome"+navprox;
var nome = get(nomepiu).value;
}

var maltezza = nalte / 2;
maltezza = maltezza + 10;
var mlarghezza = olarghe / 2;
var margini = "margin-left: -"+mlarghezza+"px; margin-top: -"+maltezza+"px;";
var maxwh = "width: "+olarghe+"px; height: "+nalte+"px;";
var maxhset = nalte - 50;
if(desc != ""){
maxhset = nalte - 35;
}
var maxh = "height: "+maxhset+"px;";
var margininav = "width: "+olarghe+"px; margin-left: -"+mlarghezza+"px; margin-top: -"+maltezza+"px;";get('top').className ="top";
get('top').innerHTML="<div class='topwhite' style='"+margini+"' >"+desc+"<img   src='"+img+"' style='"+maxwh+"' alr='' /></div>";
get('back').innerHTML ="<div class='back' onclick='zaam();'>&nbsp;</div>";
get('fotonav').className ="top";

if(status == "prima"){
get('fotonav').innerHTML= "<div class='fotonav' style='"+margininav+"' ><div style='"+maxh+"' class='navleft' >&nbsp;</div><div id='tre' style='"+maxh+"' class='navright' onclick=\"shawfoto('"+imgfile+"', '"+altezza+"', '"+larghezza+"', '"+nome+"', '"+navprox+"')\" onmouseover=\"setavanti('tre');\" onmouseout=\"setavantinull('tre');\">&nbsp;</div><div id='close' class='clearbothfoto' onclick='zaam();' onmouseover='setcloseon();' onmouseout='setcloseoff();'>&nbsp;</div></div>";
}
else if (status == "ultima"){
get('fotonav').innerHTML= "<div class='fotonav' style='"+margininav+"' ><div  id='quattro' style='"+maxh+"' class='navleft' onclick=\"shawfoto('"+imgfilepre+"', '"+altezzapre+"', '"+larghezzapre+"', '"+nomepre+"', '"+navprec+"')\" onmouseover=\"setindietro('quattro');\" onmouseout=\"setindietronull('quattro');\">&nbsp;</div><div class='navright'>&nbsp;</div><div id='close' class='clearbothfoto' onclick='zaam();' onmouseover='setcloseon();' onmouseout='setcloseoff();'>&nbsp;</div></div>";
}
else{
get('fotonav').innerHTML= "<div class='fotonav' style='"+margininav+"' ><div  id='cinque' style='"+maxh+"' class='navleft' onclick=\"shawfoto('"+imgfilepre+"', '"+altezzapre+"', '"+larghezzapre+"', '"+nomepre+"', '"+navprec+"')\" onmouseover=\"setindietro('cinque');\" onmouseout=\"setindietronull('cinque');\">&nbsp;</div><div id='sei' style='"+maxh+"' class='navright' onclick=\"shawfoto('"+imgfile+"', '"+altezza+"', '"+larghezza+"', '"+nome+"', '"+navprox+"')\" onmouseover=\"setavanti('sei');\" onmouseout=\"setavantinull('sei');\">&nbsp;</div><div id='close' class='clearbothfoto' onclick='zaam();' onmouseover='setcloseon();' onmouseout='setcloseoff();'>&nbsp;</div></div>";
}



var objs = get('back');

if(document.getElementById){

			if(document.all){
				objs.filters.alpha.opacity=65
				}
			else{
				objs.style.setProperty("-moz-opacity", 0.65, "");
				}
			}
		else{
			if(document.all){
				objs.filters.alpha.opacity=65
				}
							else{
				objs.style.setProperty("-moz-opacity", 0.65, "");
				}
			
		}

}


function zaam() {
 get('top').innerHTML="";
get('back').innerHTML="";
get('fotonav').innerHTML= "";
}
 

 function showmap() { 
get('mapgoogle').innerHTML="<iframe width=\"502\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://maps.google.it/maps?f=q&amp;source=s_q&amp;hl=it&amp;geocode=&amp;q=&amp;g=camignolo&amp;ie=UTF8&amp;t=h&amp;ll=46.106048,8.936155&amp;spn=0.001302,0.002693&amp;z=18&amp;output=embed\"></iframe>";
}
 
 
 
 
 
 
 
 





