//Definizione dell'altezza minima in base alla risoluzione utilizzata
//Prendo in considerazione le altezze tipiche: 720 - 768 - 800 - 854 / 960 - 1024 - 1050 - 1080 / 1200 / 1536 - 1600
hrisoluzione = window.screen.height;
if ((hrisoluzione < 855) && (hrisoluzione > 719)){
	altezza = 588;
	altezzaAtt = 528;
	altezzaIni = 648;
} else if ((hrisoluzione <1081) && (hrisoluzione > 959)){
	altezza = 658;
	altezzaAtt = 668;
	altezzaIni = 648;
} else if (hrisoluzione  == 1200){
	altezza = 798;
	altezzaAtt = 798;
	altezzaIni = 798;
} else if ((hrisoluzione <1601) && (hrisoluzione > 1499)){
	altezza = 858;
	altezzaAtt = 858;
	altezzaIni = 858;
}

hmainMoz = altezza.toString() + 'px';
hmenuMoz = (altezza - 20).toString() + 'px';
hcontenutiMoz = (altezza - 30).toString() + 'px';

hmainIE = (altezza + 20).toString() + 'px';
hmenuIE = altezza.toString() + 'px';
hcontenutiIE = (altezza - 10).toString() + 'px';

hmainAtt = altezzaAtt.toString() + 'px';
hmenuAtt = (altezzaAtt - 20).toString() + 'px';
hcontenutiAtt = (altezzaAtt - 30).toString() + 'px';

hmainIniMoz = altezzaIni.toString() + 'px';
hmenuIniMoz = (altezzaIni - 20).toString() + 'px';
hcontenutiIniMoz = (altezzaIni - 30).toString() + 'px';

hmainIniIE = (altezzaIni + 10).toString() + 'px';
hmenuIniIE = (altezzaIni - 10).toString() + 'px';
hcontenutiIniIE = (altezzaIni - 20).toString() + 'px';



//Funzione di precaricamento delle immagini del menu
function preload(){
	var immagini=new Array()
    for (cont=0;cont<preload.arguments.length;cont++){
        	immagini[cont]=new Image()
          	immagini[cont].src=preload.arguments[cont]
     }
}

function callPreload(){
	if ((navigator.appName == "Microsoft Internet Explorer") && ((navigator.appVersion.toString().indexOf('MSIE 6.0') != -1) || (navigator.appVersion.toString().indexOf('MSIE 5.0') != -1) || (navigator.appVersion.toString().indexOf('MSIE 4.0') != -1)))
		preload("images/buttonHomeIe6.jpg", "images/buttonCartaIe6.jpg", "images/buttonAttivitaIe6.jpg", "images/buttonIniziativeIe6.jpg", "images/buttonAssociazioniIe6.jpg", "images/buttonFotoIe6.jpg", "images/buttonLinkIe6.jpg", "images/buttonArchivioIe6.jpg", "images/logo1.jpg", "images/mail.jpg", "images/casadellapace.jpg", "images/w3c.jpg", "images/cssw3c.jpg", "images/accw3c.jpg");
 	else
 		preload("images/buttonHome.png","images/buttonCarta.png", "images/ buttonAttivita.png", "images/buttonIniziative.png",  "images/buttonAssociazioni.png", "images/buttonFoto.png", "images/buttonLink.png", "images/buttonArchivio.png", "images/logo1.jpg", "images/mail.jpg", "images/casadellapace.jpg", "images/w3c.jpg", "images/cssw3c.jpg", "images/accw3c.jpg")
}


