/*
** Evonux 2005
** evJStools version 0.1
**
** All rights reserved
*/

Evonux = {};
Evonux.lang = 'fr';
Evonux.trans = new Array();
Evonux.langLoaded = false;
Evonux.alertid = 'evonux_alert';
Evonux.bubbleinfoid = 'evonux_bubbleinfo';
Evonux.picturedir = '/picture';

Evonux._mouseX = 0;
Evonux._mouseY = 0;

// ----------------------------------------------------------------------------
// Standard functions
Evonux.W = function(input)
{ // static
    document.write(input);
}
Evonux.$ = function(id)
{ // static
    return document.getElementById(id);
}
Evonux.TopParent = function()
{ // static
    docRef = document.getElementsByTagName('body')[0];
    while (docRef.parentNode != null)
      docRef = docRef.parentNode;
    return docRef;
}
Evonux.AddEventListener = function(e, handler, obj)
{ // static
    var _obj = (obj ? obj : window.document);
    if (document.addEventListener)
      return _obj.addEventListener(e, handler, true);
    else
      return _obj.attachEvent('on'+ e, handler);
}
Evonux.RemoveEventListener = function(e, handler, obj)
{ // static
    var _obj = (obj ? obj : window.document);
    if (document.removeEventListener)
      _obj.removeEventListener(e, handler, true);
    else
      _obj.detachEvent('on'+ e, handler);
}
Evonux.GetMousePosition = function(e)
 { // static
     var new_pos_x = (Evonux.Browser() == 'ie' ? e.clientX + document.body.scrollLeft : e.pageX);
     var new_pos_y = (Evonux.Browser() == 'ie' ? e.clientY + document.body.scrollTop : e.pageY);
     // Updates mouse position records
     Evonux._mouseX	= new_pos_x;
     Evonux._mouseY	= new_pos_y;
 }
// Main window if no argument
Evonux.GetObjSize = function(obj)
 {
     if (obj)
       return Array(obj.offsetWidth, obj.offsetHeight);
     var w = window, db = document.body;
     if (w.innerWidth)
       return Array(w.innerWidth, w.innerHeight);
     return Array(db.offsetWidth, db.offsetHeight);
 }
// Return actual style property for an object (JS, style="" or CSS)
Evonux.GetStyleProp = function(obj, prop)
{
    if (obj.currentStyle)
      return obj.currentStyle[prop];
    else if (window.getComputedStyle)
      return document.defaultView.getComputedStyle(obj, null).getPropertyValue(prop);
    return false;
}
// Searches in an array (arg1;arg2;...) for an option
// Returns true/false if option is here or not
// or option's value (argn=...)
Evonux.GetOption = function(str, opt)
{
    if (!str)
      return false;
    for (var option = str.split(';'), k = 0, lg = option.length; k < lg; k++)
    {
	if (option[k].indexOf('=') != -1)
	    {
		tmp = option[k].split('=');
		if (tmp[0] == opt)
		    return tmp[1];
	    }
	else if (option[k] == opt)
	    return true;
    }
    return false;
}
Evonux.Browser = function()
{
    // opera
    if (navigator.userAgent.toLowerCase().indexOf('opera') != -1)
	return 'opera';
    // internet explorer
    if (navigator.userAgent.toLowerCase().indexOf('msie') != -1 &&
	navigator.userAgent.toLowerCase().indexOf('opera') == -1) // Opera can pretend it's other browser
	return 'ie';
    // firebird
    if (navigator.userAgent.toLowerCase().indexOf('firebird') != -1)
	return 'firebird';
    // firefox
    if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1)
	return 'firefox';
    // netscape
    if (navigator.userAgent.toLowerCase().indexOf('netscape') != -1)
	return 'netscape';
    // epiphany
    if (navigator.userAgent.toLowerCase().indexOf('epiphany') != -1)
	return 'epiphany';
    // konqueror
    if (navigator.userAgent.toLowerCase().indexOf('konqueror') != -1)
	return 'konqueror';
    // galeon
    if (navigator.userAgent.toLowerCase().indexOf('galeon') != -1)
	return 'galeon';
    // safari (contains 'mozilla')
    if (navigator.userAgent.toLowerCase().indexOf('safari') != -1)
	return 'safari';
    // mozilla
    if (navigator.userAgent.toLowerCase().indexOf('mozilla') != -1)
	return 'mozilla';
    // unlisted browser
    return 'unknown';
}
Evonux.TypeOf = function(obj)
{
    var _type = typeof(obj);
    if ((_type == 'object') && obj.type)
      return obj.type;
    return _type;
}
// Calculates available calculation power
Evonux.AvailableCalcPower = function(recalc)
{
    if ((Evonux._calcPowerLevel > 0) && !recalc)
      return Evonux._calcPowerLevel;
    var now = new Date();
    nowMS0 = now.getTime();
    for (k = 1, i = 0; k < 1000; k++)
      i += eval('Math.sqrt(k) + Math.sin(k) + Math.cos(k)');
    now = new Date();
    nowMS = now.getTime() - nowMS0;

    // Fast calc availability : [50,100%]
    if (nowMS <= 150)
      Evonux._calcPowerLevel = Math.floor(100 - ((nowMS / 150) * 50));
    // Low calc availability  : [1,50%]
    else
    {
	if (nowMS > 2000)
	    nowMS = 2000;
	tmp = 50 - ((nowMS / 2000) * 50);
	Evonux._calcPowerLevel = (tmp > 0 ? Math.floor(tmp) : 1);
    }

    return Evonux._calcPowerLevel;
}

