/* vim: set expandtab tabstop=2 shiftwidth=2 foldmethod=marker: */

// {{{ function NB_browser_sniff()

function NB_browser_sniff()
{
  // From http://www.dhtmlnirvana.com by Eddie Traversa
  agent = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);

  // WINDOWS CHECK
  this.win = ((agent.indexOf('win') != -1) || (agent.indexOf('16bit') != -1));
  this.win95 = ((agent.indexOf('win95') != -1) || (agent.indexOf('windows 95') != -1));
  this.win16 = ((agent.indexOf('win16') != -1) || (agent.indexOf('16bit') != -1) || (agent.indexOf('windows 3.1') != -1) || (agent.indexOf('windows 16-bit') != -1));
  this.win31 = ((agent.indexOf('windows 3.1') != -1) || (agent.indexOf('win16') != -1) || (agent.indexOf('windows 16-bit') != -1));
  this.win98 = ((agent.indexOf('win98') != -1) || (agent.indexOf('windows 98') != -1)); 
  this.winnt = ((agent.indexOf('winnt') != -1) || (agent.indexOf('windows nt') != -1));
  this.winnt4 = (agent.indexOf('windows nt 4.0') != -1);
  this.winnt5 = (agent.indexOf('windows nt 5.0') != -1); 
  this.winnt6 = (agent.indexOf('windows nt 6.0') != -1);
  this.win2pro = (agent.indexOf('win2000pro') != -1);
  this.win21 = (agent.indexOf('windows 2001') != -1);
  this.wince = (agent.indexOf('windows ce') != -1); 
  this.winxp = (agent.indexOf('windows xp') != -1);

  // MAC CHECK
  this.mac = (agent.indexOf('mac') != -1); 
  this.mac68k = (this.mac && ((agent.indexOf('68k') != -1) || (agent.indexOf('68000') != -1)));
  this.macppc = (this.mac && ((agent.indexOf('ppc') != -1) || (agent.indexOf('powerpc') != -1)));

  // MAC SAFARI
  this.safari = (this.mac && (agent.indexOf('safari') != -1));

  // MAC CAMINO
  this.camino = (this.mac && (agent.indexOf('camino') != -1));

  // FIREFOX
  this.firefox = (agent.indexOf('firefox') != -1);
  
  // NETSCAPE SNIFFS
  this.ns = ((agent.indexOf('mozilla') != -1) && (agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1) && (agent.indexOf('opera') == -1) && (agent.indexOf('webtv') == -1) && !this.safari && !this.camino && !this.firefox);
  this.ns2 = (this.ns && (this._major == 2));
  this.ns3 = (this.ns && (this.major == 3));
  this.ns4 = (this.ns && (this.major == 4));
  this.ns40 = (this.ns && (this.major == 4) && (agent.indexOf('4.0 ') != -1));
  this.ns401 = (this.ns && (this.major == 4) && (agent.indexOf('4.01') != -1));
  this.ns02 = (this.ns && (this.major == 4) && (agent.indexOf('4.02') != -1));
  this.ns03 = (this.ns && (this.major == 4) && (agent.indexOf('4.03') != -1));
  this.ns04 = (this.ns && (this.major == 4) && (agent.indexOf('4.04') != -1));
  this.ns05 = (this.ns && (this.major == 4) && (agent.indexOf('4.05') != -1));
  this.ns06 = (this.ns && (this.major == 4) && (agent.indexOf('4.06') != -1));
  this.ns07 = (this.ns && (this.major == 4) && (agent.indexOf('4.07') != -1));
  this.ns08 = (this.ns && (this.major == 4) && (agent.indexOf('4.08') != -1));
  this.ns450 = (this.ns && (this.major == 4) && (agent.indexOf('4.50') != -1));
  this.ns451 = (this.ns && (this.major == 4) && (agent.indexOf('4.51') != -1));
  this.ns46 = (this.ns && (this.major == 4) && (agent.indexOf('4.6') != -1));
  this.ns461 = (this.ns && (this.major == 4) && (agent.indexOf('4.61') != -1));
  this.ns47 = (this.ns && (this.major == 4) && (agent.indexOf('4.7') != -1));
  this.ns472 = (this.ns && (this.major == 4) && (agent.indexOf('4.72') != -1));
  this.ns473 = (this.ns && (this.major == 4) && (agent.indexOf('4.73') != -1));
  this.ns474 = (this.ns && (this.major == 4) && (agent.indexOf('4.74') != -1));
  this.ns475 = (this.ns && (this.major == 4) && (agent.indexOf('4.75') != -1));
  this.ns476 = (this.ns && (this.major == 4) && (agent.indexOf('4.76') != -1));
  this.ns48 = (this.ns && (this.major == 4) && (agent.indexOf('4.8') != -1));
  this.ns6 = (this.ns && (this.major == 6));
  this.ns7 = (this.ns && (this.major == 7));
  this.ns7up = (this.ns && (this.major >= 6));
  this.ns71 = (this.ns && (agent.indexOf('netscape/7.1') != -1));
  this.ns72 = (this.ns && (agent.indexOf('netscape/7.2') != -1));
  
  // MOZILLA-SPECIFIC CHECK
  this.ns6pr1 = (this.ns && (this.major == 5) && (agent.indexOf('6.0b1') != -1)); 
  this.ns6pr2 = (this.ns && (this.major == 5) && (agent.indexOf('6.0b2') != -1)); 
  this.ns6pr3 = (this.ns && (this.major == 5) && (agent.indexOf('6.0b3') != -1)); 
  this.ns6gold = (this.ns && (this.major == 5) && (agent.indexOf('netscape') != -1) && !this.ns6pr1 && !this.ns6pr2 && !this.ns6pr3);
  this.moz = (this.ns && (this.major >= 5) && (agent.indexOf('netscape') == -1) && !this.safari && !this.camino && !this.firefox);
  if (this.ns6) {
    if (agent.indexOf('; m') != -1) {
      MSnumStart = agent.indexOf('; m') + 3;
      MSnumEnd = MSnumStart + 2;
      MSnum = agent.substring(MSnumStart, MSnumEnd);
      mozmile = Number(MSnum);
    } else {
      mozmile = 'cannot obtain milestone number';
    }
  } else {
    mozmile = 'not a mozilla or netscape user agent';
  }
  this.mozBased = (agent.indexOf('gecko') != -1); 
  if (this.mozBased) {
    GeckoBuildIDStart = agent.indexOf('gecko') + 6;
    GeckoBuildIDEnd = GeckoBuildIDStart + 8;
    GeckoBuildIDnum = agent.substring(GeckoBuildIDStart, GeckoBuildIDEnd);
    GeckoBuildID = Number(GeckoBuildIDnum);
  } else {
    GeckoBuildID = 'cannot obtain gecko build #';
  }
  
  // MSIE CHECK
  this.ie = ((agent.indexOf('msie') != -1) && (agent.indexOf('opera') == -1));
  this.winie = (this.win && this.ie);
  this.ie6 = (this.ie && (agent.indexOf('msie 6.0') != -1));
  this.ie7 = (this.ie && (agent.indexOf('msie 7.0') != -1));
  this.ie3 = (this.ie && (this.major < 4) && !this.ie6);
  this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf('msie 4') != -1));
  this.ie401 = (this.ie && (this.major == 4) && (agent.indexOf('msie 4.01') != -1));
  this.ie4up = (this.ie && (this.major >= 4));
  this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf('msie 5') != -1));
  this.ie51 = (this.ie && (this.major == 4) && (agent.indexOf('msie 5.01') != -1));
  this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf('msie 5.5') != -1));
  this.ie5up = (this.ie && !this.ie3 && !this.ie4);

  // AOL CHECKS
  this.aol = (agent.indexOf('aol') != -1);
  this.aolandie3 = (this.aol && this.ie3);
  this.aolandie4 = (this.aol && this.ie4);
  this.aolandie5 = (this.aol && this.ie5);
  this.aol3 = (agent.indexOf('aol 3') != -1);
  this.aol4 = (agent.indexOf('aol 4') != -1);
  this.aol5 = (agent.indexOf('aol 5') != -1);
  this.aol6 = (agent.indexOf('aol 6') != -1);
  this.aol7 = (agent.indexOf('aol 7') != -1);
  this.aol8 = (agent.indexOf('aol 8') != -1);
  
  // MAC MSIE CHECK
  this.macie = (this.mac && this.ie); 
  this.macie4 = (this.mac && (agent.indexOf('msie 4') != -1));
  this.macie401 = (this.mac && (agent.indexOf('msie 4.01') != -1));
  this.macie45 = (this.mac && (agent.indexOf('msie 4.5') != -1));
  this.macie5 = (this.mac && (agent.indexOf('msie 5.0') != -1));
  this.macie6 = (this.mac && (agent.indexOf('msie 6.0') != -1));
  
  // OPERA CHECK
  this.opera = (agent.indexOf('opera') != -1);
  this.opera3 = (this.opera && (agent.indexOf(') 3.0') != -1));
  this.opera321 = (this.opera && (agent.indexOf(') 3.21') != -1));
  this.opera351 = (this.opera && (agent.indexOf(') 3.51') != -1));
  this.opera360 = (agent.indexOf('opera 3.60') != -1);
  this.opera361 = (agent.indexOf('opera 3.61') != -1);
  this.opera362 = (agent.indexOf('opera 3.62') != -1);
  this.opera4 = (agent.indexOf('opera 4') != -1);
  this.opera5 = (agent.indexOf('opera 5') != -1);
  this.opera51 = (agent.indexOf('opera 5.1') != -1);
  this.opera52 = (agent.indexOf('opera 5.2') != -1);
  this.opera6 = (agent.indexOf('opera 6') != -1);
  this.opera7 = (agent.indexOf('opera 7') != -1);
  
  // WEB TV CHECK
  this.webtv = (agent.indexOf('webtv') != -1);
  this.webtv12 = this.webtv && (agent.indexOf('1.2') != -1);
  this.webtv22 = this.webtv && (agent.indexOf('2.2') != -1);
  
}