//Funzione che gestisce l'evento onMouseOver dei vari pulsanti
function checkMouseOver(type){
	if (navigator.appName.toString() == "Netscape"){
		if (type == "carta")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[3].className = "VISITED2";
		else if (type == "attivitaeservizi")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[5].className = "VISITED3";
		else if (type == "iniziative")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[7].className = "VISITED4";
		else if (type == "associazioni")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[9].className = "VISITED5";
		else if (type == "foto")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[11].className = "VISITED6";
		else if (type == "link")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[13].className = "VISITED7";
		else if (type == "archivio")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[15].className = "VISITED8";
	} else if (navigator.appName.toString() == "Microsoft Internet Explorer"){
		if (type == "carta")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[1].className = "VISITED2";
		else if (type == "attivitaeservizi")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[2].className = "VISITED3";
		else if (type == "iniziative")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[3].className = "VISITED4";
		else if (type == "associazioni")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[4].className = "VISITED5";
		else if (type == "foto")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[5].className = "VISITED6";
		else if (type == "link")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[6].className = "VISITED7";
		else if (type == "archivio")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[7].className = "VISITED8";		
	}
}
		
	
//Funzione che gestisce l'evento onMouseOut dei vari pulsanti
function checkMouseOut(nameFrame){
	var contentFrame;
	if (navigator.appName.toString() == "Netscape"){
		contentFrame = this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[3].contentDocument.baseURI;
		if (contentFrame.indexOf(nameFrame) == -1){
			if (nameFrame == "carta")
				this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[3].className = "PULSANTE";
			else if (nameFrame == "attivitaeservizi")
				this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[5].className = "PULSANTE";
			else if (nameFrame == "iniziative")
				this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[7].className = "PULSANTE";
			else if (nameFrame == "associazioni")
				this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[9].className = "PULSANTE";
			else if (nameFrame == "foto")
				this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[11].className = "PULSANTE";
			else if (nameFrame == "link")
				this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[13].className = "PULSANTE";
			else if (nameFrame == "archivio")
				this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[15].className = "PULSANTE";
		}
	} else if (navigator.appName.toString() == "Microsoft Internet Explorer"){
		contentFrame = this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[1].contentWindow.location.toString();
		if (contentFrame.indexOf(nameFrame) == -1){
			if (nameFrame == "carta")
				this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[1].className = "PULSANTE";
			else if (nameFrame == "attivitaeservizi")
				this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[2].className = "PULSANTE";
			else if (nameFrame == "iniziative")
				this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[3].className = "PULSANTE";
			else if (nameFrame == "associazioni")
				this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[4].className = "PULSANTE";
			else if (nameFrame == "foto")
				this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[5].className = "PULSANTE";
			else if (nameFrame == "link")
				this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[6].className = "PULSANTE";
			else if (nameFrame == "archivio")
				this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[7].className = "PULSANTE";
		}			
	}
}
	
	
//Funzione che si occupa di ripulire i pulsanti dal colore settato con la proprietà 'VISITED'
function cleanButton(nameFrame){
	if (navigator.appName.toString() == "Netscape") {
		if (nameFrame != "carta")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[3].className = "PULSANTE";
		if (nameFrame != "attivitaeservizi")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[5].className = "PULSANTE";
		if (nameFrame != "iniziative")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[7].className = "PULSANTE";
		if (nameFrame != "associazioni")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[9].className = "PULSANTE";
		if (nameFrame != "foto")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[11].className = "PULSANTE";
		if (nameFrame != "link")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[13].className = "PULSANTE";
		if (nameFrame != "archivio")
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].childNodes[15].className = "PULSANTE";
	} else if (navigator.appName.toString() == "Microsoft Internet Explorer") {
		if (nameFrame != "carta")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[1].className = "PULSANTE";
		if (nameFrame != "attivitaeservizi")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[2].className = "PULSANTE";
		if (nameFrame != "iniziative")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[3].className = "PULSANTE";
		if (nameFrame != "associazioni")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[4].className = "PULSANTE";
		if (nameFrame != "foto")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[5].className = "PULSANTE";
		if (nameFrame != "link")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[6].className = "PULSANTE";
		if (nameFrame != "archivio")
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[7].className = "PULSANTE";
	}
}


