﻿function popUpWin(theURL,theName,winWidth, winHeight, WinProperties) 
{
	var screenWidth = (window.screen.width - winWidth) / 2;
	var screenHeight = (window.screen.height - winHeight) / 2;
	theURL = theURL.replace( /!/g, "&");
	window.open(theURL,theName,"width=" + winWidth + ",height=" + winHeight + ",left=" + screenWidth + ",top=" + screenHeight + "," + WinProperties);
}

function ChiediConferma(msg)
{
       boolEsito = true;
       conferma = window.confirm(msg)
       if (!conferma)
            boolEsito = false;
}

function ManageDxColumn()
{
   MainDxW = document.getElementById("MainDx").style.width;
   if (screen.width < 1280)
   {
        document.getElementById("MainDx").style.width = screen.width - 32;
        document.getElementById("Contenitore").style.width = screen.width - 32; 
    } 
   else
    {
       document.getElementById("MainDx").style.width = MainDxW;
       document.getElementById("Contenitore").style.width = MainDxW; 
     } 
}

//News - Fade ---------------------------------------------------------------------------------------------
var list; 
var tickerObj; 
var hexR = 188;
var hexG = 177;
var hexB = 111;

function fadeText(divId) 
{
  if(tickerObj)
  {
    if(hexR < 255) 
    {
      hexR+=5; // increase color darkness
      hexG+=6; // increase color darkness
      hexB+=15; // increase color darkness
      tickerObj.style.color="rgb("+hexR+","+hexG+","+hexB+")";
      setTimeout("fadeText('" + divId + "')", fadeSpeed); 
    } 
    else
   { 
      hexR = 188; //reset hex value
      hexG = 177
      hexB = 111
   }   
}  
}   

function initialiseList(divId) {
  tickerObj = document.getElementById(divId);
  if(!tickerObj)
    reportError("Could not find a div element with id \"" + divId + "\"");
  list = tickerObj.childNodes;
  if(list.length <= 0)
    reportError("The div element \"" + divId + "\" does not have any children");
  for (var i=0; i<list.length; i++) {
    var node = list[i];
   /*alert(node.nodeType) 
   alert(node.nodeValue)  */
//    if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
//              tickerObj.removeChild(node);
  }
  run(divId, 0);
}

function run(divId, count) {
  fadeText(divId);
  list[count].style.display = "block";
  if(count > 0)
    list[count-1].style.display = "none";
  else
    list[list.length-1].style.display = "none";
  count++;
  if(count == list.length)
    count = 0;
  window.setTimeout("run('" + divId + "', " + count+ ")", interval*1000);
}
function reportError(error) {
  alert("The script could not run because you have errors:\n\n" + error);
  return false;
}

var interval = 3; // interval in seconds
var fadeSpeed = 40;

//Fine News Fade ------------------------------------------------------------------------------------------------------