// }}}
// {{{ http user agent detection

var is = new NB_browser_sniff();

// }}}
// {{{ function NB_popup(url, title, width, height)

function NB_popup(url, title, width, height)
{
	x = parseInt(Math.round((screen.availWidth - width) / 2.0));
	y = parseInt(Math.round((screen.availHeight - height) / 2.0));
  if (is.winie) {
    x -= 6;
    y -= 20;
  }
	x = parseInt(Math.max(x, 0));
	y = parseInt(Math.max(y, 0));
  props = 'width='+width+',height='+height+',resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no';
  if (is.safari == 1) {
    props = props + ',screenX='+x+',screenY='+y;
  } else {
    props = props + ',left='+x+',top='+y;
  }
  w = window.open(url, title, props);
  w.focus();
}

// }}}
// {{{ function NB_popup_s(url, title, width, height)

function NB_popup_s(url, title, width, height)
{
	x = parseInt(Math.round((screen.availWidth - width) / 2.0));
	y = parseInt(Math.round((screen.availHeight - height) / 2.0));
  if (is.winie) {
    x -= 6;
    y -= 20;
  }
	x = parseInt(Math.max(x, 0));
	y = parseInt(Math.max(y, 0));
  props = 'width='+width+',height='+height+',resizable=no,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=no';
  if (is.safari == 1) {
    props = props + ',screenX='+x+',screenY='+y;
  } else {
    props = props + ',left='+x+',top='+y;
  }
  w = window.open(url, title, props);
  w.focus();
}