Evonux.AddEventListener('mousemove', Evonux.GetMousePosition);
//-----------------------------------------------------------------------------

Evonux.RegisterTrans = function(name, value)
{ // static
    var lang = (Evonux && Evonux.lang ? Evonux.lang : 'fr');
    if (!Evonux.trans[lang])
      Evonux.trans[lang] = new Array();
    Evonux.trans[lang][name] = value;
}
Evonux.Trans = function(name)
{
    var lang = (Evonux && Evonux.lang ? Evonux.lang : 'fr');
    return Evonux.trans[lang][name];
}

Evonux.Alert = function(output, option, title, icon)
{ // static
    if (!option) option = '';
    if (!title) title = '';
    if (!icon) icon = 'ico_info.gif';
    with (Evonux)
    {
	var alertObj = $(alertid);
	if (!output && alertObj)
	{
	    alertObj.style.visibility = 'hidden';
	    return;
	}
	if (!alertObj)
	{
	    alertObj = document.createElement('div');
	    alertObj.setAttribute('style', 'margin:0;'); // IE Fix for Evonux.Anim
	    document.getElementsByTagName('body')[0].appendChild(alertObj);
	    AddEventListener('mousedown', function(e) {new Evonux.Anim.Drag(Evonux.$(Evonux.alertid));}, alertObj);
	    alertObj.id = alertid;
	}
	if (option)
	{
	    switch (option)
	    {
		case 'foot':
		  header = (title.length > 0 ? '<div class="title"><img src="'+ Evonux.Evhe.pictureDir +'/'+ icon +'" align="middle" class="title" />'+ title +'</div>' : '');
		  footer = '<br/><center><div class="evbutton" onclick="Evonux.Alert(false);" />'+ Evonux.trans[Evonux.lang]['ok'] +'</div></center>';
		  break;
		case 'std':
		  header = '<div class="title"><img src="'+ Evonux.Evhe.pictureDir +'/ico_info.gif" align="middle" class="title" />'+ Evonux.trans[Evonux.lang]['alert'] +'</div>';
		  footer = '<br/><center><div class="evbutton" onclick="Evonux.Alert(false);" />'+ Evonux.trans[Evonux.lang]['ok'] +'</div></center>';
		  break;
		default:
		  break;
	    }
	}
	else
	{
	    header = '';
	    footer = '';
	}
	alertObj.innerHTML = header + output + footer;
	alertObj.style.visibility = 'visible';

	// Centers alert window
	var winSize = GetObjSize(), alertSize = GetObjSize(alertObj);
	alertObj.style.left = window.Math.floor((winSize[0] / 2) - (alertSize[0] / 2)) +'px';
	alertObj.style.top = window.Math.floor((winSize[1] / 2) - (alertSize[1] / 2)) +'px';
    }
}
// ----------------------------------------------------------------------------
// Advanced Photoshop like color chooser
Evonux.ColorChooser = function(r, g, b)
{
    var output = '<form id="evcolor_form" name="evcolor_form" class="evform"><table class="evcolor_main" cellpadding="0" cellspacing="0"><tr><td>colors : </td>';
    // Main chooser
    output1 = output2 = output3 = output4 = output5 = output6 = '';
    for (c = 0; c <= 255; c+=5)
    {
	// (255,0,0) to (255,0,255)
	output1 += '<td style="background-color:rgb(255,0,'+ (c) +')" onclick="Evonux.ColorChooserLocal(255,0,'+ (c) +')">&nbsp;</td>';
	// (255,0,255) to (0,0,255)
	output2 += '<td style="background-color:rgb('+ (255 - c) +',0,255)" onclick="Evonux.ColorChooserLocal('+ (255 - c) +',0,255)">&nbsp;</td>';	
	// (0,0,255) to (0,255,255)
	output3 += '<td style="background-color:rgb(0,'+ (c) +',255)" onclick="Evonux.ColorChooserLocal(0,'+ (c) +',255)">&nbsp;</td>';
	// (0,255,255) to (0,255,0)
	output4 += '<td style="background-color:rgb(0,255,'+ (255 - c) +')" onclick="Evonux.ColorChooserLocal(0,255,'+ (255 - c) +')">&nbsp;</td>';
	// (0,255,0) to (255,255,0)
	output5 += '<td style="background-color:rgb('+ (c) +',255,0)" onclick="Evonux.ColorChooserLocal('+ (c) +',255,0)">&nbsp;</td>';
	// (255,255,0) to (255,0,0)
	output6 += '<td style="background-color:rgb(255,'+ (255 - c) +',0)" onclick="Evonux.ColorChooserLocal(255,'+ (255 - c) +',0)">&nbsp;</td>';
    }
    output += output1 + output2 + output3 + output4 + output5 + output6 + '</tr></table>';
    // Local chooser
    output += '<table cellspacing="0" cellpadding="0"><tr><td rowspan="4">'
      +'<div id="evcolor_local">'+ Evonux.ColorChooserLocal(255,0,0,true) +'</div>'
      +'</td>'
      +'<td class="title">'+ Evonux.trans[Evonux.lang]['red'] +'</td><td><input name="evcolor_red" type="text" class="evinput_number" size="3" /></td>'
      +'<td rowspan="3"><div id="evcolor_preview">&nbsp;</div></td></tr>'
      +'<tr><td class="title">'+ Evonux.trans[Evonux.lang]['green'] +'</td><td><input name="evcolor_green" type="text" class="evinput_number" size="3" /></td></tr>'
      +'<tr><td class="title">'+ Evonux.trans[Evonux.lang]['blue'] +'</td><td><input name="evcolor_blue" type="text" class="evinput_number" size="3" /></td></tr>'
      +'<tr><td colspan="3" style="height:100px;">'
      +'<center><div onclick="Evonux.ColorChooserManual();" class="evbutton">'+ Evonux.trans[Evonux.lang]['update'] +'</div></center>'
      +'</td></tr>'
      +'</table>'
      +'</form>';
    return output;
}
Evonux.ColorChooserLocal = function(r, g, b, init)
{
    if (!Evonux.$('evcolor_local') && !init)
      return;
    var output = '<table class="evcolor_local" cellpadding="0" cellspacing="0">';

    column_nb = 22;// between 1 and 100
    column_range = 1;
    line_range = 5;
    r_line = r;
    g_line = g;
    b_line = b;
    r_line_range = (r / 255) * line_range;
    g_line_range = (g / 255) * line_range;
    b_line_range = (b / 255) * line_range;

    for (l = 255; l >= 0; l -= line_range)
    {
	output += '<tr>';
	_r = l;
	_g = l;
	_b = l;
	_r_range = (r_line - l) / column_nb;
	_g_range = (g_line - l) / column_nb;
	_b_range = (b_line - l) / column_nb;
	for (rate = 0;
	     rate <= column_nb;
	     rate += column_range)
	    {
		output += '<td style="background-color:rgb('
		    + _r +','
		    + _g +','
		    + _b +')" onclick="forms.evcolor_form.evcolor_red.value = '+ _r +'; forms.evcolor_form.evcolor_green.value = '+ _g +'; forms.evcolor_form.evcolor_blue.value = '+ _b +'; Evonux.$(\'evcolor_preview\').style.backgroundColor = \'rgb('+ _r +','+ _g +','+ _b +')\';">&nbsp;</td>';
		_r = Math.ceil(_r + _r_range);
		_g = Math.ceil(_g + _g_range);
		_b = Math.ceil(_b + _b_range);
	    }
	output += '</tr>';
	r_line = Math.ceil(r_line - r_line_range);
	g_line = Math.ceil(g_line - g_line_range);
	b_line = Math.ceil(b_line - b_line_range);
    }
    output += '</table>';
    if (init)
      return output;
    Evonux.$('evcolor_local').innerHTML = output;
}
Evonux.ColorChooserManual = function(rgb)
{ // static
    if (!Evonux.$('evcolor_preview') || !Evonux.$('evcolor_form'))
      return;

    var f = Evonux.ColorChooserInit();

    // Displays choosen local corresponding color grid
    // Chooses interval (2,0,1,2,0,1)
    if (rgb)
    {
	Evonux.ColorChooserLocal(rgb[0], rgb[1], rgb[2]);
	f.evcolor_red.value = rgb[0];
	f.evcolor_green.value = rgb[1];
	f.evcolor_blue.value = rgb[2];
    }
    else
    {
	s2nb = Evonux.String.ToNb;
	cur_color = [s2nb(f.evcolor_red.value), s2nb(f.evcolor_green.value), s2nb(f.evcolor_blue.value)];
	ref1 = Evonux.Math.MaxRank(cur_color[0],cur_color[1],cur_color[2]);
	ref3 = Evonux.Math.MinRank(cur_color[0],cur_color[1],cur_color[2]);
	ref2 = 3 - ref1 - ref3;
	final_color = new Array();
	final_color[ref1] = (cur_color[ref1] > 128 ? 255 : 0);
	final_color[ref2] = cur_color[ref2];
	final_color[ref3] = (cur_color[ref3] > 128 ? 255 : 0);
	Evonux.ColorChooserLocal(final_color[0], final_color[1], final_color[2]);
    }

    // Displays choosen color
    Evonux.$('evcolor_preview').style.backgroundColor =
      'rgb('+ f.evcolor_red.value
      +','+ f.evcolor_green.value
      +','+ f.evcolor_blue.value +')';
}
Evonux.ColorChooserInit = function()
{
    if (!Evonux.$('evcolor_form'))
      return;
    var f = Evonux.$('evcolor_form');
    // Checks colors are all set
    if (f.evcolor_red.value.length == 0)
      f.evcolor_red.value = 0;
    if (f.evcolor_green.value.length == 0)
      f.evcolor_green.value = 0;
    if (f.evcolor_blue.value.length == 0)
      f.evcolor_blue.value = 0;
    return f;
}
Evonux.ColorChooserGet = function()
{
    if (!Evonux.$('evcolor_form'))
      return false;
    var f = Evonux.ColorChooserInit();
    return 'rgb('+ f.evcolor_red.value +','+ f.evcolor_green.value +','+ f.evcolor_blue.value +')';
}
// ----------------------------------------------------------------------------
// Math functions
Evonux.Math = {};

