var n_botoes = 5;
var btn_distance = '80px';
var img_dir = "Img/"
var link_n_cols = 3;
var link_distance = '50px';
var fotos_n_cols = 4;


var botoes = new Array(n_botoes);
var paginas = new Array(n_botoes);
var titulos = new Array(n_botoes);

botoes[0] = "Home";
botoes[1] = "Membros";
botoes[2] = "Fotos";
botoes[3] = "Videos";
botoes[4] = "Links";

paginas[0] = "main.html";
paginas[1] = "membros.html";
paginas[2] = "fotos.html";
paginas[3] = "videos.html";
paginas[4] = "links.html";

titulos[0] = "Grupo Cemtrav&otilde;es";
titulos[1] = "Os membros do Grupo Cemtrav&otilde;es";
titulos[2] = "As fotos do Grupo Cemtrav&otilde;es";
titulos[3] = "Os Videos do Grupo Cemtravões";
titulos[4] = "Links para outros sites";

/*
function initAnimation() {
	AnimationFrames("led_r", 5, ".gif");
	for (var i=0; i<n_botoes; ++i) {
		AnimatedImage("led" + i ,"led_r", "led_r");
	}	
}
*/
	
function displayTitle() {
	document.writeln("<CENTER><IMG SRC='" + img_dir + "cemtravoes.gif'><BR><BR><BR></CENTER>");
}

function displayButtons(page) {
	document.writeln("<CENTER>");	
	document.writeln("<TABLE CELLPADIND=0 CELLSPACING=0><TR>");
	for (var i=0; i<n_botoes; ++i) {
		if (page == botoes[i]) {
		  document.write("<TD CLASS = 'LINK_PAGINA_CURRENT' TITLE='" + titulos[i] + "'>");
		}
		else {
		  document.write("<TD CLASS = 'LINK_PAGINA_NOT_CURRENT' TITLE='" + titulos[i] + "'>");
		}
		document.write("<A CLASS = 'LINK_PAGINA' HREF='" + paginas[i] + "'>" + botoes[i] + "</A></TD>");
		if (i<n_botoes-1) {
		  document.writeln("<TD WIDTH=" + btn_distance + "></TD>");
		}
	}	
	document.writeln("</TR></TABLE></CENTER><BR>");
	document.writeln("<HR ALIGN=center WIDTH=80% SIZE=4><BR>");
}

/*
function btn_click(target) {
	window.location = target;
}
*/


function displayBottom(page) {
	document.writeln("<BR><BR><BR>");
	document.writeln("<HR ALIGN='center' WIDTH=80% SIZE=4>");
	document.write("<P CLASS=CONTACTO>O nosso Contacto :&nbsp;&nbsp;");
	document.writeln("<A TITLE='O nosso Email' HREF='mailto:cemtravoes@netc.pt'><IMG CLASS=MIDDLE SRC='" + img_dir + "Mailbox.gif'></A></P>");
	document.writeln("<P CLASS='ACTUAlIZACAO' ALIGN='right'>&Uacute;ltima actualiza&ccedil;&atilde;o: 26/11/2007</P>");
}

// ******************************* Links ******************************************
var nLink;
function displayLink(url, texto, titulo, imagem) {
	if (titulo == null || titulo == "")
	{
	  titulo = texto;
	}
	
	if (url=="_inicio_") {
		document.writeln("<TABLE WIDTH='100%' CELLPADIND=0 CELLSPACING=0>");		
		nLink = 0;
	}
	else if (url=="_fim_") {
		document.writeln("</TABLE>");
	}
	else {
		imagem = img_dir + "Links/" + imagem;
		
		if ((nLink%link_n_cols)==0) {
		  document.writeln("<TR>");
	  }
	  // WIDTH='10px' -> usa o tamanho da imagem definido nas CSS
		document.writeln("<TD CLASS='LINKS' HEIGHT='130px' WIDTH='10px'><A TARGET='_blank' HREF='" + url + "'><IMG CLASS='LINKS' TITLE='" + titulo + "' ALT='Erro ao carregar imagem' SRC='" + imagem + "'></A></TD>");
		document.writeln("<TD CLASS='LINKS'><A CLASS='LINKS' TARGET='_blank' HREF='" + url + "' TITLE='" + titulo + "'>" + texto + "</A></TD>");
		if ((nLink+1)%link_n_cols) {
		  document.writeln("<TD WIDTH=" + link_distance + "></TD>");
		}
		++nLink;
	}	
}


// ***************************** Membros *******************************
function addMember(nome, dataNasc, bike, img) {
	img = img_dir + "Membros/" + img

	if (nome=="_inicio_") {
		document.writeln("<TABLE CELLPADIND=0 CELLSPACING='20px'>");		
	}
	else if (nome=="_fim_") {
		document.writeln("</TABLE>");
	}
	else {
		document.writeln("<TR>");
		document.writeln("<TD><IMG CLASS='FOTOS_MEMBROS' SRC='" + img + "' ALT='Foto ainda não disponível' TITLE='" + nome + "'></TD>");
		document.writeln("<TD CLASS='MEMBROS'>Nome: " + nome + "<BR>");
		document.writeln("Idade: " + getIdade(dataNasc) + " Anos<BR>");
		document.writeln("Bicicleta: " + bike);
		document.writeln("</TD></TR>");
	}	
}

// ********************************** Fotos ***********************************
var nFoto;
function addFoto(img, ano, texto) {
	var small_img;
	
	if (img=="_inicio_") {
		nFoto = 0;
		document.writeln("<TABLE ALIGN='center' WIDTH='100%' CELLPADIND=0 CELLSPACING=0>");		
	}
	else if (img=="_fim_") {
		document.writeln("</TABLE>");
	}
	else {
		small_img = img_dir + "Fotos/" + ano + "/small_img/" + img;
		img       = img_dir + "Fotos/" + ano + "/" + img;
		if ((nFoto%fotos_n_cols)==0) {
		  document.writeln("<TR>");
	  }
		document.writeln("<TD CLASS='FOTOS'>");
		document.writeln("<A TARGET='_blank' HREF='" + img + "'><IMG CLASS='FOTOS' TITLE='Ver Foto' ALT='Imagem não dispon&iacute;vel' SRC='" + small_img + "'></A>");
		document.writeln("<BR><B>" + texto + "</B><BR>&nbsp</TD>");
		++nFoto;
	}	
}


// *****************************************************************************
function getIdade(dataNasc) {
	var hoje = new Date();
	var nascimento = new Date(dataNasc);
	var idade = hoje.getFullYear() - nascimento.getFullYear();
	
	hoje.setYear(nascimento.getYear());
	if (hoje<nascimento) {
	 --idade;
	}
	return idade;
}
