/**
 * @author Tony Pinheiro
 */
function slideLeft(){
	this.ul = document.getElementById("letreiro").getElementsByTagName("ul")[0];
	this.getChilds = function(){
		var childs = [];
		for(var i=0; i < this.ul.childNodes.length; i++){
			if(this.ul.childNodes[i].nodeType == 1){
				this.ul.childNodes[i].style.left = '628px';
				childs.push(this.ul.childNodes[i]);
			}
		}
		return childs;
	}
	this.childs = this.getChilds();
	this.posicao = 0;
	this.anterior = 'undefined';
	this.left = 628;
	this.nav = function(){
		if(navigator.appVersion.indexOf("MSIE") == -1){
			return 4;
		}else{
			return 30;
		}
	}
	this.decre = this.nav();
	this.decremento = this.decre;
	this.slide = function(){
		this.left -= this.decremento;
		this.childs[this.posicao].style.left = this.left + 'px';
		if(this.anterior != 'undefined'){
			this.childs[this.anterior].style.left = parseInt(this.childs[this.anterior].style.left) - this.decremento + 'px';
		}

		if(parseInt(this.childs[this.posicao].style.left) > 30){
			setTimeout(function(){
				letreiro.slide();
			}, 1);
		}else if(parseInt(this.childs[this.posicao].style.left) > 0){
			this.decremento = 2;
			setTimeout(function(){
				letreiro.slide();
			}, 1);
		}else{
			this.left = 628;
			this.decremento = this.decre;
			this.anterior = this.posicao;
			if(this.posicao < this.childs.length - 1){
				this.posicao += 1;
			}else{
				this.posicao = 0;
			}
		}
	}
	this.slide();
	setInterval(function(){
		letreiro.slide();
	}, 7000);
	
}

var letreiro = new slideLeft();
