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>";
		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);
		divOpacity.style.height = this.tPg().ph + 'px';
		divOpacity.style.width = this.tPg().pw + 'px';
		if (tableLightBox){
			tableLightBox.style.width = this.tPg().ww + 'px';
			tableLightBox.style.height = this.tPg().wh + 'px';
			tableLightBox.style.top = this.ScrollP().y-250 + 'px';
			//tableLightBox.style.top = '900px';
			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 = '';
		}
	},
	
	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';
		}
		window.location.hash='';
		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 = '';
			}else{
				try {
					init_dw_Scroll();
				}catch(err) {} 
				//init_dw_Scroll();
			}
		}
	},

	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 windowWidth, windowHeight;
		if (self.innerHeight) {	// Todos exceto IE entram aqui
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // IE 6, IE 7 entraram aqui
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // Nenhum testado entrou aqui, deixo por garantia
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		// Pega altura e largura da pagina
		var pageWidth, pageHeight;
		
		if (window.innerHeight && window.scrollMaxY) {	// Nenhum testado entrou aqui, mas deixo por garantia
			pageWidth = document.body.scrollWidth;
			pageHeight = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ 
			// Opera9, Mac 3 para windows entram aqui
			pageWidth = document.body.scrollWidth;
			pageHeight = document.body.scrollHeight;
		} else { //IE6, IE7, FF, Netscape entram aqui.
			pageWidth = document.body.offsetWidth;
			pageHeight = document.body.offsetHeight;
		}	

		if(pageHeight < windowHeight){
			pageHeight = windowHeight;
		}else {
			if(/Internet Explorer/.test(navigator.appName)) {
				pageHeight+=30;  // corrigir bug IE
			}
		}

		/*if(pageWidth < windowWidth){
			pageWidth = windowWidth;
		}*/

		// Pega altura e largura do scroll
		var scrollH, scrollV;

		if (self.pageYOffset) {
			scrollV = self.pageYOffset;
			scrollH = self.pageXOffset;
		} else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)){	 // Explorer 6 Strict
			scrollV = document.documentElement.scrollTop;
			scrollH = document.documentElement.scrollLeft;
		} else if (document.body) {// all other Explorers
			scrollV = document.body.scrollTop;
			scrollH = document.body.scrollLeft;	
		}

		return {pw:pageWidth,ph:pageHeight,ww:windowWidth,wh:windowHeight,sh:scrollH,sv:scrollV};
	}
}