// JavaScript Document

function submitIt(nomeForm) {
	form = document.getElementById(nomeForm);
	myFormElements = form.elements;
	var error = 0;

	for(i=0;i<myFormElements.length;i++) {
		document.getElementById("cont_"+myFormElements[i].name).style.backgroundColor = '';
		if(myFormElements[i].type == 'checkbox') {
			if(myFormElements[i].name == 'privacy' && myFormElements[i].checked == false) {
				error++;
				document.getElementById("cont_"+myFormElements[i].name).style.backgroundColor = '#d0d7da';
			}
		} else {
			if(myFormElements[i].value=="") {
				//if(i != 0 && i != 8 && i != 11) {
					error++;
					document.getElementById("cont_"+myFormElements[i].name).style.backgroundColor = '#d0d7da';
				//}
			}
		}
	}
	if(error > 0) {
		alert("Tutti i campi sono obbligatori");
	} else {
		form.submit();
	}
}

function submitForm(nomeForm) {
	form = document.getElementById(nomeForm);
	form.submit();
}

function resetIt(nomeForm) {
	form = document.getElementById(nomeForm);
	myFormElements = form.elements;
	for(i=0;i<myFormElements.length;i++) {
		document.getElementById("cont_"+myFormElements[i].name).style.backgroundColor = '';
	}
	form.reset();
}

function allineaVert(id) {
	hImg = document.getElementById('img'+id).offsetHeight;
	if(hImg>120) {
		topImg = (120-hImg)/2;
		document.getElementById('img'+id).style.marginTop = topImg+'px';
	}
}

function detectFF() {
	if(navigator.userAgent.indexOf("Firefox")!=-1){
		trovato = 'FF';
	} else if (navigator.appVersion.indexOf("MSIE")!=-1){
		trovato = 'IE';
	} else {
		trovato = 'UNKNOW';
	}
}

function ridOscura() {
	width = document.body.offsetWidth;
	height = document.body.offsetHeight;
	
	cont1 = document.getElementById('bodyInt');
	cont2 = document.getElementById('contenitore');
	contH = cont1.offsetHeight+cont2.offsetHeight;
	contW = document.getElementById('bloccoSup').scrollWidth;
	
	detectFF();
	
	if(height == null || height == 0) {
		if (trovato == 'IE') {
			
			height1 = document.documentElement.scrollHeight;
			height2 = document.documentElement.clientHeight;
			if(height1 >= height2) {
				height = height1;
			} else {
				height = height2;
			}
			//alert("IE - "+height);
		} else if (trovato == 'FF') {
			height = document.documentElement.scrollHeight;
			//alert("FF - "+height);
		} else {
			height = document.documentElement.clientHeight;
			//alert("ELSE - "+height);
		}
	}
	
	if(height > contH) {
		h = height;
	} else {
		h = contH;
	}
	
	if(width == null || width == 0) {
		if (trovato == 'IE') {
			
			width1 = document.documentElement.scrollWidth;
			width2 = document.documentElement.clientWidth;
			if(width1 >= width2) {
				width = width1;
			} else {
				width = width2;
			}
			//alert("IE - "+height);
		} else if (trovato == 'FF') {
			width = document.documentElement.scrollWidth;
			//alert("FF - "+height);
		} else {
			width = document.documentElement.clientWidth;
			//alert("ELSE - "+height);
		}
	}
	
	if(width > contW) {
		w = width;
	} else {
		w = contW;
	}
	
	//alert(contW);
	//alert('w='+width+' h='+height);
	element = document.getElementById('oscura');
	element.style.width = w+'px';
	element.style.height = h+'px';
}

function resizePage() {
	height = document.body.scrollHeight;
	if(height == 0) {
		if (trovato == 'IE') {
			height1 = document.documentElement.scrollHeight;
			height2 = document.documentElement.clientHeight;
			if(height1 >= height2) {
				height = height1;
			} else {
				height = height2;
			}
			//alert(trovato);
		} else if (trovato == 'FF') {
			height = document.documentElement.scrollHeight;
			//alert(trovato);
		} else {
			height = document.documentElement.scrollheight;
			//alert(trovato);
		}
	}
	element = document.getElementById('oscura');
	element.style.height = (height)+'px';
	element = document.getElementById('pay');
	element.style.height = (height)+'px';
}

function viewPay(vis) {
	element = document.getElementById('pay');
	if(vis == 1) {
		bytefx.alpha(element, 95);
		element.style.display = 'block';
 	} else {
		document.getElementById('exePay').src = 'blank.asp';
		element.style.display = 'none';
	}
}

