/*********************************************
* REPORT
*********************************************/



/*********************************************
* TOOLINO									*/

function stampaDss(curUrl){
  w = 700;
  h = 600;
  l = (screen.width - w) / 2;
  t = 45;

  wnd = window.open("popup_report.php?&stampaDss=on&"+curUrl,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();		
}

function stampaReport(curUrl){
  w = 700;
  h = 600;
  l = (screen.width - w) / 2;
  t = 45;

  wnd = window.open("popup_report.php?&stampaReport=on&"+curUrl,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();		
}

function getUrlReport(curUrl) {

nomeHost		=location.hostname ;
nomePath		=window.opener.location.pathname ;

urlToGo = "http://" + nomeHost + nomePath + "?" + curUrl ;

//alert(urlToGo); 

window.opener.location.href(urlToGo);
self.close();
}

function apriSave(curUrl) {
  w = 700;
  h = 600;
  l = (screen.width - w) / 2;
  t = 45;
 
  wnd = window.open("popup_report.php?&saved=on&curUrl="+curUrl,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();	
}

function leggiSave() {
  w = 700;
  h = 600;
  l = (screen.width - w) / 2;
  t = 45;
 
  wnd = window.open("popup_report.php?&leggi=on","","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();	
} 
 
function apriKey(id) {

    x=eval(id);
	xMousePos = window.event.x;
	yMousePos = window.event.y;
 
  x.style.pixelLeft=xMousePos - 130;
  x.style.pixelTop=yMousePos;


	var el = document.getElementById(id).style; 

	if(el.visibility == "hidden") {
	el.visibility = "visible";  
	}
	else if(el.visibility == "visible") {
	el.visibility = "hidden";
	}
	
}
 
function filltextSelect(calle){
val = eval('document.report.mysql'+calle+'.options[document.report.mysql'+calle+'.selectedIndex].value ;');	
txt = eval('document.report.tool_' + calle + '.value') ;
txt_hid = eval('document.report.tool_HID_' + calle + '.value') ;
txt = txt + val ;
txt_hid = txt_hid + val ;
eval('document.report.tool_'+ calle +'.value = txt') ;
eval('document.report.tool_HID_'+ calle + '.value = txt_hid') ;

} 
 
function filltext(val,calle){
	
	
txt = eval('document.report.tool_' + calle + '.value') ;
txt_hid = eval('document.report.tool_HID_' + calle + '.value') ;
txt = txt + val ;
txt_hid = txt_hid + val ;

if(val == "CE"){
txt = "" ;	
txt_hid = "" ;
}

eval('document.report.tool_'+ calle +'.value = txt') ;
eval('document.report.tool_HID_'+ calle + '.value = txt_hid') ;

}

function apriFunc(dim,tipo){
  w = 700;
  h = 600;
  l = (screen.width - w) / 2;
  t = 15;
  wnd = window.open("popup_report.php?&select_where="+tipo+"&dim="+dim,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();	
}

function scriviFunc(sel_whe){
	
	
	var as = "" ;
	var calc = "" ;
	var calc_hid = "" ;
	
	// prendo cio che ce nell'opener
	calc_opener = eval('window.opener.report.tool_' + sel_whe + '.value;') ;
	calc_hid_opener = eval('window.opener.report.tool_HID_' + sel_whe + '.value;') ;
	
	
	// se sono in 'where' salto un po di procedure
	if(sel_whe == "select"){
		
		as = document.report.as.value ;
 		as = as.replace(" ", "_") ;
	 	fun = document.report.func.options[document.report.func.selectedIndex].value ;
	 	 
		
		Nhid = document.report.NHID_cost.value ;
		Nhid = Nhid.substr(0,Nhid.length-1) ;
		 
		
		Nhid_array = Nhid.split("|") ;
		
		hid = document.report.HID_cost.value ;
		hid_array = hid.split("|") ;
		
		fun_array = fun.split("|");
		op1 = fun_array[0] ;
		op2 = fun_array[1] ;	
		
		if(op1 != ""){
		calc = calc + op1 + "( ";
		calc_hid = calc_hid + op1 + "( ";	
		}	
		
	
		calc = calc + "(" ;
		calc_hid = calc_hid + "(" ;

 
		for(i=0;i<Nhid_array.length;i++){
	 
		calc = calc + Nhid_array[i] ;
		calc = calc + op2 ;
		
		calc_hid = calc_hid + hid_array[i] ;
		calc_hid = calc_hid + op2 ;
		}
 
	
	
		calc = calc.substr(0,calc.length-1) ;
		calc_hid = calc_hid.substr(0,calc_hid.length-1) ;
		
	
		calc = calc + ")" ;
		calc_hid = calc_hid + ")" ;
	
		if(op1 != ""){
		calc_hid = calc_hid +  " )";	
		}
		
		calc = calc_opener + calc ;
		calc_hid = calc_hid_opener + calc_hid ; 
		
		calc = calc + " AS " + as ;
		calc_hid = calc_hid + " AS " + as ;
		
	}else{
	 	
	 	cost_left		= document.report.cost_left.options[document.report.cost_left.selectedIndex].text ;
		cost_left_hid 	= document.report.cost_left.value ;
		operando 		= document.report.operando.value ;
		cost_right 		= document.report.cost_right.value ;
		
		calc = calc_opener + " " + cost_left + " " + operando + " '" + cost_right + "' " ;
		calc_hid = calc_hid_opener + " " + cost_left_hid + " " +operando + " '" + cost_right + "' " ;
	}
	
	
 
	 
 
	
	eval('window.opener.report.tool_' + sel_whe + '.value=calc;') ;
	eval('window.opener.report.tool_HID_' + sel_whe + '.value=calc_hid;') ;

	self.close();
	
}
/* TOOLINO									*/
/********************************************/


function toggleDisplay(fO)
	{
	if (fO.style.display=="none")
		{

		fO.style.display="inline";
		}
	else
		{
		fO.style.display="none";
		}
	}


 

function aggiungiR(left_select,right_select,HIDcampo,NHIDcampo,J) {

	select_left = 0 ;
	tutte_zone=0 ;
	
	val = eval('document.report.'+left_select+'.options[document.report.'+left_select+'.selectedIndex].value');
	txt = eval('document.report.'+left_select+'.options[document.report.'+left_select+'.selectedIndex].text');
	
	rx_len = eval('document.report.'+right_select+'.options.length');
	
	for (i=0;i<rx_len;i++){
	
	testo = eval ( 'document.report.'+right_select+'.options[i].text;') ;
		if(testo==txt)
		select_left=1
		}	
		
	if(select_left==0) {
	eval('document.report.'+right_select+'.options[i]=new Option(txt,val)') ;
	left_hidden	= eval('document.report.'+HIDcampo+'.value') ;
	Nleft_hidden	= eval('document.report.'+NHIDcampo+'.value') ;	
	
	eval('document.report.'+HIDcampo+'.value=left_hidden+val+"|"') ;
	eval('document.report.'+NHIDcampo+'.value=Nleft_hidden+txt+"|"') ;
	}
	else
	return ;
}




function togli(right_select,HIDcampo,NHIDcampo) {
	xxx = eval('report.'+right_select+'.selectedIndex') ;
	
	if (xxx<0)
	   return ;
	   
	datogliere = eval('document.report.'+right_select+'.options[document.report.'+right_select+'.selectedIndex].text') ;
	 
	
	splitta(datogliere,HIDcampo,NHIDcampo) ;
	
	
	eval('document.report.'+right_select+'.remove(document.report.'+right_select+'.selectedIndex)');	

}

function splitta(datogliere,HIDcampo,NHIDcampo) {

	var id_app1 = "" ;
	var Nid_app1 = "" ;
	id_str=eval('document.report.'+HIDcampo+'.value') ;
	Nid_str=eval('document.report.'+NHIDcampo+'.value') ;
	
	
	
	id_str_array = id_str.split("|") ;
	Nid_str_array = Nid_str.split("|") ;
	
	for (i=0 ;i<id_str_array.length ;i++) {
 		 
		id_app=id_str_array[i] ;
		Nid_app=Nid_str_array[i] ;
		
		
		
		if(Nid_app!=datogliere && i<((Nid_str_array.length)-1)) {
			 
			id_app1		= id_app1 + id_app + "|" ;
			Nid_app1	= Nid_app1 + Nid_app + "|" ;
		}
	}
	eval('document.report.'+HIDcampo+'.value=id_app1');	
	eval('document.report.'+NHIDcampo+'.value=Nid_app1');	
}



/*********************************************
* FINE REPORT
*********************************************/

function toggleReport(fO)
	{
	if (fO.style.display=="none")
		{

		fO.style.display="inline";
		}
	else
		{
		fO.style.display="none";
		}
	}


 

function aggiungiReport(left_select,right_select,HIDcampo,NHIDcampo,J) {

	select_left = 0 ;
	tutte_zone=0 ;
	
	val = eval('document.report.'+left_select+'.options[document.report.'+left_select+'.selectedIndex].value');
	txt = eval('document.report.'+left_select+'.options[document.report.'+left_select+'.selectedIndex].text');
	
	rx_len = eval('document.report.'+right_select+'.options.length');
	
	for (i=0;i<rx_len;i++){
	
	testo = eval ( 'document.report.'+right_select+'.options[i].text;') ;
		if(testo==txt)
		select_left=1
		}	
		
	if(select_left==0) {
	eval('document.report.'+right_select+'.options[i]=new Option(txt,val)') ;
	left_hidden	= eval('document.report.'+HIDcampo+'.value') ;
	Nleft_hidden	= eval('document.report.'+NHIDcampo+'.value') ;	
	
	eval('document.report.'+HIDcampo+'.value=left_hidden+val+"|"') ;
	eval('document.report.'+NHIDcampo+'.value=Nleft_hidden+txt+"|"') ;
	}
	else
	return ;
}




function togliReport(right_select,HIDcampo,NHIDcampo) {
	xxx = eval('report.'+right_select+'.selectedIndex') ;
	
	if (xxx<0)
	   return ;
	   
	datogliere = eval('document.report.'+right_select+'.options[document.report.'+right_select+'.selectedIndex].text') ;
	 
	
	splittaReport(datogliere,HIDcampo,NHIDcampo) ;
	
	
	eval('document.report.'+right_select+'.remove(document.report.'+right_select+'.selectedIndex)');	

}

function splittaReport(datogliere,HIDcampo,NHIDcampo) {

	var id_app1 = "" ;
	var Nid_app1 = "" ;
	id_str=eval('document.report.'+HIDcampo+'.value') ;
	Nid_str=eval('document.report.'+NHIDcampo+'.value') ;
	
	
	
	id_str_array = id_str.split("|") ;
	Nid_str_array = Nid_str.split("|") ;
	
	for (i=0 ;i<id_str_array.length ;i++) {
 		 
		id_app=id_str_array[i] ;
		Nid_app=Nid_str_array[i] ;
		
		
		
		if(Nid_app!=datogliere && i<((Nid_str_array.length)-1)) {
			 
			id_app1		= id_app1 + id_app + "|" ;
			Nid_app1	= Nid_app1 + Nid_app + "|" ;
		}
	}
	eval('document.report.'+HIDcampo+'.value=id_app1');	
	eval('document.report.'+NHIDcampo+'.value=Nid_app1');	
}


function open_sito(webpath,amb_user,id_user,center) {
	w = 770;
  	h = 550;
	l=(screen.width - w) / 2;
    t=(screen.height - h) /2;
	sito = window.open(webpath+"ambienti/operatori/index.php?id_user="+id_user+"&amb_user="+amb_user+"&center="+center ,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes, width="+w+", height="+h+", left="+l+", top="+t);
	sito.focus() ;
}

function open_sito_az (webpath,amb_user,id_user,center) {
	w = 770;
  	h = 550;
	l=(screen.width - w) / 2;
    t=(screen.height - h) /2;
	sito = window.open(webpath+"ambienti/aziende/index.php?id_user="+id_user+"&amb_user="+amb_user+"&center="+center ,"sito","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes, width="+w+", height="+h+", left="+l+", top="+t);
	sito.focus() ;
}


function open_sito_img(webpath) {
	w = 770;
  	h = 550;
	
	sito_img = window.open(webpath+"ambienti/operatori/index.jpg" ,"sito_img","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, width="+w+", height="+h+", left=240, top=0");
	sito_img.focus() ;
}

function apri_tour(webpath,amb_user,id_user,num) {
	w = 550;
  	h = 450;
	l=(screen.width - w) / 2;
    t=(screen.height - h) /2;
	tour = window.open(webpath+"popup_tour.php?amb_user="+amb_user+"&id_user="+id_user+"&num="+num ,"tour","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
	tour.focus() ;
}

function apri_classifica(webpath,poll) {

   prv = webpath + "sondaggi/poll.php?poll="+poll ;
   wnd = window.open(prv,"votazione","width=170,height=250,menubar=no,status=no,scrollbar=no,resizable=no,left=450,top=250");
}

function cambia_password(webpath,user_id){
  w = 400;
  h = 300;
  l = (screen.width - w) / 2;
  t = 45;
  wnd = window.open(webpath + "popup_cambia_password.php?&user_id="+user_id,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();

}

function apriLayCalendario(id) {

// ottengo numero di DIV in pagina
var alldiv = document.body.getElementsByTagName("DIV");
nu = alldiv.length;
var num_div = 0 ;
	// scann su tutti e inticchio l'altro per spegnere o accendere
	for(r=0;r<nu;r++){
		// qui ottengo id di altro div
		if(id != alldiv[r].getAttribute('id')){
		altro_div = alldiv[r].getAttribute('id');
		num_div++ ;
		}
	
	}
	if (num_div==0) {
	}else {
	// spengo l'altro
	var el = document.getElementById(altro_div).style;
	el.visibility = "hidden";
	}

  x=eval(id);
	xMousePos = window.event.x;
	yMousePos = window.event.y;
 
  x.style.pixelLeft=xMousePos + 20;
  x.style.pixelTop=yMousePos ;


	var el = document.getElementById(id).style; 

	if(el.visibility == "hidden") {
	el.visibility = "visible";  
	}
	else if(el.visibility == "visible") {
	el.visibility = "hidden";
	}
	
}

<!-- FINE FUNC -->




function riporta_data(data,campo,periodo_week,data_end){

len = parent.document.form.length;
periodo = periodo_week.split("|") ;

	if(periodo[1] == "mese"){
		
	// formatto la data da visualizzare il alert
		xx = data.split("-");
		aaaa	= xx[2];
		mm	= xx[1];
		gg	= 1;
		if(mm.length<2){mm = "0" + mm;}
	
		if(data_end.length<2){data_end = "0" + data_end;}
	
		
	
	data_mese_start = "01-" + mm + "-" + aaaa;
	data_mese_end = data_end + "-" + mm + "-" + aaaa;
	
	// se stai scegliendo data start 
		if(campo == "XDISP241"){	
		alert("Questo UIL ha come periodo minimo il mese.\nLe date possibili sono\n\n[ "+data_mese_start+" ] e [ "+data_mese_end+" ] \n\n e saranno impostate automaticamente dal sistema.\n\nSe vuoi pronotare piu' di un mese\nmodifica il campo [data fine].");	
		parent.document.form.XDISP241.value=data_mese_start;
		}else{
		alert("Questo UIL ha come periodo minimo il mese.\nLa data finale possibile e\n\n[ "+data_mese_end+" ] \n\n e sar… impostata automaticamente dal sistema.");	
		}
	parent.document.form.XDISP242.value=data_mese_end;
	
	}
	else if (periodo[1] == "settimana" && periodo[0] == "disp") {
		
		var week = new Array(6);
		
		week[1]="Lunedi";
		week[2]="Martedi";
		week[3]="Mercoledi";
		week[4]="Giovedi";
		week[5]="Venerdi";
		week[6]="Sabato";
		week[7]="Domenica";
		//mi restituisce il giorno della settimana della data 
		//che ho scelto
		weekday = week_day(data) ;
		if (campo == "XDISP241") {
			parent.document.form.XDISP241.value="" ;
			parent.document.form.XDISP242.value="" ;
			if (periodo[2] != weekday) {
				alert ("La Disponibilità dell'immobile è per settimane!\nIl giorno di partenza della prenotazione è " +week[periodo[2]]+ ".") ;
			}
			else {
				parent.document.form.XDISP241.value=data ;
				parent.document.form.XDISP242.value="" ;	
			}
		}
		if (campo == "XDISP242") {
			parent.document.form.XDISP242.value="" ;
			data_out = data ;
			data_in = parent.document.form.XDISP241.value ;
			if (data_in) {
				xx = data_in.split("-");
				aaaa	= parseInt(xx[2]);
				mm	= parseInt(xx[1]);
				gg	= parseInt(xx[0]);
				
				//getDaysInMonth(mm,aaaa)
				if ((gg + 7) <= getDaysInMonth(mm,aaaa)) {
					gg = gg + 7 ;
					data_add_week = gg + "-" + mm + "-" + aaaa ;					
				}  	
				else {
					num = getDaysInMonth(mm,aaaa) - gg ;
					gg = 7 - num ;
					if ( (mm + 1) < 13) {
						mm = mm + 1 ;	
					}
					else {
						mm = "01" ;
						aaaa = aaaa + 1 ;
					}
					data_add_week = gg + "-" + mm + "-" + aaaa ;
				}
				if (data_out == data_add_week) {						
					parent.document.form.XDISP242.value=data ;
				}
				else {
					alert ("L'intervallo di date iscelto non è compatibile\ncon quello del periodo di prenotazione dell'immobile!\n") ;
				}
			}
			else {
				alert ("Manca la data di inizio") ;
			}
		}
	}
	else{
		xx = data.split("-");
		aaaa	= xx[2] ;
		mm	= xx[1] ;
		gg	= xx[0] ;
		if(mm.length<2){mm = "0" + mm;}
		if(gg.length<2){gg = "0" + gg;}
		data_ok = gg + "-" + mm + "-" + aaaa ;
		data_post = aaaa + mm + gg ; 
		
		for(r=0;r<len;r++){
			
			// nome di tutti i campi di opener
			s = parent.document.form.elements[r].name;
			s_text = parent.document.form.elements[r].name ;
			if (s == campo ){
				parent.document.form.elements[r].value=data_post;
			}
			if (s_text == campo + "_text") {
				parent.document.form.elements[r].value=data_ok;	
			}
			
		}
	}
 

parent.chiudiLayCalendario(campo);

}

<!-- FINE FUNC -->

function week_day(data) {
	
	data_array = data.split("-") ;
	anno = data_array[2] ;
	mese = data_array[1] ;
	mese = mese - 1 ;
	giorno = data_array[0] ;
	if(mese.length<2){mese = "0" + mese;}
	if(giorno.length<2){giorno = "0" + giorno;}
	
	var data_str = new Date(anno,mese,giorno) ;
	
	var week_num = data_str.getDay() ;

	return week_num ;
}

function getDaysInMonth(month, year) {
        
        var month_array = new Array (11) ;
        month_array[1] = 31 ;
        month_array[2] = 28 ;
        month_array[3] = 31 ;
        month_array[4] = 30 ;
        month_array[5] = 31 ;
        month_array[6] = 30 ;
        month_array[7] = 31 ;
        month_array[8] = 31 ;
        month_array[9] = 30 ;
        month_array[10] = 31 ;
        month_array[11] = 30 ;
        month_array[12] = 31 ;        
        
        if (month < 1 || month > 12) {
            return 0;
        }
   
        d = month_array[month];
   
        if (month == 2) {
            // Check for leap year
            // Forget the 4000 rule, I doubt I'll be around then...
        
            if (year%4 == 0) {
                if (year%100 == 0) {
                    if (year%400 == 0) {
                        d = 29;
                    }
                }
                else {
                    d = 29;
                }
            }
        }
    
        return d;
}

function data_aaaammgg(data){
	xx = data.split("-");
	aaaa	= xx[2];
	mm	= xx[1];
	gg	= xx[0];
	
	
	if(mm.length<2){mm = "0" + mm;}
	if(gg.length<2){gg = "0" + gg;}
	
	dt_full = aaaa + mm + gg ;
return 	dt_full;
}

function chiudiLayCalendario(id){

id = "divcal" + id;

var el = parent.document.getElementById(id).style; 
 	
 	el.visibility = "hidden";
}

function chiudiLayPrezzi(id){

chk = "chk_" + id; 
id_l = "listino_" + id;

var el = parent.document.getElementById(id_l).style; 
el.visibility = "hidden";

eval("parent.document.form."+chk+".checked=false ;") ;

}

function chiudiLayDescrizione (id){

id_l = "descr_" + id;

var el = parent.document.getElementById(id_l).style; 
el.visibility = "hidden";

}
 
 
function apri_dim(webpath,dim_cod,id_nonno,id_area,center_dett,campo_opener) {
  w = 590;
  h = 600;
  l = (screen.width - w) / 2;
  t = 15;
  wnd = window.open(webpath + "popup_dim.php?dim_cod="+dim_cod+"&id_nonno="+id_nonno+"&campo_opener="+campo_opener+"&id_area="+id_area+"&center_dett="+center_dett,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();

}

function apri_disp (webpath,dim_cod,id_nonno,id_area,center_dett,campo_opener,id_uil,sw_uil_serv,tipo_sql,testata_id) {

  w = 700;
  h = 600;
  l = (screen.width - w) / 2;
  t = 15;
  wnd = window.open(webpath+"popup_disp.php?dim_cod="+dim_cod+"&id_nonno="+id_nonno+"&campo_opener="+campo_opener+"&id_area="+id_area+"&center_dett="+center_dett+"&uil_id="+id_uil+"&sw_uil_serv="+sw_uil_serv+"&tipo_sql="+tipo_sql+"&testata_id="+testata_id,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();
  
  //self.close();
}

function apri_dettaglio(webpath,id,dim_cod) {

  w = 700;
  h = 600;
  l = (screen.width - w) / 2;
  t = 15;
  wnd = window.open(webpath+"popup_dettaglio.php?dim_cod="+dim_cod+"&uil_id="+id,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();

}

function riporta_dim (id,text,x,campo_opener) {

id_array = id.split("|") ;
campo_opener_array = campo_opener.split("|") ;
text_array = text.split("|") ;

// lungezza di tutti i campi del opener
len = window.opener.document.form.length;

	for(r=0;r<len;r++){
	// nome di tutti i campi di opener
	s=window.opener.document.form.elements[r].name;
	
	// in opener solo il campo fasullo del testo e [nome_campo]_text
	// quindi con split sgamo il campo fasullo
	// e riporto i valori al campo fasullo 
	// e il succesivo che e l'ID che mi serve.
	t=s.split("_");
	jj=t[1];
	dd=t[0];
		
		if(jj == "text" && dd == campo_opener_array[0]){			
			window.opener.document.form.elements[r].value=text_array[0];
			nn=r+1;
			window.opener.document.form.elements[nn].value=id_array[0];	
		
			if (id_array[1] || id_array[2] || campo_opener_array[1] || campo_opener_array[2]) {	
					
				text_a = campo_opener_array[1] ;
				text_a = text_a + "_text" ;
									
				text_b = campo_opener_array[2] ;
				text_b = text_b + "_text" ;
			
			
				eval("window.opener.document.form."+campo_opener_array[1]+".value="+id_array[1]+";") ;
				eval("window.opener.document.form."+campo_opener_array[2]+".value="+id_array[2]+";") ;
				eval("window.opener.document.form."+text_a+".value='"+text_array[1]+"';") ;
				eval("window.opener.document.form."+text_b+".value='"+text_array[2]+"';") ;
			}
		
		}
		else if (jj == "num" && dd == campo_opener_array[0]) {
			old_val = eval("window.opener.document.form."+campo_opener_array[0]+"_num.value;") ;
			if (old_val) {
				old_val1= parseInt(old_val) ;
				old = old_val1 + 0 ;
			}else {
				old = 0 ;
			}
			eval("window.opener.document.form."+campo_opener_array[0]+"_num.value="+text_array[1]+";") ;
			par = window.opener.document.form.totale.value ;
			if (par) {
				par1 = parseInt(par) ;
				parziale = par1 + 0 ;
			}else {
				parziale = 0 ;
			}
			totale = (parseInt(parziale) - parseInt(old)) + parseInt(text_array[1]) ;
			eval("window.opener.document.form.totale.value="+totale+";") ;
		}	
	}

self.close();

}

function galleria_foto(titolo,foto_big){;
	i1 = new Image;
	i1.src = foto_big;
	html = "<head>";
	html = html + "<title>" + titolo + "</title>";
	html = html + "</head>";
	html = html + "<BODY LEFTMARGIN='0' MARGINWIDTH='0' TOPMARGIN='0' MARGINHEIGHT='0'>";
	html = html + "<CENTER>";
	html = html + "<IMG SRC=" + foto_big + " BORDER=0 NAME=foto_grande onLoad=window.resizeTo(document.foto_grande.width+12,document.foto_grande.height+30)>";
	html = html + "</CENTER>";
	html = html + "</BODY>";
	
	popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0');
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close()
}

function apri_scheda(webpath,id_uil,dim_cod,struttura,coords,mappa_dett,center) {

  w = 500;
  h = 500;
  l=(screen.width - w) / 2;
  t=(screen.height - h) /2;
  
  coords_arr = coords.split("|") ;
  
   
  wnd = window.open(webpath+"popup_immobile.php?uil_id="+id_uil+"&nome_struttura="+struttura+"&dim_cod="+dim_cod+"&x_cord="+coords_arr[0]+"&y_cord="+coords_arr[1]+"&mappa_dett="+mappa_dett+"&mappa_tot="+center,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();
}


function salva_dati() {
//salverò i dati nel DB
	
}

function check_week(campo,webpath) {
	
	len = document.form.length;
	for(r=0;r<len;r++){
		nome=document.form.elements[r].name;
		if (nome == campo) {
		    val = document.form.elements[r].value;
			if (val=='3') {
			   	w = 200;
 			    h = 100;
  				l=(screen.width - w) / 2;
  				t=(screen.height - h) /2;
				wnd = window.open(webpath + "popup_check_week.php","","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  				wnd.focus();
			}
			else {
				//pulisco il campo hidde se mai sto in edit
				//per evitare che rimanga valorizzato nonostante scelgo giorno o mese
				//anzicche settimana
				document.form.XUIL419.value=0 ;
			}
		}
	}
}


function scrivi_gg_week(gg_week) {

	window.opener.document.form.XUIL419.value=gg_week ;
	self.close() ;
}


/*********************************************************************************************
apre il popup per inserire o modificare la status di un servizio
**********************************************************************************************/
function status_servizio () {
	
  w = 500;
  h = 310;
  l=(screen.width - w) / 2;
  t=(screen.height - h) /2;
  wnd = window.open("http://www.welcomecampania.it/welcome_admin/php/popup_status_servizio.php","","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();
	
}
/***********************************************************************************************
seleziono o deseleziono tutti i check dei grant 
************************************************************************************************/
function select_all(nome) {
	
	
	//num e il numero di caratteri della parte costante del nome dei check che ho nel form
	num=nome.length ;	
	
	//bool la metto a true
	var bool = true ;
	
	//se un check della riga o della serie e' gia fleggato, la var bool la metto a false
	//quindi nel for successivo vado a defleggare tutti i check della riga o della serie
	//se non c'e' nessun check fleggato bool rimane valorizzata a bool
	len=document.form.length;
	for (i=0;i<len;i++) {
		if (document.form[i].type=="checkbox") {
		    //nome_check e' il nome del checkbox
			nome_check = document.form[i].name ;
			//mi prendo la parte costante del nome del check
			nome_check_cost = nome_check.substring(0,num) ;
			//se il nome della serie dei check che passo alla func e' uguale
			//alla parte costante del check sul quale mi trovo adesso
			if (nome == nome_check_cost) {
				if (document.form[i].checked==true) {
					bool=false ;
				}
			}
		}
	}
	
	//scorro negli elementi del form
	//se l'elemento che trovo e' un check lo metto a checked = true o cheked = false 
	//a seconda se bool vale true o false
	len=document.form.length;
	for (i=0;i<len;i++) {
		if (document.form[i].type=="checkbox") {	
		    nome_check = document.form[i].name ;
			nome_check_cost = nome_check.substring(0,num) ;
			if (nome == nome_check_cost) {
				document.form[i].checked=bool ;
			}
		}
    }		
}


//riceve il nome di un hidde che mi identifica il
//punto di partenza del gruppo di check che voglio
//checcare o decekkare
function check_decheck(counter) {

	//bool la metto a true
	var bool = false ;
	
	len=document.form.length;
	for (i=0;i<len;i++) {
		if (document.form[i].name==counter && document.form[i].type=="hidden") {
			//mi conservo l'indice di partenza dei campi del form che mi interessano
			xx = i+1 ;
		}
		if (document.form[i].name==(counter+1) && document.form[i].type=="hidden") {
			//ed il punto finale
			yy = i-1 ;
		}
	}
	
	//faccio un ciclo solo sui campi del form compresi tra xx e yy
	for (i=xx ;i<=yy;i++) {	
		//se trovo uncheckbox
		if (document.form[i].type=="checkbox") {
			//e se non e' chekkato, bool == false e spezzo il ciclo
			if (document.form[i].checked==false) {
				bool=true ;
				break ;
			}
		}
	}
	
	//se bool == true, vuol dire che ho trovato almeno
	//un checkbox non vistato, quindi li chekko tutti
	if (bool) {
		check_all (xx,yy) ;
	}
	//altrimenti li decekko tutti
	else {
		decheck_all (xx,yy) ;
	}
}

function decheck_all (xx,yy) {
	
	for (i=xx ;i<=yy;i++) {	
		if (document.form[i].type=="checkbox") {
			document.form[i].checked=false ;
		}
	}
}

function check_all (xx,yy) {
	
	for (i=xx ;i<=yy;i++) {	
		if (document.form[i].type=="checkbox") {
			document.form[i].checked=true ;
		}
	}
}

function submit_e_chiudi () {
	
	form_confirm.submit() ;
	//self.close() ;	
}

function check_persone_max(num_persone) {

	i = document.form.num.selectedIndex ;
	numero = document.form.num.options[i].value ;
	if (numero > num_persone) {
		alert ("Numero di persone superiore alla disponibilita dell'immobile!!\nMassimo "+num_persone+" persone.") ;	
		document.form.num.options[0].selected = true ;
	}
}

/********************************************************
*
*    FUNZIONI PER IL MONDO DELLE MAPPE
*
*********************************************************/
function apri_mappa() {

  w = 347;
  h = 290;
  l = (screen.width - w) / 2;
  t = (screen.height - h) /2; 
  wnd = window.open("popup_mappa.php?comune_reg=campania","","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();
}

function statusreport(){
status='offsetX : '+event.offsetX+', offsetY : '+event.offsetY;
x = event.offsetX;
y = event.offsetY;
}

function go_back (webpath,center) {

	parent.location.href = webpath+"?center="+center+"&center_dett=visualizza_front" ;	
}

function docoordinatein(zona){
	
	//top.location = 'docoordinatein.php?x=' + x + '&y=' + y;
	aa = " " ;
	zona_ok = zona.replace("_", aa) ;
	
	// lungezza di tutti i campi del opener
	len = window.opener.document.form.length;

	for(r=0;r<len;r++){
	// nome di tutti i campi di opener
	s=window.opener.document.form.elements[r].name;

		if (s=="coordinate") {
			window.opener.document.form.elements[r].value=x+","+y;
		}
		if (s=="XUIL442") {
			window.opener.document.form.elements[r].value=x+","+y;
		}
		if (s=="XUIL443") {
			window.opener.document.form.elements[r].value=zona_ok;
		}
	}
	self.close() ;
}

function aggiungi (J) {
	aggiungi_a_right(J)
}

function aggiungi_a_right(j) {
	
	select_left = 0 ;
	tutte_zone=0 ;
	val = document.form_zone.select_left.options[document.form_zone.select_left.selectedIndex].value;
	
	txt = document.form_zone.select_left.options[document.form_zone.select_left.selectedIndex].text;
	
	for (i=0;i<document.form_zone.select_right.options.length;i++){
	     testo=document.form_zone.select_right.options[i].text ;
	     if(testo==txt || testo=="Tutte") 
	        select_left=1 ;
	     if (txt=="Tutte") {
	     	tutte_zone=1 ;
	     	select_left = 1 ;
	     }
	}	
	if(tutte_zone==1) remove_all() ;
	if(select_left==0) {
	   document.form_zone.select_right.options[i]=new Option(txt,val) ;
	   nome_select_left=document.form_zone.elementi_sel.value ;
	   nome_select_left_hidden=document.form_zone.elementi_sel_hidden.value ;
	   document.form_zone.elementi_sel.value=nome_select_left+txt+"," ;
	   document.form_zone.elementi_sel_hidden.value=nome_select_left_hidden+val+"|" ;
	   
	}
	else
	   return ;
	
	
}

function remove_all() {
   document.form_zone.select_right.options.length = 0; 
   document.form_zone.select_right.options[0]=new Option ("Tutte") ;
   document.form_zone.elementi_sel.value="" ; 
   document.form_zone.elementi_sel.value="Tutte" ;
   document.form_zone.elementi_sel_hidden.value="" ;
    
}

function togli() {	
	togli_a_right() ;
}

function togli_a_right() {
	
	if (form_zone.select_right.selectedIndex<0)
	   return ;
	adattoper=document.form_zone.select_right.options[document.form_zone.select_right.selectedIndex].text ;
	
	splitta(adattoper) ;
	document.form_zone.select_right.remove(document.form_zone.select_right.selectedIndex);	
}

function splitta(adattoper) {
	
	var app1="" ;
	var id_app1="" ;
	str=document.form_zone.elementi_sel.value ;
	id_str=document.form_zone.elementi_sel_hidden.value ;
	str_array=str.split(",") ;
	id_str_array=id_str.split("|") ;
	for (i=0 ;i<str_array.length ;i++) {
		app=str_array[i] ;
		id_app=id_str_array[i] ;
		if(app!=adattoper && i<((str_array.length)-1)) {
			app1=app1+app+"," ;
			id_app1=id_app1+id_app+"|" ;
		}
	}
	document.form_zone.elementi_sel.value=app1 ;
	document.form_zone.elementi_sel_hidden.value=id_app1 ;	
}

function canc_riport (campo) {

	checkcampo = eval("document.form."+campo+"_text.value;") ;
	//alert (checkcampo) ;
	if (checkcampo) {
		par = eval("document.form."+campo+"_num.value;")  ;

		if (!par) {
			parziale = 0;
		}else {
			par1 = parseInt(par) ;
			parziale = par1 + 0 ;
		}
			
		eval("document.form."+campo+".value='';")  ;
		eval("document.form."+campo+"_text.value='';")  ;
		eval("document.form."+campo+"_num.value='';")  ;
		
		tot = document.form.totale.value ;
		if (tot) {
			tot1 = parseInt (tot) ;
			totale = tot1 + 0 ;
			new_totale = totale - parziale ;
		}
		
		document.form.totale.value=new_totale ;
	}
	else {
		alert ("Il campo e' vuoto!");
	}
}

function canc_dim (campo) {

	checkcampo = eval("document.form."+campo+"_text.value;") ;
	//alert (checkcampo) ;
	if (checkcampo) {
					
		eval("document.form."+campo+".value='';")  ;
		eval("document.form."+campo+"_text.value='';")  ;
	}
	else {
		alert ("Il campo e' vuoto!");
	}
}

function apriStampa(id) {

	var el = document.getElementById(id).style; 

	el.visibility = "visible";  
}

function chiudiStampa(id) {

	var el = document.getElementById(id).style; 

	el.visibility = "hidden";
}

function printit() { 
	
	javascript:window.print() ;	
}
function docjslib_getImageWidth(imgID) {
  return eval(imgID).width;
}

function docjslib_getImageHeight(imgID) {
  return eval(imgID).height;
}

function docjslib_getImageXfromLeft(imgID) {
  if (1<0) return eval(imgID).x
  else return docjslib_getRealLeft(imgID);
}

function docjslib_getImageYfromTop(imgID) {
  if (1<0) return eval(imgID).y
  else return docjslib_getRealTop(imgID);
}

function docjslib_getRealLeft(imgElem) {
	xPos = eval(imgElem).offsetLeft;
	tempEl = eval(imgElem).offsetParent;
  	while (tempEl != null) {
  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
  	}
	return xPos;
}

function docjslib_getRealTop(imgElem) {
	yPos = eval(imgElem).offsetTop;
	tempEl = eval(imgElem).offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}

function docjslib_getElementTop(id) {
  if (1<0) return eval(id).top
  else return eval(id).style.pixelTop;
}
function docjslib_getElementHeight(id) {
  if (1<0) return eval(id).clip.height
  else return eval(id).clientHeight;
}
function apri_zona (myImgId,campo,id,nome_campo) {
	
	document.form.nome_zona.value="" ;
	document.form.nome_zona.text="" ;
	
	pos = eval("document.form."+campo+".selectedIndex");
    val = eval("document.form."+campo+".options["+ pos +"].value");
    zona= eval("document.form."+campo+".options[document.form."+campo+".selectedIndex].text ;");
    val_z = eval("document.form."+campo+".options[document.form."+campo+".selectedIndex].value ;");
    
    var val_array = val.split("|");
    sw_zona = val_array[1];
    
	var xxx = docjslib_getImageXfromLeft(myImgId) ;
	var yyy = docjslib_getImageYfromTop(myImgId) ;
    
    if (sw_zona==1) {    
		//apriLayCalendario(id) ;
		
		var el = document.getElementById(id).style; 
		el.visibility = "visible";
		x=eval(id);
		xMousePos = window.event.x;
		yMousePos = window.event.y;		
		
	 	x.style.pixelLeft = xxx - 300 ; //xMousePos - 100;
		x.style.pixelTop = yyy ;//yMousePos + 1200;
		
		val = val_z.split("|") ;
		eval ("document.form."+nome_campo+".value=val[0] ;") ;
	}
	else {
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length;
		var num_div = 0 ;
		// scann su tutti e inticchio l'altro per spegnere o accendere
		for(r=0;r<nu;r++){		
			if(id == alldiv[r].getAttribute('id')){
				var el = document.getElementById(alldiv[r].getAttribute('id')).style;
				el.visibility = "hidden";
			}	
		}
		
		document.form.nome_zona.value=zona ;
		val = val_z.split("|") ;
		eval ("document.form."+nome_campo+".value=val[0] ;") ;
	}
}

function riporta_zone (id,nome_campo,id_tutte) {
	for (i=0 ; i < form_zone.length ; i++) {
		
		if (form_zone.elements[i].name=="elementi_sel") {
			zone_virgola = form_zone.elements[i].value ;
			num = zone_virgola.length ;
			if ( zone_virgola.substring(num,(num-1)) == ",") {
				zone = zone_virgola.substring(0,(num-1)) ;
			}else {
				zone = zone_virgola ;	
			}
			
			if (zone=="") zone = "Tutte" ;
			parent.form.nome_zona.value=zone ;
		}	
		else if (form_zone.elements[i].name=="elementi_sel_hidden") {
			zone_pipe = form_zone.elements[i].value ;
			num = zone_pipe.length ;
			if ( zone_pipe.substring(num,(num-1)) == "|") {
				id_zone = zone_pipe.substring(0,(num-1)) ;
			}else {
				id_zone = zone_pipe ;	
			}			
			
			if (id_zone=="") id_zone = id_tutte ;
			eval ("parent.form."+nome_campo+".value=id_zone ;") ;
		}
		chiudiLayCalendario(id) ;
	}
}
function aggiungi_pietanze (campo_id,check) {
	
	//il campo check Š del tipo ptz_3 dove 3 Š l'id della pietanza presa dal listino pietanze
	pietanza = check.split("_") ;
	id_pietanza = pietanza[1] ;
	
	//stato vale true se sto checckando il checkbox
	//false se era checckato e lo sto dechecckando
	stato = eval("document.form."+check+".checked ;") ;
	
	if (stato) {
		val = eval("document.form."+campo_id+".value;") ;
		
		//se il campo che conterra gli id delle pietanze Š vuoto
		//scrivo l'id della pietanza
		if (!val) {
			eval("document.form."+campo_id+".value="+id_pietanza+";") ;
		}
		//se gia c'Š qualcosa scrivo prima "," poi la pietanza
		else {
			/*superfluo*/ 
			val_tot = val.split(",") ;
			for (i=0 ; i < val_tot.length ; i++) {
				if (val_tot[i] == id_pietanza) {
					return ;
				}	
			}
			/*superfluo*/ 
			val_tot = val + "," + id_pietanza ;
			eval("document.form."+campo_id+".value=val_tot;") ;
		}
	}else {
		var new_value = "" ;
		val = eval("document.form."+campo_id+".value;") ;
		val_tot = val.split(",") ;
		for (i=0 ; i < val_tot.length ; i++) {
			//alert (val_tot[i]) ;
			//alert (id_pietanza) ;
			if (val_tot[i] != id_pietanza) {
				new_value += val_tot[i] + "," ;
			}	
		}
		num = new_value.length ;
		new_val = new_value.substring(0,(num - 1)) ;
		eval("document.form."+campo_id+".value=new_val;") ;
	}
}

function set_listino_ptz (nome,div_id,id_user,id_pietanza,pietanza) {
	
	//stato vale true se sto checckando il checkbox
	//false se era checckato e lo sto dechecckando
	stato = eval("document.form."+nome+".checked ;") ;
	
	if (stato) {
		
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length;
		for(r=0;r<nu;r++){
			var el = document.getElementById(alldiv[r].getAttribute('id')).style;
			if (el.visibility == "visible") {
				alert ("aggiungere una pietanza per volta!!") ;
				eval("document.form."+nome+".checked=false ;") ;
				return ;	
			}
		}
		
		var el = document.getElementById(div_id).style; 
		el.visibility = "visible";
		
		x=eval(div_id);
		xMousePos = window.event.x;
		yMousePos = window.event.y;
	 
		x.style.pixelLeft=xMousePos - 250;
		x.style.pixelTop=yMousePos + 20;
	}
	else {
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length;
		var num_div = 0 ;
		// scann su tutti e inticchio l'altro per spegnere o accendere
		for(r=0;r<nu;r++){		
			if(div_id == alldiv[r].getAttribute('id')){
				var el = document.getElementById(alldiv[r].getAttribute('id')).style;
				el.visibility = "hidden";
			}	
		}
		return ;	
	}
}

function set_listino_prod (nome,div_id,id_user,id_prodotto,prodotto) {
	
	//stato vale true se sto checckando il checkbox
	//false se era checckato e lo sto dechecckando
	stato = eval("document.form."+nome+".checked ;") ;
	
	if (stato) {
		
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length;
		for(r=0;r<nu;r++){
			var el = document.getElementById(alldiv[r].getAttribute('id')).style;
			if (el.visibility == "visible") {
				alert ("aggiungere un prodotto per volta!!") ;
				eval("document.form."+nome+".checked=false ;") ;
				return ;	
			}
		}
		
		var el = document.getElementById(div_id).style; 
		el.visibility = "visible";
		
		x=eval(div_id);
		xMousePos = window.event.x;
		yMousePos = window.event.y;
	 
		x.style.pixelLeft=xMousePos - 250;
		x.style.pixelTop=yMousePos + 20;
	}
	else {
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length;
		var num_div = 0 ;
		// scann su tutti e inticchio l'altro per spegnere o accendere
		for(r=0;r<nu;r++){		
			if(div_id == alldiv[r].getAttribute('id')){
				var el = document.getElementById(alldiv[r].getAttribute('id')).style;
				el.visibility = "hidden";
			}	
		}
		return ;	
	}
}

function view_descr_prod (div_id,id_user,id_prodotto,prodotto) {
	
	var alldiv = document.body.getElementsByTagName("DIV");
	nu = alldiv.length;
	for(r=0;r<nu;r++){
		var el = document.getElementById(alldiv[r].getAttribute('id')).style;
		if (el.visibility == "visible") {
			chiudiLayDescrizione(id_prodotto) ;
			return ;
		}
	}
	
	var el = document.getElementById(div_id).style; 
	el.visibility = "visible";
	
	x=eval(div_id);
	xMousePos = window.event.x;
	yMousePos = window.event.y;
 
	x.style.pixelLeft=xMousePos - 10;
	x.style.pixelTop=yMousePos + 20;
	
}

function check_empty_field (campo) {
	val = eval ("document.form."+campo+".value") ;
	if (val) {
		return document.form.submit() ;
	}else {
		alert ("Manca il prezzo!") ;
	}
}

function apri_style(webpath,id_user,id_st,dim_cod) {
  
  	//leggo da campo hidden l'id dello stile che sto editando e lo passo al popup crea style
  	id_stile = document.form.id_stile.value ;
  	
  	//se non ho selezionato nessuno stile dal menu a tendina, mi prendo quello proprio del locale
  	//che mi arriva nella func
  	if (!id_stile) {
  		id_stile = id_st ;	
  	}
  	
	l=2;
    t=2;
    stile = window.open(webpath+"creastyle.php?id_user="+id_user+"&id_s="+id_stile+"&dim_cod="+dim_cod ,"stile","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=238,height=550,left="+l+",top="+t);
	stile.focus();   
}

function apri_style_new(webpath,id_user,dim_cod) {
  
	l=200;
    t=200;
    stile = window.open(webpath+"creastyle_new.php?id_user="+id_user+"&dim_cod="+dim_cod ,"stile","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=220,height=100,left="+l+",top="+t);
	stile.focus();   
}

function apri_thumb_style(webpath) {
	
	l=200;
    t=100;
    thumb_style = window.open(webpath+"popup_thumb_style.php" ,"thumb_style","fullscreen=0,channelmode=no,toolbar=tes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=500,left="+l+",top="+t);
	thumb_style.focus();	
}

function riporta_id_stile () {
	
	for (i=0 ; i < form.length ; i++) {
		
		if (form.elements[i].name=="XRIST765" || form.elements[i].name=="XAZ1032") {
			id_style = form.elements[i].value ;
			eval ("document.form.id_stile.value="+id_style+";");
		}
	}	
}

function popUpPrivacy(webpath) {
	
	pvy=window.open(webpath+"ambienti/php/privacy.php", "privacy", "toolbar=no,width=370,height=400,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no"); 
}

function scheda_locale (webpath,id_user) {
	w = 480;
  	h = 500;
	l=(screen.width - w) / 2;
    t=(screen.height - h) /2;
	scheda=window.open(webpath+"scheda_locale.php?id_user="+id_user, "scheda", "toolbar=no,width="+w+",height="+h+",top="+t+",left="+l+",directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no"); 

}

function chiudi_scheda_locale (div_id) {
	
	id = div_id ;
	var el = parent.document.getElementById(id).style;  	
 	el.visibility = "hidden";
}

function riporta_nome_locale (nomeform,campo1,campo2) {
		
	val = eval ("document."+nomeform+"."+campo1+".value;") ;
	
	if (val != "Nome locale") {
		eval ("document."+nomeform+"."+campo2+".value=val;") ;
	}else {
		eval ("document."+nomeform+"."+campo2+".value='';") ;
	}
}

function riporta_tipologia (nomeform,campo1,campo2) {
		
	pos = eval("document."+nomeform+"."+campo1+".selectedIndex");
    valore = eval ("document."+nomeform+"."+campo1+".options[document."+nomeform+"."+campo1+".selectedIndex].text ;") ;
 	if (valore != "Scegli la tipologia..") {
 		eval ("document."+nomeform+"."+campo2+".value=valore;") ;
 	}
}

function chiave_ricerca (x,campo) {
	
	pos = eval("document.form.single_select"+x+".selectedIndex");
    valore = eval ("document.form.single_select"+x+".options[document.form.single_select"+x+".selectedIndex].text ;") ;
    eval ("document.form."+campo+".value=valore;") ;
}

function apri_prontoinunclik1 (id_user,webpath,ambiente) {
  w = 280 ;
  h = 420 ;
  l=(screen.width - w) / 2 ;
  t=(screen.height - h) /2 ;
 
  prv  = webpath + "ambienti/"+ambiente+"/php/popup_prontoinunclik1.php?id_user="+id_user+"&webpath="+webpath ;  
  pronto1 = window.open(prv,"pronto1","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  pronto1.focus() ;	
}

function apri_prontoinunclik (id_user,webpath) {
  w = 280 ;
  h = 520 ;
  l=(screen.width - w) / 2 ;
  t=(screen.height - h) /2 ;
  
  prv  = webpath + "php/popup_prontoinunclik.php?id_user="+id_user+"&webpath="+webpath+"&pronto=1" ;
  pronto = window.open(prv,"pronto","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  pronto.focus() ;	
}

function Help(webpath,folder_amb) {
	
  w = 770;
  h = 550;
  l=(screen.width - w) / 2;
  t=(screen.height - h) /2;
  wnd = window.open(webpath+"ambienti/contenuti/help.php?folder="+folder_amb,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
  wnd.focus();
}

function open_popup_icon(ww,hh,center,id_user_login,id_rist) {
	
	if (center=="preferiti" && !id_user_login) {
		
		w = 300;
	  	h = 250;
		l=(screen.width - w) / 2;
	    t=(screen.height - h) /2;
		reg = window.open("popup_registrati.php?form_login=1" ,"reg","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
		reg.focus() ;	
	}
	else {
		w = ww;
	  	h = hh;
		l=(screen.width - w) / 2;
	    t=(screen.height - h) /2;
		pupup_icon = window.open("popup_icon.php?id_user_login="+id_user_login+"&id_rist="+id_rist+"&center="+center+"&width="+ww+"&height="+hh ,"popup_icon","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
		pupup_icon.focus() ; 
		if (!id_user_login) {
			w = 300;
		  	h = 250;
			l=(screen.width - w) / 2;
		    t=(screen.height - h) /2;
			reg = window.open("popup_registrati.php" ,"reg","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
			reg.focus() ;
		}		
	}
}

function open_popup_icon_promo (ww,hh,center,id_user_login,id_rist,fold,id_promo,dim) {
	
	if (center=="preferiti" && !id_user_login) {
		
		w = 300;
	  	h = 250;
		l=(screen.width - w) / 2;
	    t=(screen.height - h) /2;
		reg = window.open("popup_registrati.php?form_login=1" ,"reg","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
		reg.focus() ;	
	}
	else {
		w = ww;
	  	h = hh;
		l=(screen.width - w) / 2;
	    t=(screen.height - h) /2;
		pupup_icon = window.open("popup_icon.php?id_user_login="+id_user_login+"&id_rist="+id_rist+"&center="+center+"&folder="+fold+"&id_promo="+id_promo+"&dim="+dim+"&width="+ww+"&height="+hh ,"popup_icon","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
		pupup_icon.focus() ; 
		if (!id_user_login) {
			w = 300;
		  	h = 250;
			l=(screen.width - w) / 2;
		    t=(screen.height - h) /2;
			reg = window.open("popup_registrati.php" ,"reg","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
			reg.focus() ;
		}		
	}
}

function open_popup_promo_vt (webpath,ww,hh,center,id_user_login,id_rist,fold,id_promo,dim) {
	
	if (center=="preferiti" && !id_user_login) {
		
		w = 300;
	  	h = 250;
		l=(screen.width - w) / 2;
	    t=(screen.height - h) /2;
		reg = window.open(webpath+"popup_registrati.php?form_login=1" ,"reg","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
		reg.focus() ;	
	}
	else {
		w = ww;
	  	h = hh;
		l=(screen.width - w) / 2;
	    t=(screen.height - h) /2;
		pupup_icon = window.open(webpath+"popup_icon.php?id_user_login="+id_user_login+"&id_rist="+id_rist+"&center="+center+"&folder="+fold+"&id_promo="+id_promo+"&dim="+dim+"&width="+ww+"&height="+hh ,"popup_icon","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
		pupup_icon.focus() ; 
		if (!id_user_login) {
			w = 300;
		  	h = 250;
			l=(screen.width - w) / 2;
		    t=(screen.height - h) /2;
			reg = window.open(webpath+"popup_registrati.php" ,"reg","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
			reg.focus() ;
		}		
	}
}

function aprivois(webpath) {
		
	w = 280;
  	h = 530;
	l=(screen.width - w) / 2;
    t=(screen.height - h) /2;
		
	desktop=window.open(webpath+"php/vois.php","nuova","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+w+",height="+h+",top="+t+",left="+l);

}

function set_tipologia(campo) {
	eval ("document.form."+campo+".value=1;") ;
}	

function apri_area_attiva () {
	
	val=document.form_zone_attive.zone_attive.options[document.form_zone_attive.zone_attive.selectedIndex].value ;
	
	w = 770;
  	h = 550;
	l=(screen.width - w) / 2;
    t=(screen.height - h) /2;
	zona = window.open("http://www."+val ,"zona","fullscreen=0,channelmode=no,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes, width="+w+", height="+h+", left="+l+", top="+t);
	zona.focus() ;
}

function vis_figlio (campo,livello) {
	
	ide = eval ("document.form." + campo + ".options[document.form." + campo + ".selectedIndex].value ;") ;
	
	liv_succ = parseInt(livello) + 1 ;
	id = liv_succ + "_" + ide ;
	
	
	campo_hid = campo.split("_") ;
	eval ("document.form."+campo_hid[0]+".value=ide ;") ;
	
	if (ide == 1) {
		//spengo tutti i div che stanno sotto
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length;
		var num_div = 0 ;
		// scann su tutti e inticchio l'altro per spegnere o accendere
		var i=0 ;
		var altro_div = new Array();
		for(r=0;r<nu;r++){
			// qui ottengo id di altro div
			if(id != alldiv[r].getAttribute('id')){
				altro_div[i] = alldiv[r].getAttribute('id');
				num_div++ ;
				i++ ;
			}	
		}
		if (num_div==0) {
		}else {
			// spengo gli altri
			for (i=0 ; i < altro_div.length ; i++) {
				liv_div = altro_div[i].split("_") ;
				if (livello < liv_div[0]) {
					var el = document.getElementById(altro_div[i]).style;
					el.display = "none" ;
				}
			}
		}
	}else {
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length;
		var num_div = 0 ;
		var altro_stesso_liv = "" ;
		// scann su tutti e inticchio l'altro per spegnere o accendere
		var i=0 ;
		var x=0 ;
		var altro_div = new Array();
		var a = new Array();
		for(r=0;r<nu;r++){
			altro_stesso_liv = alldiv[r].getAttribute('id');
			liv_div_corr = altro_stesso_liv.split("_") ;
			if (liv_succ == liv_div_corr[0]) {
				num_div++ ;
				altro_div[i] = alldiv[r].getAttribute('id');
				i++ ;		
			}else {
				a[x] = alldiv[r].getAttribute('id');
				x++ ;
			}
		}
		if (num_div) {
			var altro_el = null ;
			var el = document.getElementById(id).style; 
			
			for (i=0; i<num_div; i++) {
				altro_el = document.getElementById(altro_div[i]).style; 
				if(altro_el.display == "") {
					altro_el.display = "none" ;
				}
			}	
			if(el.display == "none") {
				el.display = "";  
				for (i=0; i < x; i++) {
					zzz=a[i].split("_") ;
					if (zzz[0] > livello || zzz[0] > liv_succ) {
						altro_elem = document.getElementById(a[i]).style;
						if(altro_elem.display == "") {
							altro_elem.display = "none";
						}
					}
				}
			}		
		}else {
			return ;	
		}
	}
}

function tree(div_id) {
	var nomeDiv ;
	var padre_livello ;
	var padre ;
	var livello ;
	var z ;
	
	nomeDiv = div_id ;
	
	padre_livello_z = div_id.split("_") ;
	padre = padre_livello_z[0] ;
	livello = padre_livello_z[1] ;
	z = padre_livello_z[2] ;
	liv_succ = parseInt(livello) + 1 ;
	id = padre + "_" + liv_succ + "_" + z ;
	
	var el = document.getElementById(id).style; 
	if(el.display == "none") {
		el.display = "" ;
	}else if (el.display == "") {
		el.display = "none" ;
	}
}

function riporta_cod_cost (cod_cost) {
	
	var check ;
	var chkCodCost ;
	var codCost ;
	
	chkCodCost = cod_cost ;
	codCostArr = cod_cost.split("_") ; 
	codCost = codCostArr[1] ;
		
	check = eval("document.form."+chkCodCost+".checked;") ;

	if (check) {
		//alert ("sto chekkando") ;	
		eval ("document.form."+codCost+".value=1;") ;
	}else {
		//alert ("sto dechekkando") ;	
		eval ("document.form."+codCost+".value=0;") ;
	}
}

function popup_radio(url_pagina,sw_scroll) {
		
		w = 340 ;
		h = 347 ;
	  l = (screen.width - w) / 2;
	  t = (screen.height - h) / 2;
	
	  wnd = window.open(url_pagina,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+sw_scroll+", resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
	  wnd.focus();		

}

function mostraRadio (){
	
	var el = document.getElementById('divRadio').style; 
	el.display = "";  
}

function nascondiRadio (){
	
	var el = document.getElementById('divRadio').style; 
	el.display = "none";
}