// }}}
// {{{ function NB_popup_sr(url, title, width, height)

function NB_popup_sr(url, title, width, height)
{
	x = parseInt(Math.round((screen.availWidth - width) / 2.0));
	y = parseInt(Math.round((screen.availHeight - height) / 2.0));
  if (is.winie) {
    x -= 6;
    y -= 20;
  }
	x = parseInt(Math.max(x, 0));
	y = parseInt(Math.max(y, 0));
  props = 'width='+width+',height='+height+',resizable=yes,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=no';
	if (is.safari == 1) {
		props = props + ',screenX='+x+',screenY='+y;
	} else {
		props = props + ',left='+x+',top='+y;
	}
	w = window.open(url, title, props);
  w.focus();
}

// }}}
// {{{ function NB_popup_r(url, title, width, height)

function NB_popup_r(url, title, width, height)
{
	x = parseInt(Math.round((screen.availWidth - width) / 2.0));
	y = parseInt(Math.round((screen.availHeight - height) / 2.0));
  if (is.winie) {
    x -= 6;
    y -= 20;
  }
	x = parseInt(Math.max(x, 0));
	y = parseInt(Math.max(y, 0));
	props = 'width='+width+',height='+height+',resizable=yes,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no';
	if (is.safari == 1) {
		props = props + ',screenX='+x+',screenY='+y;
	} else {
		props = props + ',left='+x+',top='+y;
	}
	w = window.open(url, title, props);
  w.focus();
}

