var _page = new Object()	
_page.topNav = new Array();	
_page.text = new Array();		
_page.link = new Array();		

_page.leftNav = new Array();  
_page.leftNavItem = ""			
_page.leftmenuarray = new Array();	
_page.flyoutarray = new Array();	
leftmenulength = 0;			
flyoutlength = 0;				
	
_page.values = new Object(); 	
_page.locales = new Object(); 
_page.currentLocale = ""
_page.hideGlobalStyle = false;	

/* Settings for microsite header */
_page.showLocales = true; 		/* Boolean to show the Locale selector */
_page.showGlobal = true; 		
_page.useGlobalStyle = false;	

/* Settings for extranet header */
_page.topNavType = "";				// External extranet navigation type
_page.pageWidth = "800";			// Default 800x600 in extranet
_page.topNavXN = new Array();		// Defined in extranet locale files 
_page.supportLinks = new Array(); 	// Multiple supportlinks in header
_page.customLogo = new Array();		// Custom logo attributes

_page.loadBrowserInfo = false; 			// Tmp added
_page.browserInfo = new Array();		// Tmp added

var browser = new BrowserDetect();
var useIframe = (browser.isIE5up &&  (!browser.isIE5x || browser.isIE55)); // Boolean to set use of iframe behind layers, only IE 5.5 or higher

var currSection = ""; 			
var menuDown = "";				
var dropDown = 0;
var hideMenu = 0;
var buttonOff = 0;
var section = '';

/*
****************************
***** General settings *****
****************************
*/

var menu_hide_delay = 600; 		// Delay of hiding all drop-down menus on a mouseout of the top-menu
var dropdown_show_delay = 200;	// Delay of showing the drop-down menu on a mouseover

var max_item_levels = 7;		// Max number of levels in the left menu, excluding flyouts
var max_menu_levels = 7;		// Max number of levels in the left menu, including flyouts	
var topmenu_dd_spacer = 6;		// Vertical space between the topmenu buttons and the corresponding dropdowns

var intTableCount = 0;
var tabTables = new Array();	// Tabbed table array

var arrLoad = new Array();		// Onload array

function include_mac(){
	// Add stylesheet for Mac
	var stylesheet_mac = "	<link rel=\"stylesheet\" type=\"text/css\" href=\"/data/mac.css\" />";
	document.write(stylesheet_mac);
}

function include_stylesheets(){
	// This function will be used to include stylesheets
	// Values in extra stylesheets will overrule values in global stylesheet
	
		//var stylesheet_global = "	<link rel=\"stylesheet\" type=\"text/css\" href=\"/data/styles_vrdm.css\" />\n"
		//document.write(stylesheet_global);

	// Show stylesheet for components
	var stylesheet_components = "	<link rel=\"stylesheet\" type=\"text/css\" href=\"/data/components.css\" />\n"
	document.write(stylesheet_components);
	

	if(browser.isMac){
		var stylesheet_mac = "	<link rel=\"stylesheet\" type=\"text/css\" href=\"/data/mac.css\" />\n"
		document.write(stylesheet_mac);
	}
	if(browser.isNS6x){
		// Add temp for fix NS6.2 drop down menu
		document.write("<style>td.dd-inactiveItem{font-size:80%;}td.dd-activeItem{font-size:80%;}.p-table_flyout{font-family:Verdana, Arial, Helvetica, sans-serif;font-size:70%;}</style>");
	}
	if(browser.isNS6x || browser.isNS7x){
		// Remove border-collapse for Netscape. This causes problems when JS files are included in the content area
		document.write("<style>.p-content-grid{border-collapse:inherit;}</style>");
	}
	if(browser.isNS7x){
		// Remove border in menu for Netscape. This was showing grids when menu should be  hidden
		document.write("<style>table.p-dropdown table td{border-width:0px;}</style>");
	}
	if(browser.isOpera && browser.isWin){
		var stylesheet_opera = "	<link rel=\"stylesheet\" type=\"text/css\" href=\"/data/opera.css\" />\n"
		document.write(stylesheet_opera);
	}
	
	// Adjust styles of some locales

	
}

