
var dom = (document.getElementById)? true : false
var op = (window.opera)?true : false
var op5 = (op && dom)?true : false
var ns = (window.outerWidth && !op)?true : false
var ns6 = (ns && dom)?true : false
var ns4 = (ns && !dom)?true : false
var ie = (document.all && !op)?true : false
var ie5 = (ie && dom)?true : false
var ie4 = (ie && !dom)?true : false

var agt = navigator.userAgent.toLowerCase();
var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var opera = (agt.indexOf("opera") != -1);
var mac = (agt.indexOf("mac") != -1);
var mac_ie = (ie && mac);
var win_ie = (ie && !mac);
var gecko  = (navigator.product == "Gecko");

var hq_img = new Image()
var zoom_win
var actprj_z, actimg_z, maxprj, cal_win, news_length
var sel1 = null, sel2 = null

function makeArray() {
  var args = makeArray.arguments;
  for (var i = 0; i < args.length; i++) {
    this[i] = args[i];
  }
  this.length = args.length;
}

function MY_getElementById (tag, id) {
	var el, i, objs = document.getElementsByTagName(tag);
	for (i = objs.length; --i >= 0 && (el = objs[i]);)
	{document.write (objs[i]+"<br>")
	if (el.id == id)
			return el;
}
	return null;
}

function attach(id)
{ var obj
  
//  if(ns4) obj = document.layers[id]
//   else if(ie4) obj = document.all[id]
//         else 
//          if(ie5 || ns6) obj = document.getElementById(id)
//           else obj = eval(id)
   //obj = document.getElementById(id)

   if (ie5)
    obj = document.all[id]
   else
    obj = document.getElementById(id)

//obj = MY_getElementById("",id)
return obj
}

 function set(id, val)
 { o = attach(id)
   o.value = val
   o.defaultValue = o.value
 }
  
 function set_to_default(id)
 { o = attach(id)
   o.value = o.defaultValue
 }
                 
 function flush(id)
 { o = attach(id)
   o.value = ""
 }

function hide_obj(id) { temp_Obj = attach(id)
                        if(ns4) temp_Obj.visibility = "hide"
                         else temp_Obj.style.visibility = "hidden"
                      }
function is_hidden(id) { temp_Obj = attach(id)
                         if(ns4) return (temp_Obj.visibility == "hide")
                          else return (temp_Obj.style.visibility == "hidden")
                      }
function show_obj(id) { temp_Obj = attach(id)
                        if(ns4) temp_Obj.visibility = "show"
                         else temp_Obj.style.visibility = "visible"
                      }

function put_on_top(id) { return
                          temp_Obj = attach(id)
                          if(ns4) temp_Obj.zIndex = "100"
                           else temp_Obj.style.zIndex = ""
                        }

function move_left(id) { step = 5
                         temp_Obj = attach(id)
                         if(ns4) temp_Obj.left = parseInt(temp_Obj.left) - step
                          else temp_Obj.style.left = parseInt(temp_Obj.style.left) - step
                       }
function move_top(id) { step = 5
                        temp_Obj = attach(id)
                        if(ns4) temp_Obj.top = parseInt(temp_Obj.top) - step
                         else temp_Obj.style.top = parseInt(temp_Obj.style.top) - step
                      }
 
function doMouseDown() { return true
                       }

function doMouseUp() { return true
                     }

//document.onmousedown = doMouseDown
//document.onmouseup = doMouseUp

function clockon() {
 var m = new makeArray("Gen","Feb","Mar","Apr","Mag","Giu","Lug","Aug","Set","Ott","Nov","Dic")
 var thistime= new Date()
 var hours=thistime.getHours()
 var minutes=thistime.getMinutes()
 var seconds=thistime.getSeconds()
 var day=thistime.getDate()
 var month=thistime.getMonth()
 var year=thistime.getFullYear()

 if (eval(hours) <10) {hours="0"+hours}
 if (eval(minutes) < 10) {minutes="0"+minutes}
 if (seconds < 10) {seconds="0"+seconds}
 thistime = day+"."+m[month]+"."+year+" "+hours+":"+minutes+":"+seconds 
 
// if(document.all) { o=attach("clock")
//                    o.value=thistime
//                  }
 o=attach('clock_span')
 o.innerHTML=thistime
	
 var timer=setTimeout("clockon()",1000)
}