// }}}
// {{{ function NB_popup_sra(url, title, width, height, warning)

function NB_popup_sra(url, title, width, height, warning)
{
  if ((screen.availWidth == 640) || (screen.availHeight == 480)) {
    width = 628;
    height = 442;
  } else if ((screen.availWidth == 800) || (screen.availHeight == 600)) {
    width = 788;
    height = 562;
  } else if ((screen.availWidth == 1024) || (screen.availHeight == 768)) {
    width = 1012;
    height = 730;
  }
	x = parseInt(Math.round((screen.availWidth - width) / 2.0));
	y = parseInt(Math.round((screen.availHeight - height) / 2.0));
  if (is.winie) {
    x -= 6;
    y -= 20;
  }
	x = parseInt(Math.max(x, 0));
	y = parseInt(Math.max(y, 0));
	props = 'width='+width+',height='+height+',resizable=yes,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=no';
	if (is.safari == 1) {
		props = props + ',screenX='+x+',screenY='+y;
	} else {
		props = props + ',left='+x+',top='+y;
	}
	w = window.open(url, title, props);
  //w.moveTo(0,0);
  //w.resizeTo(screen.width, screen.height);
  if (warning && ((screen.availWidth <= 800) || (screen.availHeight <= 600))) {
    alert('Per la migliore visualizzazione si consiglia di impostare la risoluzione ad almeno 1024x768 pixels.');
  }
  w.focus();
}

// }}}
// {{{ function NB_popup_ra(url, width, height, title, warning)

function NB_popup_ra(url, width, height, title, warning)
{
  if ((screen.availWidth == 640) || (screen.availHeight == 480)) {
    width = 628;
    height = 442;
  } else if ((screen.availWidth == 800) || (screen.availHeight == 600)) {
    width = 788;
    height = 562;
  } else if ((screen.availWidth == 1024) || (screen.availHeight == 768)) {
    width = 1012;
    height = 730;
  }
	x = parseInt(Math.round((screen.availWidth - width) / 2.0));
	y = parseInt(Math.round((screen.availHeight - height) / 2.0));
  if (is.winie) {
    x -= 6;
    y -= 20;
  }
	x = parseInt(Math.max(x, 0));
	y = parseInt(Math.max(y, 0));
	props = 'width='+width+',height='+height+',resizable=yes,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no';
	if (is.safari == 1) {
		props = props + ',screenX='+x+',screenY='+y;
	} else {
		props = props + ',left='+x+',top='+y;
	}
	w = window.open(url, title, props);
  //w.moveTo(0,0);
  //w.resizeTo(screen.width, screen.height);
  if (warning && ((screen.availWidth <= 800) || (screen.availHeight <= 600))) {
    alert('Per la migliore visualizzazione si consiglia di impostare la risoluzione ad almeno 1024x768 pixels.');
  }
  w.focus();
}

// }}}
// {{{ function NB_resize(width, height)

function NB_resize(width, height)
{
  x = (screen.availWidth - width) / 2;
  y = (screen.availHeight - height) / 2;
  if (is.winie) {
    width += 10;
    height += 50;
  }
  self.resizeTo(width, height);
  self.moveTo(x, y);
}

// }}}
// {{{ function NB_spreadsheet_clearrow(form, row)

function NB_spreadsheet_clearrow(form, row)
{
  for (i = 0; i < 8; i++) {
    form['riga_colonna_0'+i+'['+row+']'].value = '';
  }
  form['riga_commento['+row+']'].value = '';
}

// }}}
// {{{ function NB_spreadsheet_clearallrows(form, numrows)

