// ----------------------------------------------------------------------------------
// Este fichero tem de existir em dois directórios:
// Filatelia em Portugal: fp/bin
// Filatelicamente.online: bin
// 
// Passa-se o mesmo com o ficheiro de estilos
// ----------------------------------------------------------------------------------


// Mostra foto
// Duas possibilidade, ou se deixa campo vasio ou coloca-se informação sobre ficheiro a mostrar
function foto(ficheiro, w, h) {
	if (ficheiro != "") {
		document.write('<IMG SRC="../../pictures/' + ficheiro + '" WIDTH="' + w + '" HEIGHT="' + h + '" ALT="Autor" BORDER="1">')
		}
	else {
		document.write('<IMG SRC="../../pictures/margem.gif" WIDTH="10" HEIGHT="10" ALT="" BORDER="1">')
		}
}

// Conjunto de funções de aleatoriedade de banners ------------------------------------------
function banner(imgSource,url,alt,chance, w, h) {
	this.imgSource = imgSource;
	this.url = url;
	this.alt = alt;
	this.chance = chance;
	this.width = w;
	this.height = h;
}

function dispBanner() {
	with (this) document.write("<A HREF=" + url + "><IMG SRC='" + imgSource + "' WIDTH=" + this.width + " HEIGHT=" + this.height +" BORDER=0 ALT='" + alt + "'></A>");
}

// ----------------------------------- MODIFICAR ------------------------------------
banner.prototype.dispBanner = dispBanner;
banners01 = new Array();
banners01[0] = new banner("http://www.filatelicamente.online.pt/pictures/bandas/fpbanda.gif",
                        "http://www.caleida.pt/filatelia target='_blank'",
                        "Filatelia em Portugal",
                        10, "468", "60");
banners01[1] = new banner("http://www.filatelicamente.online.pt/pictures/bandas/fpbanda.gif",
                        "http://www.caleida.pt/filatelia target='_blank'",
                        "Filatelia em Portugal",
                        10, "468", "60");

//  ----------------------------------Fim de conjunto de funções de aleatoriedade de banners
function randomBanner(nome, n1, n2) {
	var b = new Array(n2-n1+1)
	sum_of_all_chances = 0;
	for (i = n1; i <= n2; i++) {
		b[i] = nome[i]
		sum_of_all_chances += b[i].chance;
		}
	chance_limit = 0;
	randomly_selected_chance = Math.round((sum_of_all_chances - 1) * Math.random()) + 1;
	for (i = n1; i <= n2; i++) {
		chance_limit += b[i].chance;
		if (randomly_selected_chance <= chance_limit) {
			document.write("<div align='right'><A HREF=" + b[i].url + "><IMG SRC='" + b[i].imgSource + "' WIDTH=" + b[i].width + " HEIGHT=" + b[i].height +"BORDER=0 ALT='" + b[i].alt + "'></A></div>");
			return b[i];
			break;
		}
	}
}

// Abrir janela com imagen
function OpenImage(fich_imagem, w, h){
	var wi = new Number()
	var he = new Number()
	if (w+40 < 640) { wi = w+40 }
	else { wi = 640 }
	if (h+40 < 480) { he = h+40 }
	else { he = 480 }
	caract = 'toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=' + wi.toString() + ',height=' + he.toString()
	aPopUp = window.open('', 'Imagem', caract)
	ndoc = aPopUp.document
	astr = '<HTML><HEAD><TITLE>Visualização de imagens</TITLE>'
	astr += '</HEAD>'
	astr += '<BODY BGCOLOR="#000000">'
	astr += '<DIV ALIGN="center">'
	astr += '<IMG SRC="' + fich_imagem + '" WIDTH="' + w + '" HEIGHT="' + h +'" ALT="Ampliação" BORDER="0">'
	astr += '<BR></DIV>'
	astr += '</BODY></HTML>'
	ndoc.clear()
	ndoc.write(astr)
	ndoc.close()
}

// Garantia de correcção no preenchimento do formulário de assinante
function checkFieldsAss() {
	missinginfo = "";
	if (document.assina.assinante.value == "") {
		missinginfo += "\n     -  Nome de Assinante por preencher (Subscriber name to fill in)";
	}
	if (document.assina.password01.value == "") {
		missinginfo += "\n     -  Palavra-chave por introduzir (Password to fill in)";
	}
	if (document.assina.password02.value != document.assina.password01.value) {
		missinginfo += "\n     -  Confirmação de palavra-chave diferente (The password confirmation is different)";
	}
	if ((document.assina.email.value == "") || 
		(document.assina.email.value.indexOf('@') == -1) || 
		(document.assina.email.value.indexOf('.') == -1)) {
		missinginfo += "\n     -  Endereço de Email inadequado (The Email Address is inadequate)";
	}
	if (document.assina.controlo01.value != document.assina.email.value) {
		missinginfo += "\n     -  Confirmação de Email diferente (The email confirmation is different)";
	}
	if (document.assina.nome.value == "") {
		missinginfo += "\n     -  Nome por preencher (Name to fill in)";
	}
	if (document.assina.morada.value == "") {
		missinginfo += "\n     -  Morada por preencher (Address to fill in)";
	}
	if (document.assina.codigo_postal.value == "") {
		missinginfo += "\n     -  Código postal por preencher (Postal code to fill in)";
	}
	if (document.assina.pais.value == "") {
		missinginfo += "\n     -  País por prencher(Country to fill in)";
	}
	if (missinginfo != "") {
		missinginfo ="_______________________________________\n" +
		"Formulário não está correctamente preenchido:\n" +
		missinginfo + "\n_______________________________________" +
		"\nPor favor volte a escrever os campos em falha!";
		alert(missinginfo);
		return false;
	}
	else return true;
}