//Funzione che definisce le dimensioni del frame centrale in base al contenuto del file caricato
function defineFrame(nameFrame){
	if (navigator.appName.toString() == "Netscape") {
		if (nameFrame == "loading"){
			contentFrame = this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[3].contentDocument.baseURI;
			if (contentFrame.indexOf('home') != -1) nameFrame = 'home';
			else if (contentFrame.indexOf('carta') != -1) nameFrame = 'carta';
			else if (contentFrame.indexOf('attivitaeservizi') != -1) nameFrame = 'attivitaeservizi';
			else if (contentFrame.indexOf('iniziative') != -1) nameFrame = 'iniziative';
			else if (contentFrame.indexOf('associazioni') != -1) nameFrame = 'associazioni';
			else if (contentFrame.indexOf('foto') != -1) nameFrame = 'foto';
			else if (contentFrame.indexOf('link') != -1) nameFrame = 'link';
			else if (contentFrame.indexOf('archivio') != -1) nameFrame = 'archivio';
		}
		if (nameFrame == "home"){
			this.document.childNodes[1].childNodes[1].childNodes[7].style.height = hmainMoz;
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].style.height = hmenuMoz;
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[3].style.height = hcontenutiMoz;
		} else if (nameFrame == "carta"){
			this.document.childNodes[1].childNodes[1].childNodes[7].style.height = '2178px';
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].style.height = '2158px';
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[3].style.height = '2148px';
		} else if (nameFrame == "attivitaeservizi"){
			this.document.childNodes[1].childNodes[1].childNodes[7].style.height = hmainAtt;
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].style.height = hmenuAtt;
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[3].style.height = hcontenutiAtt;
		} else if (nameFrame == "iniziative"){
			this.document.childNodes[1].childNodes[1].childNodes[7].style.height = hmainIniMoz;
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].style.height = hmenuIniMoz;
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[3].style.height = hcontenutiMoz;
		} else if (nameFrame == "associazioni"){
			this.document.childNodes[1].childNodes[1].childNodes[7].style.height = '1188px';
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].style.height = '1168px';
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[3].style.height = '1158px';
		} else if (nameFrame == "foto"){
			this.document.childNodes[1].childNodes[1].childNodes[7].style.height = hmainMoz;
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].style.height = hmenuMoz;
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[3].style.height = hcontenutiMoz;
		} else if (nameFrame == "link"){
			this.document.childNodes[1].childNodes[1].childNodes[7].style.height = hmainMoz;
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].style.height = hmenuMoz;
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[3].style.height = hcontenutiMoz;
		} else if (nameFrame == "archivio"){
			this.document.childNodes[1].childNodes[1].childNodes[7].style.height = '1188px';
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[1].style.height = '1168px';
			this.document.childNodes[1].childNodes[1].childNodes[7].childNodes[3].style.height = '1158px';
		}
	} else if (navigator.appName.toString() == "Microsoft Internet Explorer") {
		if (nameFrame == "loading"){
			contentFrame = this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[1].contentWindow.location.toString();
			if (contentFrame.indexOf('home') != -1) nameFrame = 'home';
			else if (contentFrame.indexOf('carta') != -1) nameFrame = 'carta';
			else if (contentFrame.indexOf('attivitaeservizi') != -1) nameFrame = 'attivitaeservizi';
			else if (contentFrame.indexOf('iniziative') != -1) nameFrame = 'iniziative';
			else if (contentFrame.indexOf('associazioni') != -1) nameFrame = 'associazioni';
			else if (contentFrame.indexOf('foto') != -1) nameFrame = 'foto';
			else if (contentFrame.indexOf('link') != -1) nameFrame = 'link';
			else if (contentFrame.indexOf('archivio') != -1) nameFrame = 'archivio';
		}
		if (nameFrame == "home"){
			this.document.childNodes[1].childNodes[1].childNodes[3].style.height = hmainIE;
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].style.height = hmenuIE;
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[1].style.height = hcontenutiIE;
		} else if (nameFrame == "carta"){
			this.document.childNodes[1].childNodes[1].childNodes[3].style.height = '2228px';
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].style.height = '2208px';
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[1].style.height = '2198px';
		} else if (nameFrame == "attivitaeservizi"){
			this.document.childNodes[1].childNodes[1].childNodes[3].style.height = hmainAtt;
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].style.height = hmenuAtt;
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[1].style.height = hcontenutiAtt;
		} else if (nameFrame == "iniziative"){
			this.document.childNodes[1].childNodes[1].childNodes[3].style.height = hmainIniIE;
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].style.height = hmenuIniIE;
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[1].style.height = hcontenutiIniIE;
		} else if (nameFrame == "associazioni"){
			this.document.childNodes[1].childNodes[1].childNodes[3].style.height = '1308px';
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].style.height = '1288px';
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[1].style.height = '1278px';
		} else if (nameFrame == "foto"){
			this.document.childNodes[1].childNodes[1].childNodes[3].style.height = hmainIE;
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].style.height = hmenuIE;
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[1].style.height = hcontenutiIE;
		} else if (nameFrame == "link"){
			this.document.childNodes[1].childNodes[1].childNodes[3].style.height = hmainIE;
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].style.height = hmenuIE;
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[1].style.height = hcontenutiIE;
		} else if (nameFrame == "archivio"){
			this.document.childNodes[1].childNodes[1].childNodes[3].style.height = '1308px';
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].style.height = '1288px';
			this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[1].style.height = '1278px';
		}
	}
}


