
var DELTA_TIME = 80;
var DELTA_SPACE = 1;

var objNews;
var containerHeight;
var tickerHeight;
var isRunning;
var isPause = false;
var idTicker = null;
var idxTicker;
var limitTicker;


function find(id)
{
	if (document.getElementById)
	{
	  	return(document.getElementById(id));
	}
	else if (document.all)
	{
		return(document.all[id]);
	}
	else if (document.layers)
	{
		return(document.layers[id]);
	}
	return(null);	
}

function start()
{

	if(find("ticker1") && find("ticker2"))
	{
		objNews = new Array(find("ticker1"),find("ticker2"));
		objNews[1].innerHTML = objNews[0].innerHTML;
		containerHeight = parseInt(find("ticker_container").style.height);
		tickerHeight = objNews[0].offsetHeight;
		if(tickerHeight<containerHeight) tickerHeight = containerHeight;
		limitTicker = -tickerHeight-tickerHeight+containerHeight;
		var yTicker = 0;
		idxTicker = 0;
		isRunning = true;
		idTicker = setTimeout("Roller()",DELTA_TIME);
	}
}

function stop()
{
	isRunning = false;
}

function pause()
{
	isPause = true;
}

function resume()
{
	isPause = false;
	if(idTicker == null) idTicker = setTimeout("Roller()",DELTA_TIME);
}

function Roller()
{
	if(isRunning)
	{
		var y = parseInt(objNews[idxTicker].style.top) - DELTA_SPACE;
		objNews[idxTicker].style.top = y+"px";
		objNews[(idxTicker+1)&1].style.top = (y+tickerHeight)+"px";
		if(y<limitTicker)
		{
			objNews[idxTicker].style.top = containerHeight+"px";
			idxTicker = (idxTicker+1)&1;			
		}
		if(isPause)
		{
			idTicker = null;
		}
		else
		{
			idTicker = setTimeout("Roller()",DELTA_TIME);
		}
	}
}

/*
var swidth=240;
var sheight=175;
var sbcolor='';
var sspeed=3;
var resumesspeed=sspeed
function start() {
		if (document.all) {
				if(document.all.ticker){
					iemarquee(ticker);
				}
		}else if (document.getElementById){
				if(document.getElementById('ticker')){
				  ns6marquee(document.getElementById('ticker'));
				}
		 } 
}

function iemarquee(whichdiv){
		iediv=eval(whichdiv)
		sheight += 0;
		iediv.style.pixelTop=sheight
		iediv.innerHTML=msg 
		sizeup=iediv.offsetHeight
		ieslide()
}

function ieslide(){
		if (iediv.style.pixelTop>=sizeup*(-1)){
				iediv.style.pixelTop-=sspeed
				setTimeout("ieslide()",100)
		}
		else{
				iediv.style.pixelTop=sheight
				ieslide()
		}
}

function ns6marquee(whichdiv){
		ns6div=eval(whichdiv)
		sheight += 50;
		ns6div.style.top=sheight + "px";
		ns6div.innerHTML=msg
		sizeup=ns6div.offsetHeight
		ns6slide()
}
function ns6slide(){
		if (parseInt(ns6div.style.top)>=sizeup*(-1)){
				theTop = parseInt(ns6div.style.top)-sspeed
				ns6div.style.top = theTop + "px";
				setTimeout("ns6slide()",100)
		}
		else {
				ns6div.style.top = sheight + "px";
				ns6slide()
		}
}
*/		
function apri_livehelp() {
						  nuovo_LiveHelp_51648=window.open('http://server.livehelp.it/client_user/default.asp?provenienza='+ escape(document.location.href) +'&info=&stanza=&ID=51648&gruppo=Assistenza','LiveHelpwin1_51648', 'status=yes,toolbar=no,width=500,height=400,resizable=yes'); 
						  nuovo_LiveHelp_51648.focus();
						  }
function controlla_modulo(f){
	
		
	var el = "riferimento";var msg = "Inserisci il riferimento";	
	if (f.elements[el].value.length < 1) {
		alert(msg); f.elements[el].focus(); return(false);
	}

	 var el = "email";var msg = "E-mail non valido";	
	 var reg = new RegExp("^[a-z0-9_\\.\\-]+@+[a-z0-9_\\.\\-]+(\\.[a-z]{2,4})$","gi");
	  if (!reg.test(f.elements[el].value)) {
		alert(msg); f.elements[el].focus(); return(false);
	  }

	var el = "messaggio";var msg = "Inserisci il messaggio";	
	if (f.elements[el].value.length < 1) {
		alert(msg); f.elements[el].focus(); return(false);
	}

}

function del(f){
	f.value="";
}

function goTo(url){
	if(url){
		window.location.href = url;
	}
}

var popUpWin=0;

function popUp(URLStr, height, width, left, top){
  if(popUpWin){
    if(!popUpWin.closed){
		popUpWin.close();
	}
  }
  
  if(height){  }
  
	  var width = (!width) ? 500 : width;
	  var height = (!height) ? 300 : height;
	 
	  var left = (!left) ? 10 : left;
	  var top = (!top) ? 10 : top;
			
		top=(screen.height/2)-(height/2);
		left=(screen.width/2)-(width/2);


  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

var menuids=["treemenu1"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus_horizontal(){
	
	if(document.getElementById(menuids))	{
		
		for (var i=0; i<menuids.length; i++){
		  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul");
		  
			for (var t=0; t<ultags.length; t++){
				if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
					ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
					ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
				}
				else{ //else if this is a sub level menu (ul)
				  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
				ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
				}
			ultags[t].parentNode.onmouseover=function(){
			this.getElementsByTagName("ul")[0].style.visibility="visible"
			}
			ultags[t].parentNode.onmouseout=function(){
			this.getElementsByTagName("ul")[0].style.visibility="hidden"
			}
			}
		  }
	}
}

if (window.addEventListener){
	window.addEventListener("load", buildsubmenus_horizontal, false);
}else if (window.attachEvent){
	window.attachEvent("onload", buildsubmenus_horizontal);
}

