/********************************************************************************
	This script is copyrighted by <eye2eye>
	www.eye2eye.net

	feel free to use this script on your pages as long as it is unmodified
	and this comment is left unchanged.

********************************************************************************/

//---------------------------------------------------------------------------------------------
//						MOUSE MOVE REGISTRATION AND EVENT HANDLING
//---------------------------------------------------------------------------------------------
// cannot assume that this script is the only one that will require to listen to mouse-movement
// so functionality is provided to register lister functions (register_for_mouse_move) 
// all these functions are stored in this array and called sequencially
var all_mouse_move_listeners;
all_mouse_move_listeners = new Array();

var mouse_x;
var mouse_y;
var p_mouse_x;
var menu_item_rows;
var root_menu_width;
var top_for_div;
var highlighted_td;
var orig_image_height;
var orig_top_div_pos;

var root_item_width;
var top_levels_after_wrap;

var char_pix;
var top_colour = "#FF6600";
var top_index = 0;

menu_item_rows = 20;
root_menu_width = 150;
root_item_width = 150;
top_levels_after_wrap = 0;
char_pix        = 15;

//changed francois
top_for_div =  51;
orig_top_div_pos = 51;

// call this function to register a function you want called on every mousemove event
function register_for_mouse_move ( mousemove_function )
{
	all_mouse_move_listeners[all_mouse_move_listeners.length] = mousemove_function;
}

//---------------------------------------------------------------------------------------------
// this function executes on every mousemove event and executes all the regitered listeners
function do_all_mousemove ( e )
{
var i;

	for ( i = 0 ; i < all_mouse_move_listeners.length ; i++ )
		all_mouse_move_listeners[i] ( e );

}

//---------------------------------------------------------------------------------------------
// capture mouse movement
if ( document.addEventListener )
	document.addEventListener ( 'mousemove', do_all_mousemove, false );
else if ( document.all )
	document.onmousemove = do_all_mousemove;
else
{
	captureEvents ( Event.MOUSEMOVE );
	onMouseMove = do_all_mousemove;
}

//---------------------------------------------------------------------------------------------
//							UTILITY DOCUMENT WRITING FUNCTIONS
//---------------------------------------------------------------------------------------------
// escape a string for use in eval or setTimeout
function escape_string ( s_string )
{
	var s_escaped_string;
	s_escaped_string = s_string.replace ( /\\/g, '\\\\' );
	s_escaped_string = s_escaped_string.replace ( /'/g, '\\\'' );
	return s_escaped_string;
}

//---------------------------------------------------------------------------------------------
// apply a property to a div or layer
function set_div_property ( s_div_tag, s_property, s_setting )
{
	if ( document.getElementById && ( document.getElementById ( s_div_tag ) != null ) )
		eval ( "document.getElementById ( '" + s_div_tag + "' ).style." + s_property + "='" + s_setting + "'" );
	else if ( document.all )
		eval ( s_div_tag + ".style." + s_property + "='" + s_setting + "'" );
	else
		eval ( "document." + s_div_tag + "." + s_property + "='" + s_setting + "'" );
}

//---------------------------------------------------------------------------------------------
// single point of call for all document writes (usefull for debuging etc.)
function doc_write ( s_text )
{
	document.writeln ( s_text );
}

//---------------------------------------------------------------------------------------------
//								MENU RENDERING FUNCTIONS
//---------------------------------------------------------------------------------------------
// main renderering function
function render_all_menus ( the_menu_setup )
{
var i;
//alert ("Showing menu: ");
	// clear the popup z-index counter and restart it as this is a new page
	the_menu_setup.n_popup_z = 10002;

	// loop thru all menus that were created (except the root) and call the appropriate render function
	for (i = 0; i < the_menu_setup.all_menus.length; i++)
		if ( the_menu_setup.all_menus[i].depth != 0 ){		
			draw_popup_menu ( the_menu_setup.all_menus[i],i );
			}
		else
			draw_root_menu ( the_menu_setup.all_menus[i] );
	
}