function NB_spreadsheet_clearallrows(form, numrows)
{
  for (row = 0; row < numrows; row++) {
    NB_spreadsheet_clearrow(form, row)
  }
}

// }}}
// {{{ function NB_spreadsheet_clearall(form, numrows)

function NB_spreadsheet_clearall(form, numrows)
{
  NB_spreadsheet_clearallrows(form, numrows);
  form['lst_titolo'].value = '';
  form['lst_titolo_dx'].value = '';
  //form['lst_sottotitolo_01'].value = '';
  //form['lst_sottotitolo_02'].value = '';
  //form['lst_sottotitolo_03'].value = '';
}

// }}}
// {{{ function NB_input_checkbox_hash_checkall(hash)

function NB_input_checkbox_hash_checkall(hash)
{
  for (var key in hash) {
    hash[key].checked = true;
  }
}

// }}}
// {{{ function NB_specialoffers_handle_ofe_utente_checkall(checkbox, form)

function NB_specialoffers_handle_ofe_utente_checkall(checkbox, form)
{
  pattern = /^ofe_utente\[.+\]\[checked\]$/;
  if (checkbox.checked) {
    for (var i = 0; i < form.elements.length; i++) {
      if (pattern.test(form.elements[i].name))
        form.elements[i].checked = true;
    }
  }
}

// }}}
// {{{ function NB_specialoffers_handle_ofe_utente_checked(checkbox, checkbox_to_uncheck, form)

function NB_specialoffers_handle_ofe_utente_checked(checkbox, checkbox_to_uncheck, form)
{
  pattern = /^ofe_utente\[.+\]\[checked\]$/;
  found_not_checked = false;

  if (!checkbox.checked) {
    checkbox_to_uncheck.checked = false;
  } else {
    for (var i = 0; i < form.elements.length; i++) {
      if (pattern.test(form.elements[i].name)) {
        if (!form.elements[i].checked) {
          found_not_checked = true;
          break;
        }
      }
    }
    if (!found_not_checked)
      checkbox_to_uncheck.checked = true;
  }
}

// }}}
// {{{ function NB_specialoffers_selectall(form)

function NB_specialoffers_selectall(form)
{
  pattern = /^ofe_utente\[.+\]\[checked\]$/;
  for (var i = 0; i < form.elements.length; i++) {
    if (pattern.test(form.elements[i].name)) {
      form.elements[i].checked = true;
    }
  }
}

// }}}
// {{{ function NB_specialoffers_deselectall(form, another_checkbox_to_deselect)

function NB_specialoffers_deselectall(form, another_checkbox_to_deselect)
{
  another_checkbox_to_deselect.checked = false;
  pattern = /^ofe_utente\[.+\]\[checked\]$/;

  for (var i = 0; i < form.elements.length; i++) {
    if (pattern.test(form.elements[i].name)) {
      form.elements[i].checked = false;
    }
  }
}

// }}}
// {{{ function NB_print_document()

function NB_print_document()
{
  window.print();
}

// }}}
// {{{ function NB_border_color_mouseover(obj, color)

function NB_border_color_mouseover(obj, color)
{
  //alert(obj.style.borderColor);
  obj.style.borderColor = color;
}

// }}}
// {{{ function NB_border_color_mouseout(obj, color)

function NB_border_color_mouseout(obj, color)
{
  obj.style.borderColor = color;
}

// }}}
// {{{ function NB_trim(str)

function NB_trim(str)
{
  first = 0;
  first_found = false;
  last = -1;
  for (i = 0; i < str.length; i++) {
    if (str.charAt(i) != ' ') {
      if (!first_found) {
        first = i;
        first_found = true;
      }
      last = i;
    }
  }
  return str.substring(first, last + 1);
}

// }}}
// {{{ function NB_popup_expander(url, title, width, height, widthStep, heightStep)

