xpos=20
ypos=20
tolleranza_x=40
tolleranza_y=tolleranza_x
xspace=screen.availWidth
yspace=screen.availHeight

var new_idt=new Array(2),old_idt=new Array(2);
//apre una finestra secondaria per le immagini
var imgWindow=false

function set_xternal(fs_inc, rel_path){
	/* 
	Descrizione della Funzione:
	compone la stringa da includere in files che hanno necessità di usare il dynmenu
	rispettando le disposizioni dell'opzione "clone_in_subdir"
	*/	
	var external_inc="",fs_inc=String(fs_inc),f_inc=fs_inc.split("|"),f_inc_num=f_inc.length;
	for(i=0; i<f_inc.length; i++){
		file_type=f_inc[i].split(".");
		if(file_type.length>1){
			ext=file_type[1];
			if(ext=="js"){
				external_inc+="<script language='JavaScript' src='"+rel_path+"external/"+f_inc[i]+"' type='text/javascript'><\/script>"
			}else{
				external_inc+="<link href='"+rel_path+"external/"+f_inc[i]+"' rel='stylesheet' type='text/css'>"
			}
		}
	}	
	return external_inc
}

function imagewin(nomeImmagine){
    /* 
    Descrizione della Funzione:
    Questa funziona carica una immagine 
    e dopo averla caricata fa un resize della window
    */
    immagine=new Image()
    immagine.src=nomeImmagine
    default_w=240
    default_h=140
    if(!imgWindow || imgWindow.closed){
        imgWindow=window.open("", "imgWin", "toolbar=no,location=no,scrollbars=auto,statusbar=yes,personalbar=no,resizable=no,top=30,left=30,width="+default_w+",height="+default_h)
    }else{
        imgWindow.resizeTo(default_w, default_h)
    }
    imgWindow.document.clear()
    
    imgWindow.focus()

    html_code="<html><HEAD>"
    
	external_inc=set_xternal(nm_fs_inc, rel_path)
	
	html_code+=external_inc
    html_code+="<TITLE>"+title+"<\/TITLE><\/HEAD>"
    if(isIE){
        html_code+="<BODY onload=\"switch_display('main_table','load_table'); fit_win_to_element('main_table'); \">";
    }else if(isNS6 || isMz){
        html_code+="<BODY>"
    }else if(isOp){
        html_code+="<BODY onload=\"switch_display('main_table','load_table');\">";
    }
    html_code+="<br><table id='load_table' width='95%' border='0' cellspacing='0' cellpadding='0' align='center' class='visibile' height='95%'><tr>"
    html_code+="<td nowrap class='full_boxed_spaced'><strong>"+loading+"<\/strong><\/td>"
    html_code+="<\/tr><\/table>"
    html_code+="<table width='95%' border='0' cellspacing='0' cellpadding='0' align='center' id='main_table' class='invisibile'><tr>"
    html_code+="<td width='100%' height='100%' nowrap style='vertical-align: middle;'>"
    if(isIE){
        html_code+="<img src='"+immagine.src+"' id='ly_img' class='bordato' alt='' style='vertical-align: top; text-align: center;' >";
    }else if(isNS6 || isMz){
        html_code+="<img src='"+immagine.src+"' id='ly_img' class='bordato' alt='' style='vertical-align: top; text-align: center;' onload=\"switch_display('main_table','load_table'); fit_win_to_element('main_table'); \">"
    }else if(isOp){
        html_code+="<img src='"+immagine.src+"' id='ly_img' class='bordato' alt='' style='vertical-align: top; text-align: center;' onload=\"fit_win_to_element('main_table'); \">"
    }
    html_code+="<\/td><\/tr><\/table>"
    html_code+="<\/BODY><\/HTML>"
    imgWindow.document.write(html_code)
    imgWindow.document.close()
    imgWindow.focus()
}

//tutte le funzioni viewDetails aprono una finestra secondaria per le news
// viewdetails: apre un afinestra senza barre di scorrrimento
//viewDetailsScrol;lapre un afinestra con barre di scorrrimento e size settabile da parametri di funzione
//

function popupwin(page_to_load, w, h, nome, x_p, y_p){
    typeof (w)=="undefined" || w=='' || w==null ? w=400 : vz;
    typeof (h)=="undefined" || h=='' || h==null ? h=400 : vz;
    isIE && x_p!="" && typeof(x_p)!="undefined" ? x_p=x_p+5 : vz;
    isIE && y_p!="" && typeof(y_p)!="undefined" ? y_p=y_p-20 : vz;

    typeof (x_p)=="undefined" || x_p=="" ? xpos=10 : xpos=x_p;
    typeof (y_p)=="undefined" || y_p=="" ? ypos=10 : ypos=y_p;
    typeof (nome)=="undefined" ? nome="detailwin" : vz;
    w_str=eval(nome+"=window.open(\""+page_to_load+"\", \""+nome+"\", \"toolbar=no,scrollbars=yes,statusbar=yes,personalbar=no,resizable=no,height="+h+",width="+w+",top="+ypos+",left="+xpos+"\");")
    if(eval(nome) && !eval(nome).closed){
        w_str+=nome+".resizeTo("+w+", "+h+");";
        w_str+=nome+".moveTo("+xpos+", "+ypos+");";
    }
    eval(nome+".focus();");
}

// serve a scrivere le informazionei di una variabile (es il titolo della pagine o il foot)
function write_info(info){
    document.write(info)
}

function fit_win_to_element(element){
    /* 
    Descrizione della Funzione:
    adatta la grandezza delle finestra di popuop al contenuto
    */
    tolleranza=tolleranza_x
    max_w_win=eval(ly+"('"+element+"')"+w+"+60")
    max_h_win=eval(ly+"('"+element+"')"+h+"+80")
    if(max_w_win>=eval(scr_w)-tolleranza){
        max_w_win=eval(scr_w)-tolleranza
    }
    if(max_h_win>=eval(scr_h)-tolleranza){
        max_h_win=eval(scr_h)-tolleranza
    }
    resizeTo(max_w_win, max_h_win)
    //alert(eval(win_w));
    if(!isOp){
        if(eval(win_x)+eval(win_w)>eval(scr_w)){
            isIE ? add_w=10 : add_w=0;
            moveTo(eval(scr_w)-eval(win_w)-add_w, 0)
        }
    }
}

function switch_display(el_to_show, el_to_hide){
	/* 
	Descrizione della Funzione:
	Una volta caricato l'elemento, esegue uno scambio tra il ly ausiliario
	con il messaggio di caricamento e il ly con l'elemento caricato.	
	*/
	eval(ly+"('"+el_to_show+"').className='visibile'");
	eval(ly+"('"+el_to_hide+"').className='invisibile'");
}

