window.onload = function()
{


	GetDPI();	
   test();
	GestisciLarghezzaContenuto();
	  cambia();
	GestisciTestoScorrevole();
	GestisciVetrina();
      doTimer();  

	}


         
         
        
var t;
var timer_is_on=0;

function timedCount()
{
if (document.getElementById('looper') == null)
  return;
  
if (document.getElementById('looper').className=='ricerca2')
{
   document.getElementById('looper').className='ricerca';

}
else
{
  document.getElementById('looper').className='ricerca2';

}

t=setTimeout("timedCount()",2000);
}

function doTimer()
{
if (!timer_is_on)
  {
  timer_is_on=1;
  timedCount();
  }
}





       function scendi()
{
           var imola,cesena,ravenna,bologna,parma,piacenza,modena,ferrara,rimini,reggio;
                  var bonus;                 
                        
           var imola=     document.getElementById("imola")             
            imola.className="section mappaelenco";
                                
                   var cesena=     document.getElementById("cesena")             
            cesena.className="section mappaelenco";
                     var ravenna=     document.getElementById("ravenna")             
            ravenna.className="section mappaelenco";
                     var bologna=     document.getElementById("bologna")             
            bologna.className="section mappaelenco";
                     var parma=     document.getElementById("parma")             
            parma.className="section mappaelenco";
                     var piacenza=     document.getElementById("piacenza")             
            piacenza.className="section mappaelenco";
                     var modena=     document.getElementById("modena")             
             modena.className="section mappaelenco";
                     var ferrara=     document.getElementById("ferrara")             
            ferrara.className="section mappaelenco";
                      var rimini=     document.getElementById("rimini")             
            rimini.className="section mappaelenco";
                           var reggio=     document.getElementById("reggio")             
            reggio.className="section mappaelenco";
  //                     var bonus=     document.getElementById(nome)             
    //        bonus.className="elenco";
            
                             
                           
                       
                       
           
              
           
       
           
   
     
 
           
  
}



function GetDPI () 
{
	var message = "";
	var yDPI = 0;
	var xDPI = 0;
	if (screen.deviceXDPI === undefined) {    // Firefox, Opera and Safari
			// Create a temporary element with 1 inch width and height
		var div = document.createElement ("div");
		div.style.width = "1in";
		div.style.height = "1in";
		div.style.position = "absolute";
		div.style.left = "-10in";
		div.style.top = "-10in";
		document.body.appendChild (div);

			// Get the size in pixels
		/*
		message += "The current horizontal DPI: " + div.offsetWidth + "<br />";
		message += "The current vertical DPI: " + div.offsetHeight + "<br />";
		*/
		xDPI = div.offsetWidth;
		yDPI = div.offsetHeight;
		
		document.body.removeChild (div);            
	}
	else 
	{
		/*
		message += "The current horizontal DPI: " + screen.deviceXDPI + "<br />";
		message += "The current vertical DPI: " + screen.deviceYDPI + "<br />";
		message += "The logical horizontal DPI: " + screen.logicalXDPI + "<br />";
		message += "The logical vertical DPI: " + screen.logicalYDPI + "<br />";
		*/
		xDPI = screen.deviceXDPI;
		yDPI = screen.deviceYDPI;
	}
	
	if (xDPI > 96 || yDPI > 96)
	{
		var headID = document.getElementsByTagName("head")[0];         
		var cssNode = document.createElement('link');
		cssNode.type = 'text/css';
		cssNode.rel = 'stylesheet';
		cssNode.href = './stili/stileCID_DPI.css';
		cssNode.media = 'screen';
		headID.appendChild(cssNode);
	}
}

var scorrimentoPagine = 0;

function GestisciTestoScorrevole(idTestoScorrevole)
{
	var testoScorrevole = document.getElementById("testoScorrevole");
	if (testoScorrevole == null)
		return;
	
	var testi = testoScorrevole.getElementsByTagName("div");
	var numeroTesti = 0;
	for (i = 0; i < testi.length; i ++)
		if (testi[i].className.indexOf("testo") > -1)
			numeroTesti += 1;
	
	linkPaginaPrecedente.className = (scorrimentoPagine > 0 ? "visibile" : "invisibile");
	linkPaginaSuccessiva.className = (scorrimentoPagine < numeroTesti - 1 ? "visibile" : "invisibile");
}