function NB_popup_expander(url, title, width, height, widthStep, heightStep)
{
  var obj = new Object();
  obj.width = width;
  obj.height = height;
  obj.widthStep = widthStep;
  obj.heightStep = heightStep;
	x = parseInt(Math.round((screen.availWidth - width) / 2.0));
	y = parseInt(Math.round((screen.availHeight - height) / 2.0));
  if (is.winie) {
    x -= 6;
    y -= 20;
  }
	x = parseInt(Math.max(x, 0));
	y = parseInt(Math.max(y, 0));
  if (is.ie || is.ns || is.safari || is.firefox || is.moz)
    props = 'width=1,height=1,resizable=no,scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,status=no';
  else
    props = 'width='+width+',height='+height+',resizable=no,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=no';
  if (is.safari == 1) {
    props = props + ',screenX='+x+',screenY='+y;
  } else {
    props = props + ',left='+x+',top='+y;
  }
  w = window.open(url, title, props);
  w.focus();
  return obj;
}
// }}}
// {{{ function NB_popup_expanded(ref)

function NB_popup_expanded(ref)
{
  if (is.ie || is.ns || is.safari || is.firefox || is.moz) {
    var height = ref.height;
    var width = ref.width;
    var heightStep = ref.heightStep;
    var widthStep = ref.widthStep;
    for (currHeight = 1; currHeight < height; currHeight += heightStep)
      self.resizeTo(1, currHeight);
    self.resizeTo(1, height);
    for (currWidth = 1; currWidth < width; currWidth += widthStep)
      self.resizeTo(currWidth, height);
    self.resizeTo(width, height);
    if (is.winie) {
      width += width - self.document.body.clientWidth;
      height += height - self.document.body.clientHeight;
      self.resizeTo(width, height);
    } else if (is.safari) {
      width += width - self.innerWidth;
      height += height - self.innerHeight;
      self.resizeTo(width, height);
    } else if (is.mozBased) {
      self.innerWidth = width;
      self.innerHeight = height;
    }
  }
}

// }}}
// {{{ function NB_inspect(obj)

function NB_inspect(obj)
{
  var str = '';
  for (var i in obj) {
    str += '<td>' + i + '</td><td>' + obj[i] + '</td></tr>';
  }
  w = window.open('', 'debug', 'height=400,width=600,resizable=no,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=no');
  d = w.document;
  d.write('<html><head><title>DEBUG</title><style>body, td, th { font-family: Arial; font-size: 11px; } td, th { background-color: #eeeeee; padding: 0px 5px; }</style></head><body>');
  d.write(navigator.userAgent.toLowerCase()+'<br>');
  d.write('<table cellspacing="1" cellpadding="0" border="0">');
  d.write(str);
  d.write('</table>');
  d.write('</body></html>');
  d.close();
}

// }}}
// {{{ function NB_debug_popup(html)

function NB_debug_popup(html)
{
  w = window.open('', 'debug', 'height=400,width=600,resizable=no,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=no');
  d = w.document;
  d.write('<html><head><title>DEBUG</title><style>body, td, th { font-family: Arial; font-size: 11px; } td, th { background-color: #eeeeee; padding: 0px 5px; }</style></head><body>'+"\n");
  d.write(html);
  d.write('</body></html>');
  d.close();
}

// }}}
// {{{ function NB_browser_test()

function NB_browser_test()
{
  var str_true = '';
  var str_false = '';
  var str_other = '';
  for (var prop in is) {
    if (is[prop] == true)
      str_true += prop + ': ' + is[prop] + '</br>';
    else if (is[prop] == false)
      str_false += prop + ': ' + is[prop] + '</br>';
    else
      str_other += prop + ': ' + is[prop] + '</br>';
  }
  w = window.open('', 'debug', 'height=400,width=600,resizable=no,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=no');
  d = w.document;
  d.write('<html><head><title>DEBUG</title><style>body, td, th { font-family: Arial; font-size: 11px; }</style></head><body>');
  d.write(navigator.userAgent.toLowerCase()+'<br>');
  d.write('<hr>');
  d.write(str_true);
  d.write('<hr>');
  d.write(str_false);
  d.write('<hr>');
  d.write(str_other);
  d.write('</body></html>');
  d.close();
}

// }}}
// {{{ function NB_popup_expand_resize(ref)

