// JavaScript Document
var meuarray = new Array();
var linkopcao;

function mostra(id,frame) {
 var obj = document.getElementById(id);
 var cont = document.getElementById(id);
 var img_atual;
 
 
 obj.innerHTML = cont.innerHTML;
 obj.style.display = "inline";
}
function esconde(id) {
 var obj = document.getElementById(id);
 obj.style.display = "none";
}
function fechar()
{
	esconde('imagem');
	esconde('nav');
	meuarray = new Array();
	var div_opcoes = document.getElementById('opcoes');
	div_opcoes.innerHTML="";
}
function loading()
{
	mostra('nav');
	mostra('imagem');
	
	var div = document.getElementById("imagem");
	var w = window, b = document.body, s = div.style;
	s.top = 0 + (w.scrollY || b.scrollTop || 0) + "px";
	
	document.getElementById('conteudo').innerHTML  = '<img src="lightbox/carregando.gif" width="71" height="62">';
}
function set_opcoes(a,b,c,d,e,figura)
{
	 meuarray[meuarray.length]= new Array(a,b,c,d,e,figura);
}
function lightbox(img,imgflex,legenda)
{
	var carregando = new Image();
	carregando.src = 'lightbox/carregando.gif';
		
		loading();
		var imagem = new Image();
	    imagem.src = img;
		img_atual = img;
		legenda_atual = legenda;
	
		imagem.onload= function(){
			
			var conteudo = document.getElementById("conteudo");
			conteudo.style.width = (imagem.width+20)+"px";
			//if(imagem.height<=540)
				conteudo.style.height=imagem.height;
			//else
			//	conteudo.style.height=540;
			

			conteudo.innerHTML  = '<img src="'+imagem.src+'">';
		}
		
		if(meuarray.length>0)
		{
			var div_opcoes = document.getElementById('opcoes');
			div_opcoes.innerHTML = "";
			
			for(var j=0;j<meuarray.length;j++)
			{
				if(meuarray[j][3]>0)
				{
					
					if(meuarray[j][5])
					{
						div_opcoes.innerHTML +='<img src="lightbox/'+meuarray[j][5]+'">';
					}
					for(var i=0;i<meuarray[j][3];i++)	
					{
						if(!meuarray[j][4])
						meuarray[j][4] = 0;
						
						linkopcao = meuarray[j][0]+meuarray[j][1]+meuarray[j][2]+"_"+(i+meuarray[j][4])+".jpg";
					
						
						div_opcoes.innerHTML += '<a href="javascript:lightbox(\'pb/'+linkopcao+'\')"><img src="lightbox/op'+i+'.jpg" border="0"></a>';
					}
					
					div_opcoes.innerHTML += "<br>";
				
				}
			}
		}


}
function preload() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preload.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function imprimir()
{
	window.open('print.php?img='+img_atual,'print','top=0,left=0,width=1,height=1,scrollbars=auto');	
}