Produtos ={
	PosicaoAtual : 0,
	CodigoProduto : '',
	CodigoCor : '',
	CodigoTamanho : '',
	Quantidade : 0,
	
	Inicia : function(){
		idProduto = document.form1.hidProduto.value;
		codigoProduto = document.form1.hidCodigoProduto.value;
		idCor = document.form1.hidCor.value;
		codigoCor = document.form1.hidCodigoCor.value;
		tipo = document.form1.hidTipo.value;
		posicao = document.form1.hidPosicao.value;
		
		if (idProduto != ''){
			document.form1.ComboCores.value = idProduto + ' - ' + codigoProduto + ' - ' + idCor + ' - ' + codigoCor + ' - ' + tipo;
			this.TrocaCor(idProduto + ' - ' + codigoProduto + ' - ' + idCor + ' - ' + codigoCor + ' - ' + tipo, posicao);
		}
	},
	
	TrocaCor : function(valor, posicao){
		array_valor = valor.split(' - ');
		produto = array_valor[0];
		this.CodigoProduto = array_valor[1];
		cor = array_valor[2];
		this.CodigoCor = array_valor[3];
		tipo = array_valor[4];

		if (document.getElementById('cor_'+posicao)){
			document.getElementById('imgPrincipal').src = '_IMG/_PRODUTOS/' + array_valor[1] + '_' + array_valor[3] + '_G.jpg';
			document.form1.ComboCores.selectedIndex = posicao;
			document.getElementById('cor_'+this.PosicaoAtual).style.border = '1px solid #ffffff';
			document.getElementById('cor_'+posicao).style.border = '1px solid #d4d4d4';
			this.PosicaoAtual = posicao;
			
			document.getElementById('ImgFrente').href = '#';
			document.getElementById('ImgLateral').href = '#';
			document.getElementById('ImgMedial').href = '#';
			document.getElementById('ImgSolado').href = '#';
			document.getElementById('ImgDetalhe').href = '#';
			document.getElementById('ImgAmpliada').href = '#';
			
			arquivo = funcoes.verificaArquivo('../_IMG/_PRODUTOS/' + array_valor[1] + '_' + array_valor[3] + '_G.jpg');
			if (arquivo.value == 'S'){
				document.getElementById('ImgFrente').href = "javascript:Produtos.TrocaImg('" + array_valor[1] + "_" + array_valor[3] + "_G.jpg')";
	 			document.getElementById('ImgFrente').style.color = '#7F7F7F';
			}else{
				document.getElementById('ImgFrente').style.color = '#d4d4d4';
			}
			
			arquivo = funcoes.verificaArquivo('../_IMG/_PRODUTOS/' + array_valor[1] + '_' + array_valor[3] + '_G.jpg');
			if (arquivo.value == 'S'){
				document.getElementById('ImgLateral').href = "javascript:Produtos.TrocaImg('" + array_valor[1] + "_" + array_valor[3] + "_G.jpg')";
	 			document.getElementById('ImgLateral').style.color = '#7F7F7F';
			}else{
				document.getElementById('ImgLateral').style.color = '#d4d4d4';
			}
			
			arquivo = funcoes.verificaArquivo('../_IMG/_PRODUTOS/' + array_valor[1] + '_' + array_valor[3] + '_GL.jpg');
			if (arquivo.value == 'S'){
				document.getElementById('ImgMedial').href = "javascript:Produtos.TrocaImg('" + array_valor[1] + "_" + array_valor[3] + "_GL.jpg')";
				document.getElementById('ImgMedial').style.color = '#7F7F7F';
			}else{
				document.getElementById('ImgMedial').style.color = '#d4d4d4';
			}
			
			arquivo = funcoes.verificaArquivo('../_IMG/_PRODUTOS/' + array_valor[1] + '_' + array_valor[3] + '_GS.jpg');
			if (arquivo.value == 'S'){
				document.getElementById('ImgSolado').href = "javascript:Produtos.TrocaImg('" + array_valor[1] + "_" + array_valor[3] + "_GS.jpg')";
				document.getElementById('ImgSolado').style.color = '#7F7F7F';
			}else{
				document.getElementById('ImgSolado').style.color = '#d4d4d4';
			}
			
			arquivo = funcoes.verificaArquivo('../_IMG/_PRODUTOS/' + array_valor[1] + '_' + array_valor[3] + '_G_D.jpg');
			if (arquivo.value == 'S'){
				document.getElementById('ImgDetalhe').href = "javascript:Produtos.TrocaImg('" + array_valor[1] + "_" + array_valor[3] + "_G_D.jpg')";
				document.getElementById('ImgDetalhe').style.color = '#7F7F7F';
			}else{
				document.getElementById('ImgDetalhe').style.color = '#d4d4d4';
			}
			
			arquivo = funcoes.verificaArquivo('../_IMG/_PRODUTOS/' + array_valor[1] + '_' + array_valor[3] + '_GG.jpg');
			if (arquivo.value == 'S'){
				document.getElementById('ImgAmpliada').href = "javascript:Produtos.AmpliaImg('" + array_valor[1] + "_" + array_valor[3] + "_GG.jpg')";
				document.getElementById('ImgAmpliada').style.color = '#7F7F7F';
			}else{
				document.getElementById('ImgAmpliada').style.color = '#d4d4d4';
			}
			
			document.getElementById('esgotado').style.display = 'none';
			document.getElementById('DivComboNumero').innerHTML = produtos.carregaNetshoes(produto, cor, tipo).value;
			relacionamentos = produtos.carregaRelacionados(produto, cor).value;
			if (relacionamentos == ''){
				document.getElementById('relacionados').style.display = 'none';
			}else{
				document.getElementById('relacionados').style.display = '';
				document.getElementById('DivRelacionados').innerHTML = relacionamentos;
			}
			document.getElementById('DestaquesLaterais').innerHTML = produtos.carregaDestaques(produto, cor).value;
		}
	},
	
	TrocaImg : function(valor){
		document.getElementById('imgPrincipal').src = '_IMG/_PRODUTOS/' + valor;
	},
	
	AmpliaImg : function(valor){
		FuncoesGerais.popup("pop_ampliada.aspx?img=_IMG/_PRODUTOS/"+valor, 'ASICS', 'width=460,height=390');
	},
	
	Pisada : function(){
		document.getElementById('DivPisada').style.display = 'none';
	},
	
	CarregaComprar : function(codigo){
		array_valor = codigo.split(' - ');
		this.CodigoTamanho = array_valor[0];
		this.Quantidade = array_valor[1];
		if(this.CodigoTamanho == 'Selecione'){
			document.getElementById('esgotado').style.display = 'none';
			document.getElementById('DivPreco').style.display = 'none';
		}else if(this.CodigoTamanho != '' && this.Quantidade > 0){
			document.getElementById('esgotado').style.display = 'none';
			document.getElementById('DivPreco').style.display = '';
		}else if(this.CodigoTamanho != '' && this.Quantidade == 0){
			document.getElementById('DivPreco').style.display = 'none';
			document.getElementById('BtnAvise').style.display = 'none';
			document.getElementById('esgotado').style.display = '';
		}else{
			document.getElementById('DivPreco').style.display = 'none';
			document.getElementById('BtnAvise').style.display = 'none';
			document.getElementById('esgotado').style.display = '';
		}
	},
	
	Comprar : function(){
		if (this.CodigoTamanho != ''){
			//alert('ok');
			var urlCompra = 'http://www.rumo.com.br/sistema/AddProduto.asp?IDLoja=9170&IDProduto=' + this.CodigoTamanho;
			window.location.href = urlCompra;
		}else{
			alert('Selecione o tamanho');
		}
	},
	
	Avise : function(){
		window.open('http://www.rumo.com.br/sistema/AvisaDispProduto.asp?IDLoja=9170&IDProduto=' + this.CodigoTamanho, 'ASICS',"width=420, height=300"); 
	},
	
	Relacionado : function(idProduto, codigoProduto, idCor, codigoCor, tipo, url){
		document.form1.hidProduto.value = idProduto;
		document.form1.hidCodigoProduto.value = codigoProduto;
		document.form1.hidCor.value = idCor;
		document.form1.hidCodigoCor.value = codigoCor;
		document.form1.hidTipo.value = tipo;
		document.form1.action = url;
		document.form1.submit();
	}
}