//Audição de uma gravação com abertura de janela
//Englogar num form, associado a botão
function ouvir(titulojanela, ficheiro){
aPopUp = window.open('', 'Audicao', 'toobar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=200,height=200')
ndoc = aPopUp.document
astr = '<HTML><HEAD><TITLE>Audição de gravação</TITLE>'
astr += '</HEAD>'
astr += '<BODY BGCOLOR="#FFFFCC">'
astr += '<DIV ALIGN="center">'
astr += '<B>' + titulojanela + '</B><BR><BR>'
if (navigator.appName == "Microsoft Internet Explorer") {
astr += '<embed src=' + ficheiro + ' autostart=true hidden=false volume=100 width=128 height=128 loop=true>'
}
if (navigator.appName == "Netscape") {
astr += '<embed src="' + ficheiro +'" loop=true width=128 height=128>'
}
astr += '<BR></DIV>'
astr += '</BODY></HTML>'
ndoc.clear()
ndoc.write(astr)
ndoc.close()
}

// EXPERIÊNCIA
//
var op01Array =  new Array("('Escolha ...','',true,true)",
"('# 101 - 2001/12')",
"('# 100 - 2001/08')",
"('# 099 - 2001/06')",
"('# 098 - 2001/04')",
"('# 097 - 2001/02')",
"('# 096 - 2000/12')");
var op02Array =  new Array("('Escolha ...','',true,true)",
"('# 106 - 2002/05')",
"('# 105 - 2002/04')",
"('# 104 - 2002/03')",
"('# 103 - 2002/02')",
"('# 102 - 2002/01')");
var op03Array =  new Array("('Escolha ...','',true,true)",
"('Porto 2001')");
var op04Array =  new Array("('Sem opções','',true,true)");
function escolhamenu02(inForm,selected) 
{
	var selectedArray = eval(selected + "Array");
	while (selectedArray.length < inForm.menu02.options.length) 
	{
		inForm.menu02.options[(inForm.menu02.options.length - 1)] = null;
	}
	for (var i=0; i < selectedArray.length; i++) 
	{
		eval("inForm.menu02.options[i]=" + "new Option" + selectedArray[i]);
	}
	if (inForm.menu01.options[0].value == '') 
	{
		inForm.menu01.options[0]= null;
		if ( navigator.appName == 'Netscape') 
		{
			if (parseInt(navigator.appVersion) < 4) 
			{
				window.history.go(0);
			}
			else 
			{   	
				if (navigator.platform == 'Win32' || navigator.platform == 'Win16') 
				{
					window.history.go(0);
				}
			}
		}
	}
}
function accaomenu02(inForm,selected) 
{
	switch (document.menu.menu01.selectedIndex){
		// Opção #1 do menu principal
		case 0: 
			switch (document.menu.menu02.selectedIndex){
			case 0: alert("Por favor, Escolha uma das opções"); break
			case 1: window.location = "revista101.html"; break
			case 2: window.location = "revista100.html"; break
			case 3: window.location = "revista099.html"; break
			case 4: window.location = "revista098.html"; break
			case 5: window.location = "revista097.html"; break
			case 6: window.location = "revista096.html"; break
			default: window.location = "index.html";
			}; break
		// Opção #2 do menu principal		
		case 1: 
			switch (document.menu.menu02.selectedIndex){
			case 0: alert("Por favor, Escolha uma das opções"); break
			case 1: window.location = "revista106.html"; break
			case 2: window.location = "revista105.html"; break
			case 3: window.location = "revista104.html"; break
			case 4: window.location = "revista103.html"; break
			case 5: window.location = "revista102.html"; break
			default: window.location = "index.html";
			}; break
		// Opção #3 do menu principal		
		case 2: 
			switch (document.menu.menu02.selectedIndex){
			case 0: alert("Por favor, Escolha uma das opções"); break
			case 1: window.location = "revista900.html"; break
			default: window.location = "index.html";
			}; break
		// Opção #4 do menu principal		
		case 3: 
			switch (document.menu.menu02.selectedIndex){
			default: window.location = "index.html";
			}; break
	}
}

// Fim da experiência -----------------------------------------------------------


