//funzioni per il testo scorrevole sulla homepage
function pad(id,nr)
{
 document.getElementById(id).style.left=nr;
 nr-=step;
 if(nr < - offset) setText(id)
 else {
 if((nr < 5) &&(stop == false))  {stop=true;setTimeout("pad('"+id+"',"+nr+")",delay);}
 else setTimeout("pad('"+id+"',"+nr+")",speed);
 }
}
function setText(id)
{
  stop = false
  document.getElementById("scrollerContext").innerHTML = newsarray[pointer];
  offset = document.getElementById("scrollerContext").offsetWidth;
  pointer++;
  if(pointer >= newsarray.length) pointer = 0;
  pad(id,width);
}
function go() {
	window.location = 'quesito.php';
}
//altre funzioni
function MM_openBrWindow(theURL,winName,features) { //v2.0
  w = window.open(theURL,winName,features);
  w.focus();
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function findObj(n,d) {
  var p, i, x;
  if (!d)
    d = document;
  if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
    d = parent.frames[n.substring(p+1)].document;
    n = n.substring(0,p);
  }
  if (!(x = d[n]) && (d.all))
    x = d.all[n];
  for (i = 0; !x && (i < d.forms.length); i++)
    x = d.forms[i][n];
  for (i = 0; !x && (d.layers && i < d.layers.length); i++)
    x = findObj(n, d.layers[i].document);
  if (!x && document.getElementById)
    x = document.getElementById(n);
  return x;
}
  
// Sort a select menu box.
function sortSelect(theSelect) {
  for (i = 0; i < theSelect.length; i++) {
    for (j = i+1; j < theSelect.length; j++) {
      if (theSelect.options[j].text < theSelect.options[i].text) {
        tempText = theSelect.options[i].text;
        tempValue = theSelect.options[i].value;
        theSelect.options[i].text = theSelect.options[j].text;
        theSelect.options[i].value = theSelect.options[j].value;
        theSelect.options[j].text = tempText;
        theSelect.options[j].value = tempValue;
      }
    }
  }
}

// Move an option from a select menu box to another.
function moveOption(selectFrom, selectTo) {
  from = findObj(selectFrom);
  if (from.selectedIndex != -1) {
    to = findObj(selectTo);
    i = 0;
    while (i < from.length) {
      if (from.options[i].selected) {
        newOption = new Option(from.options[i].text, from.options[i].value);
        to.options[to.length] = newOption;
        from.options[i] = null;
      }
      else {
        i++;
      }
    }
    sortSelect(to);
  }
}

// Select all items of a select menu box.
function selectAllItems(sName) {
  s = findObj(sName);
  if (s) {
    for (j = 0; j < s.length; j++) {
      s.options[j].selected = true;
    }
  }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  var w;
  w = window.open(theURL,winName,features);
  w.close();
  w = window.open(theURL,winName,features);  
  w.focus();
}

function showImageWindow(nome, winWidth, winHeight) {
    var posX = 0;                                 // screen size
    var posY = 0;                           // take taskbar into account
    var screenW = screen.width;                                 // screen size
    var screenH = screen.height - 20;                           // take taskbar into account
    if (winWidth < screenW) { 
    	posX = (screenW - winWidth)/2; 
    }       // if mouse too far right
    if (winHeight < screenH) { 
    	posY = (screenH - winHeight)/2;
    }       // if mouse too far down
    var wPosition   = "dialogLeft:" +posX+ "; dialogTop:" +posY;
    var wDimension   = "dialogWidth:" +winWidth+ "; dialogHeight:" +winHeight+ ";";
    var newColor = window.showModalDialog('imageWindow.html',nome,wDimension + 'resizable:no;help:no;status:no;scroll:no;' + wPosition);
}