function popUp(vis,id,zona) {
	if (vis == 1) {
		rand = Math.floor(Math.random()*99999999);
		pageToLoad = zona+'.asp';
		if(document.body.scrollTop) {	
			document.getElementById('popUp').style.top = (document.body.scrollTop+25)+'px';
		} else {
			document.getElementById('popUp').style.top = (document.documentElement.scrollTop+25)+'px';
		}
		
		if(document.getElementById('popUp').style.display != 'block') {
			ridOscura();
			bytefx.alpha(element, 0);
			bytefx.fade(element, 0, 80, 30, function(){
			});
			element.style.display = 'block';
			document.getElementById('popUp').style.display = 'block';
		}
		completeAHAH.ahah(pageToLoad+'?id='+id+'&rand='+rand,'popUp','0','GET');
	} else {
		completeAHAH.ahah('blank.asp','popUp','0','GET');
		document.getElementById('popUp').style.display = 'none';
		element = document.getElementById('oscura');

		bytefx.fade(element, 80, 0, 30, function(){
			document.getElementById('oscura').style.display = 'none';
		});
		//bytefx.alpha(element, 0);
		
		
	}
}


function S() {
	var sound = document.getElementById('click');
	sound.Play();
}

function ripristinaForm() {
	document.getElementById('target').innerHTML = "";
	document.getElementById('target').style.display = "none";
	document.getElementById('contenitoreForm').style.display = "block";
}


function playSound(preview,div) {
	if (preview == "") {
		alert('nessuna preview disponibile')
	} else {
		divPlay = document.getElementById(div);
		if (divPlayOld == "") {
			divPlayOld = divPlay;
			divPlayOld.style.display = "block";
			var sound = document.getElementById(preview);
			sound.Play();
		} else {
			divPlayOld.style.display = "none";
			divPlayOld = divPlay;
			divPlayOld.style.display = "block";
			var sound = document.getElementById(preview);
			sound.Play();
		}	
	}
	
}

//function popup(vis,div) {
	//if (vis == "si") {
		//document.getElementById('contPopup').style.display = "block";
		//document.getElementById('centerPopup').style.display = "block";
		//document.getElementById(div).style.display = "block";
		//popup.location.href="news.asp?idrand="+idrand;
	//} else {
		//document.location.href="news.asp?idrand=&data=&txtXS=&txtL=";
		//document.getElementById(div).style.display = "none";
		//parent.document.getElementById('centerPopup').style.display = "none";
		//parent.document.getElementById('popupNews').style.display = "none";
		
	//}
//}

function righello(div,active) {
	if(active == 1) {
		nomeDiv = document.getElementById(div).name;
		if(nomeDiv !== "selected") {
			document.getElementById(div).style.background = "#c3cbcf";
		}
	} else {
		nomeDiv = document.getElementById(div).name;
		if(nomeDiv !== "selected") {
			document.getElementById(div).style.background = "none";
		}
	}
}

function righello2(div,active) {
	if(active == 1) {
		document.getElementById(div).style.background = "#ededed";
	} else {
		document.getElementById(div).style.background = "none";
	}
}
	
	
	
//function righelloTunes(div) {
//	alert("ciao");
//	document.getElementById(div).style.background = "#3d80df";
//}
//
//function righelloTunesOut(div,esa) {
//	document.getElementById(div).style.background = esa;
//}
	
	
	
function onMenu(div) {
	var lista_a = document.getElementsByTagName("a");
	for(i=0; i < lista_a.length; i++)
	if(lista_a.item(i).getAttribute("id") == div)
	a = lista_a.item(i);
	a.style.color = "#FF8C00";
	caricaNews = 0;
}

function outMenu(div) {
	var lista_a = document.getElementsByTagName("a");
	for(i=0; i < lista_a.length; i++)
	if(lista_a.item(i).getAttribute("id") == div)
	a = lista_a.item(i);
	a.style.color = "#35535f";
	caricaNews = 0;
}

function onMenuSub(div) {
	document.getElementById(div).style.display = "block";
	caricaNews = 1;
}

function outMenuSub(div) {
	document.getElementById(div).style.display = "none";
	caricaNews = 0;
}


function gotourl(url) {
	//pagina = url+".asp";
	document.location.href=url;
}

function goto(valore) {
	document.location.href = valore;
}


function evidenza(div) {
	document.getElementById(div).style.background = "#c3cbcf";
}


function callServer(id) {
	var path = 'callNews.asp?idrand=';
	var element = document.getElementById('popupNews');
	element.style.display = "block";
	completeAHAH.ahah(path+id,'popupNews','0','GET');
	bytefx.fade(element, 0, 90, 5);
}

