// abrir e fechar o menu de galerias
function menu(obj){
	alvo = document.getElementById(obj);
	if(alvo.className == 'galeria_off'){
		alvo.className = 'galeria_on';
	}
	else{
		alvo.className = 'galeria_off';
	}
}

// abrir nova janela
function abreJanela(theURL,winName,features) {
  window.open(theURL,winName,features);
}

// popup das galerias

function abrirGaleria(pasta,nome,autor,maximo){
	var wnd = window.open('', '', 'width=612,height=417,status=yes,top=300,left=200');
	var code = '<html><head><title>'+pasta+'</title>\n'+
				'<script src="js/scripts.js" type="text/javascript"></script>\n</head>\n'+
				'<body onload="listarMinis(\''+pasta+'\',\''+nome+'\',\''+autor+'\',\''+maximo+'\')">\n</body>\n</html>';
	wnd.document.write(code);
	wnd.document.close();
}

function listarMinis(pasta,nome,autor,maximo){
	var code1 = '<html>\n<head>\n<title>'+pasta+'</title>\n'+
				'<meta http-equiv="imagetoolbar" content="no">\n'+
				'<link rel="stylesheet" href="css/galeria.css" type="text/css" media="screen" />\n'+
				'<script src="js/scripts.js" type="text/javascript"></script>\n'+
				'</head>\n'+
				'<body>\n<h3>&nbsp;</h3>\n<div id="minis"><ul>\n';
	document.write(code1)
	for(i=1;i<=maximo;i++){
		document.write('<li><img src="galerias/'+pasta+'/'+i+'.jpg" width="40" height="40" alt="imagem '+i+'" onclick="mudarFoto(\''+i+'\',\''+pasta+'\');return false" /></li>\n')
	}
	document.write('</ul>\n<p>'+nome+'</p>\n</div>\n')
	document.write('<div id="caixa_foto"><img id="foto" src="galerias/'+pasta+'/1.jpg" alt="Imagem 1" title="Imagem 1" />\n<p>'+autor+'</p>\n</div>\n<h4>&nbsp;</h4>\n</body>\n</html>')
	document.close();
}

// troca as imagens ao clicar na miniatura
// a variável 'numero' é definida automaticamente na função listarMinis através da variável 'i'
// Não é necessário mudar nada nesta função
function mudarFoto(numero,pasta){
	var imagem = document.getElementById('foto');
	imagem.src = 'galerias/'+pasta+'/'+numero+'.jpg';
	imagem.title = 'Imagem '+numero;
}

function abrirNova(){
	var nova = window.open('galerias/galeria.html','nova','width=646,height=417,status=yes');
	nova.listarMinis('casamento','Casamento',' ',15);
}

function abrirFotos(pasta){
	var nova = window.open('galeria.asp?p='+pasta,'nova','width=646,height=417,status=yes');
	nova.focus();
}