//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
// main renderering function
function render_left_menu ( in_menu_setup )
{
var i;
var the_menu_setup = eval(in_menu_setup);

set_top_div_height();

if (typeof(window.parent.g_menu_number) == "undefined" || window.parent.g_menu_number == -1){
	return;
}

var left_menu_number = window.parent.g_menu_number;
	
//alert ("Showing menu: ");
	// clear the popup z-index counter and restart it as this is a new page
	the_menu_setup.n_popup_z = 10002;

	// loop thru all menus that were created (except the root) and call the appropriate render function
	for (i = 0; i < the_menu_setup.all_menus.length; i++)
		if ( the_menu_setup.all_menus[i].depth != 0 ){		
						if (left_menu_number > 0 && the_menu_setup.all_menus[i].menu_number == left_menu_number){
				draw_left_menu (the_menu_setup.all_menus[i]);	
					
			}
		}
		
}

//---------------------------------------------------------------------------------------------

function find_root_item_width( menu ){

	var temp_root_index,i;
	
	temp_root_index = 0;
	
	if (typeof(menu.menu_setup) == "undefined" || typeof(menu.menu_setup) != "object" || menu.menu_setup == null){
		return temp_root_index;
	}
	
	for (i = 0; i < menu.menu_setup.all_menus.length; i++){
		if ( menu.menu_setup.all_menus[i].depth == (menu.depth-1) ){
		      for (items=0;items<menu.menu_setup.all_menus[i].menu_item_array.length;items++){
		      	  if (menu.menu_setup.all_menus[i].menu_item_array[items].sub_menu != null){
				if (menu.menu_setup.all_menus[i].menu_item_array[items].sub_menu.menu_number == menu.menu_number){
				  if (menu.menu_setup.all_menus[i].menu_item_array[items].root_item_width != null){
				 
					return menu.menu_setup.all_menus[i].menu_item_array[items].root_item_width;
					
				  }
				  //return temp_root_index;
				}
		      	  }		      	  
		      }
		}
	}	
	
	//window.alert(temp_root_index);
	return temp_root_index;
	
}
//----------------------------------------------------------------------------------------
function find_root_item_index( menu ){

	var temp_root_index,i;
	
	temp_root_index = 0;
	
	if (typeof(menu.menu_setup) == "undefined" || typeof(menu.menu_setup) != "object" || menu.menu_setup == null){
		return temp_root_index;
	}
	
	for (i = 0; i < menu.menu_setup.all_menus.length; i++){
		if ( menu.menu_setup.all_menus[i].depth == (menu.depth-1) ){
		      for (items=0;items<menu.menu_setup.all_menus[i].menu_item_array.length;items++){
		      	  if (menu.menu_setup.all_menus[i].menu_item_array[items].sub_menu != null){
				if (menu.menu_setup.all_menus[i].menu_item_array[items].sub_menu.menu_number == menu.menu_number){
				  return temp_root_index;
				}
		      	  }		      	  
		      }
		}
	}	
	
	return -1;
}