Evonux.Math.Max = function()
{
    var argv = Evonux.Math.Max.arguments;
    var argc = argv.length;
    var max = argv[0];
    for (r = 0; r < argc; r++)
      max = (argv[r] > max ? argv[r] : max);
    return max;
}
Evonux.Math.MaxRank = function()
{
    var argv = Evonux.Math.MaxRank.arguments;
    var argc = argv.length;
    var max = argv[0];
    var max_rank = 0;
    for (r = 0; r < argc; r++)
    if (argv[r] > max)
    {
	max = argv[r];
	max_rank = r;
    }
    return max_rank;
}
Evonux.Math.Min = function()
{
    var argv = Evonux.Math.Min.arguments;
    var argc = argv.length;
    var min = argv[0];
    for (r = 0; r < argc; r++)
      min = (argv[r] < min ? argv[r] : min);
    return min;
}
Evonux.Math.MinRank = function()
{
    var argv = Evonux.Math.MinRank.arguments;
    var argc = argv.length;
    var min = argv[0];
    var min_rank = 0;
    for (r = 0; r < argc; r++)
    {
	if (argv[r] < min)
	    {
		min = argv[r];
		min_rank = r;
	    }
    }
    return min_rank;
}
// ----------------------------------------------------------------------------
// String functions
Evonux.String = {};