//Serie di funzioni che vengono richiamate esclusivamente se il browser utilizzato è una versione di Explorer minore della 7.0
//che si occupano di lanciare le funzioni cleanButton() e defineFrame passandogli il parametro corretto. Ci si è avvalsi di
//questo sistema perchè non risulta possibile chiamare una funzione javascript con passaggio di parametri nell'innerHTML.

function setButtonHome(){
	cleanButton('home');
	defineFrame('home');
}

function setButtonCarta(){
	cleanButton('carta');
	defineFrame('carta')
}

function setButtonAttivita(){
	cleanButton('attivitaeservizi');
	defineFrame('attivitaeservizi');
}

function setButtonIniziative(){
	cleanButton('iniziative');
	defineFrame('iniziative');
}

function setButtonAssociazioni(){
	cleanButton('associazioni');
	defineFrame('associazioni');
}

function setButtonFoto(){
	cleanButton('foto');
	defineFrame('foto');
}

function setButtonLink(){
	cleanButton('link');
	defineFrame('link');
}

function setButtonArchivio(){
	cleanButton('archivio');
	defineFrame('archivio');
}


//Funzione che si occupa di settare l'immagine jpg nei pulsanti se il browser è una
//versione di Explorer inferiore alla 7. Viene spostato l'evento onclick sull'immagine e non più sul div
function setJpg(){
	if ((navigator.appName == "Microsoft Internet Explorer") && ((navigator.appVersion.toString().indexOf('MSIE 6.0') != -1) || (navigator.appVersion.toString().indexOf('MSIE 5.0') != -1) || (navigator.appVersion.toString().indexOf('MSIE 4.0') != -1))){
		
		//Pulsante Home
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[0].attributes[66].nodeValue = null;
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[0].childNodes[0].innerHTML = "<img src='images/buttonHomeIe6.jpg' alt='Home' style='border:none; margin-left:79px; margin-top:17px' onclick='setButtonHome()'>";
		
		//Pulsante Carta
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[1].attributes[66].nodeValue = "";
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[1].childNodes[0].innerHTML = "<img src='images/buttonCartaIe6.jpg' alt='Carta degli Intenti' style='border:none; margin-left:8px; margin-top:17px' onclick='setButtonCarta()'>";
		
		//Pulsante Attivita e Servizi
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[2].attributes[66].nodeValue = "";
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[2].childNodes[0].innerHTML = "<img src='images/buttonAttivitaIe6.jpg' alt='Attivita e Servizi' style='border:none; margin-left:13px; margin-top:18px' onclick='setButtonAttivita()'>";
		
		//Pulsante Iniziative
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[3].attributes[66].nodeValue = "";
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[3].childNodes[0].innerHTML = "<img src='images/buttonIniziativeIe6.jpg' alt='Iniziative' style='border:none; margin-left:50px; margin-top:18px' onclick='setButtonIniziative()'>";

		//Pulsante Associazioni
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[4].attributes[66].nodeValue = "";
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[4].childNodes[0].innerHTML = "<img src='images/buttonAssociazioniIe6.jpg' alt='Associazioni' style='border:none; margin-left:40px; margin-top:18px' onclick='setButtonAssociazioni()'>";

		//Pulsante Foto
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[5].attributes[66].nodeValue = "";
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[5].childNodes[0].innerHTML = "<img src='images/buttonFotoIe6.jpg' alt='Foto' style='border:none; margin-left:80px; margin-top:18px' onclick='setButtonFoto()'>";
		
		//Pulsante Link
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[6].attributes[66].nodeValue = "";
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[6].childNodes[0].innerHTML = "<img src='images/buttonLinkIe6.jpg' alt='Link' style='border:none; margin-left:77px; margin-top:18px' onclick='setButtonLink()'>";

		//Pulsante Archivio
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[7].attributes[66].nodeValue = "";
		this.document.childNodes[1].childNodes[1].childNodes[3].childNodes[0].childNodes[7].childNodes[0].innerHTML = "<img src='images/buttonArchivioIe6.jpg' alt='Archivio' style='border:none; margin-left:59px; margin-top:18px' onclick='setButtonArchivio()'>";
	}
}