//---------------------------------------------------------------------------------------------
// draw the root menu
function draw_root_menu ( menu )
{

	// draw all the menu items in a table
	draw_root_items ( menu );

}
//---------------------------------------------------------------------------------------------
// draws a table of menu items with href and mouse events - shared by root and sub menus
function draw_root_items ( menu )
{
	var i;
	
	var current_width_usage;
	var X_current_width_usage;
	var td_class_style = 'whitebolds';
        
   
	current_width_usage = 0;
			
	//The table that the root items are drawn in
	doc_write ( '<table height=10 width=490 border=0 cellpadding=0 cellspacing=0><tr>' );
	
	doc_write ( '' );

			
		//spacer for menu

		
				
	for ( i = 0; i < menu.menu_item_array.length; i++ )
	{
		//window.alert(root_item_width*i);
		td_class_style = 'odyssey_root_menu';

	        menu.menu_item_array[i].set_menu_level( top_levels_after_wrap );
	        menu.menu_item_array[i].set_root_item_width( current_width_usage );
	   
	   	if (typeof(window.parent.menu_section) != "undefined"){
			   if (window.parent.menu_section == ("td" + menu.menu_item_array[i].menu_item_number) ){
			   	td_class_style = 'whitebolds';
		                top_colour = get_colour_schema(i);
		                top_index  = i;
				if (top_colour != "-1"){
	   			}
			   }
			}
			X_current_width_usage = ((char_pix*menu.menu_item_array[i].target_name.length).toString());
			//window.alert(current_width_usage);
		//window.alert((char_pix*menu.menu_item_array[i].target_name.length).toString());
		//window.alert('td' + menu.menu_item_array[i].menu_item_number);
		
	   	if(i==0){
		doc_write ( '<td>&nbsp;</td><td class="odyssey_root_menu" name="td' + menu.menu_item_array[i].menu_item_number + '" id="td' + menu.menu_item_array[i].menu_item_number + '" width=' + X_current_width_usage +' height=' + menu.menu_setup.n_menu_item_height + ' align = "center" onmouseover="javascript: menu_item_mouseover ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ',' + i + ' ); menu_sub_click ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ',' + i + ' );window.scrollTo(0, 0);" onmouseout="javascript: un_highlight_td( );menu_item_mouseout ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ' );">&nbsp;<a class="' + td_class_style + '" href="javascript: menu_item_click ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ' );" onmouseover="javascript: menu_item_mouseover ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ',' + i + ' ); menu_sub_click ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ',' + i + ' );window.scrollTo(0, 0);" onmouseout="javascript: un_highlight_td( );menu_item_mouseout ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ' );">' + menu.menu_item_array[i].target_name + '</a></td>' );
		}else{
		doc_write ( '<td class="sep">&nbsp;</td><td class="odyssey_root_menu" name="td' + menu.menu_item_array[i].menu_item_number + '" id="td' + menu.menu_item_array[i].menu_item_number + '" width=' + X_current_width_usage +' height=' + menu.menu_setup.n_menu_item_height + ' align = "center" onmouseover="javascript: menu_item_mouseover ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ',' + i + ' ); menu_sub_click ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ',' + i + ' );window.scrollTo(0, 0);" onmouseout="javascript: un_highlight_td( );menu_item_mouseout ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ' );">&nbsp;<a class="' + td_class_style + '" href="javascript: menu_item_click ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ' );" onmouseover="javascript: menu_item_mouseover ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ',' + i + ' ); menu_sub_click ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ',' + i + ' );window.scrollTo(0, 0);" onmouseout="javascript: un_highlight_td( );menu_item_mouseout ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ' );">' + menu.menu_item_array[i].target_name + '</a></td>' );
		
		}
	
	
		//current_width_usage += (char_pix*menu.menu_item_array[i].target_name.length);
	}
	
		
	doc_write ( '</tr></table>' );

}
//---------------------------------------------------------------------------------------------
// draw the popup menu

function draw_popup_menu ( menu,i )
{
//alert(i);
	if (menu.menu_item_array.length == 0){
		return;
	}
	
	// open the div/layer for the popup
	if ( document.layers )
		doc_write ( '<layer name="menubox' + menu.menu_number + '" pagey= ' + (i*50) + ' pagex=' + find_root_item_width( menu ) + ' width=' + menu.menu_setup.n_menu_item_width + ' z-index=' + menu.menu_setup.n_popup_z + ' visibility="hide">' );
	else
		doc_write ( '<div id="menubox' + menu.menu_number + '" style="position:absolute; top: ' + (i*50) + '; left:' + find_root_item_width( menu ) + 'px; z-index: ' + menu.menu_setup.n_popup_z + '; visibility:hidden;" >' );

	// draw all the menu items in a table
	//alert (find_root_item_width( menu ));
	draw_menu_items ( menu );

	// close the div/layer
	if ( document.layers )
		doc_write ( '</layer>' );
	else
		doc_write ( '</div>' );
}

