lightbox = {
	contentBox : '',

	abrir : function(box, conteudo){
		
		document.body.innerHTML = "<div id='opacity' style='z-index: 888; position: absolute; left: 0; top: 0; width: 100%; line-height: 0; height: 100%; background-color: #000; -moz-opacity: 0.70; opacity:.70; filter: alpha(opacity=70); display: none;'></div><table align='center' id='tabela' cellpadding='0' cellspacing='0' style='position:absolute; top:0; left:0; z-index: 990;'>	<tr><td align='center' id='tabelaTd'></td></tr></table>" + document.body.innerHTML;
		this.contentBox = this.E(box).cloneNode(true);
		this.removeElement(box);
		this.E('tabelaTd').appendChild(this.contentBox);

		this.apagaCombos();
		this.reexibeCombos(box);

		divOpacity = this.E('opacity');
		tableLightBox = this.E('tabela');
		divBox = this.E(box);

		medidas = this.pegaMedidas(true); 
		larguraPag = medidas[0];
		alturaPag = medidas[1];

		divOpacity.style.height = alturaPag + 'px';
		divOpacity.style.width = larguraPag + 'px';
		if (tableLightBox){
			tableLightBox.style.width = this.tPg().ww + 'px';
			tableLightBox.style.height = this.tPg().wh + 'px';
			tableLightBox.style.top = this.ScrollP().y + 'px';
			tableLightBox.style.left = this.ScrollP().x + 'px';
			tableLightBox.style.display = '';
		}
		divOpacity.style.display = '';
		divOpacity.style.filter = 'alpha(opacity=0)';
		divOpacity.style.opacity = '0';
		if (navigator.userAgent.toLowerCase().indexOf('gecko/') != -1){
			lightbox.OpacityInicia('opacity',5,0,75,box);
		}else{
			lightbox.OpacityInicia('opacity',15,0,75,box);
		}
		if (this.E(conteudo)) {
			this.E(conteudo).style.display = '';
		}
		
	},




	abrirProdutos : function(box, conteudo,imagem){
		
		document.getElementById('img_lightbox').src = '_IMG/PRODUTOS/'+imagem
		document.body.innerHTML = "<div id='opacity' style='z-index: 888; position: absolute; left: 0; top: 0; width: 100%; line-height: 0; height: 100%; background-color: #000; -moz-opacity: 0.70; opacity:.70; filter: alpha(opacity=70); display: none;'></div><table align='center' id='tabela' cellpadding='0' cellspacing='0' style='position:absolute; top:0; left:0; z-index: 990;'>	<tr><td align='center' id='tabelaTd'></td></tr></table>" + document.body.innerHTML;
		
		this.contentBox = this.E(box).cloneNode(true);
		this.removeElement(box);
		this.E('tabelaTd').appendChild(this.contentBox);

		this.apagaCombos();
		this.reexibeCombos(box);

		divOpacity = this.E('opacity');
		tableLightBox = this.E('tabela');
		divBox = this.E(box);

		medidas = this.pegaMedidas(true); 
		larguraPag = medidas[0];
		alturaPag = medidas[1];

		divOpacity.style.height = alturaPag + 'px';
		divOpacity.style.width = larguraPag + 'px';
		if (tableLightBox){
			tableLightBox.style.width = this.tPg().ww + 'px';
			tableLightBox.style.height = this.tPg().wh + 'px';
			tableLightBox.style.top = this.ScrollP().y + 'px';
			tableLightBox.style.left = this.ScrollP().x + 'px';
			tableLightBox.style.display = '';
		}
		divOpacity.style.display = '';
		divOpacity.style.filter = 'alpha(opacity=0)';
		divOpacity.style.opacity = '0';
		if (navigator.userAgent.toLowerCase().indexOf('gecko/') != -1){
			lightbox.OpacityInicia('opacity',5,0,75,box);
		}else{
			lightbox.OpacityInicia('opacity',15,0,75,box);
		}
		if (this.E(conteudo)) {
			this.E(conteudo).style.display = '';
		}
		
	},
	
	
	
	abrirVideosProdutos : function(box,conteudo,video,frame){
		
		
		document.body.innerHTML = "<div id='opacity' style='z-index: 888; position: absolute; left: 0; top: 0; width: 100%; line-height: 0; height: 100%; background-color: #000; -moz-opacity: 0.70; opacity:.70; filter: alpha(opacity=70); display: none;'></div><table align='center' id='tabela' cellpadding='0' cellspacing='0' style='position:absolute; top:0; left:0; z-index: 990;'>	<tr><td align='center' id='tabelaTd'></td></tr></table>" + document.body.innerHTML;
		
		this.contentBox = this.E(box).cloneNode(true);
		this.removeElement(box);
		this.E('tabelaTd').appendChild(this.contentBox);

		this.apagaCombos();
		this.reexibeCombos(box);

		divOpacity = this.E('opacity');
		tableLightBox = this.E('tabela');
		divBox = this.E(box);

		medidas = this.pegaMedidas(true); 
		larguraPag = medidas[0];
		alturaPag = medidas[1];

		divOpacity.style.height = alturaPag + 'px';
		divOpacity.style.width = larguraPag + 'px';
		if (tableLightBox){
			tableLightBox.style.width = this.tPg().ww + 'px';
			tableLightBox.style.height = this.tPg().wh + 'px';
			tableLightBox.style.top = this.ScrollP().y + 'px';
			tableLightBox.style.left = this.ScrollP().x + 'px';
			tableLightBox.style.display = '';
		}
		divOpacity.style.display = '';
		divOpacity.style.filter = 'alpha(opacity=0)';
		divOpacity.style.opacity = '0';
		if (navigator.userAgent.toLowerCase().indexOf('gecko/') != -1){
			lightbox.OpacityInicia('opacity',5,0,75,box);
		}else{
			lightbox.OpacityInicia('opacity',15,0,75,box);
		}
		if (this.E(conteudo)) {
			this.E(conteudo).style.display = '';
		}
		
		FuncoesGerais.carregaVideoProdutos(video);

	},

	fechar : function(){
		this.reexibeCombos();

		this.removeElement('opacity');
		this.removeElement('tabela');
		document.body.appendChild(this.contentBox);
//		document.body.innerHTML = this.contentBox + document.body.innerHTML;

		spans = tableLightBox.getElementsByTagName('span');
		quantidade = spans.length;
		for(a=0;a<quantidade;a++){
			spans[a].style.display = 'none';
		}

		divBox.style.display = 'none';
		divOpacity.style.display = 'none';
		tableLightBox.style.display = 'none';
	},
	
	Opacity_elemento : '',
	Opacity_tamanho_final : 0,
	Opacity_tamanho_atual : 0,
	Opacity_taxa : 0,
	
	OpacityInicia : function(elemento,taxa,inicio,fim,box){
		this.Opacity_elemento = elemento;
		this.Opacity_taxa = taxa;
		this.Opacity_tamanho_final = fim;
		this.Opacity_tamanho_atual = inicio;
		this.OpacityAnima(box);
	},
	
	OpacityAnima : function(box){
		if(this.Opacity_tamanho_final!=this.Opacity_tamanho_atual){
			if(this.Opacity_tamanho_final<this.Opacity_tamanho_atual){
				this.Opacity_tamanho_atual = this.Opacity_tamanho_atual-this.Opacity_taxa ;
			}else{
				this.Opacity_tamanho_atual = this.Opacity_tamanho_atual+this.Opacity_taxa ;
			}
			this.E(this.Opacity_elemento).style.filter = 'alpha(opacity=' + this.Opacity_tamanho_atual + ')';
			this.E(this.Opacity_elemento).style.opacity = this.Opacity_tamanho_atual/100;
			setTimeout("lightbox.OpacityAnima('" + box + "')",1);
		}else{
			if (box != 'undefined'){
				if (navigator.userAgent.toLowerCase().indexOf('gecko/') != -1){
					lightbox.OpacityInicia(box,2,0,100);
				}else{
					lightbox.OpacityInicia(box,10,0,100);
				}
				divBox.style.filter = 'alpha(opacity=0)';
				divBox.style.opacity = '0';
				divBox.style.display = '';
			}
		}
	},

	apagaCombos : function(){
		drops = document.body.getElementsByTagName('select');
		for(c=0;c<drops.length;c++){
			drops[c].style.visibility='hidden';
		}
	},

	reexibeCombos : function(box){
		if (document.getElementById(box)) {
			drops = document.getElementById(box).getElementsByTagName('select');
		}else {
			drops = document.body.getElementsByTagName('select');
		}
		for(c=0;c<drops.length;c++){
			drops[c].style.visibility='visible';
		}
	},

	removeElement: function(divNum) {
	  var olddiv = this.E(divNum);
	  document.body.removeChild(olddiv);
	},
		E : function(id_elemento){
		return document.getElementById(id_elemento);
	},

	//Retorna Scrolls Da pagina
	ScrollP : function(){
		var xScroll, yScroll;

		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
			xScroll = self.pageXOffset;
		} else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
			xScroll = document.documentElement.scrollLeft;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
			xScroll = document.body.scrollLeft;	
		}

		return {x:xScroll,y:yScroll};
	},

	//Retorna Tamanho da pagina
	tPg : function(){
		var xScroll, yScroll;

		if (self.pageYOffset) {
			yScroll = self.offsetHeight;
			xScroll = self.offsetWidth;
		} else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollHeight;
			xScroll = document.documentElement.scrollWidth;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollHeight;
			xScroll = document.body.scrollWidth;	
		}

		var windowWidth, windowHeight;

	//	console.log(self.innerWidth);
	//	console.log(document.documentElement.clientWidth);
	
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && (document.documentElement.clientHeight || document.documentElement.clientWidth)) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}

	//	console.log("xScroll " + xScroll)
	//	console.log("windowWidth " + windowWidth)
	
		// for small pages with total width less then width of the viewport
		if(xScroll > windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
	//	console.log("pageWidth " + pageWidth)

		return {pw:pageWidth,ph:pageHeight,ww:windowWidth,wh:windowHeight};
	},
	pegaMedidas : function(rolagem){
		// Pega altura e largura do conteudo da pagina
		var larguraPag, alturaPag;
		if (self.innerHeight) {	// Todos exceto IE entram aqui
			larguraPag = self.innerWidth;
			alturaPag = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // IE 6, IE 7 entraram aqui
			larguraPag = document.documentElement.clientWidth;
			alturaPag = document.documentElement.clientHeight;
		} else if (document.body) { // Nenhum testado entrou aqui, deixo por garantia
			larguraPag = document.body.clientWidth;
			alturaPag = document.body.clientHeight;
		}
		if(rolagem){ // se foi pedidos os valores incluindo barra de rolagem
			var rolagemH, rolagemV;
			
			if (window.innerHeight && window.scrollMaxY) {	// Nenhum testado entrou aqui, mas deixo por garantia
				rolagemH = document.body.scrollWidth;
				rolagemV = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ 
				// Opera9, Mac 3 para windows entram aqui
				rolagemH = document.body.scrollWidth;
				rolagemV = document.body.scrollHeight;
			} else { //IE6, IE7, FF, Netscape entram aqui.
				rolagemH = document.body.offsetWidth;
				rolagemV = document.body.offsetHeight;
			}	
			// Verifica se deve usar a altura do quadro do navegador ou da rolagem se existir
			if(rolagemV > alturaPag) {
				alturaPag = rolagemV;
				if(/Internet Explorer/.test(navigator.appName)) alturaPag+=30; // corrigir bug IE
			}
			// Verifica se deve usar a largura do quadro do navegador ou da rolagem se existir
			if(rolagemH > larguraPag) larguraPag = rolagemH;
		}
		valores = new Array(larguraPag,alturaPag); 
		return valores;
	}
}