function ScorriTesto(scorriDx)
{
  if (scorriDx == null)
    return;

	var testoScorrevole = document.getElementById("testoScorrevole");
	var testi = testoScorrevole.getElementsByTagName("div");
	var numeroTesti = 0;
	for (i = 0; i < testi.length; i ++)
		if (testi[i].className.indexOf("testo") > -1)
			numeroTesti += 1;
	
	
//	var larghezzaTesti = 360;      


	var larghezzaTesti= testi[0].clientWidth;

  var scorrimentosecondo= larghezzaTesti/2 +15;
	if (scorriDx)
		scorrimentoPagine += 1;
	else
		scorrimentoPagine -= 1;
		
	var linkPaginaSuccessiva = document.getElementById("linkPaginaSuccessiva");
	var linkPaginaPrecedente = document.getElementById("linkPaginaPrecedente");
	
	linkPaginaPrecedente.href = "javascript: ScorriTesto(null);";
	linkPaginaSuccessiva.href = "javascript: ScorriTesto(null);";
	
	/*
	linkPaginaPrecedente.className = "invisibile";
	linkPaginaSuccessiva.className = "invisibile";
	*/
	
	for (i = 0; i < scorrimentosecondo; i ++)
		setTimeout("Scorrimento(2, " + scorriDx + ", " + (i + 1 == scorrimentosecondo) + ", " + numeroTesti + ");", (i * 2));
		
	return;
	/*
	testoScorrevole.style.left = ((scorrimentoPagine * -1) * larghezzaTesti) + "px";
	
	var linkPaginaSuccessiva = document.getElementById("linkPaginaSuccessiva");
	var linkPaginaPrecedente = document.getElementById("linkPaginaPrecedente");
	
	linkPaginaPrecedente.className = (scorrimentoPagine > 0 ? "visibile" : "invisibile");
	linkPaginaSuccessiva.className = (scorrimentoPagine < numeroTesti - 1 ? "visibile" : "invisibile");
	*/
}

function Scorrimento(distanza, scorriDx, ultimo, numeroTesti)
{
	var testoScorrevole = document.getElementById("testoScorrevole");
	var posizioneCorrente = 0;
	if (testoScorrevole.style.left != null && testoScorrevole.style.left != "")
		posizioneCorrente = parseInt(testoScorrevole.style.left, 10);
	if (scorriDx)
		testoScorrevole.style.left = posizioneCorrente - distanza;
	else
		testoScorrevole.style.left = posizioneCorrente + distanza;
		
	if (ultimo)
	{
		var linkPaginaSuccessiva = document.getElementById("linkPaginaSuccessiva");
		var linkPaginaPrecedente = document.getElementById("linkPaginaPrecedente");
		
		linkPaginaPrecedente.className = (scorrimentoPagine > 0 ? "visibile" : "invisibile");
		if (linkPaginaPrecedente.className == "visibile")
      linkPaginaPrecedente.href = "javascript: ScorriTesto(false);";
		
		linkPaginaSuccessiva.className = (scorrimentoPagine < numeroTesti - 1 ? "visibile" : "invisibile");
		if (linkPaginaSuccessiva.className == "visibile")
      linkPaginaSuccessiva.href = "javascript: ScorriTesto(true);";
	}
	//alert(((scorrimentoPagine * -1) * distanza) + "px");
}

function GestisciLarghezzaContenuto()
{
  
  var menuDx = document.getElementById("menuDx");
  
  if (menuDx != null)
    return;
    
  var testoCentrale = document.getElementById("testoCentrale");
  if (testoCentrale == null)
    return;
  
  testoCentrale.className += " testoCentraleEspanso";
  
  var i = 0;
  var testoScorrevole = document.getElementById("testoScorrevole");
  var testi = testoScorrevole.getElementsByTagName("div");
  
  for (i = 0; i < testi.length; i ++)
  {
    if (testi[i].className == "testo")
      testi[i].className += " testoEspanso";
  }
  return;
}




