NomeSito  = "100 anni di fotografia"
Autore    = "Paolo Bonavoglia";
Is_NS=window.navigator.appName == "Netscape"
Is_IE=window.navigator.appName == "Microsoft Internet Explorer"

MailWeb = "paolo.bonavoglia@aruba.it";

function GetElement(nome){
     return document.getElementById(nome);
}

function WinWidth(){
	if (window.navigator.appName == "Microsoft Internet Explorer") {
		return document.body.clientWidth;
	} else {
		return window.innerWidth;
	}
}

function PopupXY(nome, menuItem, dx, dy, wi, hi){
	PopCloseHint();
	showBox = GetElement(nome);
	mleft = menuItem.offsetLeft + dx;
	mtop  = menuItem.offsetTop + menuItem.offsetHeight + dy;
	parente = menuItem.offsetParent;
	while (parente){
		mtop  += parente.offsetTop; 
		mleft += parente.offsetLeft;
		parente = parente.offsetParent;
	}
	if (wi) {
		out_right = mleft + wi*1.2 - WinWidth();
		if (out_right > 0) mleft = mleft - out_right;
	}
	if (wi) showBox.style.width = wi;
	if (hi) showBox.style.height = hi;
	if (mleft < 0) mleft = 0;
	if (mtop < 0) mtop = 0;
	showBox.style.top  = mtop; 
	showBox.style.left = mleft;
	showBox.style.visibility = "visible";
}

function PopupHint(nome, menuItem, wi){
	PopCloseHint();
	PopupXY(nome, menuItem, -64, -8, wi)
}

function PopClose(nome){
	showBox = GetElement(nome);
	if (showBox){
		showBox.style.visibility = "hidden";
		return true
	} else {
		return false
	}
}

function PopCloseAllNamed(name){
	conta = 0;
	while (PopClose(name+conta)) {++conta;}
	return conta;
}

function PopCloseHint(){
	return PopCloseAllNamed('Hint');
}

function ColOrdina(chiave){
	ord = document.forms[0].Ordine;
	ord.value = chiave;
	tip = document.forms[0].Tipo;
	if (tip.value == 'ASC'){
		tip.value = 'DESC';
	} else {
		tip.value = 'ASC';
	}
	document.forms[0].submit()
}

function GiraFoto(filename, titolo){
	GetElement("Foto").src = filename;
	GetElement("Scelta").value = filename;
	GetElement("Titolo").innerHTML= titolo;
}

function ScriviMail(aMail){
	document.write("<A HREF=\"mailto:", aMail, "\">", aMail, "</A>")
}

function ScriviLocali(dir){
	document.write('<TH CLASS="Ancora">', dir, "</TH>");
}

function ScriviUltimaData(){
	var datAgg = new Date(document.lastModified);
	with (datAgg) {
		var anno = getFullYear();
		if (anno < 1980) {anno += 100}
		document.writeln(getDate(), '-', getMonth()+1, '-', anno, '<BR>');
	}
}

function ScriviCoda(dir, data){
	document.write("<br style='clear: both'><hr><ul><li><a href='/registro.phtml'>Registro visitatori</a></li></ul>");
	document.write("<br style='clear: both'><hr><div class='Ancora'>Sito ospitato nello ");
	document.write("<a href='http://www.bonavoglia.eu'>spazio web di Paolo Bonavoglia</a>");
	document.write('</div><br style="clear: both">');
	document.write('<div>Testo e <a href="', dir);
	document.write('fotografie.html">fotografie</a> sono di <a href="', dir,'index.html">');
	document.writeln(Autore, '</a>');
	document.write(' (E-Mail: <A HREF="mailto:', MailWeb, '">', MailWeb, '</A>)');
	document.writeln(' e possono essere liberamente riprodotti a condizione che la cosa non sia a fini di lucro e che venga citata esplicitamente e possibilmente con un link la fonte.</DIV>');
	document.write("<p>La foto del logo rappresenta la <i>fotocamera del nonno</i> una Gaumont tascabile a lastre 4,5x6 con obiettivo Zeiss Protar del 1905 circa");
	document.writeln(" accanto alla mia Olympus E-300 del 2005: un secolo di fotografia!</p>");
}

function Angolo(foc, diag2){
	var ang = 2*Math.atan(diag2/foc);
	ang = Math.round(1800*ang/Math.PI);
	return ang/10;
}

function Focale(ang, diag2){
	var foc = diag2/Math.tan(Math.PI*ang/360);
	foc = Math.round(foc*10);
	return foc/10;
}

function Calcola(focale, formato, angolo, last){
	if (last.value == 'f'){
		angolo.value = Angolo (focale.value, formato.value);
	} else if (last.value == 'a') {
		focale.value = Focale (angolo.value, formato.value);
	} 
}





