var _e3Scroll = function() {
	
	this.scrollspeed = 1;
	this.sc_delay = 100;
	this.sc_scrolldelay = 50;
	this.sc_class = "e3news";
	this.sc_tabId = "tabNews";
	this.sc_newsId = "newsBox";
	this.sc_contId = "news";
	this.sc_nTab = 0;
	this.sc_array = new Array();
	this.sc_timeouts = new Array();
	this.sc_height = new Array();
	
	this.Init = function(){
		this.InitScroll();
		this.InitMenu();
	}
	
		this.InitScroll = function() {
			
			var dataobj;
			
			var n = document.getElementsByClassName(this.sc_class);
			
			for(var i=0; i < n.length; i++) {
				
				n[i].style.position = "relative";
				n[i].style.overflow = "hidden";
				dataobj = n[i].getElementsByTagName("dl")[0];
				
				var height = document.getElementInformations(n[i]).height;
				dataobj.style.top = height + "px";
				dataobj.style.position = "absolute";
				this.sc_array.push(dataobj);
				this.sc_height.push(height);
				
				dataobj.onmouseover = e3Utility.Bind(e3Scroll.stopScrolling,i);
				dataobj.onmouseout = e3Utility.Bind(e3Scroll.startScrolling,i);
		
				this.sc_timeouts.push(setTimeout('e3Scroll.startScrolling(\''+i+'\')',this.sc_delay));
			}
	}
	
	this.InitMenu = function() {
		
		var menuobj;
		
		var newsDiv = document.getElementById(this.sc_contId);
		if (newsDiv) {
			var n = newsDiv.getElementsByTagName("h2");
			this.sc_nTab = n.length;
		
			for(var i = 0; i < n.length; i++) {
				
				menuobj = n[i];
				menuobj.id = this.sc_tabId + i;
				menuobj.onclick = e3Utility.Bind(e3Scroll.attivaTab,i);
			
			}
		}
		
	}
	
	this.attivaTab = function(i) {
		var newsobj;
		var height;
		
		for(var j = 0; j < e3Scroll.sc_nTab ; j++) {
			
			newsobj = document.getElementById(e3Scroll.sc_newsId + j);
	
			if (newsobj) {
			
				if (i == j) {
					newsobj.style.display = "block";
					newsobj.style.visibility = "visible";
					height = document.getElementInformations(newsobj).height;
					e3Scroll.sc_height[j] = height;
				}else {
					newsobj.style.display = "none";
					newsobj.style.visibility = "hidden";
				}
			}
				
		}
		
		return false;
		
	}
	

	this.stopScrolling = function(i) {
	
		clearTimeout(e3Scroll.sc_timeouts[i]);
	}

	this.startScrolling = function(i) {
		
		var dataobj = e3Scroll.sc_array[i]
	 	
		dataobj.style.top = parseInt(dataobj.style.top) - e3Scroll.scrollspeed + "px";
		
		if (parseInt(dataobj.style.top) < dataobj.offsetHeight *(-1))
			dataobj.style.top= e3Scroll.sc_height[i] + "px";
	
		e3Scroll.sc_timeouts[i] = setTimeout('e3Scroll.startScrolling(\''+i+'\')',e3Scroll.sc_scrolldelay);
		
	}

};

var e3Scroll = new _e3Scroll();
e3Utility.Main(
	function(){
			e3Scroll.Init();
		}			   
)
