// JavaScript Document
function init()
{
	// detect browser
	// siStile o noStile
	setButton();
}
function switchStyle(stato) {
  if (!document.getElementsByTagName) return;
  var el = document.getElementsByTagName("style");
 for (var i = 0; i < el.length; i++ ) {
    if (el[i].getAttribute("type").indexOf("text/css") != -1 /*&& el[i].getAttribute("title")*/) {
      el[i].disabled = stato;
     // if (el[i].getAttribute("title") == s) el[i].disabled = false;
    }
  }
}
function setButton(tipo)// siStile o noStile
{
	var testo_noStile="DISATTIVA STILE";
	var titolo_noStile="Disattiva lo stile di visualizzazione";
	
	var titolo_siStile="Attiva lo stile di visualizzazione";
	var testo_siStile="ATTIVA STILE";
	
	//creo l'Oggetto bottone
	if(!document.getElementById) return;
	var pul = document.createElement("A");
	if(tipo=='siStile')
	{
		pul.setAttribute('href','javascript:switchStyle(false);setButton("noStile")');
		pul.setAttribute('accesskey','6') ;
		pul.setAttribute('title',titolo_siStile) ;
		pul.setAttribute('id','ad-css') ;
		var txt=document.createTextNode(testo_siStile);
		pul.appendChild(txt);
		//--------------------------------------------
		document.getElementById("menu_top").replaceChild(pul,document.getElementById("ad-css"));
	} else if(tipo=='noStile')
	{
		pul.setAttribute('href','javascript:switchStyle(true);setButton("siStile")');
		pul.setAttribute('accesskey','6') ;
		pul.setAttribute('title',titolo_noStile) ;
		pul.setAttribute('id','ad-css') ;
		var txt=document.createTextNode(testo_noStile);
		pul.appendChild(txt);
		//--------------------------------------------
		document.getElementById("menu_top").replaceChild(pul,document.getElementById("ad-css"));
	} else {
		pul.setAttribute('href','javascript:switchStyle(true);setButton("siStile")');
		pul.setAttribute('accesskey','6') ;
		pul.setAttribute('title',titolo_noStile) ;
		pul.setAttribute('id','ad-css') ;
		var txt=document.createTextNode(testo_noStile);
		pul.appendChild(txt);
		//--------------------------------------------
		var spazio = document.createTextNode(" | ");
		document.getElementById("menu_top").appendChild(spazio); 
		document.getElementById("menu_top").appendChild(pul);
	}
}