Evonux.String.ToNb = function(str)
{
    return eval(str);
}

Evonux.String.Trim = function(str)
{
    return str.replace(RegExp('^\s+', 'g'), '').replace(RegExp('\s+$', 'g'), '');
}
if (!String.trim)
String.prototype.trim = function()
{
    return this.replace(RegExp('^[ \t\v\f\n\r]+', 'g'), '').replace(RegExp('[ \t\v\f\n\r]+$', 'g'), '');
}

Evonux.String.WordCount = function(str)
{
    ;
}

// Calculates strings similarity
// 0 = equal, the higher is result, the more strings are different
Evonux.String.LevenshteinDistance = function (s, t)
{
    var dG = new Array();

    var i; // iterates through s
    var j; // iterates through t
    var s_i; // ith character of s
    var t_j; // jth character of t
    var cost; // cost
    
    // Step 1
    var n = s.length; // length of s
    var m = t.length; // length of t
    if (n == 0)
	return m;
    if (m == 0)
	return n;
    
    // Construct a matrix containing 0..m rows and 0..n columns
    var d = new Array();

    // Step 2
    // Initialize the first row to 0..n.
    // Initialize the first column to 0..m
    for (i = 0; i <= n; i++)
    {
	d[i] = new Array();
	d[i][0] = i;
    }
    
    for (j = 0; j <= m; j++)
	d[0][j] = j;

    // Step 3
    // Examine each character of s (i from 1 to n)
    // Step 4
    // Examine each character of t (j from 1 to m)
    // Step 5
    // Determine cost
    // Step 6
    // Set cell d[i,j] of the matrix equal to the minimum of:
    // a. The cell immediately above plus 1: d[i-1,j] + 1.
    // b. The cell immediately to the left plus 1: d[i,j-1] + 1.
    // c. The cell diagonally above and to the left plus the cost: d[i-1,j-1] + cost

    // Does it ! :
    for (i = 1; i <= n; i++)
    {
	for (j = 1; j <= m; j++)
	    {
		s_i = s.charAt(i - 1);
		t_j = t.charAt(j - 1);
		cost = (s_i == t_j ? 0 : 1);

		d[i][j] = Evonux.Math.Min(d[i-1][j]   + 1,
					  d[i][j-1]   + 1,
					  d[i-1][j-1] + cost);
	    }
    }

    // Step 7
    return d[n][m];
}

