// ho brutalmente copiato questo javascript da
// http://www.alistapart.com/articles/alternate/
// ho tolto la parte dei cookie perche' non mi interessava

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
	  a.disabled = true;
	  if(a.getAttribute("title") == title) a.disabled = false;
	}
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	if(a.getAttribute("rel").indexOf("style") != -1
	   && a.getAttribute("rel").indexOf("alt") == -1
	   && a.getAttribute("title")
	   ) return a.getAttribute("title");
  }
  return null;
}

// questo invece e' sudata farina del mio sacco
function alignElem2Elem ( what, towho )
{
	var myBox1 = document.getElementById( towho);
	var bottomCoord = myBox1.offsetTop + myBox1.offsetHeight ;
	var myBox2 = document.getElementById( what);
	myBox2.style.height =  (bottomCoord - myBox2.offsetTop - 2) + "px" ;
}

function formatNumb ( uot )
{
	if ( uot < 1 ) uot = 1 ;
	var myStr = uot.toString() ;
	if ( uot < 10 )
		return ( '00' + myStr );
	if ( uot < 100 )
		return ( '0' + myStr );
	return ( myStr );
}
