var sel = null;
var lastColor;
function selectLine(ctl) {
  if (sel != null && sel != ctl) {
    var l = getLink(sel);
    if (l != null) {
      l.style.backgroundColor='#f0f0f0';
      l.style.color = lastColor;
    }
    sel.style.backgroundColor='#f0f0f0';
    sel.style.color = "black";
  }
  if (sel == ctl)
	return true;
  var l = getLink(ctl);
  if (l != null) {
  //  alert(document.styleSheets[1].rules.item(1).style.color );
  		lastColor = l.currentStyle.color;
      l.style.backgroundColor='#b82719';
      l.style.color = "white";
  }
  ctl.style.backgroundColor='#b82719';
  ctl.style.color = "white";
  sel=ctl;
  return false;
}

function getLink(ctl) {
  for (var i = 0; i < ctl.childNodes.length; i++)  {
  		c = ctl.childNodes.item(i);
	  while (c.children.length > 0) {
	    c = c.children[0];
	    if (c.tagName == "A") {
	      return c;
	    }
	  }
  }
  return null;
}

function selText(i) {
  return sel.cells(i).innerText
}

function checkSel() {
  if (sel != null)
    return true;
  alert("Devi prima selezionare una riga cliccandoci sopra");
  return false;
}

function newsWin(art) {
  var w = window.open('articoli/' + art + ".html", 'newsProxima','scrollbars=yes,status=no,top=100,left=150,width=500,height=400');
  return true;
}