//---------------------------------------------------------------------------------------------
// draws a table of menu items with href and mouse events - shared by root and sub menus
function draw_menu_items ( menu )
{
	var i,c;
	var col = 1;
    var menu_item_index;
	var padded_cell;
	var border_block;

	// we need to determine width used
	padded_cell = find_root_item_width(menu);
	
	
	//The popup Table starts...
	doc_write ( '<table width="700" border="0" cellspacing="0" cellpadding="0" >' );
	
	// render padded cell if it is greater then zero
	doc_write ( '<tr>' );
	
	//if (padded_cell > 0 ){
		//window.alert(find_root_item_width(menu));
	    //doc_write ( '<td onmouseout="close_all_sub_menus(daily);"  style="FILTER: alpha(opacity=20);" width=' + (find_root_item_width(menu)) + ' >&nbsp;</td> ');
	//}
	
//This is the table for the cells within the popup
	doc_write ( '<td valign="top"  >' );
	doc_write ( '<table id="menuboxtbl' + menu.menu_number + '" name="menuboxtbl' + menu.menu_number + '" border=0 cellpadding=0 cellspacing=0 style=""><tr>' );
	
        col = menu.menu_item_array.length/4;

	for ( i = 0; i < menu_item_rows; i++ )  //loop through rows (index 1)
	{
		doc_write ( '' );	// open a row tag;
		for (c=0;c<col;c++){ // render out the columns in the row
		        
			if (c>0){
				
			}
			//window.alert(menu.menu_item_array.length);
			menu_item_index = i + ( c * menu_item_rows);
			if(i==menu.menu_item_array.length){
			border_block = 1
			}else{
			border_block = 0
			}
			//change the colour of the drop down in here...remeber the style sheet.		
			if (menu_item_index < menu.menu_item_array.length){
			//window.alert (menu_item.sub_menu);
			//window.alert(menu.menu_item_array[menu_item_index].sub_menu);
			if (menu.menu_item_array[menu_item_index].sub_menu != null){
			var arrow = '<font face="Arial">&#9658;</FONT>';
			}else{
			var arrow = '';
			}
				doc_write ( '<td nowrap bgcolor="white" id="td' + menu.menu_item_array[menu_item_index].menu_item_number + '" name="td' + menu.menu_item_array[menu_item_index].menu_item_number + '" valign="top" class="odyssey_menu_item" height=' + (15) + ' onmouseover="javascript:menu_item_mouseover ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ',' + i + ' ); menu_sub_click ( window.menu_item_' + menu.menu_item_array[i].menu_item_number + ',' + i + ' );reset_timer( window.menu_' + menu.menu_number + '.menu_setup);menu_item_mouseover ( window.menu_item_' + menu.menu_item_array[menu_item_index].menu_item_number + ',-1 );" onmouseout="javascript: menu_item_mouseout ( window.menu_item_' + menu.menu_item_array[menu_item_index].menu_item_number + ' );">&nbsp;&nbsp;&nbsp;<a class="odyssey_menu_item" href="javascript: menu_item_click ( window.menu_item_' + menu.menu_item_array[menu_item_index].menu_item_number + ');">' + menu.menu_item_array[menu_item_index].target_name + '</a>&nbsp;&nbsp;&nbsp;</td>' );			
			}else{
				
			}			
		}
		
	        doc_write ( '' );	//close the row tag		
		
	}

      	doc_write ( '</tr></table>' );
	doc_write ( '</td>' );
	if (padded_cell > 0 ){
	   // doc_write ( '<td  onmouseout="close_all_sub_menus(daily);" style=""  width=' + (root_menu_width - (root_item_width + padded_cell)).toString() + ' >&nbsp;1</td> ');
	}	
	doc_write ( '</tr><tr><td height=8 onmouseout="close_all_sub_menus(daily);"></td></tr>' );
	
	doc_write ( '</table>' );
}
//---------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------
//								MENU RUN TIME FUNCTIONS
//---------------------------------------------------------------------------------------------
// perform this function when user clicks on a menu item
function menu_item_click ( menu_item)
{
        
	if (typeof(highlighted_td) != "undefined")	        
	    window.parent.g_menu_number = -1;
	
	if ( menu_item.target_url != '' )
	{
	
	        if (typeof(highlighted_td) != "undefined"){
		   window.parent.menu_section = highlighted_td;
		}   

		if (menu_item.sub_menu != null){			
			window.parent.g_menu_item       = menu_item.menu_item_number;			
			window.parent.g_menu_number     = menu_item.menu.menu_number;
		
		}
				
		window.location.href = 	menu_item.target_url;
		
	}
	
	close_all_sub_menus ( menu_item.menu.menu_setup );
}
//--------------------------------------------------------------------------------------
function get_total_width_to_point( menu_item ){

	var total_width;
	var item_width;
	var start_pos;

		
	total_width = 0;
	start_pos   = 186;
	
	total_width = start_pos;
	
	//item_width = menu_item.menu.menu_setup.n_menu_item_width-18;
	item_width = 100;
		
	for ( i = 0; i < menu_item.menu.menu_item_array.length; i++ )
	{

	  if (menu_item.menu.menu_item_array[i].menu_item_number ==  menu_item.menu_item_number) {
	  	 //window.alert("found item pos:" + i + " , number" + menu_item.menu.menu_item_array[i].menu_item_number);
//		 total_width += item_width;
	  	 return total_width;
	  }
	  else{
//	  	total_width += menu_item.menu.menu_item_array[i].
		total_width += item_width;
	  }
	  
	}

	// need to decide if I am going to return -1 or some error or the total
	// width calculated up to this point
	return 0;
	
}
//---------------------------------------------------------------------------------------------
// perform this function when user clicks on a menu item's sub menu button

