/*
	DOMnews 1.0 
	homepage: http://www.onlinetools.org/tools/domnews/
	released 11.07.05
*/

/* Variabili che è possibile cambiare */
	// posizione iniziale 
	var dn_startpos = 760; 			
	// posizione finale
	var dn_endpos = 0; 			
	// Velocità dello scroller: un numero più alto indica una velocità inferiore 
	var dn_speed = 20;				
	// ID da assegnare al box delle news nel codice HTML
	var dn_newsID = 'contact';			
	// Div che effettua lo scrolling;
	var dn_scrollingDiv;

	/* Initialise scroller when window loads */
	//window.onload = function() {
		// check for DOM
		//if(!document.getElementById || !document.createTextNode){
			//return;
		//}
		
		//initDOMnews();
		
		// add more functions as needed

 	//}
	
	
	/* stop scroller when window is closed */
	window.onunload = function() {
		clearInterval(dn_interval);
	}
	
/*
	This is the functional bit, do not press any buttons or flick any switches
	without knowing what you are doing!
*/

	var dn_scrollpos = dn_startpos;
	
	/* Initialise scroller */
	function initDOMnews() {
		var n = document.getElementById(dn_newsID);
		
		dn_scrollingDiv = document.getElementById('contact_text');
		// For IE8
		dn_scrollingDiv.style.visibility = 'visible';
		
		dn_endpos = "-" + dn_scrollingDiv.offsetWidth;
		
		if(!n){
			return;
		}
		
		dn_interval = setInterval('scrollDOMnews()',dn_speed);
		
		n.onmouseover = function() {		
			clearInterval(dn_interval);
		}
		
		n.onmouseout = function() {
			dn_interval=setInterval('scrollDOMnews()',dn_speed);
		}
	}


	function stopDOMnews() {
		clearInterval(dn_interval);
		var n=document.getElementById('contact');
		return false;
	}
	
	
	function scrollDOMnews() {
		dn_scrollingDiv.style.left=dn_scrollpos+'px';
		
		if(dn_scrollpos == dn_endpos){
			dn_scrollpos = dn_startpos;
		}
		
		dn_scrollpos--;	
	}
	