// SEZIONE FUNZIONI NAVIGAZIONE SETUP


function callSetup(div,level,level1) {
	var path = 'callSetup.asp'
	completeAHAH.ahah(path,div,'0','GET');
}

function callSetup2(level1,div) {
	
	DivPassato = document.getElementById(div);
	if (DivSelected == "") {
		DivSelected = DivPassato;
		DivSelected.name = "selected";
		DivSelected.style.background = "#ffffff";
		DivSelected.style.color = "#35535f";
	} else {
		DivSelected.name = "";
		DivSelected.style.background = "";
		DivSelected.style.color = "#ffffff";
		DivSelected = DivPassato;
		DivSelected.name = "selected";
		DivSelected.style.background = "#ffffff";
		DivSelected.style.color = "#35535f";
	}
	
	var path = 'callSetup2.asp?level1='+level1;
	var div = 'downBodyInt';
	element = document.getElementById(div);
	
	if (cCount == 0) {
		document.getElementById('downloadBody').style.width = "560px";
		document.getElementById('downBodyInt').style.width = "540px";
		document.getElementById('nifty2').style.display = "none";
		document.getElementById('downloadBody').style.display = "block";

		bytefx.size(
		element,
		{width:540,height:320},
		10,
			function(){
				document.getElementById('downBodyInt').style.overflow = "auto";
				//document.getElementById('downBodyInt').style.overflow-x = "hidden";
				completeAHAH.ahah(path,div,'0','GET');
				cCount = cCount+1
			});
		} else {
			var path = 'blank.asp';
			var div = 'downBodyInt';
			completeAHAH.ahah(path,div,'0','GET');
		
			bytefx.size(
			element,
			{width:540,height:0},
			20,
				function(){				
					bytefx.size(
					element,
					{width:540,height:320},
					10,
						function(){
							var path = 'callSetup2.asp?level1='+level1;
							document.getElementById('downBodyInt').style.overflow = "auto";
							//document.getElementById('downBodyInt').style.overflow-x = "hidden";
							completeAHAH.ahah(path,div,'0','GET');
							cCount = cCount+1
						});
				});	
		}
}


// SEZIONE FUNZIONI NAVIGAZIONE STUDIO


function callStudio(div,level,level1) {
	var path = 'callStudio.asp';
	completeAHAH.ahah(path,div,'0','GET');
}

function callStudio2(level1,div) {
	
	DivPassato = document.getElementById(div);
	if (DivSelected == "") {
		DivSelected = DivPassato;
		DivSelected.name = "selected";
		DivSelected.style.background = "#ffffff";
		DivSelected.style.color = "#35535f";
	} else {
		DivSelected.name = "";
		DivSelected.style.background = "";
		DivSelected.style.color = "#ffffff";
		DivSelected = DivPassato;
		DivSelected.name = "selected";
		DivSelected.style.background = "#ffffff";
		DivSelected.style.color = "#35535f";
	}
	
	var path = 'callStudio2.asp?level1='+level1;
	var div = 'studioContentInt';
	element = document.getElementById(div);
	
	
	if(element.style.height == 0) {
		element = document.getElementById('studioContent');
		bytefx.alpha(element, 0);
		element.style.display = 'block';
		bytefx.fade(element, 0, 100, 10);
		div = 'studioContentInt';
		completeAHAH.ahah(path,div,'0','GET');
	} else {
		element = document.getElementById('studioContent');
		bytefx.fade(element, 100, 0, 10,
			function() {
				div = 'studioContentInt';
				completeAHAH.ahah(path,div,'0','GET');
				bytefx.fade(element, 0, 100, 10);
			}
		);
	}
}


	
	//alert("ok");
