/**
 * @author fsweb
 */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}



//Create namespace
if (at == undefined) var at = {};
if (at.jer == undefined) at.jer = {};

//Newsticker Class
at.jer.fadescrpt = Class.create();
at.jer.fadescrpt.prototype = {
	initialize: function(){
		$arg = $A(arguments);
		this.d = document;
		this.imgs = new Array();
		this.zInterval = null;
		this.current = 0;
		var rand_no = Math.random();

		this.tempodefade=3000;
		this.pause = false;
		if (!this.d.getElementById || !this.d.createElement) 
			return;
		this.container= $($arg[0]);
		this.elementos = "img";
		if($arg[1] != null)
			this.elementos=$arg[1];		
		if($arg[2] != null)
			this.tempodefade=$arg[2];
		this.imgs = $A(this.container.getElementsByTagName(this.elementos));
		if (this.imgs.length > 0) {
			for (this.i = 1; this.i < this.imgs.length; this.i++) 
			{
				this.imgs[this.i].xOpacity = 0;
				this.imgs[this.i].style.visibility = 'hidden';
				this.imgs[this.i].style.position = 'absolute';
				this.imgs[this.i].style.top = '0px';
				this.imgs[this.i].style.left = '0px';
				this.setOpacity(this.imgs[this.i]);
			}
			
			this.imgs[0].style.visibility = 'visible';
			this.imgs[0].style.position = 'relative';
			this.imgs[0].xOpacity = .99;
			setTimeout(this.so_xfade.bind(this), this.tempodefade);
		}
	},
	so_xfade: function(){
		this.cOpacity = this.imgs[this.current].xOpacity;
		this.nIndex = this.imgs[this.current + 1] ? this.current + 1 : 0;
		this.nOpacity = this.imgs[this.nIndex].xOpacity;
		
		this.cOpacity -= .05;
		this.nOpacity += .05;
		
		this.imgs[this.nIndex].style.visibility = 'visible';
		this.imgs[this.current].xOpacity = this.cOpacity;
		this.imgs[this.nIndex].xOpacity = this.nOpacity;
		
		this.setOpacity(this.imgs[this.current]);
		this.setOpacity(this.imgs[this.nIndex]);
		
		if (this.cOpacity <= 0) {
			this.imgs[this.current].style.visibility = 'hidden';
			this.current = this.nIndex;
			setTimeout(this.so_xfade.bind(this), this.tempodefade);
		}
		else {
			setTimeout(this.so_xfade.bind(this), 50);
		}
	},
	setOpacity: function(obj){
		if (obj.xOpacity > .99) {
			obj.xOpacity = .99;
			return;
		}
		
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity * 100) + ')';
	}
}

function GetWidth()
{
        var x = 0;
        if (self.innerHeight)
        {
                x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
                x = document.body.clientWidth;
        }
        return x;
}

function GetHeight()
{
        var y = 0;
        if (self.innerHeight)
        {
                y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                y = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
                y = document.body.clientHeight;
        }
        return y;
}
function fitToScreen()
{
	if(GetWidth()<1024)
	{
		document.getElementById('right').style.width = "660px";
		document.getElementById('container').style.width = "960px";
		document.getElementById('conteudo').style.paddingRight = "80px";
		document.getElementById('containerSombraEsk').style.width = "960px";
		document.getElementById('containerSombraEsk').style.marginRight = "180px";
		document.getElementById('slogan').style.right = "150px";
		document.getElementById('vinte_anos').style.display = "none";
	}
		
}