// ----------------------------------------------------------------------------
// nLevels menu
Evonux.Menu = {};
// Creates a menu instance
Evonux.Menu = function(title, icon, destination, target)
{
    // Members
    this.id		= Evonux.Menu._id++;
    this.title		= title;
    this.icon		= icon;
    this.destination	= destination;
    this.target		= target;
    this.parent		= null;
    this.child		= new Array(); // of Evonux.Menu or Evonux.Menu._blank (EVX_MENU_BLANK)

    // Misc
    Evonux.Menu._item[this.id] = this;
}

Evonux.Menu._id = 1;
Evonux.Menu._item = new Array();
Evonux.Menu._curid = -1;
Evonux.Menu._default_target = '';
Evonux.Menu.DISPLAY_ON = 1;
Evonux.Menu.DISPLAY_OFF = 0;

// Adds some menus to this menu
Evonux.Menu.prototype.Add = function()
{
    var	argv = Evonux.Menu.prototype.Add.arguments;
    var argc = argv.length;

    for (var i = 0; i < argc; i++)
	{
	    this.child[this.child.length] = argv[i];
	    argv[i].parent = this;
	}
}
// Displays menu tree
Evonux.Menu.prototype.Display = function(level, return_result, title_disp)
{
    var output = '';
    
    if (isNaN(level))
	level = 0;
    if (isNaN(return_result))
	return_result = Evonux.Menu.DISPLAY_ON;
    if (isNaN(title_disp))
	title_disp = Evonux.Menu.DISPLAY_ON;
    // Menu main title
    if (level == 0)
	{
	    output += '<div class="menu0">'
		+ (title_disp ?
		   '<div class="maintitle" onclick="with (Evonux.Menu) {if (_curid != '+ this.id +') {Display('+ this.id +');} else Display(-'+ this.id +');}">'
		   + '<a href="'+ (this.destination ? this.destination : 'javascript:;') +'"'
		   + (this.target ? ' target="'+ this.target : Evonux.Menu._default_target) +'">'
		   + this.title
		   + '</a>'
		   + '</div>' : '')
		+ '<table cellspacing="0" cellpadding="2px" id="menu_'+ this.id +'" class="menu1" '+ (title_disp ? 'style="display:none;"' : '') +'>'
		+ '<tr><td>';
	    for (var i = 0, child_lg = this.child.length; i < child_lg; i++)
		{
		    if (this.child[i] != 'blank')
			output += this.child[i].Display(level + 1, return_result, title_disp);
		    else
			output += '<hr/>';
		}
	    output += '</td></tr>'
		+ '</table>'
		+ '</div>';
	    if (return_result)
		Evonux.W(output);
	    else
		return output;
	}
    // Main menu or Submenu
    else
	{
	    // No children
	    if (this.child.length == 0)
		{
		    output += '<a href="'+ this.destination +'" onmouseover="Evonux.Menu.Display('+ this.id +');"'
			+ (this.target ? ' target="'+ this.target : Evonux.Menu._default_target) +'"'
			+ ' onclick="Evonux.Menu.Display(-1);"'
			+ ' id="evmenuelt'+ this.id +'" class="evmenuelt">'
			+ (this.icon ? '<img src="'+ Evonux.picturedir +'/'+ this.icon +'" align="middle" alt="" border="0" /> &nbsp;' : '')
			+ this.title
			+ '</a>';
		}
	    
	    // This Menu object has children
	    else
		{
		    output += '<table cellpadding="0" cellspacing="0" class="filled">'
			+ '<tr>'
			// Submenu title
			+ '<td class="title">'
			+ '<a href="'+ (this.destination ? this.destination : 'javascript:;') +'"'
			+ ' target="'+ (this.target ? this.target : Evonux.Menu._default_target) +'"'
			+ ' onmouseover="Evonux.Menu.Display('+ this.id +');" onclick="Evonux.Menu.Display(-'+ this.id +'); parent.Evonux.Loading(true);" id="evmenuelt'+ this.id +'" class="evmenuelt">'
			+ (this.icon ? '<img src="'+ Evonux.picturedir +'/'+ this.icon +'" align="middle" alt="" border="0" /> &nbsp;' : '')
			+ this.title
			+ '</a>'
			+'</td>'
			// Submenu content
			+ '<td class="content" id="menu_'+ this.id +'" style="display:none;">'
			+ '	<div class="content">'
			+ '	<table cellpadding="2px" cellspacing="0" class="content"><tr><td>';

		    // Submenu children
		    for (var i = 0, child_lg = this.child.length; i < child_lg; i++)
			{
			    if (this.child[i] != 'blank')
				output += this.child[i].Display(level + 1, return_result, title_disp);
			    else
				output += '<hr/>';
			}
		    output += '	</td></tr></table>'
			+ '	</div>'
			+ '</td>'
			+ '</tr>'
			+ '</table>';
		}
	     return output;
	}
}
// Displays a subtree
Evonux.Menu.Display = function(id)
{ // static
    with (Evonux)
    {
	if (Menu._item.length == 0)
	  return;
	var disp = !(id < 0);
	id = (id < 0 ? -id : id);
	// Hides current menu tree until it reaches new menu-to-open level
	if (Menu._curid != -1)
	{
	    var cur_item = Menu._item[Menu._curid];
	    while (cur_item != Menu._item[id].parent)
		{
		    if (cur_item.child.length > 0)
			$('menu_'+ cur_item.id).style.display = 'none';
		    cur_item = cur_item.parent;
		}
	}
	// Displays (id >= 0) or hides (id < 0) asked menu
	if (Menu._item[id].child.length > 0)
	{
	    $('menu_'+ id).style.display = (disp ? '' : 'none');
	    $('menu_'+ id).style.zIndex = 1;
	}
	Menu._curid = (disp ? id : -1);
    }
}

