/*
 *
 * GoldenVitrine
 * Desenvolvedor: Fernando Arroyo
 * GoldenLight [ fernando.arroyo@goldenlight.biz ]
 * 31.08.2009
 *
 */

var GoldenVitrineV3=function(Parametros){

	/*
	 * Parâmetros:
	 * 
	 * Itens: array[ [ Nome, Descrição, Imagem, Miniatura, Função ] ]
	 * Alvo: Objeto
	 * 
	 */

	GoldenVitrineV3_SomenteLeitura={
			ImagemSelecionada:0
	}
	this.Nova=function(){

		GoldenVitrine_Funcoes={
				RolarMiniaturas:this.RolarMiniaturas
				,SelecionarMiniatura:this.SelecionarMiniatura
				,SelecionarDestaque:this.SelecionarDestaque
		}

		/*_-_-_- + Elemento contendo o Botão Esquerda + -_-_-_*/


		__gV__ElementoPaiSubir = document.createElement("div");
		__gV__ElementoPaiSubir.style.display = "inline-block";
		__gV__ElementoPaiSubir.style.position = "absolute";
		__gV__ElementoPaiSubir.style.top = "10px";
		__gV__ElementoPaiSubir.style.left = "225px";
		__gV__ElementoPaiSubir.style.zIndex = "999999";
		__gV__ElementoPaiSubir.style.width = "13px";
		__gV__ElementoPaiSubir.style.height = "13px";
		__gV__ElementoPaiSubir.style.textAlign = "center";
		/*_-_-_- - Elemento contendo o Botão Subir - -_-_-_*/
		
		
		/*_-_-_- + Elemento contendo a div com o Titulo + -_-_-_*/


		Div_Titulo = document.createElement("div");

		Div_Titulo.setAttribute("id","Div_Titulo")
		Div_Titulo.style.display    = "block";
		Div_Titulo.style.position   = "absolute";
		Div_Titulo.style.top        = "5px";
		Div_Titulo.style.left       = "377px";
		Div_Titulo.style.width      = "241px";
		Div_Titulo.style.padding    = "0px";
		Div_Titulo.style.fontFamily = "Verdana";
		Div_Titulo.style.fontSize   = "14px";
		Div_Titulo.style.fontWeight = "bolder";
		Div_Titulo.style.color      = "black";
		Div_Titulo.style.textAlign  = "center";
		Div_Titulo.style.height     = "36px";
		Div_Titulo.style.overflow   = "hidden";

		/*_-_-_- + Elemento contendo a div com o contador de paginas + -_-_-_*/
		Div_Contador = document.createElement("div");
		Div_Contador.setAttribute("id","Div_Contador")
		Div_Contador.style.display    = "block";
		Div_Contador.style.position   = "absolute";
		Div_Contador.style.top        = "276px";
		Div_Contador.style.left       = "495px";
		Div_Contador.style.width      = "30px";
		Div_Contador.innerHTML        ="teste";
		Div_Contador.style.marginRigth = "100px";


		/*_-_-_- + Elemento contendo a div com os botoes + -_-_-_*/
		Div_Botoes = document.createElement("div");
		Div_Botoes.setAttribute("id","Div_Botoes");
		Div_Botoes.style.display    = "block";
		Div_Botoes.style.position   = "absolute";
		Div_Botoes.style.top        = "276px";
		Div_Botoes.style.left       = "540px";
		Div_Botoes.style.width      = "85px";
		Div_Botoes.style.textAlign  = "right";


		/*_-_-_- + Elemento com o Link Recuar + -_-_-_*/
		Link_Recuar = document.createElement("a");
		Link_Recuar.setAttribute("href","javascript:void(0);")
		Link_Recuar.style.outline=0;
		Link_Recuar.setAttribute("rel","Recuar");
		Link_Recuar.style.marginRight = "14px";
		Link_Recuar.onclick=this.ControleDestaque;
		/*_-_-_- - Elemento com o Link Recuar - -_-_-_*/


		/*_-_-_- + Elemento com o Link Avançar + -_-_-_*/
		Link_Avancar = document.createElement("a");
		Link_Avancar.setAttribute("href","javascript:void(0);");
		Link_Avancar.setAttribute("rel","Avancar");
		Link_Avancar.style.outline=0;
		Link_Avancar.onclick=this.ControleDestaque;
		/*_-_-_- - Elemento com o Link Avançar - -_-_-_*/	


		/*_-_-_- + Elemento com o Link Pausar + -_-_-_*/
		Link_Pausar = document.createElement("a");
		Link_Pausar.setAttribute("href","javascript:void(0);");
		Link_Pausar.style.outline=0;
		Link_Pausar.setAttribute("rel","Pausar");
		Link_Pausar.style.marginRight = "13px";
		Link_Pausar.onclick=this.ControleDestaque;



		/*_-_-_- - Elemento com o Link Pausar - -_-_-_*/	


		/*_-_-_- + Elemento contendo a Imagem de Recuar + -_-_-_*/
		Imagem_Recuar = document.createElement("img");
		Imagem_Recuar.setAttribute("src",window["CaminhoRaiz"]+"/goldenguia/img/GV_btnEsque.jpg");
		/*_-_-_- - Elemento contendo a Imagem de Recuar - -_-_-_*/

		/*_-_-_- + Elemento contendo a Imagem de Avaçar + -_-_-_*/
		Imagem_Avancar = document.createElement("img");
		Imagem_Avancar.setAttribute("src",window["CaminhoRaiz"]+"/goldenguia/img/GV_btnDirei.jpg");
		/*_-_-_- - Elemento contendo a Imagem de Avançar - -_-_-_*/ 	

		/*_-_-_- + Elemento contendo a Imagem de Pausar + -_-_-_*/
		Imagem_Pausar = document.createElement("img");
		Imagem_Pausar.setAttribute("src",window["CaminhoRaiz"]+"/goldenguia/img/GV_btnPause.jpg");
		/*_-_-_- - Elemento contendo a Imagem de Pausar - -_-_-_*/ 	


		/*_-_-_- + Elemento contendo o Link do Botão Subir + -_-_-_*/
		__gV__ElementoLinkSubir = document.createElement("a");
		__gV__ElementoLinkSubir.setAttribute("href","javascript:void(0);");
		__gV__ElementoLinkSubir.style.textDecoration="none";
		__gV__ElementoLinkSubir.onclick=function(){
			GoldenVitrine_Funcoes.RolarMiniaturas("Subir");
		};
		__gV__ElementoLinkSubir.onmouseover=function(){

		};
		__gV__ElementoLinkSubir.onmouseout=function(){

		};
		/*_-_-_- - Elemento contendo o Link do Botão Subir - -_-_-_*/

		/*_-_-_- + Elemento Botão Subir + -_-_-_*/
		__gV__ElementoBotaoSubir = document.createElement("img");
		__gV__ElementoBotaoSubir.setAttribute("src",window["CaminhoRaiz"]+"/images/"+"SetaCimaBrancaVitrineV2.png");
		__gV__ElementoBotaoSubir.setAttribute("alt","");
		__gV__ElementoBotaoSubir.style.width  = "13px";
		__gV__ElementoBotaoSubir.style.height = "13px";
		__gV__ElementoBotaoSubir.style.border = "none";
		/*_-_-_- - Elemento Botão Subir - -_-_-_*/

		/*_-_-_- + Elemento contendo a Faixa de Informações + -_-_-_*/
		__gV__ElementoFaixaInformacoes = document.createElement("div");
		__gV__ElementoFaixaInformacoes.setAttribute("id","__GoldenVitrine__FaixaInformacoes__")
		__gV__ElementoFaixaInformacoes.style.display         = "inline-block";
		__gV__ElementoFaixaInformacoes.style.position        = "absolute";
		__gV__ElementoFaixaInformacoes.style.left            = "377px";
		__gV__ElementoFaixaInformacoes.style.top             = "0px";
		__gV__ElementoFaixaInformacoes.style.width           = "270px";
		__gV__ElementoFaixaInformacoes.style.backgroundColor = "#f4f4ef";
		__gV__ElementoFaixaInformacoes.style.overflow        = "hidden";
		/*_-_-_- - Elemento contendo a Faixa de Informações - -_-_-_*/

		/*_-_-_- + Elemento contendo a Faixa de Informações + -_-_-_*/
		__gV__ElementoTituloEmpresa = document.createElement("div");
		__gV__ElementoTituloEmpresa.style.display     = "inline-block";
		__gV__ElementoTituloEmpresa.style.position    = "absolute";
		__gV__ElementoTituloEmpresa.style.left        = "10px";
		__gV__ElementoTituloEmpresa.style.top         = "10px";
		__gV__ElementoTituloEmpresa.style.fontWeight  = "bolder";
		__gV__ElementoTituloEmpresa.style.fontSize    = "16px";
		__gV__ElementoTituloEmpresa.innerHTML         = "Golden Light Business";
		__gV__ElementoTituloEmpresa.style.overflow    = "hidden";
		/*_-_-_- - Elemento contendo a Faixa de Informações - -_-_-_*/

		/*_-_-_- + Elemento contendo o Botão Descer + -_-_-_*/
		__gV__ElementoPaiDescer = document.createElement("div");
		__gV__ElementoPaiDescer.style.display    = "inline-block";
		__gV__ElementoPaiDescer.style.position   = "absolute";
		__gV__ElementoPaiDescer.style.top        = "270px";
		__gV__ElementoPaiDescer.style.left       = "225px";
		__gV__ElementoPaiDescer.style.zIndex     = "999999";
		__gV__ElementoPaiDescer.style.width      = "13px";
		__gV__ElementoPaiDescer.style.height     = "13px";
		__gV__ElementoPaiDescer.style.paddingTop = "0px";
		__gV__ElementoPaiDescer.style.textAlign  = "center";
		/*_-_-_- - Elemento contendo o Botão Descer - -_-_-_*/

		/*_-_-_- + Elemento contendo o Link do Botão Descer + -_-_-_*/
		__gV__ElementoLinkDescer = document.createElement("a");
		__gV__ElementoLinkDescer.setAttribute("href","javascript:void(0);");
		__gV__ElementoLinkDescer.style.textDecoration="none";
		__gV__ElementoLinkDescer.onclick=function(){
			GoldenVitrine_Funcoes.RolarMiniaturas("Descer");
		};
		__gV__ElementoLinkDescer.onmouseover=function(){
		};
		__gV__ElementoLinkDescer.onmouseout=function(){

		};
		/*_-_-_- - Elemento contendo o Link do Botão Descer - -_-_-_*/

		/*_-_-_- + Elemento Botão Descer + -_-_-_*/
		__gV__ElementoBotaoDescer = document.createElement("img");
		__gV__ElementoBotaoDescer.setAttribute("src",window["CaminhoRaiz"]+"/images/"+"SetaBaixoCinzaVitrineV2.png");
		__gV__ElementoBotaoDescer.setAttribute("alt","");
		__gV__ElementoBotaoDescer.style.width = "13px";
		__gV__ElementoBotaoDescer.style.height = "13px";
		__gV__ElementoBotaoDescer.style.border = "none";
		/*_-_-_- - Elemento Botão Descer - -_-_-_*/

		/*_-_-_- + Elemento Destaque + -_-_-_*/
		__gV__ElementoDestaque = document.createElement("div");
		__gV__ElementoDestaque.style.display = "block";
		__gV__ElementoDestaque.style.position = "absolute";
		__gV__ElementoDestaque.style.top = "5px";
		__gV__ElementoDestaque.style.left = "5px";
		__gV__ElementoDestaque.style.width = "372px";
		__gV__ElementoDestaque.style.height = "290px";
		__gV__ElementoDestaque.style.overflow = "hidden";
		__gV__ElementoDestaque.style.backgroundColor = "#ffffff";
		__gV__ElementoDestaque.style.border = "none";
		/*_-_-_- - Elemento Destaque - -_-_-_*/

		/*_-_-_- + Elemento Destaque Camada contendo Imagem + -_-_-_*/
		__gV__ElementoDestaqueCamada = document.createElement("span");
		__gV__ElementoDestaqueCamada.setAttribute("id","__GoldenVitrine__sDestaque__");
		__gV__ElementoDestaqueCamada.style.display = "block";
		__gV__ElementoDestaqueCamada.style.position = "absolute";
		__gV__ElementoDestaqueCamada.style.top = "0px";
		__gV__ElementoDestaqueCamada.style.left = "0px";
		__gV__ElementoDestaqueCamada.style.width = "372px";
		__gV__ElementoDestaqueCamada.style.height = "290px";
		__gV__ElementoDestaqueCamada.style.filter="alpha(opacity=25)";
		__gV__ElementoDestaqueCamada.style.opacity=0.25;
		/*_-_-_- - Elemento Destaque Camada contendo Imagem - -_-_-_*/

		/*_-_-_- + Elemento Destaque Imagem + -_-_-_*/
		__gV__ElementoImagemDestaque = document.createElement("img");
		__gV__ElementoImagemDestaque.setAttribute("id","__GoldenVitrine__iDestaque__");
		__gV__ElementoImagemDestaque.style.width = "372px";
		__gV__ElementoImagemDestaque.style.border = "none";
		/*_-_-_- - Elemento Destaque Imagem - -_-_-_*/

		/*_-_-_- + Elemento contendo o Link do Destaque + -_-_-_*/
		__gV__ElementoLinkDestaque = document.createElement("a");
		__gV__ElementoLinkDestaque.setAttribute("href","javascript:void(0);");
		__gV__ElementoLinkDestaque.setAttribute("rel","i=0");
		__gV__ElementoLinkDestaque.style.textDecoration="none";
		__gV__ElementoLinkDestaque.onclick = function(){
			Parametros.Itens[(parseInt(__gV__ElementoLinkDestaque.rel.toString().split("=")[1]))][4]();
		}
		__gV__ElementoLinkDestaque.onmouseover=function(){

		};
		__gV__ElementoLinkDestaque.onmouseout=function(){

		};
		/*_-_-_- - Elemento contendo o Link do Destaque - -_-_-_*/

		/*_-_-_- + Elemento Descrição + -_-_-_*/
		__gV__ElementoDescricao = document.createElement("div");
		__gV__ElementoDescricao.setAttribute("id","__GoldenVitrine__Descricao__")
		__gV__ElementoDescricao.style.display     = "block";
		__gV__ElementoDescricao.style.position    = "absolute";
		__gV__ElementoDescricao.style.top         = "41px";
		__gV__ElementoDescricao.style.left        = "379px";
		__gV__ElementoDescricao.style.width       = "240px";
		__gV__ElementoDescricao.style.height      = "225px";
		__gV__ElementoDescricao.style.padding     = "5px";
		__gV__ElementoDescricao.style.fontFamily  = "Verdana";
		__gV__ElementoDescricao.style.fontSize    = "11px";
		__gV__ElementoDescricao.style.fontWeight  = "bolder";
		__gV__ElementoDescricao.style.color       = "black";
		__gV__ElementoDescricao.style.overflow    = "hidden";
		// __gV__ElementoDescricao.style.backgroundImage = "url("+window["CaminhoRaiz"]+"/goldenguia/img/bk_preto_transparente.png)";
		/*_-_-_- - Elemento Descrição - -_-_-_*/

		/*_-_-_- + Elemento Pai + -_-_-_*/
		__gV__ElementoPai = document.createElement("div");
		__gV__ElementoPai.style.display         = "inline-block";
		__gV__ElementoPai.style.position        = "relative";
		__gV__ElementoPai.style.cssFloat        = "left";
		__gV__ElementoPai.style.width           = "630px";
		__gV__ElementoPai.style.height          = "300px";
		__gV__ElementoPai.style.overflow        = "hidden";
		__gV__ElementoPai.style.backgroundColor = "#ededed";
		__gV__ElementoPai.style.border          = "none";
		/*_-_-_- - Elemento Pai - -_-_-_*/

		/*_-_-_- + Hierarquia de Elementos + -_-_-_*/
		__gV__ElementoLinkDestaque.appendChild(__gV__ElementoImagemDestaque);
		__gV__ElementoDestaqueCamada.appendChild(__gV__ElementoLinkDestaque);
		__gV__ElementoDestaque.appendChild(__gV__ElementoDestaqueCamada);
		__gV__ElementoPai.appendChild(Div_Titulo);
		__gV__ElementoPai.appendChild(Div_Contador);
		
		Link_Recuar.appendChild(Imagem_Recuar);
		Div_Botoes.appendChild(Link_Recuar);
		Link_Pausar.appendChild(Imagem_Pausar);
		Div_Botoes.appendChild(Link_Pausar);
		Link_Avancar.appendChild(Imagem_Avancar);
		Div_Botoes.appendChild(Link_Avancar);
		__gV__ElementoPai.appendChild(Div_Botoes);
		__gV__ElementoPai.appendChild(__gV__ElementoDestaque);
		__gV__ElementoPai.appendChild(__gV__ElementoDescricao);
		Parametros.Alvo.appendChild(__gV__ElementoPai);
		/*_-_-_- - Hierarquia de Elementos - -_-_-_*/
		GoldenVitrine_Funcoes.SelecionarDestaque(0);

		//PreLoader(0,Parametros);
	}

	this.ControleDestaque = function (){
		Controle=this.rel;
		switch(Controle){
		case "Recuar":
			if(GoldenVitrineV3_SomenteLeitura.ImagemSelecionada){
				GoldenVitrine_Funcoes.SelecionarDestaque(GoldenVitrineV3_SomenteLeitura.ImagemSelecionada-1);			
			}
			else{
				GoldenVitrine_Funcoes.SelecionarDestaque(Parametros.Itens.length-1);			
			}
			break;
		case "Avancar":
			if(GoldenVitrineV3_SomenteLeitura.ImagemSelecionada<(Parametros.Itens.length-1)){
				GoldenVitrine_Funcoes.SelecionarDestaque(GoldenVitrineV3_SomenteLeitura.ImagemSelecionada+1);			
			}
			else{
				GoldenVitrine_Funcoes.SelecionarDestaque(0);
			}
			break;
		case "Pausar":
			if(typeof(window["AutoSelDestaque"])!="undefined"){
				clearTimeout(AutoSelDestaque);
			}
			else{
				AutoSelDestaque = window.setTimeout("_gV.SelecionarDestaque("+GoldenVitrineV3_SomenteLeitura.ImagemSelecionada+1+")",20000);
			}
			break;

		}



	}

	/*_-_-_- + Seleção de Destaque + -_-_-_*/
	this.SelecionarDestaque=function(Indice){
		if(typeof(window["AutoSelDestaque"])!="undefined"){
			clearTimeout(AutoSelDestaque);
		}
		__gV__ElementoImagemDestaque.setAttribute("src",Parametros.Itens[Indice][3]);
		__gV__ElementoImagemDestaque.setAttribute("alt",Parametros.Itens[Indice][3].toString().split("/")[(Parametros.Itens[Indice][3].toString().split("/").length-1)].split(".")[0]);
		__gV__ElementoLinkDestaque.setAttribute("rel","i="+Indice);
		__gV__ElementoDestaqueCamada.style.filter="alpha(opacity=25)";
		__gV__ElementoDestaqueCamada.style.opacity=0.25;
		Div_Titulo.innerHTML        = Parametros.Itens[Indice][0];
		Div_Contador.innerHTML      = (Indice+1)+"/"+Parametros.Itens.length;

		$("#__GoldenVitrine__Descricao__").html(
				Parametros.Itens[Indice][1]
		);
		if(typeof(window["AnmTexto"])!="undefined"){
			clearTimeout(AnmTexto);
		}
		$("#__GoldenVitrine__sDestaque__").animate({
			filter:"alpha(opacity=100)"
				,opacity:1
		},600,"swing",function(){
			$("#__GoldenMiniaturas_i"+Indice+"__").animate({
				filter:"alpha(opacity=100)"
					,opacity:1
			},600,"swing",function(){
				for(xAlfaMiniaturas=0;xAlfaMiniaturas<document.getElementById("__GoldenVitrine__Miniaturas__").childNodes.length;xAlfaMiniaturas++){
					if (xAlfaMiniaturas != Indice) {
						$("#__GoldenMiniaturas_d" + (xAlfaMiniaturas) + "__").css("border", "solid 2px #D1D1D1");
						$("#__GoldenMiniaturas_i" + (xAlfaMiniaturas) + "__").animate({
							filter: "alpha(opacity=25)",
							opacity: 0.25
						}, 600, "swing",function(){
							$("#__GoldenVitrine__Miniaturas__").scrollTop(Indice*75);								
						});
					}
				}
			});
		});
		ProxIndice=Indice+1;
		if(ProxIndice==Parametros.Itens.length){
			ProxIndice=0;
		}
		AutoSelDestaque = window.setTimeout("_gV.SelecionarDestaque("+ProxIndice+")",20000);
		iGM=0;
		GoldenVitrineV3_SomenteLeitura.ImagemSelecionada=Indice;
	}
	/*_-_-_- - Seleção de Destaque - -_-_-_*/

	/*_-_-_- + PreLoader das Imagens + -_-_-_*/
	PreLoader=function(Indice,Parametros){
		pLoad=new Image();
		pLoad.src=Parametros.Itens[Indice][3];
//		pLoad.onload=function(){
		if(Indice<(Parametros.Itens.length-1)){
			PreLoader((Indice+1),Parametros);
		}
		else{
			Parametros.Alvo.innerHTML="";
			Parametros.Alvo.appendChild(__gV__ElementoPai);
			GoldenVitrine_Funcoes.SelecionarDestaque(0);
		}
//		}
		GoldenVitrine_Funcoes.SelecionarDestaque(0);
	}
	/*_-_-_- - PreLoader das Imagens - -_-_-_*/
}