function menu_sub_click ( menu_item, rt_index )
{

	var close_menus;
	var x_pos
	var menu_level;
	var level = 100;
	var test = 100;
	x_pos = get_total_width_to_point( menu_item )
	
	
	// if there is a sub menu, show it
	
	if ( menu_item.sub_menu != null ){
	
			// register this menu on the chain of open menus, this will return a list of menus that need to be closed
			close_menus = menu_item.menu.menu_setup.add_open_menu ( menu_item.menu, menu_item.sub_menu );
			for (var i = 0; i < close_menus.length ; i++)
				
				set_div_property ( 'menubox' + close_menus[i].menu_number, 'visibility', 'hidden' );
			
			// make the sub menu visible and position it correctly
			if (menu_item.menu_level != null){
				menu_level = menu_item.menu_level;
				
			}else{
				menu_level = top_levels_after_wrap;
		}
		//alert (menu_item.sub_menu);
	// set the top property for the popup block
	
	set_div_property ( 'menubox' + menu_item.sub_menu.menu_number, 'top', 10);
	
	
	if (typeof(top_colour) != "undefined"){
		     
	    //set_div_property ( 'menuboxtbl' + menu_item.sub_menu.menu_number, 'backgroundColor', 'white');
		}
		
		//	set the left property for the popup block
		
		set_div_property ( 'menubox' + menu_item.sub_menu.menu_number, 'left', (eval('td' + menu_item.menu_item_number).offsetLeft)+5);
		
		
		if(eval('td' + menu_item.menu_item_number).offsetLeft!=1){
			
				//var XCX = getElementsByClassName(document, "*", "odyssey_root_menu");	
				//	for (var ii=0;ii<XCX.length;ii++){
				//		if (ii==0||ii==2||ii==4||ii==6||ii==10){
	 					//	alert(XCX[ii].offsetWidth);
				//		}
				//	}
				
				level=30;
				
				if	(mouse_x >= 0 && mouse_x <= 155){
						test=10;
					}
				if	(mouse_x >= 155 && mouse_x <= 290){
						test=10;
					}
				if	(mouse_x >= 290 && mouse_x <= 360){
						test=10;
					}
				if	(mouse_x >= 360 && mouse_x <= 440){
						test=10;
					}
				
							
				if(menu_item.target_name.length>24){
				level=level+20;
				} 
				
				//set_div_property ( 'td' + menu_item.menu_item_number, 'backgroundColor', 'white');
				set_div_property ( 'menubox' + menu_item.sub_menu.menu_number, 'left', test);
				set_div_property ( 'menubox' + menu_item.sub_menu.menu_number, 'top', level);
				
								
		}
		if(eval('td' + menu_item.menu_item_number).offsetLeft==1){
				
				if	(event.y >= 80 && mouse_y <= 102){
						alert(mouse_y);
						level=20;
					}
				if	(mouse_y >= 103 && mouse_y <= 124){
						alert(mouse_y);
						level=41;
					}
				if	(mouse_y >= 125 && mouse_y <= 146){
						level=62;
					}
				if	(mouse_y >= 147 && mouse_y <= 168){
						level=83;
					}
				if	(mouse_y >= 169 && mouse_y <= 190){
						//alert(mouse_y);
						level=104;
					}
				if	(mouse_y >= 191 && mouse_y <= 212){
						//alert(mouse_y);
						level=125;
					}
				if	(mouse_y >= 213 && mouse_y <= 234){
						level=146;
					}
				if	(mouse_y >= 235 && mouse_y <= 256){
						level=167;
					}
					
					
					
				
				if	(mouse_x >= 0 && event.x <= 155){
						test=10;
					}
				if	(mouse_x >= 155 && mouse_x <= 290){
						test=158;
					}
				if	(mouse_x >= 280 && mouse_x <= 435){
						test=440;
					}
				if	(mouse_x >= 435 && mouse_x <= 440){
						test=360;
					}
				
				if(menu_item.target_name.length>24){
					level=level+20;
				} 
				
				//set_div_property ( 'td' + menu_item.menu_item_number, 'backgroundColor', 'white');
				set_div_property ( 'menubox' + menu_item.sub_menu.menu_number, 'left', test);
				set_div_property ( 'menubox' + menu_item.sub_menu.menu_number, 'top', level);
				
		}
		//window.alert(eval('td' + menu_item.menu_item_number).offsetParent.offsetWidth);
				
		//if(rt_index==0){menubox' + menu.menu_number +
		
		//}else{
		//set_div_property ( 'menubox' + menu_item.sub_menu.menu_number, 'left', 120);
		//}
		//- (mouse_y - menu_item.menu.menu_setup.n_offset_y) % menu_item.menu.menu_setup.n_menu_item_height );
		set_div_property ( 'menubox' + menu_item.sub_menu.menu_number, 'visibility', 'visible' );
		
		
		// start / restart the timer that will close all menus
		
		if (menu_item.menu.menu_setup.close_timer_running)
			clearTimeout (menu_item.menu.menu_setup.close_timer);
		menu_item.menu.menu_setup.close_timer_running = true;
		menu_item.menu.menu_setup.close_timer = setTimeout ( 'close_all_sub_menus ( window.menu_item_' + menu_item.menu_item_number + '.menu.menu_setup );', 4000 );

/* UNCOMMENT TO FIGURE OUT OFFSET	
		alert (menu_item.menu.menu_setup.n_offset_y);
		menu_item.menu.menu_setup.n_offset_y ++;
*/
	}
}