_page.showProperties = function () {
    var text="";
    text+="_page properties:\n\n"
    for (var name in _page) {
       if (typeof(_page[name])=="string") {
           text+=name+": "+_page[name]+"\n";
       }
    }
    alert(text);
    
    return false;
}


	
	/*
	**********************************
	******* Top menu functions *******
	**********************************
	*/



	
	// This function returns the X position of 'objElement'
	function getLeftPos(objElement) {
		var offsetLeft = findPosX(objElement);
		return offsetLeft - 2;
	}

	
	// This function returns the Y position of 'objElement'
	// Note: instead of returning the top of the object, the bottom is returned!
	function getTopPosBottom(objElement) {
		var offsetTop = 0;
		var adjust = 0;
		
		if(objElement.offsetHeight!=33){
			// 33 is height of top menu (return bottom of object). Return top of object for rest.
			if(objElement.offsetHeight==34){
				// Two lines in flyout
				adjust = objElement.offsetHeight - 18;
			}
			else{
				adjust = objElement.offsetHeight - 20;
			}		
		}
		return findPosY(objElement) + objElement.offsetHeight - adjust;
	}

	// This function positions all the dropdown layers
	// Every dropdown is aligned with the corresponding menu-button
	function positionDropDown(section){
		var objButton = gE(section + 'button');
		var dd = gE('p-' + section + 'DD');
		var extra_left = 0;
		var extra_right = 0;

		// Position drop-down
		
		// If page direction is RTL, then dropdown aligns with right-side of button
		if(_page.direction=="rtl"){
			// Calculate space to move box to the left
			extra_left = dd.offsetWidth - objButton.offsetWidth - 4;
			extra_right=2
		}
		
		// Position the dropdown-menu
		sX(dd, getLeftPos(objButton)-extra_left);
		sY(dd, getTopPosBottom(objButton)); 	// Spacer defined in general settings 
		hE(dd);

		// If browser is not NS or IE5, set size and position the iframe behind dropdown
		if (useIframe) {
			var	ddframe = gE('p-' + section + 'IF');
			sH(ddframe, (dd.offsetHeight+3));
			sW(ddframe, (dd.offsetWidth+3));
			sX(ddframe, getLeftPos(objButton)-extra_left);
			sY(ddframe, getTopPosBottom(objButton)+ topmenu_dd_spacer); 	// Spacer defined in general settings
		}
	}

	
	// This function initiates the positioning of dropdowns and overlay fillers
	function initDropDowns(){
		for(counter=1;counter< menuArray.length;counter++) {
			positionDropDown(menuArray[counter]);
		}
		/* Move extra when RTL format */
		extra_right=0;
		if(_page.direction=="rtl"){extra_right=5};
		// Init current state of dropdowns overlay's
		hideAllMenus();
	}	

	
	/*
	*********************************
	****** Left menu functions ******
	*********************************
	*/

	// Object for left menu items
	function _Item(text, link, options) {		
		this.text = text;
		this.link = link;
		this.options = options;
		this.flyoutid = 0;
		this.flyoutopenid = 0;
		this.parentid = "";
		this.level = 0;				// Default level, incremented during item_update
		this.children = false;		// By default -> no children. Value is changed in _Item_update()
		this.showlink = true; 		// Show standard the links in the menu
		
		/* Temporary options added for Philips Lighting */
		this.hideChilds = false;	// Always use flyout instead of childs in left-menu
		this.showAll = false;		// Show all childs or not
		this.hideLink = false;		// Hide current link from left menu
	}	
	
	
		// This function loops through all leftmenu-items and sets all variables 
	function _Item_update(){
		var item_update;
		var active_item = _page.leftNavItem;
		var leftNavItem_level = getItemLevel(_page.leftNavItem);
		var debug_flyouts = ""; // Used for debug options
		
		for (z=0; z < _page.sortedArray.length; z++){
						
			item_update=_page.sortedArray[z];	
			item_update.level = getItemLevel(item_update.id);
			
			// If not a top-item:
			// - add the ID of the parent item
			// - set the parent to have children
			if (item_update.level > 1) {
				next_item = item_update.id.lastIndexOf("_");
				item_update.parentid = item_update.id.substr(0,next_item);
				_page.leftNav[item_update.parentid].children = true;
			}
				
			// Get extra options if option-string is not empty
			if(item_update.options != "" && typeof(item_update.options)!="undefined"){
				// First, split option-string in seperate options
				array_options = item_update.options.split(",")
				
				// Initial / default option values
				var flyout = 1;
				var disable_link = false;
				var hide_childs = false;
				var show_all = false;		
				var hide_link = false;
				var show_category = false;

				// Check for options
				for(i=0;i<array_options.length;i++){
					if(array_options[i].indexOf("flyout=no")==0){
						// Don't show flyout
						flyout=0;
					}
					else if(array_options[i].indexOf("link=no")==0){
						//Don't show links
						disable_link = true;
					}
					else if(array_options[i].indexOf("hidechilds=yes")==0){
						// Don't show childs directly, only as flyout
						hide_childs = true;
					}
					else if(array_options[i].indexOf("showall=yes")==0){
						// Show all childs
						show_all = true;					
					}
					else if(array_options[i].indexOf("hidelink=yes")==0){
						// Hide this link
						hide_link = true;					
					}
					else if(array_options[i].indexOf("category=yes")==0){
						// Hide this link
						show_category = true;					
					}
				}
				
				// Update status of hide_childs
				item_update.hideChilds = hide_childs;
				
				// Update status of show_all
				item_update.showAll = show_all;

				// Update status of hide_link
				item_update.hideLink = hide_link;
				
				// Update status of show_category, only shown at level 1
				if(item_update.level==1) item_update.showCategory = show_category;
				
				// Update flyout status of item
				if(flyout==0 && item_update.level < max_item_levels && hide_childs==false){
					// No flyout is needed for first 'max_item_levels' levels
					//alert(item_update.id);
					item_update.flyout = false;
				}
				else{
					if(item_update.level < max_menu_levels){
						// Only flyout on levels < 'max_menu_levels'
						item_update.flyout = true;
					}
					else{
						// Level >= 'max_menu_levels'
						item_update.flyout = false;
					}
				}
				
				// Update status of link should be shown of item
				// Disable link is set in parameters			
				if(disable_link){
					item_update.showlink = false;
				}
			}
			else{
				// Nothing defined in options
				if(item_update.level < max_menu_levels){
					// Only flyout on levels < 'max_menu_levels'
					item_update.flyout = true;
				}
				else{
					// Level >= 'max_menu_levels'
					item_update.flyout = false;
				}				
			}
						
			// Check if item is (parent of) active item and not more then 2 levels flyout
			active_item = _page.leftNavItem;
			item_update.active = false;
			
			// Check if this is the active item
			//if(item_update.id==active_item){
			//	item_update.showlink = false;
			//}
			
			for(i=0;i<leftNavItem_level;i++){
				// Check if current item matches the string
				if(item_update.id==active_item){
					item_update.active = true;
				}
				// Remove last two characters from string (one level less)				
				get_items = active_item.lastIndexOf("_");
				active_item = active_item.substr(0,get_items)
			}			
			
			// Check if current flyout is allowed to be rendered
			if(item_update.active) {
				// No flyout allowed for active item at level 1-4 (show children first)
				if(item_update.level < max_item_levels){
					item_update.flyout = false;
				}
			}
			else if(item_update.level>1) {
				if(_page.leftNav[item_update.parentid].flyout || item_update.parentid == _page.leftNavItem){
					// Parent has flyout or is active, flyout possible
					if(item_update.level>2 && _page.leftNav[_page.leftNav[item_update.parentid].parentid].flyout){
						item_update.flyout = false; // Grandparent already has flyout, flyout not allowed
					}
					else {
						if(item_update.flyout == true) {
						item_update.flyout = true;	// Parent has flyout or is active --> flyout is allowed
						}
					}
				}				
				else{
					item_update.flyout = false;
				}
			} 
			
			else if(item_update.level==1) {
				//item_update.flyout = false;
			}						
			else {
				item_update.flyout = false;
			}
			
			// If childs of active item are hidden in leftmenu, force flyout
			if(item_update.active == true && item_update.hideChilds == true && _page.leftNav[item_update.parentid].flyout == false) {
				item_update.flyout = true;
			}	
			
			// If item inherits a showall-property, all child are shown in leftmenu --> no flyout
			if (inheritsShowall(item_update)) {
				item_update.flyout = false;
			}
		}
	}

	/*
	***********************************
	****** Generate Left menu  ********
	***********************************
	*/
	_page.currentTime = function(){
		d = new Date(); 
    	time_hr = d.getHours(); 
  		time_min = d.getMinutes(); 
   		time_sec = d.getSeconds(); 
    	time_milli= d.getMilliseconds(); 
		total_time = time_hr + ":" + time_min + ":" + time_sec + ":" + time_milli;
		return total_time;
	}
	
	_page.writeLeftNav = function (activeItem) {
			include_stylesheets();
		// Set active item if given as function parameter
		if (activeItem != null && trim(activeItem) != "") {
			_page.leftNavItem = activeItem
		} else {
			_page.leftNavItem = "";
		}
		
		// Sort item array
		_Item_sort();
		
		// Update all items objects
		_Item_update();
		
		_page.leftmenuarray[leftmenulength++] = "<table id=\"p-table-left\" class=\"p-section-nav\" cellspacing=\"1\">\n";

		var active_level = getItemLevel(_page.leftNavItem);
		var current_level = 1;
		var previous_level = 0;
		var previous_item = "";
			
		for (z=0; z < _page.sortedArray.length; z++){
		 	anItem = _page.sortedArray[z].id;
			show_active = false;
			show_item = false;
			
			// Get level of current item
			current_level = _page.leftNav[anItem].level;
			
			// Check if item need to be shown
			// Only show if one of the following options is true:
			// Item is not hidden (hideLink)
			// - Item is level 1 item
			// - Item is active item
			// - Item is in currently opened menu
			if(_page.leftNav[anItem].hideLink){
				// Never show Link if this value is true
				show_item = false;
			}
			else{
			  if (current_level==1) show_item = true;	// First level items are always visible
			  else if (current_level > 1 && (_page.leftNav[anItem].active || (_page.leftNavItem!="" && _page.leftNav[_page.leftNav[anItem].parentid].id == _page.leftNavItem) || inheritsShowall(_page.leftNav[anItem]) || isSibling(_page.leftNav[anItem]))) {
				// An item-level should be < max_item_levels. No more levels are allowed on the left. A flyout is needed for the rest
				//alert(anItem + "-" + inheritsShowall(_page.leftNav[anItem]));
				
				if(_page.leftNav[_page.leftNav[anItem].parentid].hideChilds == true){
					//Check if this item is still active. Don't hide then
					if(_page.leftNav[anItem].active){
						show_item = true;
					}
					else{
						show_item = false;
					}
				}
				else if(current_level <= max_item_levels){
					show_item = true;
				}
			  }
			}
			if(show_item){
				if(previous_item!=""){
					// Skip first item
					if (previous_level!=1 && current_level !=1 && (current_level<previous_level)){
						_page.leftmenuarray[leftmenulength++] = "<tr><td><div class=\"p-solidsep\"> </div></td></tr>\n";
					}
				}
				
				// If flyout is allowed and children are present --> generate flyout 
				if(_page.leftNav[anItem].flyout && _page.leftNav[anItem].children){
					_page.flyout_create(anItem, 1)
				}
				
				// Add dotted seperator when a level 1 item starts, only not before the first one
				if (previous_level != 0){
					// Only show seperator when not the first item
					if (current_level==1 && previous_level!=1){
						//Only show dotted seperator when previous item is not a level 1 item
						_page.leftmenuarray[leftmenulength++] = "<tr><td><div class=\"p-dottedsep\"> </div></td></tr>\n";
					}
				}
				
				_page.leftmenuarray[leftmenulength++] = "	<tr>\n";
				// Get layout of this item
				if(_page.leftNav[anItem].showCategory) {
					set_class="p-left_level_"+ +current_level+ "_category";								// Category item
				}				
				else if(_page.leftNav[anItem].level==max_item_levels && _page.leftNav[anItem].flyout && _page.leftNav[anItem].children){
					set_class="p-left_level_" +current_level+ "_fly_active";		// Special item for flyout on active item on 'max_item_level'
				}
				else if(_page.leftNav[anItem].active && _page.leftNav[anItem].flyout) {
					set_class="p-left_level_" +current_level+ "_fly_active";		// Special item for flyout on active item with forced flyout
				}
				else if(_page.leftNav[anItem].active){
					set_class="p-left_level_" + current_level + "_open";			// Active item
				}
				else if(_page.leftNav[anItem].flyout && _page.leftNav[anItem].children){
					set_class="p-left_level_" + current_level + "_fly";				// Fly out item
				}
				else{
					set_class="p-left_level_" + current_level + "_closed";			// Inactive item
				}
				
				// Make sure no hand is shown when no link s available
				if(_page.leftNav[anItem].showlink==false){
					set_class += " p-nolink";
				}
								
				// Create item with or without mouseover for flyout 
				if (_page.leftNav[anItem].flyout && _page.leftNav[anItem].children && !_page.leftNav[anItem].showCategory){
					_page.leftmenuarray[leftmenulength++] = "		<td id='"+anItem+"' class=\""+set_class + "\" onmouseover=\"_page.flyout('"+anItem+"', 1);_page.item_mouseover('"+anItem+"');\" onmouseout=\"_page.flyout_hide('"+anItem+"');\"";
				}
				else {		
					_page.leftmenuarray[leftmenulength++] = "		<td id='"+anItem+"' class=\""+set_class + "\" onmouseover=\"_page.item_mouseover('"+anItem+"');\"";
				}
				
				// If this item has a link, create it
				if(_page.leftNav[anItem].showlink && !_page.leftNav[anItem].showCategory){
					_page.leftmenuarray[leftmenulength++] = "			><a id=\"left_level_link_"+anItem+"\" class=\"p-left-level_link_"+current_level+"\" href=\""+_page.leftNav[anItem].link+"\"";
					_page.leftmenuarray[leftmenulength++] = "			>"+_page.leftNav[anItem].text+"</a>";		
				} else {
					_page.leftmenuarray[leftmenulength++] = "			><span class=\"p-left-level_link_"+current_level+"\">"+_page.leftNav[anItem].text+"</span>";		// Item without link
				}

				_page.leftmenuarray[leftmenulength++] = "		</td>\n";
				_page.leftmenuarray[leftmenulength++] = "	</tr>\n";

				previous_level = current_level; // used to check if dotted seperator is needed
				previous_item = anItem; 		// used to check if solid seperator need to be shown
			}
		}
		_page.leftmenuarray[leftmenulength++]  = "</table>\n";
		
		// Write all items of menu
		total_menu_length=_page.leftmenuarray.length;
		for(nr=0;nr<total_menu_length;nr++){
			document.write(_page.leftmenuarray[nr]);
		}
					
		//Write all items of flyout menu
		document.write("<div id=\"flyoutitems\">");
		total_flyout_length=_page.flyoutarray.length;
		for(nr=0;nr<total_flyout_length;nr++){
			document.write(_page.flyoutarray[nr]);
		}
		document.write("</div>");
	}
	
	// This function generates a flyout layer for the current item
	_page.flyout_create = function(current_item, flyout_level){
		// Function to create the fly-out items
		nr_flyout = 1; // Counter for number of items
		flyoutmenu = "";	
		
		var current_level = getItemLevel(current_item);
					
		for(anItem2 in _page.leftNav){
			// Loop through all items in array
			// Check if current item ID is included in name and next level
			if(anItem2.indexOf(current_item + "_")==0 && (_page.leftNav[anItem2].level==current_level+1)){
				// Check if second level flyouts need to be generated
				
				if (_page.leftNav[anItem2].flyout && flyout_level==1 && _page.leftNav[anItem2].children){
					
					// Temp to store current position and menu
					temp_item = anItem2; 
					temp_flyoutmenu = flyoutmenu;
					temp_nrflyout = nr_flyout;
					
					// Generate 2nd level 
					_page.flyout_create(anItem2, 2);
									
					// Continue current position and menu
					anItem2 = temp_item; 		
					flyoutmenu = temp_flyoutmenu;
					nr_flyout = temp_nrflyout;
				}
													
				if(nr_flyout==1){
					// Add first part of table
					if(flyout_level==1){
						// Style for first level
						flyout_class="p-flyoutdiv";
					}
					else{
						// Style for second level
						flyout_class="p-flyoutdiv-2";
					}

					// Other style for first left part of item
					left_class = "p-flyout-left-first";
					
					flyoutmenu = "<div class=\""+flyout_class+"\" id=\"flyout_"+current_item+"\" onmouseover=\"_page.flyout_hide_cancel('"+current_item+"')\" onmouseout=\"_page.flyout_hide('"+current_item+"')\">\n";
					flyoutmenu += "	<table id=\"table-flyout\" class=\"p-table_flyout\" cellspacing=\"0\">\n";
					flyoutmenu += "	<tr>\n";
					flyoutmenu += "		<td class=\""+left_class+"\"><div id=\"right_arrow_"+current_item+"\" class=\"p-right_arrow\">&nbsp;</div><img alt=\"\" src=\"/images/spacer.gif\" width=\"16\" height=\"1\" /></td>\n";
					flyoutmenu += "		<td class=\"p-flyout-right\">\n"; 
					flyoutmenu += "			<table cellspacing=\"1\" width=\"100%\">\n"; 
					flyoutmenu += "				<tr>\n";
					
				}
				else{
					left_class = "p-flyout-left-middle";
				}
				
				if(_page.leftNav[anItem2].flyout && _page.leftNav[anItem2].children){
					// Add class for flyout
					content_class="p-flyout-content-flyout";
				}
				else{
					content_class="p-flyout-content";
				}
				// Make sure no hand is shown when no link is available
				if(_page.leftNav[anItem2].showlink==false){
					content_class += " p-nolink";
				}
					
				// Create item with or without flyout
				if (_page.leftNav[anItem2].flyout && flyout_level==1 && _page.leftNav[anItem2].children){
					flyoutmenu += "		<td	id='"+anItem2+"' class=\""+content_class+"\" onmouseover=\"_page.flyout('"+anItem2+"', 2);_page.item_mouseover('"+anItem2+"');\" onmouseout=\"_page.flyout_hide('"+anItem2+"')\"";
				}
				else {	
					flyoutmenu += "		<td	id='"+anItem2+"' class=\""+content_class+"\" onmouseover=\"_page.item_mouseover('"+anItem2+"');\"";
				}
				
				// Show item with/without link
				if(_page.leftNav[anItem2].showlink){
					flyoutmenu += " 		><a id=\"left_level_link_"+anItem2+"\" class=\"p-left-level_link_1\" href=\""+_page.leftNav[anItem2].link+"\"";
					flyoutmenu += "			>"+replaceAll(_page.leftNav[anItem2].text, '&nbsp;', ' ')+"</a>";
				}
				else{
					flyoutmenu += "			><span class=\"p-left-level_link_"+current_level+"\">"+_page.leftNav[anItem2].text+"</span>";		// Item without link
				}
				flyoutmenu += "			</td>\n";
				flyoutmenu += "		</tr>\n";
				nr_flyout += 1;
			}
		}

		flyoutmenu += "				</table>\n";
		flyoutmenu += "			</td>\n";
		flyoutmenu += "		</tr>\n";
		flyoutmenu += "	</table>\n";
		flyoutmenu += "</div>\n\n";
		
		// If needed for browsertype, create IFRAME to solve select-problem
       	if(useIframe) {
	    	flyoutmenu +="		<IFRAME frameborder=0 id=\"flyout-"+current_item+"-IF\" src=\"\" scroll=none style=\"FILTER:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);visibility:hidden;height:0;position:absolute;width:0px;top:0px;z-index:0\"></iframe>";
    	}	
		_page.flyoutarray[flyoutlength++] = flyoutmenu;
	}
	
	_page.flyout_cancel = function(current_item){
		// Cancel timeout for opening new flyout
		clearTimeout(_page.leftNav[current_item].flyoutopenid);
		// Reset id
		_page.leftNav[current_item].flyoutopenid = 0;	
	}
	
	_page.flyout = function(current_item, flyout_level){
		// Cancel possibile hide-action on current_item
		_page.flyout_hide_cancel(current_item);
		
		// If flyout is not scheduled, schedule it		
		if(_page.leftNav[current_item].flyoutopenid==0){
			// Wait short moment before flyout opens
			_page.leftNav[current_item].flyoutopenid = setTimeout("_page.flyout2('"+current_item+"', "+flyout_level+")", 100);
		}
	}
	
	_page.flyout2 = function(current_item, flyout_level){
		// Function to show the fly-out items
		// Hide all flyouts
		for(anItem_flyout in _page.leftNav){
			// Check if flyout is available and this is not the current item
			if(_page.leftNav[anItem_flyout].flyout && _page.leftNav[anItem_flyout].children && current_item!=anItem_flyout){
				// Don't close parent
				if(current_item.indexOf(anItem_flyout)!=0){
					_page.flyout_hide2(anItem_flyout);
				}
			}
		}
		
		dd = gE("flyout_" + current_item);
		var obj = gE(current_item)
		var arrow = gE("right_arrow_"+current_item);
		
		if(flyout_level==1){
			if(_page.direction=="rtl") {
				move_right = -158;
			} else {
				move_right = 173; 	/* 173 */
			}			
			move_up = 20; 		/* 19 */
		}
		else{
			if(_page.direction=="rtl") {
				move_right = -158;
			} else {
				move_right = 125; 	/* 121 */
			}	
			move_up = 21;		/* 21*/	
		}
		// Flyout x and y positions
		var xPos = getLeftPos(obj)+move_right;
		var yPos = getTopPosBottom(obj)-move_up;

		// Get browser dimensions		
		var scrollPosTop = getScrollPosTop();  				 // Positon top in scrolled browser window
		var screenHeight = getScreenHeight();				// Available height browser window
		var scrollPosBottom = scrollPosTop + screenHeight;	// Positon bottom in scrolled browser window	
		
		// Flyout dimensions
		var flyoutWidth = dd.offsetWidth;					// Flyout width
		var flyoutHeight = dd.offsetHeight;					// Flyout height
		var flyoutPosTop = findPosY(obj); 					// Top position of flyout
		var flyoutPosBottom = flyoutPosTop + flyoutHeight; 	// Bottom position of flyout
			
		// Adjust positioning from top or bottom
		var screenAvailable = scrollPosBottom - scrollPosTop;
		var flyoutHeightAvailable = scrollPosBottom - flyoutPosBottom;
		
		if(flyoutHeightAvailable < 0) {  
			var i = 1;
			var objTopPosBottom = getTopPosBottom(obj);
			var td_item = current_item + "_" + i;
			var objTD = gE(td_item);
			var loop = true;
	
			while(loop != false) {
				if(objTD != null) {
					// Calculate positions
					flyoutPosBottom = flyoutPosBottom - objTD.offsetHeight-1;
					yPos = flyoutPosBottom - flyoutHeight; 
					
					// Statements to set the position
					if(flyoutPosBottom < objTopPosBottom) {
						yPos = yPos + (objTopPosBottom - flyoutPosBottom +1);
						loop = false;
					}
					else if(yPos < scrollPosTop) {
						yPos = yPosPrev;
						loop = false;
					} 
					else if(flyoutPosBottom < scrollPosBottom) {
						loop = false;
					}
					yPosPrev = yPos;
					
					// Get next TD item
					i = i + 1;
					position = td_item.lastIndexOf("_");
					td_item = td_item.substring(0,position) + "_" +i;
					objTD = gE(td_item);
				} else {
					loop = false;
				}
			}			
		}
		
		// Position Arrow 
		move_up = (flyout_level==1?-1:0);
		position = flyoutPosTop-yPos-move_up;
		if(arrow!=null) sY(arrow, position);
		
		// Position Flyout and Iframe
		if(useIframe){
			var fframe = gE("flyout-"+current_item+"-IF");
			// Initiate iframe behind flyout
			sH(fframe, flyoutHeight);
			sW(fframe, flyoutWidth);
			sX(fframe, xPos);
			sY(fframe, yPos);
			sE(fframe);
		}		
		sX(dd, xPos);
		sY(dd, yPos);
		sE(dd);
		if(arrow!=null) sE(arrow);	
	}
	
	_page.flyout_hide_cancel = function(current_item){
		// Cancel timeout for hiding
		clearTimeout(_page.leftNav[current_item].flyoutid);
		// Reset id
		_page.leftNav[current_item].flyoutid=0;
		
		if(_page.leftNav[current_item].level>1){
			// Only cancel timeout for parent if item is not first level
			clearTimeout(_page.leftNav[_page.leftNav[current_item].parentid].flyoutid);
			// Reset id
			_page.leftNav[_page.leftNav[current_item].parentid].flyoutid=0;
		}
	}
	
	_page.flyout_hide = function(current_item){
		// Cancel direct the opening of the flyout
		_page.flyout_cancel(current_item);
		
		// Set interval before removing flyout
		if(_page.leftNav[current_item].flyoutid==0){
			_page.leftNav[current_item].flyoutid = setTimeout("_page.flyout_hide2('"+current_item+"')", 100);
		}
		
		if(_page.leftNav[current_item].level>1){
			// Only check parent if item is not first level
			if(_page.leftNav[_page.leftNav[current_item].parentid].flyout){
				// Check if parentis also flyout
				if(_page.leftNav[_page.leftNav[current_item].parentid].flyoutid==0){
					// Set interval before removing parent flyout
					_page.leftNav[_page.leftNav[current_item].parentid].flyoutid = setTimeout("_page.flyout_hide2('"+_page.leftNav[current_item].parentid+"')", 1000);
				}
			}
		}
	}
	
	_page.flyout_hide2 = function(current_item){
		// Hide flyout
		dd = gE("flyout_" + current_item);
		hE(dd);
		
		if (useIframe) {
	  		var fframe = gE("flyout-"+current_item+"-IF");
	  		hE(fframe);
		}
		// reset id
		_page.leftNav[current_item].flyoutid=0;

	}
	
	// Left navigation mouse over
	_page.item_mouseover = function(active_item) {
		var link_start = "left_level_link_";
		item_level = _page.leftNav[active_item].level

		// Only set underline if item has flyout	
		if(_page.leftNav[active_item].flyout && _page.leftNav[active_item].children) {
			objItem = gE(link_start + active_item);
			if(objItem!=null)objItem.style.textDecoration = "underline";
		}
		
		// Create array with all known allowed underlined items
		allowArray = new Array();
		var counter = 0;
		for(i=0;i<active_item.length;i++){
			if(active_item.charAt(i)!="_"){
				allowArray[counter] = active_item.substring(0,i+1);
				counter += 1;
			}
		}

		// Clear all items who are not in allowed array
		for(current_item in _page.leftNav){
			var clear = true;
			
			for(i=0;i<allowArray.length;i++){
				if(current_item == allowArray[i]) clear = false;
			}
		
			if(_page.leftNav[current_item].flyout && _page.leftNav[current_item].children) {
				objItem = gE(link_start + current_item);
				if(objItem!=null) {
					if(clear == false) {
						if(objItem.style.textDecoration != "underline") {
						objItem.style.textDecoration = "underline";
						}
					} else {
						if(objItem.style.textDecoration != "none") {
							objItem.style.textDecoration = "none";	
						}
					}
				}
			}
		}

	}
	
	// article tools
	_page.email = function(posturl) {
		// if(posturl!=""){
			// Go to next page where user can add details
			// doc_title = escape(document.title);
			// doc_url = encodeURI(document.location);
			// window.open(posturl + '?doc_title='+doc_title+'&doc_url='+doc_url, '_self');
		// }
		// else{
			// Open email client
			window.location='mailto:?subject='+escape(document.title)+'&body=Please see '+encodeURI(document.location);
			//window.location='mailto:?subject='+escape(document.title)+'&body="Please see '+escape(document.title)+' on: '+document.location+'"';
		//}
	}
	
	
	
	// Function to create cookie
	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		} else { 
			var expires = "";
			// document.cookie = name+"="+value+expires+"; path=/;domain=philips.com";
			document.cookie = name+"="+value+expires+"; path=/";
		}
	}	

	// Function to read cookie
	function readCookie(name)	{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++)	{
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length); // Remove spaces in front of cookie name
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	// Function to erase cookie
	function eraseCookie(name)	{
		createCookie(name,"",-1);
	}

	// Check if flash supports js communication
	function JS2FlashSupport(objFlashCheck) {
		if(objFlashCheck) {
			try {
				objFlashCheck.PercentLoaded()  // Sample communction function
				return "true";
			} catch (e) {
				return "false";
			}
		}
	}

	// Function which replaces the current sectionBanner
	
	
	
	
	// Function which set's active tab
	_page.showTab = function (intTable,intRow){	
		// Get table objects
		var tmpTableTop = gE("table_top"+intTable);
		var tmpTableContent = gE("table_content"+intTable);
		var rowsLength = gE("table_content"+intTable).rows.length;
		
		for(i=0;i<rowsLength;i=i+2){
			if(i==intRow){	
				//Display the tab as active.
				applyStyle(gE("headermain"+intTable+"_"+i),"p-tab-active");
				// Get selected boy node and duplicate it
				var tmpRowTop = tmpTableTop.rows[1];
				var tmpRowContent = gE("body"+intTable+"_"+(intRow+1));
				var tmpCellContentNew = tmpRowContent.firstChild;
				var tmpCellContentDup = tmpCellContentNew.cloneNode(true);
				applyStyle(tmpCellContentDup,"p-content");
				// Add extra cell and delete previous one
				tmpTableTop.rows[1].appendChild(tmpCellContentDup);
				tmpTableTop.rows[1].deleteCell(0);
				// Copy extra cell into new row
				var tmpRow = tmpRowTop.cloneNode(true);
				tmpRowTop.parentNode.insertBefore(tmpRow,tmpRowTop);
				tmpTableTop.deleteRow(1);
			}else{
				applyStyle(gE("headermain"+intTable+"_"+i),"p-tab-inactive");			
			}
		}
	}
 
 	// Function which creates tabbed tables
	_page.createTabs = function(intTableCount , tmpTableObj){
		var maxHeight = 0;
		var strTableType = tmpTableObj.type;
		// Set content table style to hidden or nodisply
		tmpTableObj.cellSpacing = 0;
		tmpTableObj.cellPadding = 0;
		applyStyle(tmpTableObj,(strTableType == "p-tab-double"?"p-tabbedtable-hidden":"p-tabbedtable-nodisplay"));
	
		// Create Main Table
		var tmpTable = document.createElement("table");
		var tmpBody = document.createElement("tbody")
		var tmpRow = document.createElement("tr");
		var tmpCell = document.createElement("td");
		tmpTable.id = "table_top"+intTableCount;
		applyStyle(tmpTable,(strTableType == "p-tab-double"?"p-extrainfo-double":"p-extrainfo-multiple"));
		tmpTable.cellSpacing = 0;
		tmpTable.cellPadding = 0;
		tmpCell.className = "p-top";
		tmpTableObj.parentNode.insertBefore(tmpTable,tmpTableObj);
		tmpTable.appendChild(tmpBody);
		tmpBody.appendChild(tmpRow);
		tmpRow.appendChild(tmpCell);
		
		//Process all rows and display the tabs
		maxRows = tmpTableObj.rows.length;
		intRow = 0;
		for(i=0;i<maxRows;i++) {
			curRow = tmpTableObj.rows[i];
			
			// Only process child rows, no nested table/rows (Opera compat. issue)
			if(curRow.parentNode.parentNode.id == tmpTableObj.id) {
			curRow.id = "body"+intTableCount+"_"+intRow;
				
				//Header row
				if(Math.round(intRow/2)==intRow/2){
					// Tab Header left
					var tmpDiv = document.createElement("div");
					applyStyle(tmpDiv,"p-tab-border-left");
					tmpDiv.id="headerleft"+intTableCount+"_"+intRow;
					tmpCell.appendChild(tmpDiv);					
				
					// Tab Header body
					var tmpDiv = document.createElement("div");
					applyStyle(tmpDiv,"p-tab-inactive");
					tmpDiv.id="headermain"+intTableCount+"_"+intRow;
					eval('tmpDiv.onclick = function() {_page.showTab('+intTableCount+','+intRow+')};');
					tmpCell.appendChild(tmpDiv);
				
					//Create a new text object in the cell object.
					var tmpText = document.createTextNode(ReplaceTags(curRow.firstChild.innerHTML));
					tmpDiv.appendChild(tmpText);
				
					// Tab Header right
					var tmpDiv = document.createElement("div");
					applyStyle(tmpDiv,"p-tab-border-right");
					tmpDiv.id="headerright"+intTableCount+"_"+intRow;
					tmpCell.appendChild(tmpDiv);
				
					// Tab spacer, only visibile between tabs
					if(tmpTableObj.rows[i+2]!=null) {
						var tmpDiv = document.createElement("div");
						applyStyle(tmpDiv,"p-tab-spacer");
						tmpCell.appendChild(tmpDiv);
					}	
				} else {
					// Get heighest tab
					if(strTableType=="p-tab-double") {
						var curHeight = curRow.firstChild.offsetHeight
						maxHeight = (curHeight>maxHeight?curHeight:maxHeight)
					}	
				}
			
				intRow++;
			} else {
				maxRows++;
			}
		}
		
		// Create body row
		var tmpRowBody = document.createElement("tr");
		var tmpCellBody = document.createElement("td");
		tmpBody.appendChild(tmpRowBody);
		tmpRowBody.appendChild(tmpCellBody);
		
		if(strTableType=="p-tab-double") {
			// Create bottom, only in double tabbed table
			var tmpRowBottom = document.createElement("tr");
			var tmpCellBottom = document.createElement("td");
			applyStyle(tmpCellBottom,"p-bottom");
			tmpBody.appendChild(tmpRowBottom);
			tmpRowBottom.appendChild(tmpCellBottom);
			
			// Create footer table in cell bottom
			var tmpTableFooter = document.createElement("table");
			var tmpBodyFooter = document.createElement("tbody");
			var tmpRowFooter = document.createElement("tr");
			tmpTableFooter.cellSpacing = "0";
			tmpTableFooter.cellPadding = "0";
			tmpCellBottom.appendChild(tmpTableFooter);
			tmpTableFooter.appendChild(tmpBodyFooter);
			tmpBodyFooter.appendChild(tmpRowFooter);
			
			// Left footer cell
			var tmpCellFooter = document.createElement("td");
			applyStyle(tmpCellFooter,"p-bottom-left");
			tmpRowFooter.appendChild(tmpCellFooter);
			
			// Right footer cell
			var tmpCellFooter = document.createElement("td");
			applyStyle(tmpCellFooter,"p-bottom-right");
			tmpRowFooter.appendChild(tmpCellFooter);
			
			//Set max height to each body row
			intRow = 0;
			for(z=0;z<tmpTableObj.rows.length;z++) {
				curRow = tmpTableObj.rows[z];
				sH(curRow.firstChild,maxHeight+6)
			}
	
			//Set content table back top display: none
			applyStyle(tmpTableObj,"p-tabbedtable-nodisplay");
		}	
	}	
 
	function processTables(moreLoad){	
		allTables=document.getElementsByTagName("table");
		for(k=0;k<allTables.length;k++){
			if(getStyle(allTables[k]) == "p-tab-multiple" || getStyle(allTables[k]) == "p-tab-double") {
				allTables[k].type = getStyle(allTables[k]);
				allTables[k].id="table_content"+(intTableCount+1);
				tabTables[intTableCount] = allTables[k];
				intTableCount++;
			}
		}

		intTableCount=0;
		for(j=0;j<tabTables.length;j++){
			//Create a handle to the table.
			tmpTableObj=tabTables[j];
			//Increase the table counter.
			intTableCount++;
			//Create the tabs for all tabbed tables.
			_page.createTabs(intTableCount, tmpTableObj);
			// Set active tab
			maxRows = tmpTableObj.rows.length;
			intRow = 0;
			var bActivated = false;
			for(i=0;i<maxRows;i++) {
			curRow = tmpTableObj.rows[i];
				// Only process child rows, no nested table/rows (Opera compat. issue)
				if(curRow.parentNode.parentNode.id == tmpTableObj.id) {
					if(getStyle(curRow) == "active") {_page.showTab(intTableCount,intRow);bActivated = true}
					intRow++;
				} else {
					maxRows++
				}
			}
			if(bActivated == false) _page.showTab(intTableCount,0);
		}
		// Reinitalize dropdowns if doload is set.
		if(typeof(moreLoad) != "undefined") {
			if(moreLoad == true) initDropDowns();
		}
	}
	
	// Add onload event
	function addOnLoadEvent(strEvent) {
		var curContainer = arrLoad.length;
		arrLoad[curContainer] = strEvent;
	}
	
	// Generic onload handler
	function onloadHandler() {
		// Load all arrays
		function doLoad() {
			for(k=0;k<arrLoad.length;k++) {
				eval(arrLoad[k]);
			}
		
		}

		//setup onload function
		if(typeof(window.addEventListener) != 'undefined')	{
			//.. gecko, safari, konqueror and standard
			window.addEventListener('load', doLoad, false);
		}
		else if(typeof(document.addEventListener) != 'undefined')	{
			//.. opera 7
			document.addEventListener('load', doLoad, false);
		}
		else	{
			//.. mac ie
			if(browser.isMac && browser.isIE) {
				// First load body onload, then load handler
				if(window.onload!=null) document.onload = window.onload();
				window.onload = doLoad;	
			//.. win ie
			}else {
				document.onload = doLoad();	
			}
		}
	
	}
	
	_page.font_resize = function (resize) {
		i=0;
		if(document.styleSheets[i].rules != undefined){	// IE
			for(j = 0; document.styleSheets[0].rules.length > j; j++){ //IE
				if(document.styleSheets[0].rules[j].selectorText.toLowerCase() == ".p-article"){
					current_size = document.styleSheets[0].rules[j].style.fontSize;
					current_size = current_size.substring(0,current_size.length-1); // Remove %
					current_size = parseInt(current_size);
					new_size = (current_size * resize);
					if(new_size>90 && new_size <110){
						// Reset size to 100%
						new_size=100;
					} 
					document.styleSheets[0].rules[j].style.fontSize = new_size + "%";
				}
			}
		} else{
			for(j = 0; document.styleSheets[0].cssRules.length > j; j++){ // Mozilla
				if(document.styleSheets[0].cssRules[j].selectorText.toLowerCase() == ".p-article"){
					current_size = document.styleSheets[0].cssRules[j].style.fontSize;
					current_size = current_size.substring(0,current_size.length-1); // Remove %
					current_size = parseInt(current_size);
					new_size = (current_size * resize);
					if(new_size>90 && new_size <110){
						// Reset size to 100%
						new_size=100;
					} 
					document.styleSheets[0].cssRules[j].style.fontSize = new_size + "%";
				}
			}
		}
			
	// Sace setting in Cookie
	// _page.setcookie_fontsize(new_size);
	}
	
	

	
	// Function which created array with all current browser information
	_page.setBrowserInfo = function () {
		// Flash 
		if(typeof(browser_flashInstalled) == "undefined") {
			FlashDetect();
		}	 
		_page.browserInfo["browser_flash_installed"] = browser.flashInstalled;
		_page.browserInfo["browser_flash_version"] = browser.flashVersion;
		
		// Philips browser compliancy			
		_page.browserInfo["browser_name"] = browser.name;
		_page.browserInfo["browser_version"] = browser.versionMinor;
		_page.browserInfo["browser_platform"] = browser.platform;
		_page.browserInfo["browser_dhtml"] = browser.isDHTML;
		_page.browserInfo["browser_dom"] = browser.isDOM;
		
		// Current browser supported
		_page.browserSupport = new Array();
		_page.browserSupport["1"] = [// Philips Supported browsers  / == if equal
										["win32","Internet Explorer",5.5],
										["win32","Internet Explorer",6],
										["win32","Netscape",6.2],
										["win32","Netscape",7],
										["win32","FireFox",1.0],
										["mac","Internet Explorer",5.23],
										["mac","Netscape",6.2],
										["mac","Netscape",7],
										["mac","Netscape",7.1]
									];									
		_page.browserSupport["2"] = [// Philips best-practise browsers  / => if equal or higher
										["win32","Internet Explorer",5],
										["win32","Mozilla",1.6],
										["win32","Opera",7.54],
										["win32","Firefox",0.9],
										["mac","Internet Explorer",5],
										["mac","OmniWeb",563],
										["mac","Firefox",0.9],
										["mac","Safari",1.2],
										["mac","Opera",7.54]
									];
									
		var intBrowserSupported = 3; // Default not supported (1/2/3)
		var fltMinBrowserVersion = parseFloat(browser.versionMinor);
		intBreak = false;
		for(id in _page.browserSupport) {
			if(intBreak == false) {
				for(intBrowser=0;intBrowser<=(_page.browserSupport[id].length-1);intBrowser++) {
					strBrowserPlatform = _page.browserSupport[id][intBrowser][0];
					strBrowserName = _page.browserSupport[id][intBrowser][1];
					fltBrowserVersion = parseFloat(_page.browserSupport[id][intBrowser][2]);
					// Match platform and browser name
					if((strBrowserName.toLowerCase() == browser.name.toLowerCase()) && (strBrowserPlatform == browser.platform)) { 
						switch (id){
						case "1": 
							// Equal same version 
							if( fltMinBrowserVersion == fltBrowserVersion) {intBrowserSupported = id; intBreak = true}; 
							break;
						case "2":
							// Equal or higher version
							if( fltMinBrowserVersion >= fltBrowserVersion) {intBrowserSupported = id; intBreak = true}; 
							break;
						}
					}
				}
			}	
		}
		_page.browserInfo["browser_supported"] = intBrowserSupported;
	}
	
	// Print all browser info
	_page.printBrowserInfo = function() {
		tableHTML = new Array();
		var table_count = 0;
		tableHTML[table_count++] = "<table class=\"p-table\" cellspacing=\"0\" id=\"12345\">\n";
		tableHTML[table_count++] = "	<tr>\n";
		tableHTML[table_count++] = "		<td class=\"p-header\"><H4>Browser info</H4></td>\n";
		tableHTML[table_count++] = "	</tr>\n";
		tableHTML[table_count++] = "	<tr>\n";
		tableHTML[table_count++] = "		<td class=\"p-content\">\n";
		tableHTML[table_count++] = "			<table cellspacing=\"0\">\n";
		tableHTML[table_count++] = "				<tr class=\"p-bold\">\n";
		tableHTML[table_count++] = "					<td>Id</td>\n";
		tableHTML[table_count++] = "					<td class=\"p-hl\">Value</td>\n";
		tableHTML[table_count++] = "				</tr>\n";
		if(_page.loadBrowserInfo == false) {
				tableHTML[table_count++] = "				<tr><td colspan=\"2\"><i>To retrieve browser info, make sure <b>_page.loadBrowserInfo = true;</b> has been set in the HTML header. </i></td></tr>\n";		
		} else {
			for(id in _page.browserInfo) {
				tableHTML[table_count++] = "				<tr>\n";
				tableHTML[table_count++] = "					<td>"+id+"</td>\n";
				tableHTML[table_count++] = "					<td class=\"p-hl\">"+_page.browserInfo[id]+"</td>\n";
				tableHTML[table_count++] = "				</tr>\n";
			}
		}		
		tableHTML[table_count++] = "			</table>\n";
		tableHTML[table_count++] = "		</td>\n";
		tableHTML[table_count++] = "	</tr>\n";
		tableHTML[table_count++] = "</table>\n";
		for(x=0;x<tableHTML.length;x++){
			document.write(tableHTML[x]);
		}
	}
	
	/*
	*****************************
	****** Helper functions *****
	*****************************
	*/
	// 1k DHTML API - standards version
	d=document;l=d.layers;op=navigator.userAgent.indexOf('Opera')!=-1;px='px';
	function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}if(d.getElementById)return d.getElementById(e);if(d.all)return d.all[e];else return null;}
	function sE(e){l?e.visibility='show':e.style.visibility='inherit';}
	function hE(e){l?e.visibility='hide':e.style.visibility='hidden';}
	function sZ(e,z){l?e.zIndex=z:e.style.zIndex=z;}
	function sX(e,x){l?e.left=x:op?e.style.pixelLeft=x:e.style.left=x+px;}
	function sY(e,y){l?e.top=y:op?e.style.pixelTop=y:e.style.top=y+px;}
	function sW(e,w){l?e.clip.width=w:op?e.style.pixelWidth=w:e.style.width=w+px;}
	function gW(e){if(l){return e.clip.width}else if(op){return e.style.pixelWidth}else{return e.style.width;}}
	function sH(e,h){l?e.clip.height=h:op?e.style.pixelHeight=h:e.style.height=h+px;}
	function sC(e,t,r,b,x){l?(X=e.clip,X.top=t,X.right=r,X.bottom=b,X.left=x):e.style.clip='rect('+t+px+' '+r+px+' '+b+px+' '+x+px+')';}
	function wH(e,h){if(l){Y=e.document;Y.open();Y.write(h);Y.close();}if(e.innerHTML)e.innerHTML=h;}

	// This function applies the style-class 'className' to the element 'elementId'
	function applyStyle(elementId, className) {
		if(browser.isIE){
			elementId.setAttribute("className", className);
		} else {
			elementId.setAttribute("class", className);
		}
	}
	
	// This function returns the current style of the element
	function getStyle(elementId) {
		if(browser.isIE){
			return elementId.getAttribute("className");
		} else {
			return elementId.getAttribute("class");
		}
	}
	
	function inheritsShowall(menu_item) {
		if(menu_item.level > 1 && _page.leftNav[menu_item.parentid].showAll == true && _page.leftNav[menu_item.parentid].active){
				return true;
		}
		else if (menu_item.level > 2 && (menu_item.level < getItemLevel(_page.leftNavItem)+1) && _page.leftNav[menu_item.parentid].active) {
			return inheritsShowall(_page.leftNav[menu_item.parentid]);
		}
		else return false;
	}

	//This function checks if this item is the sibling of the active item
	function isSibling(menu_item){
		if(_page.leftNavItem==""){
			// No selection
			return false;
		}
		else{
			// Check if current item and active item have the same parent
			if(menu_item.level>1){
				if(menu_item.parentid==_page.leftNav[_page.leftNavItem].parentid){
					return true;
				}
				else{
					return false;
				}
			}
			else{
					// Top level item
					return false;
			}
		}
	}

	// This function determines the level in the left menu of the passed item
	function getItemLevel(menu_item) {
		var counter = 1;
		for(i=0;i<menu_item.length;i++){
			if(menu_item.charAt(i)=="_"){
				counter += 1;
			}
		}
		return counter;
	}
	

	// This function returns the x-pos of 'obj'
	function findPosX(obj) {
		var curleft = 0;
		if (obj.offsetParent) {			
			while (obj.offsetParent) {
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x) curleft += obj.x;
		return curleft;
	}

	
	// This function returns the y-pos of 'obj'
	function findPosY(obj) {
		var curtop = 0;
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)	curtop += obj.y;
		return curtop;
	}

	// Returns top positon in scrolled browser window
	function getScrollPosTop(){
	var pos="";
		if(typeof(self.pageYOffset)!="undefined"){	
			pos = self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop) {
			pos = document.documentElement.scrollTop;
		}
		else if (document.body) {
			pos = document.body.scrollTop
		}
	return pos;	
	}   
	
	// Returns available height browser window
	function getScreenHeight(){
	var pos="";
		if(typeof(self.innerHeight)!="undefined"){	
			pos = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight) {
			pos = document.documentElement.clientHeight;
		}
		else if (document.body) {
			pos = document.body.clientHeight;
		}
	return pos;
	}
	
	// Flash detection
	function FlashDetect() {
		var flashInstalled = 0;			// 0 = not installed, 1 = unknown, 2 = installed 
		var flashVersion = 0;			// Flash version, default 0
		MSDetect = "false";				// MS IE detection, default false

		if (navigator.plugins && navigator.plugins.length)	{
			x = navigator.plugins["Shockwave Flash"];
			if (x)	{
				flashInstalled = 2;
				if (x.description)	{
					y = x.description;
					flashVersion = y.charAt(y.indexOf('.')-1);
				}
			} else {
				flashInstalled = 1;
			}
			if (navigator.plugins["Shockwave Flash 2.0"])	{
				flashInstalled = 2;
				flashVersion = 2;
			}
		} else if (navigator.mimeTypes && navigator.mimeTypes.length)	{
			x = navigator.mimeTypes['application/x-shockwave-flash'];
			if (x && x.enabledPlugin) {
				flashInstalled = 2;
		 	} else {
				flashInstalled = 1;
			}
		} else {
			MSDetect = "true";
		}

		// MS IE detect
		if(MSDetect == "true") {
			for(var i=9; i>0; i--){
				flashVersion = 0;
				try{
					var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
					flashVersion = i;
					flashInstalled = 2;
					break;
				}
				catch(e){
				}
			}
		}
	
		browser.flashInstalled = flashInstalled;
		browser.flashVersion = flashVersion;
	}
	
	// This function performs an extensive browser detection and stores 
	// all data in an object for later use.		
	function BrowserDetect() {
   		var ua = navigator.userAgent.toLowerCase(); 

   		// browser engine name
   		this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
		this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   		// browser name
   		if(ua.indexOf('opera') != -1) {this.isOpera = true; this.name = "Opera"};
   		if((ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) )) {this.isIE=true; this.name = "Internet Explorer"};
   		if(this.isGecko && ua.indexOf('gecko/') + 14 == ua.length) {this.isMozilla=true; this.name = "Mozilla"};
		if((this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) )) {this.isNS=true; this.name = "Netscape"};
   		if(ua.indexOf('firebird/') != -1) {this.isFirebird=true; this.name = "Firebird"};
		if(ua.indexOf('firefox/') != -1) {this.isFirefox=true; this.name = "FireFox"};
		if(ua.indexOf('safari/') != -1) {this.isSafari=true; this.name = "Safari"};
   		if(ua.indexOf('konqueror') != -1) {this.isKonqueror=true; this.name = "Konqueror"};
		if(ua.indexOf('omniweb') != -1) {this.isOmniweb=true; this.name = "Omniweb"};
		if(ua.indexOf('webtv') != -1) {this.isWebtv=true; this.name = "WebTV"};
		if(ua.indexOf('icab') != -1) {this.isICab=true; this.name = "Icab"};
		if(ua.indexOf('camino') != -1) {this.isCamino=true; this.name = "Camino"};
      
   		// spoofing and compatible browsers
   		this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   		this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
		// rendering engine versions
   		this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   		this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   
   		// browser version
		this.versionMinor = parseFloat(navigator.appVersion); 

   	   	// correct version number
   		if (this.isGecko && !this.isMozilla) {
			if(this.isFirefox) {
				this.versionMinor = parseFloat(ua.substring(ua.indexOf('firefox/')+8,ua.length));
			} else {
				this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
			}
   		}
   		else if (this.isMozilla) this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
	   	else if (this.isIE && this.versionMinor >= 4) this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
		else if(this.isSafari) this.versionMinor = parseFloat( ua.substring( ua.indexOf('safari/') + 7) );
		else if(this.isOmniweb) this.versionMinor = parseFloat(ua.substring( ua.indexOf('omniweb/v') + 9));
		else if(this.isOpera && !this.isMac) this.versionMinor = parseFloat(ua.substring( ua.indexOf('opera') + 6));
   		this.versionMajor = parseInt(this.versionMinor); 
   
   		// dom support 
		this.isDOM = (document.getElementById && document.createElement?true:false);
   		this.isDOM1 = (document.getElementById?true:false);
  		this.isDOM2Event = (document.addEventListener && document.removeEventListener?true:false);
		
		// dhtml support
		this.isDHTML = (document.getElementById || document.all || document.layers?true:false);
   
   		// css compatibility mode
   		this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   		// platform
		if(ua.indexOf('win') != -1) {this.isWin=true; this.platform="win"}
		if(this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1)){this.isWin32=true; this.platform = "win32"}
		if(ua.indexOf('mac') != -1){this.isMac=true; this.platform = "mac"}
		if(ua.indexOf('x11') != -1){this.isMac=true; this.platform = "unix"}
		if(ua.indexOf('linux') != -1){this.isMac=true; this.platform = "linux"}
   
   		// specific browser shortcuts
   		this.isNS6x = (this.isNS && this.versionMajor == 6);
   		this.isNS6up = (this.isNS && this.versionMajor >= 6);
   		this.isNS7x = (this.isNS && this.versionMajor == 7);
   		this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   		this.isIE5x = (this.isIE && this.versionMajor == 5);
   		this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   		this.isIE5up = (this.isIE && this.versionMajor >= 5);
   		this.isIE6x = (this.isIE && this.versionMajor == 6);
   		this.isIE6up = (this.isIE && this.versionMajor >= 6);
	}
	
	// Function which removes all tags from string
	function ReplaceTags(xStr){
		var regExp = /<\/?[^>]+>/gi;
        	xStr = xStr.replace(regExp,"");
        	return xStr;
	}		
	
	function replaceAll(streng, soeg, erstat) { 
		var st = streng;
  		if (soeg.length == 0) return st;
  		var idx = st.indexOf(soeg);
  		while (idx >= 0){  st = st.substring(0,idx) + erstat + st.substr(idx+soeg.length);
    		 idx = st.indexOf(soeg);
  		}
	  	return st;
	}

	function trim(s) {
  		// Remove leading spaces and carriage returns
    		while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')) {
    			s = s.substring(1,s.length);
	  	}

	 	// Remove trailing spaces and carriage returns
  		while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')) {
    			s = s.substring(0,s.length-1);
  		}
  		return s;
	}

	
	// This function sorts the leftnavigation menu by id
	_Item_sort = function () {
		//timer = "ITEM start:" + _page.currentTime() + "<br \>";
		_page.sortedArray = new Array();	// Array to sort left menu items
		var length = 0;
		var i = 0;
		for (id in _page.leftNav){
			_page.leftNav[id].id = id;
			_page.sortedArray[i] = _page.leftNav[id];
			i++;
		}
		//timer += "after sort1:" + _page.currentTime() + "<br \>";
		length = i;
		_page.sortedArray.sort(_Item_sort_left_nav);
		//timer += "after .sort:" + _page.currentTime() + "<br \>";
		_page.leftNav = new Array(length);
		for (i = 0; i < length; i++){
			_page.leftNav[_page.sortedArray[i].id] = _page.sortedArray[i];
		}
		//timer += "after sort2:" + _page.currentTime() + "<br \>";
		//document.write(timer);
	}
		
	_Item_sort_left_nav = function(arg1, arg2){
		var arg1IDs = arg1.id.split('_');
		var arg2IDs = arg2.id.split('_');
		var minLength = (arg1IDs.length <= arg2IDs.length ? arg1IDs.length : arg2IDs.length);
			
		for (var i = 0; i < minLength; i++){
			if (parseInt(arg1IDs[i]) < parseInt(arg2IDs[i])) return -1;
			if (parseInt(arg1IDs[i]) > parseInt(arg2IDs[i])) return 1;
		}
	
		if (arg1IDs.length < arg2IDs.length) return -1;
		if (arg1IDs.length > arg2IDs.length) return 1;
				
		return 0;
	}
	
