	var pause = 5000;
	var incrementnews = 5;
	var decrementnews = 5;
	var recallnews = 50;	
	var curindexnews = 0;
	var curalphanews = 0;
	var timernews = null;
	var intervalnews = null;
	var ocontnews = new Array();
		
  function stopboxnews(){
  	curindexnews = 0;
  	curalphanews = 0;
		window.clearTimeout(timernews);
		timernews = null;
  	intervalnews = null;
  	ocontnews = new Array();	
	}	
	
  function runboxnews(){
	
    var otempcont = document.getElementsByTagName("div");
    	for (x=0; x<otempcont.length; x++){
  		  if (otempcont[x].className=="rb"){
      		ocontnews.push(otempcont[x]); 
  			}
  		}  
  	if (ocontnews.length>0){
  		runnews();
  	}
  }

	function runnews(){
		if (ocontnews.length>0){			 
  		ocontnews[curindexnews].style.display = "block";
  	  if (curalphanews<=100){
    	  ocontnews[curindexnews].style.filter = "alpha(opacity=" + curalphanews + ")";
  			ocontnews[curindexnews].style.MozOpacity = curalphanews/100;
				ocontnews[curindexnews].style.opacity = curalphanews/100;
  			curalphanews = curalphanews + incrementnews;
  			timernews = window.setTimeout("runnews()", recallnews);  
  		}
  		else{
    		clearTimeout(timernews);
  			curalphanews = 100; 
  			intervalnews = window.setTimeout("resetnews(1)", pause);
  		}
		}	
	}
	
	function runback(){
  	if (ocontnews.length>0){
  	  if (curalphanews>=0){
    	  ocontnews[curindexnews].style.filter = "alpha(opacity=" + curalphanews + ")";
  			ocontnews[curindexnews].style.MozOpacity = curalphanews/100;
				ocontnews[curindexnews].style.opacity = curalphanews/100;
  			curalphanews = curalphanews - decrementnews;
  			timernews = window.setTimeout("runback()", recallnews);  
  		}
  		else{
    		clearTimeout(timernews); 
  			ocontnews[curindexnews].style.display = "none";
      	curalphanews = 0;
      	curindexnews++;
      	if (curindexnews==ocontnews.length){curindexnews=0;}			
  			resetnews(0);
  		}
		}
	}	
	
	function resetnews(ind){
		intervalnews = null
		if (ind==0){runnews();}else{runback();}
	}					

  function validateEmail(strValue){
    var objRegExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return objRegExp.test(strValue);
  }
	
  function Ctrlcommento()
  {
  	var Stringa = ""			 
    if (document.getElementById("nomecom").value==""){
  	Stringa += "Inserire il nome.\n"
  	}
  	if (document.getElementById("emailcom").value==""){
  	Stringa += "Inserire l'e-mail.\n"
  	}
  	else{
    	if (!validateEmail(document.getElementById("emailcom").value)){
    	Stringa += "Inserire l'e-mail in modo corretto.\n"
    	}
  	}
    if (document.getElementById("commentocom").value==""){
  	Stringa += "Inserire il commento.\n"
  	}
		
    if (document.getElementById("securechar").value==""){
  	Stringa += "Inserire il codice.\n"
  	}										
  		
  	if (Stringa!=""){
  	alert(Stringa)
  	return false;
  	}
  	else{
  	return true; 
  	}
  }
	
	var xmlhttp;
	var xmlhttpc;
	var startheight;
	var html_el = null;
	var html_elc = null;
	
  function load_cntA(url){
  xmlhttp=null;
  if (window.XMLHttpRequest){
    xmlhttp=new XMLHttpRequest();
    }
  else if (window.ActiveXObject){
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  if (xmlhttp!=null){
	xmlhttp.onreadystatechange=state_ChangeA;
    xmlhttp.open("GET",url,true);
    xmlhttp.setRequestHeader("Content-Type", "text/xml");
    xmlhttp.setRequestHeader("charset", "iso-8859-1");		
    xmlhttp.send(null);
    }
  else{
    alert("Your browser does not support XMLHTTP.");
    }
  }
  
  function load_cntC(url){
  xmlhttpc=null;
  if (window.XMLHttpRequest){
    xmlhttpc=new XMLHttpRequest();
    }
  else if (window.ActiveXObject){
    xmlhttpc=new ActiveXObject("Microsoft.XMLHTTP");
    }
  if (xmlhttpc!=null){
	xmlhttpc.onreadystatechange=state_ChangeC;
    xmlhttpc.open("GET",url,true);
    xmlhttpc.setRequestHeader("Content-Type", "text/xml");
    xmlhttpc.setRequestHeader("charset", "iso-8859-1");		
    xmlhttpc.send(null);
    }
  else{
    alert("Your browser does not support XMLHTTP.");
    }
  }  
  
	function state_ChangeA(){
        if (xmlhttp.readyState==4){
          if (xmlhttp.status==200){
				html_el.innerHTML = xmlhttp.responseText
				setHeight();
				readyA=1;
				setBothHeight();
            }
          else{
			window.clipboardData.setData('Text',url);
			setHeight();
            //alert("Problem retrieving XML data");
            }
          }
        }  
		
	function state_ChangeC(){
        if (xmlhttpc.readyState==4){
          if (xmlhttpc.status==200){
				html_elc.innerHTML = xmlhttpc.responseText
				setHeight();
				readyC=1;
				setBothHeight();
            }
          else{
			window.clipboardData.setData('Text',url);
            //alert("Problem retrieving XML data");
            }
          }
        }  		
  
  
   var readyA = 0
   var readyC = 0
   
   function setBothHeight(){
	if (readyA==1 && readyC==1){
	  setHeight();
	  readyA = 0;
	  readyC = 0;
	}
   }
  
	var index_on = false;
	
	function getObjA(){
		var obj = (document.getElementById("content_a")) ? document.getElementById("content_a") : document.getElementById("content_a_nav");
		return obj;
	}
	
	function getObjC(){
		var obj = (document.getElementById("content_c")) ? document.getElementById("content_c") : document.getElementById("content_c_nav");
		return obj;
	}	
	
	function loadingA(){
		var height_sx = parseInt(document.getElementById("box_numero").offsetHeight)-21;
		var str_load = "<div class=\'box_1 txt_rosso\'><b>Loading . . .</b></div><div class=\'box_2\' id=\'box_numero\' style=\'height: " + height_sx + "px;\'><div style=\'padding: 20px; text-align: left;\'><img src=\'/img/loading.gif\' alt='loading' border='0'/></div></div></div>";
		return str_load;
	}		
	
	function loadingC(){
		var height_dx = parseInt(document.getElementById("box_index").offsetHeight)-21;	
		//alert(height_dx)
		var str_load = "<div class=\'box_1 txt_rosso\'><b>Loading . . .</b></div><div class=\'box_2\' id=\'box_index\' style=\'height: " + height_dx + "px;\'><div style=\'padding: 20px; text-align: left;\'><img src=\'/img/loading.gif\' alt='loading' border='0'/></div></div></div>";
		return str_load;
	}			
		
		
	function load_index(ind){
  	html_el = getObjC();
  	load_cntC("http://" + host + "/it/get_index.asp?KeyRivista=" + keyrivista);
		stopboxnews()
		index_on = true;
		setHeight()
	}
	
	function load_numero(ind){
  	html_el = getObjA();
	html_el.innerHTML = loadingA();
	load_cntA("http://" + host + "/it/get_numero.asp?KeyRivista=" + ind);
	html_elc = getObjC();
	html_elc.innerHTML = loadingC();	
	load_cntC("http://" + host + "/it/get_index.asp?KeyRivista=" + ind);
	
	html_el.style.width = "320px";
	html_elc.style.width = "590px"; 
	
	keyrivista = ind;
	if (index_on){load_news()};
	}
	
	function load_articolo(ind){
  	html_el = getObjA();
	html_el.innerHTML = loadingA();
	load_cntA("http://" + host + "/it/get_articolo.asp?KeyArticolo=" + ind);
	html_elc = getObjC();
  	
	document.documentElement.scrollTop = "0";
	document.getElementById("box_index").style.height = "";
	
	html_el.style.width = "590px";
	html_elc.style.width = "320px"; 
	
	}
	
	function load_news_nav(ind){
  	html_el = document.getElementById("content_a");	
  	load_cnt("http://" + host + "/it/get_news_nav.asp?KeyNews=" + ind);
		document.documentElement.scrollTop = "0";
		document.getElementById("box_index").style.height = "";
		setHeight();
	}								
	
	function load_news(){
  	html_el = document.getElementById("content_c");
  	load_cnt("http://" + host + "/it/get_news.asp")
		document.getElementById("box_numero").style.height = "";
		index_on = false;
		runboxnews();
	}
	
	function load_result(str_query){
  	html_elc = getObjC();
	html_elc.innerHTML = loadingC();
  	load_cntC("http://" + host + "/it/get_result.asp?" + str_query)
		document.getElementById("box_numero").style.height = "";
		document.documentElement.scrollTop = "0";
		setHeight();
	}
	
	function load_news_index(str_query){
  	html_el = document.getElementById("content_c");
  	load_cnt("http://" + host + "/it/get_news_index.asp?" + str_query)
		document.getElementById("box_numero").style.height = "";
		document.documentElement.scrollTop = "0";
		setHeight();		
	}											
	
	function setHeight(){
	
		var objsx = getObjA();
		var objdx = getObjC();
		var height_sx = parseInt(objsx.offsetHeight);
		var height_dx = parseInt(objdx.offsetHeight);
		var iheight = 55;
	    var browser = navigator.appName;
		if (browser=="Microsoft Internet Explorer" && navigator.userAgent.indexOf('6.0') > -1){
		iheight = 29;
		}
		if (height_sx>height_dx){
			document.getElementById("box_index").style.height = (height_sx-iheight) + "px";
		} 						 			 
		else{
			document.getElementById("box_numero").style.height = (height_dx-iheight) + "px";
		}
	} 
	
	function chkimg(){
		document.getElementById("box_index").style.height = "";
		document.getElementById("box_numero").style.height = "";
		setHeight();
	}
	
  function comm(){
  var obj = document.getElementById("divcommento");
    if (obj.style.display=="none"){
      obj.style.display="block";
    }
    else{
      obj.style.display="none";			
    }
		document.getElementById("box_index").style.height = "";
		document.getElementById("box_numero").style.height = "";
		setHeight();
  }	
	
	function setlink(objlink){
  	var list_a = document.getElementsByName("link_index")
		for (x=0;x<list_a.length;x++){
  		list_a[x].className = "txt_link_nero";
		}
		objlink.className = "txt_rosso";
	}
	
	function setvar(){
  	startheight = parseInt(document.getElementById("box_numero").offsetHeight);
	}
	
	function continua(){
  	window.location.href="it/iscriviti.asp?denominazione=" + document.getElementById("denominazione").value + "&email=" + document.getElementById("email").value 
	}