//---------------------------------------------------------------------------------------------

function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}
//---------------------------------------------------------------------------------------------


function menu_sub_hide ( menu_item )
{
	var close_menus;
	if ( p_mouse_x < mouse_x ){
	  set_div_property ( 'menubox' + menu_item.sub_menu.menu_number, 'visibility', 'hidden' );	
	}  
}

//---------------------------------------------------------------------------------------------
// this will close all open sub-menus belonging to a menu-setup
function close_all_sub_menus ( menu_setup )
{
	var close_menus;

	// if the clear all timer is running, stop it now
	if (menu_setup.close_timer_running)
		clearTimeout (menu_setup.close_timer);
	menu_setup.close_timer_running = false;
	un_highlight_td( );
	//set_div_property ( 'InvestmentFundFactSheets', 'top', 218);
	//set_div_property ( 'InvestmentPartners', 'top', 220);
	//set_div_property ( 'PortfolioFactSheets', 'top', 190);
	//set_div_property ( 'business_units_ody', 'top', 280);
	//set_div_property ( 'business_units_ody_1', 'top', 280);

	// close all sub menus
	close_menus = menu_setup.remove_all_sub_open_menu ();
	for (var i = 0; i < close_menus.length ; i++)
		set_div_property ( 'menubox' + close_menus[i].menu_number, 'visibility', 'hidden' );
		
}

