function gE(tI) { var d=document, r, n, i;
  if (tI instanceof Array) {
    for (n=tI.length, i=0; i<n; i++) r[r.length]=d.getElementById ? d.getElementById(tI) : d.all ? d.all[tI] : false; return r;
  } else { return (d.getElementById) ? d.getElementById(tI) : (d.all) ? d.all[tI] : false; }
}
function adEvento(tO, tE, tF, tPs) { //3.1 - <str/arr tObject(s)>, <str tEvent>, <func tFunction> [, arr tParams]
  if (tO instanceof Array) { for (n=tO.length; n>0; ) { if (!adEvento(tO[--n], tE, tF, tPs)) return false; } return true; }
  var tnF=(tPs) ? function(e) { tF.apply(tO, Array(e).concat(tPs)); } : tF;
  /* Iniciar arrays, caso não existam */ if (!tO.eventos) { tO.eventos=[]; } if (!tO.eventos[tE]) { tO.eventos[tE]=[]; }
  tO.eventos[tE][tO.eventos[tE].length]={tE: tE,   tF: tF,   tPs: tPs };
  if (tO.attachEvent) { tO.attachEvent('on'+tE, tnF); return true; }
  if (tO.addEventListener) { tO.addEventListener(tE, tnF, true); return true; }
  /* alert('Erro!'); */ return false;
}
function childsOfType(tO, tT) { /* tParentObject, <string/arr tTag(s)> */ var i, n, tCs, tR=[];
  tT=new RegExp( (tT instanceof Array)?tT.join('|') : tT , 'i');
  for (i=0, n=(tCs=tO.childNodes).length; i<n; i++) {
    if (tCs[i].nodeType==1 && tT.test(tCs[i].nodeName.toLowerCase())) tR[tR.length]=tCs[i];
  } return (tR.length) ? tR:false;
}
function setOpacity(tObj, curOpacity) {
  with (tObj.style) { opacity=MozOpacity=curOpacity /100; filter='alpha (opacity='+  curOpacity +')'; }
}


function crossFadeRiver() { this.tE=gE('quickopts');
  this.tSecImg=document.createElement('img'); this.tSecImg.src='./images/header2.jpg';
  setOpacity(this.tSecImg, 0);
  this.tPriMenu=this.tE.getElementsByTagName('ul')[0]; this.tSecMenu=this.tPriMenu.cloneNode(1);
  this.tE.appendChild(this.tSecImg); this.tE.appendChild(this.tSecMenu);
  this.tSecMenu.className='d2';

  this.doFade.apply(this);
}
crossFadeRiver.prototype={ fadeSpeed: 3, stopTime: 20000,
  tEs: null, offset: 0, crossFadeRiverTimer: null, curOpacity: 0, fadeDirection: 0, //0 = In, 1 = Out

  doFade: function(haveHiddenMenus) { var demora=100; window.clearTimeout(this.crossFadeRiverTimer);
    //Se está começando um fade (durante o fade), mostrar os dois menus:
    if (haveHiddenMenus) {
      this.tPriMenu.className=this.tPriMenu.className.replace('desativado', '');
      this.tSecMenu.className=this.tSecMenu.className.replace('desativado', '');
    }
    this.curOpacity=(this.fadeDirection) ? this.curOpacity -this.fadeSpeed : this.curOpacity +this.fadeSpeed;
    //Limitar a range 0-100.
    this.curOpacity=(Math.floor(this.curOpacity) < 0) ? 0 : Math.floor(this.curOpacity);
    this.curOpacity=(this.curOpacity > 100) ? 100 : this.curOpacity;
    //Definir opacidade atual
    setOpacity(this.tSecImg, this.curOpacity);
    
    //Verificar se está na hora de mudar a direção...
    if (this.curOpacity == 0 || this.curOpacity == 100) { var tHiddenMenu=0;
      /* Se acabou um FadeOut... */ if (this.fadeDirection) { (tHiddenMenu=this.tSecMenu).className+=' desativado'; }
      /* Se acabou um FadeIn... */ else { (tHiddenMenu=this.tPriMenu).className+= 'desativado'; }
      this.fadeDirection=(!this.fadeDirection); //Inverter direção
      demora=this.stopTime;
    }
    this.crossFadeRiverTimer=window.setTimeout(function() { _this=this;
      return function() { _this.doFade.apply(_this, [tHiddenMenu]); }
    }.apply(this), demora);
    return true;
  }
};
var cD=0; function holocausto() { if (cD) return false; cD=1;
  new crossFadeRiver(); return true;
}
adEvento(window, 'load', holocausto);

	// show menus for editing individual articles
	function toggleEditToolbar()
	{
		var oTglMenus = getObjByID('toggleEditArticleMenus');
		var menus = getNodesFromObj_filterByTagClass(document.body,new Array('div'), 'editArticleMenu');
		var displ = (oTglMenus.innerHTML.toLowerCase().indexOf('hide') > -1)?'none':'block';

		for(var i=0;i < menus.length; i++){ 
			if(menus[i].style) menus[i].style.display = displ;
			else if(menus[i].display) menus[i].display = displ;
		}
		if(displ == 'none'){
			oTglMenus.innerHTML = 'Edit Page';
			oTglMenus.className = '';
		}else{
			oTglMenus.innerHTML = 'Hide Edit Page';
			oTglMenus.className = 'emph';
		}
	}
