home = {
	carregaVideo : function(video){
		document.getElementById('tituloVideo').innerHTML = document.getElementById('txtTitulo' + video).value;
		document.getElementById('embedVideo').innerHTML = document.getElementById('txtVideo' + video).value;
		
		divs = document.getElementById('divGaleriaHome').getElementsByTagName('a');
		quantidade = divs.length;
		for(a=0;a<quantidade;a++){
			divs[a].style.backgroundColor = '';
		}
		
		document.getElementById('linkVideo' + video).style.backgroundColor = '#9e180a';
		
		classVideosViews.insere(video).value;
	},
	
	//////////////////////////////Galeria////////////////////////////////
	Galeria_totVideos : 1,
	Galeria_distanciaVideos : 0,
	Galeria_elementoVideos : '',
	Galeria_posicao_inicialVideos : 0,
	ExecutandoVideos : 0,
	Galeria_tot_finalVideos : 0,
	VideosTotal : 0,
	VideosAtual : 0,
	VideosFinal : 0,
	DistanciaInicial : 0,
		
	GaleriaIniciaVideos : function(elemento,distancia){
		this.DistanciaInicial = distancia;
		this.Galeria_distanciaVideos = distancia;
		this.Galeria_elementoVideos = elemento;
		this.Galeria_tot_finalVideos = Math.ceil(document.getElementById('divTotalVideos').value / 5);
		this.VideosTotal = document.getElementById('divTotalVideos').value;
		if (this.VideosTotal > 5){
			this.VideosAtual = 5;
		}else{
			this.VideosAtual = this.VideosTotal;
		}
		if (this.Galeria_tot_finalVideos <=1){
			document.getElementById('btnProximo').innerHTML = '<a><img src="_IMG/bt_video_scroll_bottom.gif" alt="" /></a>';
		}
	},
	
	ExecutarVideos : function(sentido){
		if(this.ExecutandoVideos==0){
			this.Galeria_totVideos -= sentido;
			this.ExecutandoVideos = 1;
			this.GaleriaCorreVideos(sentido);
			this.VideosFinal = this.VideosAtual - (sentido * 5);

			if (this.VideosFinal > this.VideosTotal){
				this.VideosFinal = this.VideosTotal;
			}
			if (((this.VideosFinal - this.VideosAtual) < 5) && ((this.VideosFinal - this.VideosAtual) >= 0)){
				this.Galeria_distanciaVideos = (this.DistanciaInicial / 5) * (this.VideosTotal - this.VideosAtual);
			}else{
				if (this.VideosFinal > 5){
					this.Galeria_distanciaVideos = this.DistanciaInicial;
				}else{
					this.Galeria_distanciaVideos = (this.DistanciaInicial / 5) * (this.VideosFinal);
				}
			}
			this.VideosAtual -= (sentido * 5);
			if (this.VideosAtual < 5){
				this.VideosAtual = 5;
			}
			if (this.VideosAtual > this.VideosTotal){
				this.VideosAtual = this.VideosTotal;
			}
		}
	},
	
	GaleriaCorreVideos : function(sentido){
		div_left = document.getElementById(this.Galeria_elementoVideos).style.marginTop;
		if(div_left=='')
			div_left=0;
		else{
			aux = div_left.split('p');
			div_left = parseInt(aux[0]);
		}

		if(sentido==-1){
			posicao_final = this.Galeria_posicao_inicialVideos - this.Galeria_distanciaVideos;
		}else if(sentido==1){
			posicao_final = this.Galeria_posicao_inicialVideos + this.Galeria_distanciaVideos;
		}

		if (((sentido == -1) && (div_left > posicao_final)) || ((sentido == 1) && (div_left < posicao_final))){
			if(sentido==-1){
				var aux =  Math.floor((posicao_final - div_left) / 20);
				div_left_novo = (div_left + aux) + 'px'; 
				document.getElementById(this.Galeria_elementoVideos).style.marginTop = div_left_novo;
				setTimeout("home.GaleriaCorreVideos(-1)",15);
			}else if(sentido==1){
				var aux =  Math.ceil((posicao_final - div_left) / 20);
				div_left_novo = (div_left + aux) + 'px'; 
				document.getElementById(this.Galeria_elementoVideos).style.marginTop = div_left_novo;
				setTimeout("home.GaleriaCorreVideos(1)",15);
			}
		}else{
			this.Galeria_posicao_inicialVideos = posicao_final;

			if(div_left==0)
				document.getElementById('btnAnterior').innerHTML = '<a><img src="_IMG/bt_video_scroll_top.gif" alt="" /></a>';
			else
				document.getElementById('btnAnterior').innerHTML = '<a href="javascript:home.ExecutarVideos(1)"><img src="_IMG/bt_video_scroll_top.gif" alt="" /></a>';

			if(this.Galeria_tot_finalVideos<=this.Galeria_totVideos)
				document.getElementById('btnProximo').innerHTML = '<a><img src="_IMG/bt_video_scroll_bottom.gif" alt="" /></a>';
			else
				document.getElementById('btnProximo').innerHTML = '<a href="javascript:home.ExecutarVideos(-1)"><img src="_IMG/bt_video_scroll_bottom.gif" alt="" /></a>';

			this.ExecutandoVideos=0;
		}
		
	}
	//////////////////////////////Galeria////////////////////////////////
}