// apertura del messaggio di attesa
// true -> genera la finestra di attesa
var messaggio=false; 

// Array per gestione immagini (utilizzate in fotodb.js)
var thumb 	= new Array();
var immagine 	= new Array();
var descriz 	= new Array();

// Variabili per funzioni di popup
var titolo="";
var apice= "'";
var ffile="";
var ftitolo="";
var fdidascalia="";
var frichiesto = 0;

fimg=new Image();

// Funzioni popup
function w_opent(file,titolo,didascalia) {
frichiesto=0;
if (messaggio) {open_msg();} else {
document.getElementById('loading').style.display = "inline";}

img= new Image();
img.src=file;
fimg=img;

ffile=file;
ftitolo=titolo;
if (didascalia == null)
	fdidascalia = titolo;
	else
	fdidascalia=didascalia;
i_open();}


function i_open() {

if (frichiesto == 0) {
fimg.src=ffile;
frichiesto = 1;
}
if (! fimg.complete) 
thd1=setTimeout('i_open()', 500)
else {
if (thd1 != null)
clearTimeout(thd1);
w_opent1(ffile,ftitolo,fdidascalia);
}
}

function open_msg() {
w1=window.open("","x2",'resizable=no,menubar=no,directories=no,toolbar=no,scrollbars=no,status=no, height=345, width=330');
w1.document.open();
//w1.document.write("<html><head><title>Caricamento...</title></head><body bgcolor='#0000FF'>");
//w1.document.write("<p><font size='1' color='#9BC72A'><i>Attendere!!  Caricamento in corso... 
// </i></font></p><br>");
w1.document.write("<p align='center'> <img src='loading.gif' height='319' width='305' > </p>");
}

function close_msg() {
w1.document.write("</body> </html>");
w1.close();
}

	
function w_opent1(file,titolo,didascalia) {
x = fimg.width + 30;
y = fimg.height + 70;

var altezza = window.screen.height;
var larghezza = window.screen.width;

var xc = (larghezza-x)/2;
var yc = (altezza-y)/2/3*2;

udidascalia=didascalia.toUpperCase();
if (udidascalia.indexOf("<BR>") != 0) {y += 30;}

titolo=titolo.replace("<br>"," ");
titolo=titolo.replace("<BR>"," ");
titolo=titolo.replace("<Br>"," ");
titolo=titolo.replace("<bR>"," ");

w=window.open("","x1",'resizable=no,menubar=no,directories=no,toolbar=no,scrollbars=no,status=no,screenX=' + xc + ', screenY=' + yc +', height='+ y + ', width='+ x);
w.document.open();
w.document.write("<html><head><title> "+titolo.toUpperCase()+" </title></head><body bgcolor='#9BC72A'>");
w.document.write("<table border='0' cellpadding='0' cellspacing='0' width='100%'>");
w.document.write("<tr> <td align='center'>");
w.document.write("<img name='img' border='0' src="+file+">");
w.document.write("</td> </tr>");
w.document.write("<tr> <td>");
w.document.write("<font color='#5B5A5A' size='5'><b><i>"+didascalia+"</i></b></font>");
w.document.write("</td> </tr>");
w.document.write("<tr> <td>");
w.document.write("<form name='chiudi'> <input type='button' name='bchiudi' value='Chiudi' onclick='window.close()'> </form>");
w.document.write("</td> </tr> </table>");
w.document.write("<script>document.chiudi.bchiudi.focus()</script"+"></html>");
w.document.write("</body></html>");
if (messaggio) {close_msg();} else {
document.getElementById('loading').style.display = "none";}
}
// FINE Funzioni popup

// document.getElementById(div_id).style.JS_property_reference = "new_CSS_property_value"

function cambia_url() {
//filtro.argomento.value=filtro.argomento.value.replace(" ", "§");
filtro.argomento.value=filtro.argomento.value.replace("'", "");
var newurl="galleria.php?";
if (filtro.argomento.value > "") {
newurl = newurl + "argomento="+filtro.argomento.value+"&";
filtro.lato.value='4';}
slato=filtro.lato.value;
stlato=String(slato);
newurl = newurl+"lato="+stlato;
document.location=newurl;
}

//function cambia_url1() {
//filtro1.argomento.value=filtro1.argomento.value.replace(" ", "§");
//var newurl="galleria.php?";
//if (filtro.argomento.value > "") {
//newurl = +"argomento="+filtro.argomento.value+"&";}
//newurl = +"lato="+filtro.lato.value;
//document.location=newurl;
//}


