// JavaScript Document
jQuery.noConflict();

jQuery(function(){
	jQuery("#site-cont-produtos h4 a").click(function() {
		jQuery("#site-cont-produtos h4 a").removeClass("pai-ativo");		
		jQuery(this).addClass("pai-ativo");
	});		
});



function exibir_referencia(seg,primeiro)
{
	//document.getElementById('site-cont-produtos-descricao-fotos').innerHTML	= "";
	document.getElementById('site-cont-produtos-ref').innerHTML	= "";
	
	doLoading('site-cont-produtos-ref');	
	
	xmlhttp	=	mount_XMLHttp();
	url	=	"../shared/_ajax.exibir-referencia.php?a=1&seg="+seg;
	
	xmlhttp.open("GET", url,true);
	
	xmlhttp.onreadystatechange=function() {
	
		if(xmlhttp.readyState==4){
			retorno	=	xmlhttp.responseText;		
			document.getElementById('site-cont-produtos-ref').innerHTML	= retorno;
			exibir_referencia_fotos(primeiro,seg);
			jQuery(function(){
				jQuery("#site-cont-produtos-ref h4 a").click(function() {
					jQuery("#site-cont-produtos-ref h4 a").removeClass("ativo-ref");
					jQuery(this).addClass("ativo-ref");
				});		
			});			
		}			
	
	}
	xmlhttp.send(null);
	
}
function exibir_referencia2(seg,primeiro)
{
	
	document.getElementById('site-cont-produtos-descricao-fotos').innerHTML	= "";
	document.getElementById('site-cont-produtos-ref').innerHTML	= "";
	
	doLoading('site-cont-produtos-ref');	
	
	xmlhttp	=	mount_XMLHttp();
	url	=	"../shared/_ajax.exibir-referencia.php?a=1&seg="+seg;
	
	xmlhttp.open("GET", url,true);
	
	xmlhttp.onreadystatechange=function() {
	
		if(xmlhttp.readyState==4){
			retorno	=	xmlhttp.responseText;		
			document.getElementById('site-cont-produtos-ref').innerHTML	= retorno;
			exibir_referencia_fotos(primeiro,seg);
			jQuery(function(){
					jQuery(".categoriaitens li").removeClass("cor");
			});	
			
		}			
	
	}
	xmlhttp.send(null);
	
}

function exibir_referencia_fotos(cod,seg)
{
	doLoading('site-cont-produtos-descricao-fotos');

	xmlhttp	=	mount_XMLHttp();
	url	=	"../shared/_ajax.exibir-referencia-fotos.php?a=1&cod="+cod+"&seg="+seg;
	
	xmlhttp.open("GET", url,true);
	
	xmlhttp.onreadystatechange=function() {
	
		if(xmlhttp.readyState==4){
			retorno	=	xmlhttp.responseText;		
			document.getElementById('site-cont-produtos-descricao-fotos').innerHTML	= retorno;
			jQuery(function(){	
				jQuery("#site-cont-produtos-ref h4 ").click(function() {
					jQuery("#site-cont-produtos-ref h4").removeClass("ativo");
					jQuery(this).addClass("ativo");
				});			
			});			
		}			
	
	}
	xmlhttp.send(null);
}

function doLoading(destino) {
	document.getElementById(destino).innerHTML = "<img src='../shared/img/loading.gif' alt='Carregando' />";
}

function mostra_imagem(imagem,legenda,nro_foto,codigo){
	indImagem										=	nro_foto - 1;
	document.images.img_show.src					=	"../upl/" + imagem;
	document.getElementById("descricao-produtos").innerHTML	=	legenda;
	return false;	
}
function ajaxExibirLinhas(produto){

	xmlhttp	=	mount_XMLHttp();
	url	=	"../shared/_ajax.exibir-linhas.php?a=1&cod="+produto;
	
	xmlhttp.open("GET", url,true);
	
	xmlhttp.onreadystatechange=function() {
	
		if(xmlhttp.readyState==4){
			retorno	=	xmlhttp.responseText;		
			document.getElementById('categorias').innerHTML	= retorno;				
		}					
	
	}

	xmlhttp.send(null);
	
}
function ajaxDescricaoFotos(codigo){

	xmlhttp	=	mount_XMLHttp();
	url	=	"../shared/_ajax.exibir-descricao-imagem.php?produto="+codigo;
	
	xmlhttp.open("GET", url,true);
	
	xmlhttp.onreadystatechange=function() {
	
		if(xmlhttp.readyState==4){
			retorno	=	xmlhttp.responseText;		
			document.getElementById('descricao-produtos').innerHTML	= retorno;				
		}					
	
	}

	xmlhttp.send(null);
	
}
function showFoto(src){
//criando um link falso, para o LightBox captar as informações
var a_false = document.createElement("A");
a_false.rel = "lightbox";
a_false.href = src;
//chamando a função do lightbox responsável pelo início das ações
myLightbox.start(a_false);
//anulando o link
a_false = null;
}