//---------------------------------------------------------------------------------------------
// write some text in the status bar
function status_change ( s_text )
{
	window.status = s_text;
}

//---------------------------------------------------------------------------------------------
// perform this function when user moves the mouse over a menu item
function menu_item_mouseover ( menu_item, rt_index )
{	

	//if(navigator.userAgent.indexOf("Firefox")!=-1){
//alert("using");
	//}else{
	if (menu_item.sub_menu == null && menu_item.menu.depth == 0){	        
		close_all_sub_menus ( menu_item.menu.menu_setup );
		setTimeout ( 'un_highlight_td( );', 2000 );
	}else{
		//clearTimeout ( 'un_highlight_td( );');
	}
	//event.style.cursor="wait";
	highlight_td( 'td' + menu_item.menu_item_number, rt_index );
	//window.alert(menu_item.menu.depth);

	// setting the window.status immediately on mouseover doesn't work
	//window.alert(menu_item.menu_item_number);
	status_change ( menu_item.target_name );
	setTimeout ( 'status_change ( \'' + escape_string ( menu_item.target_name ) + '\' );', 1 );
//}
}

//---------------------------------------------------------------------------------------------
// perform this function when user moves the mouse over a menu item
function menu_sub_mouseover ( menu_item )
{

	// setting the window.status immediately on mouseover doesn't work
	status_change ( menu_item.target_name );
	setTimeout ( 'status_change ( \'show sub menu items\' );', 1 );
	
}

//---------------------------------------------------------------------------------------------
// perform this function when user moves the mouse away from a menu item
function menu_item_mouseout ( menu_item )
{	
	//window.alert(menu_item)
	// clear window status
	status_change ( '' );
	
	
}

//---------------------------------------------------------------------------------------------
// perform this function when user moves the mouse away from a menu item
function menu_sub_mouseout ( menu_item )
{
	// clear window status
	status_change ( '' );
	//close_all_sub_menus ( menu_item.menu.menu_setup );
		
}

//---------------------------------------------------------------------------------------------
// capture mouse position
function on_mouse_move (e)
{
	// catch mouse location (necessary even when no menu is selected, for offset)
	p_mouse_x = mouse_x;
	
	if ( document.all )
	{
		mouse_x = event.x;
		mouse_y = event.y;
	}
	else
	{
		mouse_x = e.pageX;
		mouse_y = e.pageY;
	}
}
// register the popup menu move function with the mousemove listener handler
register_for_mouse_move ( on_mouse_move );


//---------------------------------------------------------------------------------------------
		
function highlight_td( td_name, rt_index )
{
    var highlight_colour;
    
           
	if ( document.getElementById && ( document.getElementById ( td_name ) != null ) ){
           //     if (rt_index > 0 || rt_index == 0) 
                   highlight_colour = "white";
           //     else
           //        highlight_colour = get_colour_schema(0);
		un_highlight_td();
		eval ( "document.getElementById ( '" + td_name + "' ).style.backgroundColor='white'" );		
		eval ( "document.getElementById ( '" + td_name + "' ).style.cursor='default'" );
		highlighted_td = td_name;
	}
}