// ----------------------------------------------------------------------------
// Left menu
Evonux.MenuLeft = {};
Evonux.MenuLeft.SwitchView = function(visibleObj)
{
    var menuObj = Evonux.$('menu');

    // Retrieves menu div elements
    obj = menuObj.getElementsByTagName('div');
    for (k = 0, lg = obj.length; k < lg; k++)
    {
	if (obj[k].className == 'content')
	    {
		if (obj[k] == visibleObj)
		    obj[k].style.display = 'block';
		else
		    obj[k].style.display = 'none';
	    }
    }
}

// ----------------------------------------------------------------------------
// Misc
Evonux.ObjProps = function(obj)
{
    var output = '';
    var re_italictag = new RegExp('(<i>|</i>)', 'gi');

    for (i in obj)
      output += i.italics().replace(re_italictag, '') +', ';
    return output;
}

Evonux.CSSset = function(objId, prop, value)
{
    eval('Evonux.$(\''+ objId +'\').'+ prop +' = \''+ value +'\'');
    return value;
}

// ----------------------------------------------------------------------------
// Bubble Info
Evonux.BubbleInfo = {};
Evonux.BubbleInfo = function(output, parent_obj, option)
{ // static
    if (!option) option = '';
    if (!parent_obj) parent_obj = null;
    with (Evonux)
    {
	var BIObj = $(bubbleinfoid);
	if (!output)
	{
	    if (BIObj)
		{
		    BIObj.style.visibility = 'hidden';
		    Evonux.BubbleInfo.active = false;
		}
	    return;
	}
	// If object doesn't exist, it is now
	if (!BIObj)
	{
	    BIObj = document.createElement('div');
	    //BIObj.setAttribute('style', 'position:absolute; margin:0;'); // IE Fix for Evonux.Anim
	    BIObj.style.position = 'absolute';
	    BIObj.style.margin = 0;
	    document.getElementsByTagName('body')[0].appendChild(BIObj);
	    AddEventListener('mousedown', Evonux.BubbleInfo.Hide);
	    AddEventListener('mousemove', Evonux.BubbleInfo.Refresh);
	    BIObj.id = bubbleinfoid;
	}
	if (parent_obj != null)
	    AddEventListener('mouseout', Evonux.BubbleInfo.Hide, parent_obj);

	BIObj.innerHTML = output;
	BIObj.style.visibility = 'visible';
	Evonux.BubbleInfo.active = true;
	BIObj.style.zIndex = 1000;
	// Position
	BIObj.style.left = (Evonux._mouseX) +'px';
	BIObj.style.top = (Evonux._mouseY + 15) +'px';
    }
}