function NB_popup_expand_resize(location, ref, newWidth, newHeight)
{
  if (is.ie || is.ns || is.safari || is.firefox || is.moz) {
    var height = ref.height;
    var width = ref.width;
    var heightStep = ref.heightStep;
    var widthStep = ref.widthStep;
    if (newHeight > height) {
      for (currHeight = height; currHeight < newHeight; currHeight += heightStep) {
        self.resizeTo(width, currHeight);
        moveBy(0, -heightStep/2);
      }
    } else {
      for (currHeight = height; currHeight > newHeight; currHeight -= heightStep) {
        self.resizeTo(width, currHeight);
        moveBy(0, heightStep/2);
      }
    } // if (newHeight > height) {
    if (newWidth > width) {
      for (currWidth = width; currWidth < newWidth; currWidth += widthStep) {
        self.resizeTo(currWidth, newHeight);
        moveBy(-widthStep/2, 0);
      }
    } else {
      for (currWidth = width; currWidth > newWidth; currWidth -= widthStep) {
        self.resizeTo(currWidth, newHeight);
        moveBy(widthStep/2, 0);
      }
    } // if (newWidth > width) {
    self.resizeTo(newWidth, newHeight);
    if (is.winie) {
      newWidth += newWidth - self.document.body.clientWidth;
      newHeight += newHeight - self.document.body.clientHeight;
      self.resizeTo(newWidth, newHeight);
    } else if (is.safari) {
      newWidth += newWidth - self.innerWidth;
      newHeight += newHeight - self.innerHeight;
      self.resizeTo(newWidth, newHeight);
    } else if (is.mozBased) {
      self.innerWidth = newWidth;
      self.innerHeight = newHeight;
    }
    self.location = location;
  } // if (is.ie || is.ns || is.safari || is.firefox || is.moz) {
}

// }}}
// {{{ function NB_getElementLeft(obj)

function NB_getElementLeft(obj)
{
  if (is.macie)
    x = obj.clientLeft;
  else
    x = obj.offsetLeft;
  tmp = obj.offsetParent;
  while (tmp != null) {
    if (is.macie)
      x += tmp.clientLeft;
    else
      x += tmp.offsetLeft;
    tmp = tmp.offsetParent;
  }
  return x;
}

// }}}
// {{{ function NB_getElementTop(obj)

function NB_getElementTop(obj)
{
  if (is.macie)
    y = obj.clientTop;
  else
    y = obj.offsetTop;
  tmp = obj.offsetParent;
  while (tmp != null) {
    if (is.macie)
      y += tmp.clientTop;
    else
      y += tmp.offsetTop;
    tmp = tmp.offsetParent;
  }
  return y;
}

// }}}
// {{{ function NB_getElementLeftById(name)

function NB_getElementLeftById(name)
{
  if (document.getElementById)
    obj = document.getElementById(name);
  else if (document.all)
    obj = document.all[name];
  return NB_getElementLeft(obj);
}

// }}}
// {{{ function NB_getElementTopById(name)

function NB_getElementTopById(name)
{
  if (document.getElementById)
    obj = document.getElementById(name);
  else if (document.all)
    obj = document.all[name];
  return NB_getElementTop(obj);
}

// }}}
// {{{ function NB_show_date(date)

function NB_show_date(date, lang)
{
  var months = {ita:['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Guigno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'], eng:['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']};
  var days = {ita:['Domenica', 'Lunedi', 'Martedi', 'Mercoledi', 'Giovedi', 'Venerdi', 'Sabato'], eng:['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thurday', 'Friday', 'Saturday']};

  //NB_inspect(months);
  
  document.write(days[lang][date.getDay()]+' '+date.getDate()+' '+(months[lang][date.getMonth()])+' '+date.getFullYear());
}

// }}}
// {{{ function NB_add_to_bookmark(url, title, lang)

function NB_add_to_bookmark(url, title, lang)
{
  if (is.winie)
    window.external.AddFavorite(url, title);
  else if (lang == 'ita') {
    if (is.mac)
      window.alert('Premi Mela+D per aggiungere ai preferiti');
    else
      window.alert('Premi Ctrl+D per aggiungere ai preferiti');
  } else  {
    if (is.mac)
      window.alert('Hit Command+D to add to bookmark');
    else
      window.alert('Hit Ctrl+D to add to bookmark');
  }
}

// }}}