var intervalloScorrimento = null;
var altezzaVetrina = 200;


function GestisciVetrina()
{





	var vetrina = document.getElementById("vetrina");
	var boxScorrimento = null;
	
	var i = 0;
	if (vetrina != null)
	{
		var boxVetrina = vetrina.getElementsByTagName("div");
		for (i = 0; i < boxVetrina.length; i ++)
		{
			if (boxVetrina[i].id == "boxScorrimento")
			{
				boxScorrimento = boxVetrina[i];
				break;
			}
		}
		
		var linkVetrina = vetrina.getElementsByTagName("a");
		for (i = 0; i < linkVetrina.length; i ++)
		{
			linkVetrina[i].onmouseover = function() { ScorriNews(null); };
			linkVetrina[i].onmouseout = function() { ScorriNews(boxScorrimento.id); };
		}
		
		if (boxScorrimento != null)
		{
			boxScorrimento.style.top = altezzaVetrina;
			intervalloScorrimento = setInterval("ScorriNews('" + boxScorrimento.id + "')", 25)
		}
	}
}

function ScorriNews(idBoxScorrimento)
{
	if (idBoxScorrimento == null)
	{
		clearInterval(intervalloScorrimento);
		intervalloScorrimento = null;
		return;
	}
	
	var boxScorrimento = document.getElementById(idBoxScorrimento);
	if (intervalloScorrimento == null)
		intervalloScorrimento = setInterval("ScorriNews('" + boxScorrimento.id + "')", 25)
		
	boxScorrimento.style.top = parseInt(boxScorrimento.style.top, 10) - 1;
	
	if ((parseInt(boxScorrimento.style.top, 10) + boxScorrimento.clientHeight) == 0)
		boxScorrimento.style.top = altezzaVetrina;
}







         function cambia()
                 {
                    var p = "stamp";
                          // gli ho messo se trova stamp=3  allora è una pagina stampabile
                 if   (getParam(p)==3)
                        {
                           prova();
                        
                            //return;
                            window.print();
                            window.onfocus = function() { window.close(); }

                            
                          //  setTimeout("window.close()",10000);
                   


                         }   
                 }                  
           
           
           
           function prova()
           {
                if(document.getElementById('menuDx')) 
                { 
                 document.getElementById("menuDx").className = "invisibile";   
                } 
              //  if(document.getElementById('home'))                                               
              //  { 
              //   document.getElementById("home").className += "pagina2 home";   
              //  }                           
                if(document.getElementById('prova')) 
                { 
                 document.getElementById("prova").className = "marginL20 marginT25 testoCentraleEspanso";   
                }    
                
                 if(document.getElementById('testoCentrale')) 
                { 
                 document.getElementById("testoCentrale").className = "marginL20 marginT25 testoCentraleEspanso";   
                }   
              
                if (document.getElementById('rassegnaStampaLink'))
                {
                  var i = 0;
                  var divDati = document.getElementById('rassegnaStampaLink').getElementsByTagName("DIV");
                  
                  
                  for (i = 0; i < divDati.length; i ++)
                  {
                    if (divDati[i].className == "dato")
                    {
                      divDati[i].style.height = parseInt(divDati[i].getAttribute("altezza"), 10) + "px";
                    }
                  }
                  
                  document.getElementById("home").className = "rassegnaStampaLinkStampa";
                }
                
                             
           }
           
 
                 
              
        
                 
                 
         function getParam(param) 
           {
              param = param.replace(/[[]/, '\[').replace(/[]]/, '\]');
              var regexS = '[\?&]' + param + '=([^&#]*)',
              regex = new RegExp(regexS),
              results = regex.exec(window.location.href);
              if (results === null) 
                 {
                    return '';
                 } 
             else 
              {
              return results[1];  
              }  
           }







        var SLIDETIMER = 3;