//---------------------------------------------------------------------------------------------

function un_highlight_td( ){

	if (highlighted_td != null){
		if ( document.getElementById && ( document.getElementById ( highlighted_td ) != null ) ){
			eval ( "document.getElementById ( '" + highlighted_td + "' ).style.backgroundColor=''" );		
			highlighted_td = null;
		}
	
	}

}

//---------------------------------------------------------------------------------------------

function get_colour_schema(root_index){

  var return_val = "-1";
  var root_index;
  var tmp_obj;
  
  if (typeof(window.parent.schemas) == "undefined"){
    if (typeof(schemas) == "undefined"){
       return return_val;
    }else{
       tmp_obj = schemas;
    }    
  }else{
    tmp_obj = window.parent.schemas;
  }
  
  if (root_index == -1 || root_index > tmp_obj.length){
    return_val = tmp_obj[0][tmp_obj.length];
  }else{
    return_val = tmp_obj[root_index][tmp_obj.length];
  }

  return return_val;
  
}

//---------------------------------------------------------------------------------------------

function set_top_div_height(){

	top_for_div = window.parent.default_top_bar_height + orig_top_div_pos;
	//window.alert("top_for_div:" + top_for_div);
	//window.alert(window.document.getElementById("context_banner").height);

}

//---------------------------------------------------------------------------------------------

//---- This is to create the search and the download images on the right -----
function make_search_image(img_index){

  var tmp_img = get_context_array_val(img_index);
  
  if (tmp_img != "-1")
     document.write('<img border=0 src="' + tmp_img + '" alt="" ><br>');  

}

//---------------------------------------------------------------------------------------------

function get_context_array_val(index_pos){

  var return_val = "-1";
  var root_index;
  var tmp_obj;
  
  if (typeof(window.parent.schemas) == "undefined"){
    if (typeof(schemas) == "undefined"){
       return return_val;
    }else{
       tmp_obj = schemas;
    }    
  }else{
    tmp_obj = window.parent.schemas;
  }
    
  if (top_index == -1 || top_index > tmp_obj.length){
        return_val = tmp_obj[0][4]
  }else{
     if (index_pos > tmp_obj.length){
        return_val = -1;
     }else{
        return_val = tmp_obj[top_index][index_pos];  
     }
  }
  
  return return_val;
}

//---------------------------------------------------------------------------------------------

function get_top_bar_logo_href(){

   var tmp = get_context_array_val(0);
   var return_val = "-1";
   if (!isNaN(tmp)){
      return_val = window.parent.context_top_bar_images[tmp][0];
   }
   return return_val;
   
}

//---------------------------------------------------------------------------------------------

function get_top_bar_logo_height(){

   var tmp = get_context_array_val(0);
   var return_val = "-1";
   if (!isNaN(tmp)){
      return_val = window.parent.context_top_bar_images[tmp][1];
   }
   return return_val;

}

//---------------------------------------------------------------------------------------------

function replace_top_bar_image(){

 var new_html;
 var tmp_href;
 var tmp_height;
 var curr_height_diff;

 tmp_height       = get_top_bar_logo_height();        
 tmp_href         = get_top_bar_logo_href();
 curr_height_diff = 0;
 
 if (tmp_href != "-1"){
    new_html = "<img src='" + tmp_href + "'>";
    curr_height_diff = tmp_height;
 }
 
 top_for_div = orig_top_div_pos + curr_height_diff;

 (window.document.getElementById("context_banner")).innerHTML = new_html;

}

//---------------------------------------------------------------------------------------------

function reset_timer(menu_setup){
   
   //window.alert(menu_setup.close_timer);
   //menu_setup.close_timer = null;
   clearTimeout (menu_setup.close_timer);
   
}