function scroll_news() {
 step = 1
 o=attach('news_div')
 o.style.top = parseInt(o.style.top) - step
 if (parseInt(o.style.top) < parseInt(-news_length))
  o.style.top = 80
 var timer=setTimeout("scroll_news()",100)
}

 function set_day_href(d, m, y, s)
 { d = new Date(y,m,d)
//   o = attach(s)
   //o=document.getElementById(s)
   //o.value = d.toUTCString()
//   o = attach(s+"v")
   o=window.opener.document.getElementById(s+'v')
   o.value = d.toLocaleString()
   o=window.opener.document.getElementById(s)
//   alert ('|'+d.getTimezoneOffset()/60+'|')
//   d.setHours(d.getHours() + (d.getTimezoneOffset()/60))
//   o.value = d.toUTCString()
   o.value = d.getFullYear()+"/"+(d.getMonth()+1)+"/"+d.getDate()
//   hide_obj ('div_cal_'+s)
   close_calendar()
 }

 function set_event_date(d, m, y, s)
 { d = new Date(y,m,d)
   o = document.getElementById(s)
   o.value = d.toLocaleString()
   o.value = d.getFullYear()+"/"+(d.getMonth()+1)+"/"+d.getDate()
 }
 
 function open_calendar(s)
 { cal_win = window.open('calendar.php?cal='+s, 'Calendar', 'toolbar=no, location=no, directories=no, titlebar=no, menubar=no, scrollbars=yes, resizable=yes, status=no, width=208, height=240, top=128, left=128')
//   zoomhq()
//   alert (cal_win.name+" "+zoom_win.name)
 }
   
 function close_calendar()
 {//    alert (cal_win.name+" "+zoom_win.name)
if (cal_win)
    cal_win.close()
   cal_win=null
window.close()
//adjust_zoom_hq()
//alert (zoom_win.name)
 }

 function set_calendar(m, y, day, s, func)
 { var ld = new makeArray(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
   var hdate = new makeArray()
   var t, o, k, d, x, act_date

   if ((y%4) == 0) ld[1]++
    
   //if (m == "") m = 1;
   //if (y == "") y = 2005;
   //if (day != "")
   // document.getElementById('get_day_'+s).value=day
   
   //if (act_date = document.getElementById(s).value)
   // hdate = act_date.split("/")
   //else
   // hdate = 
   
   //t = new Date(y, m-1, 1);
   t = new Date()
   if (m)
    t.setMonth(m-1)
   else
    m=parseInt(t.getMonth()+1)
   if (y)
    t.setFullYear(y)
   else
    y=t.getFullYear()
   if (day)
   { document.getElementById('get_day_'+s).value=day
     t.setDate(day)
   }
   else
    day=t.getDate()
   //alert (t.getMonth()+' '+t.getFullYear()+' '+day)
   
   if (act_date = document.getElementById(s).value)
    hdate = act_date.split("/")
   else
   { hdate[0] = y
     hdate[1] = m
     hdate[2] = day
   }
   hdate[0] = parseInt(hdate[0],10)
   hdate[1] = parseInt(hdate[1],10)
   hdate[2] = parseInt(hdate[2],10)
   
   o = attach('get_month_'+s)
   o.selectedIndex=m-1
   o = attach('get_year_'+s)
   o.value=y

   for (k = 0; k <= 13; k++)
   { o = attach(s+'_d'+eval(k+29))
     o.innerHTML=''
     o = attach(s+'_a'+eval(k+29))
     o.href='javascript:void(0)'
   }
   d = 1
   for (k = 0, t.setDate(d); k < t.getDay(); k++)
   { o=attach(s+'_d'+eval(d+k))
     o.innerHTML=''
     o=attach(s+'_a'+eval(d+k))
     o.href='javascript:void(0)'
     o=attach(s+'_td'+eval(d+k))
     o.className='cal_td'
     o.onmouseover=''
     o.onmouseout=''
   }
   for (;d <= ld[m-1]; d++)
   { t.setDate(d)
     o=attach(s+'_d'+eval(d+k))
     o.innerHTML=d
     o=attach(s+'_td'+eval(d+k))
     if ((d==hdate[2]) && (m==hdate[1]) && (y==hdate[0]))
      o.className='cal_tdH'
     else
      o.className='cal_td'
     //<a class='cal_link' name='{$s}_a{$d}' id='{$s}_a{$d}' href=''><span class='cal_lab' name='{$s}_d{$d}' id='{$s}_d{$d}'>31</span></a></td>";
     o=attach(s+'_a'+eval(d+k))
     o.href="javascript:"+func+"("+d+","+parseInt(m-1)+","+y+", '"+s+"');set_calendar("+m+","+y+","+d+",'"+s+"','"+func+"')"
   }
   for (t.setDate(d), x = 6-t.getDay(); x >=0 ; x--)
   { o=attach(s+'_d'+eval(d+k+x))
     o.innerHTML=''
     o=attach(s+'_a'+eval(d+k+x))
     o.href='javascript:void(0)'
     o=attach(s+'_td'+eval(d+k))
     o.className='cal_td'
     o.onmouseover=''
     o.onmouseout=''
   }
   //document.getElementById('get_day_'+s).value=day
 }

 function set_cal(m, y, s)
 { var ld = new makeArray(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
   var t, o, k, d, x

   if ((y%4) == 0) ld[1]++
    
   if (m == "") m = 1;
   if (y == "") y = 2000;

   t = new Date(y, m-1, 1);
   o = attach('get_month_'+s)
   o.value = m
   o = attach('get_year_'+s)
   o.value=y

   for (k = 0; k <= 13; k++)
   { o = attach(s+'_d'+eval(k+29))
     o.innerHTML=''
     o = attach(s+'_a'+eval(k+29))
     o.href='javascript:void(0)'
   }
   d = 1
   for (k = 0, t.setDate(d); k < t.getDay(); k++)
   { o=attach(s+'_d'+eval(d+k))
     o.innerHTML='-'
     o=attach(s+'_a'+eval(d+k))
     o.href='javascript:void(0)'
   }
   for (;d <= ld[m-1]; d++)
   { t.setDate(d)
     o=attach(s+'_d'+eval(d+k))
     o.innerHTML=d
     o=attach(s+'_a'+eval(d+k))
     o.href="javascript:set_day_href("+d+","+parseInt(m-1)+","+y+", '"+s+"')"
   }
   for (t.setDate(d), x = 6-t.getDay(); x >=0 ; x--)
   { o=attach(s+'_d'+eval(d+k+x))
     o.innerHTML='-'
     o=attach(s+'_a'+eval(d+k+x))
     o.href='javascript:void(0)'
   }
 }

 function cal_pos (c)
 { o=attach(c)
   o.style.left = event.x + document.body.scrollLeft
   o.style.top = event.y + document.body.scrollTop
   if (is_hidden(c))
    show_obj(c)
   else
    hide_obj(c)
   return true
 }

 function stripSlashes(str)
 { return str.replace(/\\/g, '');
 }

 function prep_gallery_obj(o)
 { // a[0] = id
   // a[1] = file name
   // a[2] = file size
   // a[3] = dimensions
   // a[4] = icon file name
   // a[5] = desc
   // a[6] = ord
   // a[7] = copyright
   a = new Array()
   if (o.options.length != 0)
   { if (o.selectedIndex == -1)
     { o.options[0].selected=true
       a=o.options[0].value.split("|")
     }
     else
      a=o.value.split("|")
//alert(attach('gallery_pos').value)
     set('gallery_pos', a[0]+"|"+o.id+"|"+a[6])
//alert(attach('gallery_pos').value)
     o1 = attach(o.id+'_img')
     //o1.src = user_img_dir+a[1]
     o1.src = a[4]
     //alert(o1.src) 
     //alert(a.toString())
     //o1.src = a[4]
     //o1.src = a[1]
     //o1 = attach(o.id+'_fn')
     //o1.innerHTML = a[1]
     o1 = attach(o.id+'_fs')
     o1.innerHTML = a[2]
     o1 = attach(o.id+'_fd')
     o1.innerHTML = a[3]
     o1 = attach(o.id+'_desc')
     o1.value = unescape(a[5])
     o1 = attach(o.id+'_copyright')
     o1.value = unescape(a[7])
   }
 }
 
 function prep_resources_obj(o)
 { // a[0] = id
   // a[1] = file name
   // a[2] = file size
   // a[3] = dimensions
   // a[4] = icon file name
   // a[5] = desc
   // a[6] = ord
   // a[7] = copyright
   a = new Array()
   
   if (o.options.length != 0)
   { if (o.selectedIndex == -1)
     { o.options[0].selected=true
       a=o.options[0].value.split("|")
     }
     else
      a=o.value.split("|")
     set('gallery_pos', a[0]+"|"+o.id+"|"+a[6])
     o1 = attach(o.id+'_img')
     //o1.src = user_img_dir+a[1]
     o1.src = a[4]
     //alert(o1.src) 
     //alert(a.toString())
     //o1.src = a[4]
     //o1.src = a[1]
     //o1 = attach(o.id+'_fn')
     //o1.innerHTML = a[1]
     o1 = attach(o.id+'_fs')
     o1.innerHTML = a[2]
     o1 = attach(o.id+'_fd')
     o1.innerHTML = a[3]
     o1 = attach(o.id+'_desc')
     o1.value = a[5]
     o1 = attach(o.id+'_copyright')
     o1.value = a[7]
   }
 }

 function download(id)
 { // a[0] = id
   // a[1] = file name
   // a[2] = file size
   // a[3] = dimensions
   // a[4] = icon file name
   // a[5] = desc
   // a[6] = ord
   // a[7] = copyright
   a = new Array()
   
   o=attach(id)
   if (o.options.length != 0)
   { if (o.selectedIndex != -1)
     { a=o.value.split("|")
	   top.location.href='index.php?section=download&file='+a[1]
	 }
   }
 }

 function get_sel_date(s)
 { o=document.getElementById(s)
   return o.value
 }
 
 function get_sel_event_date(s)
 { o=document.getElementById(s)
   if (o.options.length != 0)
   { if (o.selectedIndex != -1)
     { return o.options[o.selectedIndex].value
     }
   }
   return false
 }

 function get_sel_event_progr(s)
 { o=parent.document.getElementById(s)
   if (o.options.length != 0)
   { if (o.selectedIndex != -1)
     { return o.options[o.selectedIndex].value
     }
   }
   return false
 }
 
 function prep_events_obj(o, fc, lc)
 { //events_dates_id|events_dates_event_id|first_date|last_date|lang_id
   ename = o.id.split("|")
   a = new Array()
   if (o.options.length != 0)
   { if (o.selectedIndex == -1)
     { o.options[0].selected=true
       a=o.options[0].value.split("|")
     }
     else
      a=o.value.split("|")
	 document.getElementById(fc).value=a[2]
     document.getElementById(lc).value=a[3]
     d1=a[2].split("/")
     set_calendar(d1[1],d1[0],d1[2],fc,'set_event_date')
     d2=a[3].split("/")
     set_calendar(d2[1],d2[0],d2[2],lc,'set_event_date')
	 document.getElementById('event_progr|'+ename[1]).src='index.php?section=put_progr&edid='+a[0]+'&progr_id='+ename[1]+'&lang_id='+a[4]
     //document.getElementById('event_progr_zoom').src='?section=put_progr&edid='+a[0]
     
     //o=document.getElementById('event_progr_zoom')
     //prep_events_zoom_obj(o)
   }
 }
 
 function prep_events_zoom_obj(o)
 { //events_dates_id|events_dates_event_id|first_date|last_date|lang_id
   a = new Array()
   var extra_link
   
   extra_link = ""
   if (o.options.length != 0)
   { if (o.selectedIndex == -1)
     { o.options[0].selected=true
       a=o.options[0].value.split("|")
     }
     else
      a=o.value.split("|")
     //document.getElementById(fc).value=a[2]
     //document.getElementById(lc).value=a[3]
     //d1=a[2].split("/")
     //set_calendar(d1[1],d1[0],d1[2],fc,'set_event_date')
     //d2=a[3].split("/")
     //set_calendar(d2[1],d2[0],d2[2],lc,'set_event_date')
     //document.getElementById('event_progr_zoom').src='?section=put_progr&edid='+a[0]//+'&epid'+a[1]
     extra_link = '&edid='+a[0]+'&lang_id='+a[4]
     //document.getElementById('event_progr_zoom').src='?section=put_progr&edid='+a[0]
   }
   document.getElementById('event_progr_zoom').src='?section=put_progr'+extra_link
 }
 
 function prep_progr_obj(o)
 { //events_progr_id|events_dates_id|first_time|last_time|lang_id
   a = new Array()
   
   ename = o.id.split("|")
   if (o.options.length != 0)
   { if (o.selectedIndex == -1)
     { o.options[0].selected=true
       a=o.options[0].value.split("|")
     }
     else
      a=o.value.split("|")
     // alert(a[0]+' '+a[1])
     //document.getElementById(fc).value=a[2]
     //document.getElementById(lc).value=a[3]
     //d1=a[2].split("/")
     //set_calendar(d1[1],d1[0],d1[2],fc,'set_event_date')
     //d2=a[3].split("/")
     //set_calendar(d2[1],d2[0],d2[2],lc,'set_event_date')
	 document.getElementById('event_progr_zoom|'+ename[1]).src='index.php?section=put_progr&act=event_progr_zoom&edid='+a[1]+'&epid='+a[0]+'&progr_id='+ename[1]+'&lang_id='+a[4]
   }
   else
   { o=attach('edid')
     document.getElementById('event_progr_zoom|'+ename[1]).src='index.php?section=put_progr&act=event_progr_zoom&edid='+o.value+'&epid=&progr_id='+ename[1]+'&lang_id='
   }
 }

 function prep_event_date_obj(o)
 { // a[0] = position
   // a[1] = file name
   // a[2] = file size
   // a[3] = dimensions
   a = new Array()
   
   if (o.options.length != 0)
   { if (o.selectedIndex == -1)
     { o.options[0].selected=true
       a=o.options[0].value.split("|")
     }
     else
      a=o.value.split("|")
     //set('gallery_pos', a[0]+"|"+o.id)
     o1 = attach(o.id+'_img')
     //o1.src = user_img_dir+a[1]
     o1.src = a[1]
     o1 = attach(o.id+'_fs')
     o1.innerHTML = a[2]
     o1 = attach(o.id+'_fd')
     o1.innerHTML = a[3]
   }
 }
 
 function prep_chars_obj(o, qs)
 { // a[0] = this_name
   // a[1] = obj_id
   // a[2] = char_elem_id
   // a[3] = lang
   // a[4] = return address
   a = new Array()
   
   if (o.options.length != 0)
   { if (o.selectedIndex == -1)
     { o.options[0].selected=true
       a=o.options[0].value.split("|")
     }
     else
      a=o.value.split("|")
      o1=attach('if|'+a[1]+'|'+a[3])
//      o2=attach('main_qs')
//      o1.src="index.php?section=put_chars&char="+a[2]+"&tab=char&lang="+a[3]+"&ra="+a[4]+"&main_qs="+o2.value
      //o1.src="index.php?section=put_chars&char="+a[2]+"&t=char&l="+a[3]+"&main_qs="+o2.value
      o1.src="index.php?section=put_chars&char="+a[2]+"&t=char&l="+a[3]
//      o1.innerHTML="index.php?section=put_chars&char="+a[2]+"&tab=char&lang="+a[3]+""
//     set('char_sel|'+a[1]+'|'+a[3], a[0]+"|"+o.id)
//     o1 = attach(o.id+'_img')
//     o1.src = user_img_dir+a[1]
//     o1 = attach(o.id+'_fs')
//     o1.innerHTML = a[2]
//     o1 = attach(o.id+'_fd')
//     o1.innerHTML = a[3]
   }
 }

 function zoomhq(img)
 { var aw = screen.availWidth
   var ah = screen.availHeight
   var sx = 256
   var sy = 64
   var x = (aw < sx)?0:(aw-sx)/2
   var y = (ah < sy)?0:(ah-sy)/2
   var dx = (aw < sx)?aw:sx
   var dy = (ah < sy)?ah:sy
   if (zoom_win)
   { zoom_win.close()
     zoom_win = null
   }
   zoom_win = window.open("", "zoom", 'toolbar=no, location=no, directories=no, menubar=no, scrollbars=no, resizable=yes, status=no, width='+dx+', height='+dy+', top='+y+', left='+x)
   hq_img.src = img
   //hq_img.width=100
   //hq_img.height=100
   zoom_win.document.write("<DIV ID='D_loading' STYLE='position: absolute; top: 28; left: 48; visibility: visible; z-index: -1000'>loading...</DIV>")
   hq_img.onload = adjust_zoom_hq
}

 function adjust_zoom_hq()
 {  if ((window.screen) && (zoom_win) && !zoom_win.closed)
   { var aw = screen.availWidth
     var ah = screen.availHeight
     var sx = parseInt(hq_img.width) + 12
     var sy = parseInt(hq_img.height) + 38
     var x = (aw < sx)?0:(aw-sx)/2
     var y = (ah < sy)?0:(ah-sy)/2
     var dx = (aw < sx)?aw:sx
     var dy = (ah < sy)?ah:sy
//alert (hq_img.availWidth)
     zoom_win.moveTo(x, y)
     zoom_win.resizeTo(dx, dy)
     zoom_win.document.write("<DIV ID='D_i' STYLE='position: absolute; top: 0; left: 0; z-index: 1000'><img id='zoom_img' name='zoom_img' src='"+hq_img.src+"' width='"+hq_img.width+"' height='"+hq_img.height+"'></div>")
   }
   return true
 }
 //hq_img.onload = adjust_zoom_hq

 function is_selected(o)
 { var t, d
   t = ((o.className == 'tableline_sel') || (o.className == 'tableline_selover') || (o.className == 'tableline_lastsel') || (o.className == 'tableline_lastselover'))
   d = ((o.className == 'diapo_sel') || (o.className == 'diapo_selHover') || (o.className == 'diapo_lastsel') || (o.className == 'diapo_lastselHover'))
   return (t || d)
 }

 function select_it(o)
 { switch(o.className)
   { case 'tableline':
     case 'tablelineover':
      if ((o == sel1) || (o == sel2))
       o.className = 'tableline_lastsel'
      else
       o.className = 'tableline_sel'
     break;
     
     case 'tableline_sel':
     case 'tableline_selover':
     case 'tableline_lastsel':
     case 'tableline_lastselover':
     o.className = 'tableline'
     break;
     
     case 'diapo':
     case 'diapoHover':
      if ((o == sel1) || (o == sel2))
       o.className = 'diapo_lastsel'
      else
       o.className = 'diapo_sel'
     break;
     
     case 'diapo_sel':
     case 'diapo_selover':
     case 'diapo_lastsel':
     case 'diapo_lastselHover':
     o.className = 'diapo'
     break;
   }
   return true
 }
 
 function force_select_it(o,f)
 { if (f)
   { switch(o.className)
     { case 'tableline':
       case 'tablelineover':
        if ((o == sel1) || (o == sel2))
         o.className = 'tableline_lastsel'
        else
         o.className = 'tableline_sel'
        break;
        
       case 'tableline_sel':
       case 'tableline_selover':
       case 'tableline_lastsel':
       case 'tableline_lastselover':
        //o.className = 'tableline'
        break;
        
       case 'diapo':
       case 'diapoHover':
        if ((o == sel1) || (o == sel2))
         o.className = 'diapo_lastsel'
        else
         o.className = 'diapo_sel'
        break;
        
       case 'diapo_sel':
       case 'diapo_selover':
       case 'diapo_lastsel':
       case 'diapo_lastselHover':
        //o.className = 'diapo'
       break;
     }
   }
   else
   { switch(o.className)
     { case 'tableline':
       case 'tablelineover':
        //if ((o == sel1) || (o == sel2))
        // o.className = 'tableline_lastsel'
        //else
        // o.className = 'tableline_sel'
        break;
        
       case 'tableline_sel':
       case 'tableline_selover':
       case 'tableline_lastsel':
       case 'tableline_lastselover':
        o.className = 'tableline'
        break;
        
       case 'diapo':
       case 'diapoHover':
        //if ((o == sel1) || (o == sel2))
        // o.className = 'diapo_lastsel'
        //else
        // o.className = 'diapo_sel'
        break;
        
       case 'diapo_sel':
       case 'diapo_selover':
       case 'diapo_lastsel':
       case 'diapo_lastselHover':
        o.className = 'diapo'
       break;
     }
   }
   return true
 }

 function last_two_selection(o)
 { if ((o != sel1) && (o != sel2) && ((is_selected(o))))
   { if (sel2)
      if (is_selected(sel2))
      { if (sel2.className.search('tableline') != -1)
         sel2.className='tableline_sel'
        else
         if (sel2.className.search('diapo') != -1)
          sel2.className='diapo_sel'
      }
     if (o.className.search('tableline') != -1)
      o.className='tableline_lastsel'
     else
      if (o.className.search('diapo') != -1)
       o.className='diapo_lastsel'
     sel2 = sel1
     sel1 = o
   }
 }

 function hilite_it(o)
 { switch(o.className)
   { case 'tableline':
     o.className = 'tablelineover'
     break;
     
     case 'tableline_sel':
     o.className = 'tableline_selover'
     break;
     
     case 'tableline_lastsel':
     o.className = 'tableline_lastselover'
     break;
     
     case 'diapo':
     o.className = 'diapoHover'
     break;
     
     case 'diapo_sel':
     o.className = 'diapo_selHover'
     break;
     
     case 'diapo_lastsel':
     o.className = 'diapo_lastselHover'
     break;
   }
   return true
 }

 function dehilite_it(o)
 { switch(o.className)
   { case 'tableline':
     case 'tablelineover':
     o.className = 'tableline'
     break;
     
     case 'tableline_sel':
     case 'tableline_selover':
     o.className = 'tableline_sel'
     break;
     
     case 'tableline_lastsel':
     case 'tableline_lastselover':
     o.className = 'tableline_lastsel'
     break;
     
     case 'diapo':
     case 'diapoHover':
     o.className = 'diapo'
     break;
     
     case 'diapo_sel':
     case 'diapo_selHover':
     o.className = 'diapo_sel'
     break;
     
     case 'diapo_lastsel':
     case 'diapo_lastselHover':
     o.className = 'diapo_lastsel'
     break;
   }
   return true
 }
 
 function select_all(f)
 { all_files=document.getElementsByTagName("tr")
   for (t = 0; t < all_files.length; t++)
   { n = all_files[t].id
	 a = n.split("|")
     if ((a[0] == "tr") || (a[0] == "file"))
	 { //if (f)
	   { /*
	     if ((all_files[t] == sel1) || (all_files[t] == sel2))
         { all_files[t].className = 'tableline_lastsel'
		 }
		 else
          all_files[t].className = 'tableline_sel'
         //select_it(all_files[t])
	     last_two_selection(all_files[t])*/
		 //select_it(all_files[t]);
	   }
	   //else
	   { /*
	     all_files[t].className = 'tableline'
         //select_it(all_files[t])
	     last_two_selection(all_files[t])
		 */
		 //select_it(all_files[t]);
	   }
       force_select_it(all_files[t],f)
	   last_two_selection(all_files[t])
	 }
   }
 }
 
 function get_all_selected()
 { var s="", f = false
   
   all_files=document.getElementsByTagName("tr")
   for (t = 0; t < all_files.length; t++)
   { n = all_files[t].id
	 a = n.split("|")
     if ((a[0] == "tr") && (is_selected(all_files[t])))
     { if (f)
        s = s + "|"
       f = true
       s = s + a[1]
     }
   }
   //alert (s)
   return s
 }
 
 function selected_files(tag)
 { var s="", f = false

   all_files=document.getElementsByTagName(tag)
   for (t = 0; t < all_files.length; t++)
   { n = all_files[t].id
	 a = n.split("|")
     if ((a[0] == "file") && (is_selected(all_files[t])))
     { if (f)
        s = s + "|"
       f = true
       s = s + a[1]
     }
   }
   //alert (s)
   return s
}
 function prep_to_delete(form_name)
 { id=get_all_selected()
   if(id)
   { ids=id.split('|')
     if (confirm('Sicuro di voler eliminare '+ids.length+' elementi?'))
	 { set('act','del')
	   set('id',id)
	   o=attach(form_name)
	   o.onSubmit=''
	   o.submit()
     }
   }
 }
 
 function prep_to_delete_cat(form_name)
 { id=get_all_selected()
   if(id)
   { ids=id.split('|')
     if (confirm('Sicuro di voler eliminare '+ids.length+' elementi?'))
	 { set('act','del')
	   set('key',id)
	   o=attach(form_name)
	   o.onSubmit=''
	   o.submit()
     }
   }
 }
 
 function extract_file_name(o)
 { if (o)
   { a = o.id.split("|")
     if (a[0] == 'file')
      return a[1]
   }  
   return false
 }

 function get_new_name(o)
 { var nn
   
   if (o)
   { if (nn = extract_file_name(o))
      return prompt('Rinomina',nn)
   }  
   return false
 }

 function select_option(sel_obj, sel_opt_value)
 { for (t = 0; t < sel_obj.options.length; t++)
   { if (sel_obj.options[t].value == sel_opt_value)
      return t
   }
   return false
 }
 
 function go_to(form_name, url)
 { o = document.getElementById(form_name)
   o.action = url
   o.submit()
 }

 function pack_perms_bits(fn)
 { var s
 
   s = (document.getElementById('px_'+fn).checked?'1':'0')
   s = s + (document.getElementById('pw_'+fn).checked?'1':'0')
   s = s + (document.getElementById('pr_'+fn).checked?'1':'0')
   s = s + (document.getElementById('gx_'+fn).checked?'1':'0')
   s = s + (document.getElementById('gw_'+fn).checked?'1':'0')
   s = s + (document.getElementById('gr_'+fn).checked?'1':'0')
   s = s + (document.getElementById('ox_'+fn).checked?'1':'0')
   s = s + (document.getElementById('ow_'+fn).checked?'1':'0')
   s = s + (document.getElementById('or_'+fn).checked?'1':'0')
   return s
 }
 
 function prep_keywords_sel(o)
 { var s, f
   
   s = ""
   f = false
   for (t = 0; t < o.options.length; t++)
   { if (o.options[t].selected)
     { if (f)
        s = s + "|"
       else
        f = true
       s = s + o.options[t].value
     }
   }
   return s
 }

function fix_pagesize()
{ o1 = attach('ps')
  o2 = attach('get_pagesize')
  o1.value = o2.value
  return true
}
 