var SLIDESPEED = 30;
var SCROLLTIMER = 3;
var SCROLLSPEED = 3;
var STARTINGOPACITY = 40;

// handles section to section scrolling of the content //
function slideContent(id,prefix,timer) {
scendi();
  var div = document.getElementById(id);
  var slider = div.parentNode;
  clearInterval(slider.timer);
  slider.section = parseInt(id.replace(/\D/g,''));
  slider.target = div.offsetLeft;
  slider.style.left = slider.style.left || '0px';
  slider.current = slider.style.left.replace('px','');
  slider.direction = (Math.abs(slider.current) > slider.target) ? 1 : -1;
  slider.style.opacity = STARTINGOPACITY * .01;
  slider.style.filter = 'alpha(opacity=' + STARTINGOPACITY + ')';
  slider.timer = setInterval( function() { slideAnimate(slider,prefix,timer) }, SLIDETIMER);
}

function slideAnimate(slider,prefix,timer) {
  var curr = Math.abs(slider.current);
  var tar = Math.abs(slider.target);
  var dir = slider.direction;
  if((tar - curr <= SLIDESPEED && dir == -1) || (curr - tar <= SLIDESPEED && dir == 1)) {
    slider.style.left = (slider.target * -1) + 'px';
	slider.style.opacity = 1;
	slider.style.filter = 'alpha(opacity=100)';
    clearInterval(slider.timer);
	if(slider.autoscroll) {
	  setTimeout( function() { autoScroll(slider.id,prefix,timer) }, timer * 1000);
	}
  } else {
	var pos = (dir == 1) ? parseInt(slider.current) + SLIDESPEED : slider.current - SLIDESPEED;
    slider.current = pos;
    slider.style.left = pos + 'px';
  }
}

// handles manual scrolling of the content //
function scrollContent(id,dir) {
  var div = document.getElementById(id);
  clearInterval(div.timer);
  var sections = div.getElementsByTagName('div');
  var length = sections.length;
  var limit;
  if(dir == -1) {
    limit = 0;
  } else {
    if(length > 1) {
      limit = sections[length-1].offsetTop;
    } else {
      limit = sections[length-1].offsetHeight - div.parentNode.offsetHeight + 20;
    }
  }
  div.style.opacity = STARTINGOPACITY * .01;
  div.style.filter = 'alpha(opacity=' + STARTINGOPACITY + ')';
  div.timer = setInterval( function() { scrollAnimate(div,dir,limit) }, SCROLLTIMER);
}

function scrollAnimate(div,dir,limit) {
  div.style.top = div.style.top || '0px';
  var top = div.style.top.replace('px','');
  if(dir == 1) {
	if(limit - Math.abs(top) <= SCROLLSPEED) {
	  cancelScroll(div.id);
	  div.style.top = '-' + limit + 'px';
	} else {
	  div.style.top = top - SCROLLSPEED + 'px';
	}
  } else {
	if(Math.abs(top) - limit <= SCROLLSPEED) {
	  cancelScroll(div.id);
	  div.style.top = limit + 'px';
	} else {
	  div.style.top = parseInt(top) + SCROLLSPEED + 'px';
	}
  }
}

// cancel the scrolling on mouseout //
function cancelScroll(id) {
  var div = document.getElementById(id);
  div.style.opacity = 1;
  div.style.filter = 'alpha(opacity=100)';
  clearTimeout(div.timer);
}

// initiate auto scrolling //
function autoScroll(id,prefix,timer,restart) {
  var div = document.getElementById(id);
  div.autoscroll = (!div.autoscroll && !restart) ? false : true;
  if(div.autoscroll) {
    var sections = div.getElementsByTagName('div');
    var length = sections.length;
    div.section = (div.section && div.section < length) ? div.section + 1 : 1;
    slideContent(prefix + '-' + div.section,prefix,timer);
  }
}

// cancel automatic scrolling //
function cancelAutoScroll(id) {
  var div = document.getElementById(id);
  div.autoscroll = false;
}





          
          
          
          
          
          
          
          
          
          
          
   var scrllTmr;

