// ------------------------------------------------ FUNZIONI --------------------------------
function add_text(text){
	document.form1.testo.value = document.form1.testo.value + text;
}
function open_radio(){
	window.open('streaming-radio.php','radio','noresizable, width=200, height=10');
}
function popup_apri(nome){
	document.getElementById(nome).style.visibility = "visible";
}
// --------------------- BALLOON 
function AM_open_balloon_utente(id,username,userid,sessione){
	// <a href="javascript: AM_messaggio_istantaneo('+id+',\''+username+'\','+userid+',\''+sessione+'\');">messaggio privato</a><br />
	document.all["BALLOON"].innerHTML = '<p><img src="" width="12" height="12" align="right" onclick="AM_close_balloon();" /><a href="blog.php?utente='+id+'&userid='+userid+'&sessione='+sessione+'">blog</a></p>';
	getMouseXY();
	document.getElementById("BALLOON").style.visibility = "visible";
}
function AM_close_balloon(){
	document.getElementById("BALLOON").style.visibility = "hidden";
}
<!--
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false
// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)
// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	} else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	}  
	// catch possible negative values in NS4
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}  
	// show the position values in the form named Show
	// in the text fields named MouseX and MouseY
	document.getElementById("BALLOON").style.left = tempX-5;
	document.getElementById("BALLOON").style.top = tempY-5;
	return true
}
//---------------------------------------------------------------
function avviso(titolo,testo,comando){
	testo.replace("'","\"");
	document.getElementById("POPUP").innerHTML = '<table align="center" width="350"  border="0" cellpadding="20" cellspacing="10" bgcolor="#006699"><tr><td valign="middle" bgcolor="#0099CC"><h1 align="center">' + titolo + '</h1><p align="center">' + testo + '<br><br><br><a href="javascript: ' + comando + ' popup_chiudi(\'POPUP\');" title="CHIUDI">CHIUDI</a><br></p></td></tr></table>';
	popup_apri("POPUP");
	centra("POPUP");
}
function foto(tot,url,n,nomeserata,id_evento){
	rand = Math.random(10000);
	fotocorrente = "";
	prev="";
	next="";
	document.getElementById("POPUP").innerHTML ='<table align="center" width="350"  border="0" cellpadding="20" cellspacing="10" bgcolor="#006699"><tr><td valign="middle" bgcolor="#0099CC"><h1 align="center"> BLACKSOLO GALLERY </h1><p align="center"><img src="http://www.e-green.eu/thumb.php?url=http://www.e-green.eu/'+url+'.jpg&twidth=400&theight=300&quality=95&'+rand+'"><br><br><br>'+prev+'<a href="javascript: popup_chiudi(\'POPUP\');" title="CHIUDI">CHIUDI</a> <a href="http://www.e-green.eu/scarica.php?url='+url+'&nomeserata='+nomeserata+'" title="SCARICA LA FOTO GRANDE">SCARICA GRANDE</a> '+next+'<br></p></td></tr></table>';
	popup_apri("POPUP");
	centra("POPUP");
}
function AM_messaggio_istantaneo(id,username,userid,sessione){
	username.replace("'","\"");
	sessione.replace("'","\"");
	document.getElementById("MESSAGEBOX").innerHTML = '<table align="center" width="300" height="200" border="0" cellpadding="20" cellspacing="10" bgcolor="#0099CC"><tr><td valign="middle" bgcolor="#006699"><img src="http://www.e-green.eu/thumb.php?url=http://www.e-green.eu/foto/utenti/utente'+id+'-1.jpg&twidth=30&theight=30&quality=80" align="left"><h1 align="center">' + username + '</h1><form id="form1" name="form1" method="post" action="?userid='+userid+'&sesseione='+sessione+'"><div align="center"><textarea rows="6" name="testo" type="text" class="input" id="testo" value="" cols="40"></textarea><br><input name="Submit" type="submit" class="button" value="INVIA"></div></form></td></tr></table>';
	popup_apri("MESSAGEBOX");
	centra("MESSAGEBOX");
}
function AM_WEBSPOT(){
	document.getElementById("WEBSPOT").style.visibility = "visible";
	document.getElementById("WEBSPOT").style.top = 0;
}
function popup_chiudi(nome){
	document.getElementById(nome).style.visibility = "hidden";
}
function centra(nome){
	if(nome == "POPUP"){larg = 800; alt = 200;}
	if(nome == "MESSAGEBOX"){larg = 300; alt = 200;}
	if(nome == "WEBSPOT"){larg = 600; alt = 600;}
	if (parseInt(navigator.appVersion)>3) {
	if (navigator.appName=="Netscape") {
		winW = window.innerWidth;
		winH = window.innerHeight;
	}
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		winW = document.body.offsetWidth;
		winH = document.body.offsetHeight;
	}
	}
	document.getElementById(nome).style.left = (winW/2)-(larg/2)-15;
	document.getElementById(nome).style.top = 0;//(winH/2)-(alt/2);
	var position = 0;	
	setInterval("poll('"+nome+"');",1);
}
function poll(nome){
	if (navigator.appName == "Microsoft Internet Explorer"){
		var position = document.body.scrollTop;
		var height = document.body.clientHeight;
		var width = document.body.clientWidth;
	}
	else {
		var position = window.pageYOffset;
		var height = document.body.clientHeight;
		var width = document.body.clientWidth;
	}
	if(nome=="testata"){
		document.getElementById(nome).style.top = position;
		document.getElementById(nome).style.left = 0;
		}
	if(nome=="layer-flash"){
		document.getElementById(nome).style.top = position;
		document.getElementById(nome).style.left = 0;
		}
	if(nome=="flash-footer"){
		document.getElementById(nome).style.left = width-300-20;
		document.getElementById(nome).style.top = position+height-150;
	}
	//return true;
}
function shake(x){ 
	sha = (navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4); 
	if (sha) { 
		for (i = 5; i > 0; i--) { 
			for (j = x; j > 0; j--) { 
				self.moveBy(0,i); 
				self.moveBy(i,0); 
				self.moveBy(0,-i); 
				self.moveBy(-i,0); 
			} 
		} 
	} 
} 
// ------------------------------------------------ EVENTI -------------------------------
window.onresize= centra("POPUP");
// ------------------------------------------------------------------------------------------
function writeObjectTagGeneric(adspanName, objText){
	document.all[adspanName].innerHTML = '<object ' + objText + '</object\>';
}
function initFlash_AM(){
	if (event.srcElement.readyState == "complete"){
		writeObjectTagGeneric("ANDREA_MAZZILLI", objText_AM);
		//attachEvents_AM();
	}
}
function dlWrite_AM(url,w,h,quality,wmode,bgcolor,scale,align,salign,title){
	if(!w){w="100%";}
	if(!h){h="100%";}
	//url = url+"?"+Math.random(10000);
	document.write('<object title="' + title + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,16,0" width="' + w + '" height="' + h + '" hspace="0" vspace="0"> <param name="movie" value="' + url + '"> <param name="salign" value="' + salign + '" /> <param name="allowScriptAccess" value="always" /><param name="scale" value="'+scale+'"> <param name="menu" value="false"> <param name="wmode" value="' + wmode + '"> <embed title="' + title + '" src="' + url + '" width="' + w + '" height="' + h + '" salign="' + salign + '" menu="false" scale="'+scale+'" swLiveConnect="true" allowScriptAccess="always" hspace="0" vspace="0" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="' + wmode + '"></embed> </object>');
}
function AM_ff(url,w,h,quality,wmode,bgcolor,scale,align,salign,title){
	//setInterval("poll('"+nome+"')",10);
	var g_bShowFlash=false;
	if (navigator.appVersion.indexOf("Win")>=0 && parseFloat(navigator.appVersion.substr(navigator.appVersion.indexOf("MSIE ")+5))>=4) {
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');document.write('on error resume next \n');
		document.write('g_bShowFlash = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
		document.write('</SCR' + 'IPT\>');
	}
	if(g_bShowFlash == true){
		var sFlashObjName_AM = "AM_flash_" + Math.floor(10000*Math.random());
		var objText_AM = 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" title="'+title+'" id="' + sFlashObjName_AM + '" width="'+w+'"  height="'+h+'" menu="false" salign="' + salign + '" scale="'+scale+'" style="z-index:-1"><param name="movie" value="'+url+'"><param name="wmode" value="'+wmode+'"><param name="quality" value="'+quality+'"><param name="scale" value="'+scale+'"><param name="salign" value="' + salign + '" /><param name="menu" value="false"><param name="loop" value="true">';
		
		if (typeof(inDapIF) != "undefined"){
			document.write('<object ' + objText_AM + '</object>');
		}else{	
			if (document.body == null) document.write('<html><body>');
				document.write('<span id="ANDREA_MAZZILLI"></span>');
				document.write('<scr' + 'ipt language="javascript" src="flashlib.js" onreadystatechange="initFlash_AM();"><\/scr' + 'ipt>');		
			if (document.body == null) document.write('</body></html>');
		}
	}else{
		dlWrite_AM(url,w,h,quality,wmode,bgcolor,scale,align,salign,title);
	}	
}

function menu(voce){
	if(voce == "servizi"){
		document.getElementById("menuNav2").style.visibility = "visible";
		document.getElementById("menuNav1").style.visibility = "hidden";
		document.getElementById("menuNav3").style.visibility = "hidden";
	}
	if(voce == "progetti"){
		document.getElementById("menuNav3").style.visibility = "visible";
		document.getElementById("menuNav1").style.visibility = "hidden";
		document.getElementById("menuNav2").style.visibility = "hidden";
	}	
}