//
//	divs = document.getElementsByName('servizio');
//	for(k=0;k<(divs.length);k++) {
//		altezze[k] = divs[k].offsetHeight;
//	}	

	
	var stato = 0;
	var oldId = '';
	
	function servizi(id,stato) {
		
		titolo = document.getElementById('titolo'+id);
		imgArrow = document.getElementById('imgs2_'+id);
		
		if(id != oldId) {
			
			
			element = document.getElementById('s2_'+id);
			imgArrow.src = 'img/arrowOpen.jpg';
			element.style.height = 0;
			element.style.display = 'block';
			
			bytefx.size(
			element,
			{width:700,height:70},
			15,
				function(){
					if(oldId != '') {
						titoloOld = document.getElementById('titolo'+oldId);
						imgArrowOld = document.getElementById('imgs2_'+oldId);
						element = document.getElementById('s2_'+oldId);
						imgArrowOld.src = 'img/arrowClose.jpg';
		
						bytefx.size(
						element,
						{width:700,height:0},
						15,
							function() {
								document.getElementById('s2_'+oldId).style.display = 'none';
								oldId = id;
							}
						)
					} else {
						oldId = id;
					}
					
				}
			)
			
			
			
		} else {
			titoloOld = document.getElementById('titolo'+oldId);
			imgArrowOld = document.getElementById('imgs2_'+oldId);
			element = document.getElementById('s2_'+oldId);
			imgArrowOld.src = 'img/arrowClose.jpg';

			bytefx.size(
			element,
			{width:700,height:0},
			15,
				function(){
					document.getElementById('s2_'+oldId).style.display = 'none';
					oldId = '';
				}	
			)
		}
	}
	
	var statoCorsi = 0;
	var oldIdCorsi = '';
	
	function corsi(id,statoCorsi) {
		
		titolo = document.getElementById('titolo'+id);
		imgArrow = document.getElementById('imgs2_'+id);
		
		if(id != oldIdCorsi) {
			
			
			element = document.getElementById('s2_'+id);
			imgArrow.src = 'img/arrowOpen.jpg';
			element.style.height = 0;
			element.style.display = 'block';
			
			bytefx.size(
			element,
			{width:700,height:200},
			15,
				function(){
					if(oldIdCorsi != '') {
						titoloOld = document.getElementById('titolo'+oldIdCorsi);
						imgArrowOld = document.getElementById('imgs2_'+oldIdCorsi);
						element = document.getElementById('s2_'+oldIdCorsi);
						imgArrowOld.src = 'img/arrowClose.jpg';
		
						bytefx.size(
						element,
						{width:700,height:0},
						15,
							function() {
								document.getElementById('s2_'+oldIdCorsi).style.display = 'none';
								oldIdCorsi = id;
							}
						)
					} else {
						oldIdCorsi = id;
					}
					
				}
			)
			
			
			
		} else {
			titoloOld = document.getElementById('titolo'+oldIdCorsi);
			imgArrowOld = document.getElementById('imgs2_'+oldIdCorsi);
			element = document.getElementById('s2_'+oldIdCorsi);
			imgArrowOld.src = 'img/arrowClose.jpg';

			bytefx.size(
			element,
			{width:700,height:0},
			15,
				function(){
					document.getElementById('s2_'+oldIdCorsi).style.display = 'none';
					oldIdCorsi = '';
				}	
			)
		}
	}


// SEZIONE FUNZIONI NAVIGAZIONE GALLERY


function callGallery(div,level,level1) {
	var path = 'callGallery.asp'
	completeAHAH.ahah(path,div,'0','GET');
}

function callGallery2(level1,div) {
	
	DivPassato = document.getElementById(div);
	if (DivSelected == "") {
		DivSelected = DivPassato;
		DivSelected.name = "selected";
		DivSelected.style.background = "#ffffff";
		DivSelected.style.color = "#35535f";
	} else {
		DivSelected.name = "";
		DivSelected.style.background = "";
		DivSelected.style.color = "#ffffff";
		DivSelected = DivPassato;
		DivSelected.name = "selected";
		DivSelected.style.background = "#ffffff";
		DivSelected.style.color = "#35535f";
		
	}
	
	var path = 'callGallery2.asp?level1='+level1;
	var div = 'downBodyIntG';
	element = document.getElementById(div);
	
	if (cCount == 0) {
		document.getElementById('downloadBodyG').style.width = "660px";
		document.getElementById('downBodyIntG').style.width = "640px";
		document.getElementById('nifty2').style.display = "none";
		document.getElementById('downloadBodyG').style.display = "block";

		bytefx.size(
		element,
		{width:640,height:320},
		10,
			function(){
				document.getElementById('downBodyIntG').style.overflow = "auto";
				//document.getElementById('downBodyInt').style.overflow-x = "hidden";
				completeAHAH.ahah(path,div,'0','GET');
				cCount = cCount+1
			});
		} else {
			var path = 'blank.asp';
			var div = 'downBodyIntG';
			completeAHAH.ahah(path,div,'0','GET');
		
			bytefx.size(
			element,
			{width:640,height:0},
			20,
				function(){				
					bytefx.size(
					element,
					{width:640,height:320},
					10,
						function(){
							var path = 'callGallery2.asp?level1='+level1;
							document.getElementById('downBodyIntG').style.overflow = "auto";
							//document.getElementById('downBodyInt').style.overflow-x = "hidden";
							completeAHAH.ahah(path,div,'0','GET');
							cCount = cCount+1
						});
				});	
		}
}