Evonux.BubbleInfo.active = false;

Evonux.BubbleInfo.Refresh = function()
{ // static
    var BIObj = Evonux.$(Evonux.bubbleinfoid);
    if (Evonux.BubbleInfo.active)
    {
	BIObj.style.left = (Evonux._mouseX) +'px';
	BIObj.style.top = (Evonux._mouseY + 15) +'px';
    }
}
Evonux.BubbleInfo.Hide = function()
{ // static
    Evonux.BubbleInfo(false);
}

// Returns words space-separated without any tag from an XML tree
Evonux.RemoveTags = function(inputNode)
{ // static
    if (inputNode.nodeType == 3)
      return inputNode.nodeValue;

    var output = '',
	node = (inputNode.childNodes.length > 0 ? inputNode.childNodes.item(0) : null),
	pnode = inputNode;
    while (node != null)
    {
	if (node.nodeType == 3) // Text content
	    output += ' '+ node.nodeValue;
	// Node (1) - NB. attribute = 2
	if (node.childNodes.length > 0)
	    node = node.childNodes.item(0);
	else
	    {
		if (node.nextSibling != null)
		    node = node.nextSibling;
		else
		    {
			while ((node.parentNode.nextSibling == null) && (node.parentNode != pnode))
			    node = node.parentNode;
			node = (node.parentNode != pnode ? node.parentNode.nextSibling : node.nextSibling);
		    }
	    }
    }
    return output;
}