function test()
{
  cw = parseInt(document.getElementById('scroll').offsetWidth);
	w = parseInt(document.getElementById('scrollme').offsetWidth);
	
	
	lft = cw ;
	document.getElementById('scrollme').style.left = lft + "px";
	scrollStep(cw,w,lft);
}

function scrollStep(cw,w,lft)
{
  if(lft == cw * -2)
		lft = cw ;
	document.getElementById('scrollme').style.left = lft + "px";
	
	
	if(scrllTmr)
		clearTimeout(scrllTmr);
	scrllTmr = setTimeout('scrollStep(' + cw + ',' + w + ',' + (lft - 1) + ')', 10);
}
     
     
function beta()
{
var gg =parseInt(document.getElementById('scrollme').style.left);
return  gg;    
}





















// not animated collapse/expand
function togglePannelStatus(content)
{
    var expand = (content.style.display=="none");
    content.style.display = (expand ? "block" : "none");
    toggleChevronIcon(content);
}

// current animated collapsible panel content
var currentContent = null;

function togglePannelAnimatedStatus(content, interval, step)
{
    // wait for another animated expand/collapse action to end
    if (currentContent==null)
    {
        currentContent = content;
        var expand = (content.style.display=="none");
        if (expand)
            content.style.display = "block";
        var max_height = content.offsetHeight;

        var step_height = step + (expand ? 0 : -max_height);
        toggleChevronIcon(content);
                
        // schedule first animated collapse/expand event
        content.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
}

function togglePannelAnimatingStatus(interval,
    step, max_height, step_height)
{
    var step_height_abs = Math.abs(step_height);

    // schedule next animated collapse/expand event
    if (step_height_abs>=step && step_height_abs<=(max_height-step))
    {
        step_height += step;
        currentContent.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
    // animated expand/collapse done
    else
    {
        if (step_height_abs<step)
            currentContent.style.display = "none";
        currentContent.style.height = "";
        currentContent = null;
    }
}

// change chevron icon into either collapse or expand
function toggleChevronIcon(content)
{
    var chevron = content.parentNode
        .firstChild.childNodes[1].childNodes[0];
    var expand = (chevron.src.indexOf("expand.gif")>0);
    chevron.src = chevron.src
        .split(expand ? "expand.gif" : "collapse.gif")
        .join(expand ? "collapse.gif" : "expand.gif");
}







     


























 
  function VisualizzaTesto(idTestoFoto, dicitura, durata)
{
//	var durataTesto = parseFloat(durata / 2 );
	
//	var opacityTween = new OpacityTween(document.getElementById(idTestoFoto), Tween.strongEaseOut, 100, 0, durataTesto);
//	opacityTween.onMotionFinished = function() { VisualizzazioneTestoCompleto(idTestoFoto, dicitura, durataTesto); AbilitaScorrimentobloccasx(); AbilitaScorrimentobloccadx(); };
//	opacityTween.start();
//		opacityTween.onMotionStarted = function() { AbilitaScorrimentobloccasx(); AbilitaScorrimentobloccadx(); };

}
function VisualizzazioneTestoCompleto(idTestoFoto, dicitura, durataTesto)
{
//	var testoFoto = document.getElementById(idTestoFoto);
//	testoFoto.innerHTML = dicitura;
//	var opacityTween = new OpacityTween(testoFoto, Tween.strongEaseOut, 0, 100, durataTesto);
//	opacityTween.start();
}

//OpacityTween.prototype = new Tween();
//OpacityTween.prototype.constructor = Tween;
//OpacityTween.superclass = Tween.prototype;

//function OpacityTween(obj,func,fromOpacity,toOpacity,duration){
//	this.targetObject = obj;
//	this.init(new Object(),'x',func,fromOpacity,toOpacity,duration);
//}
//var o = OpacityTween.prototype;
//o.targetObject = {};

function ritornaTesto(nome)
{
//var testo=document.getElementById(nome);
//var dicitura=testo.innerHTML 
//return dicitura;
}
