//Funzioni comuni per Medilink
//Le funzioni contenute in questo file vengono importate in tutte le pagine del sito.
//Le funzioni definite sono comuni a tutti gli elementi del sito.
//Attenzione tutte le funzioni sono compatibili in Explorer 5.0+

//Variabili globali
var defaultStatusBarInterval;
var statusValue = "";

//Funzioni per il controllo del menu laterale di navigazione delle pagine
//Funzione per mostrare o nascondere le voci di una sezione
function showHideSectionMenu(num, name, list) {
	//Apre o chiude i menu delle sezioni.
	//Se un menu è già aperto e si tenta di aprirne un altro allora il primo viene chiuso.
	var line;
	var status;
	hideSectionMenues(list);
	line = document.getElementById("line" + name + "0");
	if (line.style.display == "inline") {
		status = true;
	} else {
		status = false;
	}
	for (var count = 0; count <= num; count++){
		line = document.getElementById("line" + name + count);
		if (status == true) {
			line.style.display = "none";
		} else if (status == false) {
			line.style.display = "inline";
		}
	}
}
//funzione per aprire all'inizio il menu in relazione alla pagina selezionata
function openMenuOnOpen(page) {
	//All'id page corrisponde la posizione di arrayVoices
	var arrayVoices = new Array("serv", "prod", "cont", "partner", "forma", "down", "forum", "link");
	var arrayVoicesSubelements = new Array(7, 2, 0, 1, 3, 0, 0, 0);
	var thelist = "";
	for (var counter = 0; counter < arrayVoices.length; counter++) {
		if (arrayVoicesSubelements[counter] != 0) {
			thelist += arrayVoices[counter] + "-" + arrayVoicesSubelements[counter] + ",";
		}
	}
	thelist = thelist.substring(0, thelist.length);
	if (page != -1) {
		var voice = arrayVoices[page];
		var voiceSubelements = arrayVoicesSubelements[page];
		var stringOtherElements = "";
		if (voiceSubelements != 0) {
			for (var counter = 0; counter < arrayVoices.length; counter++) {
					if (arrayVoicesSubelements[counter] != 0) {
						stringOtherElements += arrayVoices[counter] + "-" + arrayVoicesSubelements[counter] + ",";
					}
			}
			stringOtherElements = stringOtherElements.substring(0, stringOtherElements.length);
			showHideSectionMenu(voiceSubelements, voice, stringOtherElements);
		} else {
			hideSectionMenues(thelist);
		}
	} else {
		hideSectionMenues(thelist);
	}
}
//Funzione per inizializzare i menu della pagina o per effettuare un hiding multiplo
function hideSectionMenues(list) {
	//Il parametro passa un array di stringhe
	//Ogni stringa contiene due elementi divisi da uno score: la sezione, il numero di elementi per ognuna
	var elements = list.split(",");
	var line;
	for (var count = 0; count < elements.length; count++){
		for (var subcount = 0; subcount <= elements[count].split("-")[1]; subcount++){
			line = document.getElementById("line" + elements[count].split("-")[0] + subcount);
			line.style.display = "none";
		}
	}
}

//Funzioni di controllo generico
//Funzione per allargare l'intera finestra alla capacità risolutiva del video e la posiziona al centro
function maximizeWindow() {
	var widthScreenResolution = window.screen.width;
	var heightScreenResolution = window.screen.height;
	window.resizeTo(widthScreenResolution, heightScreenResolution);
	window.moveTo(0, 0);
}
//Funzione per andare ad una determinata pagina
function goPage(page) {
	window.location.href = page;
}
//Funzione per settare il valore di default della barra in basso nella finestra del browser
function setDefaultStatusBarValue(val) {
	statusValue = getTotalDate() + " - " + val;
	defaultStatusBarValue = window.setInterval("window.status = statusValue", 500);
}
//Funzione per ritornare una data formattata in lungo
function getTotalDate() {
	var objDate = new Date();
	var theDay = objDate.getDate();
	var theWeek = objDate.getDay();
	var theMonth = objDate.getMonth();
	var theYear = objDate.getFullYear();
	switch (theWeek) {
		case 0: theWeek = "Domenica"; break;
		case 1: theWeek = "Lunedì"; break;
		case 2: theWeek = "Martedì"; break;
		case 3: theWeek = "Mercoledì"; break;
		case 4: theWeek = "Giovedì"; break;
		case 5: theWeek = "Venerdì"; break;
		case 6: theWeek = "Sabato"; break;
	}
	switch (theMonth) {
		case 0: theMonth = "Gennaio"; break;
		case 1: theMonth = "Febbraio"; break;
		case 2: theMonth = "Marzo"; break;
		case 3: theMonth = "Aprile"; break;
		case 4: theMonth = "Maggio"; break;
		case 5: theMonth = "Giugno"; break;
		case 6: theMonth = "Luglio"; break;
		case 7: theMonth = "Agosto"; break;
		case 8: theMonth = "Settembre"; break;
		case 9: theMonth = "Ottobre"; break;
		case 10: theMonth = "Novembre"; break;
		case 11: theMonth = "Dicembre"; break;
	}
	return (theWeek + " " + theDay + " " + theMonth + " " + theYear)
}
//Funzione per cambiare pagina
function goPage(page) {
	window.location.href = page;
}
function popup() 
{ 
window.open('Images/Certificato.jpg','Immagine','resizable=no,width=730,height=1131') 
}
function popupMOD() 
{ 
window.open('../Images/Certificato.jpg','Immagine','resizable=no,width=730,height=1131') 
}
