//***************************************************************************** // Menu object //***************************************************************************** var TOP_OFFSET_DEFAULT = 75; var TOP_MENU_OFFSET = 15; var LEFT_OFFSET_DEFAULT = -10; var RIGHT_OFFSET_DEFAULT = 20; var MAX_WIDTH = 920; var CURR_MENU = -1; var menuItems; function menuItem( text, width, height, left, top, searchIdx, data ) { this.recalc = true; this.text = text; this.width = width; this.height = height; this.left = left; this.top = top; this.searchIdx = searchIdx; this.data = data; } function showMenuItem() { // position the div and display the nav if (this.data != '') { var shim = document.getElementById("shim"); var menu_div = document.getElementById("top_nav"); menu_div.style.width = this.width+"px"; menu_div.style.left = this.left+"px"; menu_div.style.top = this.top+"px"; menu_div.style.display = 'block'; menu_div.innerHTML = this.data; shim.style.width = this.width+"px"; shim.style.height = menu_div.offsetHeight +"px"; shim.style.left = this.left+"px"; shim.style.top = this.top+"px"; shim.style.display = 'block'; } } function hideMenuItem() { var navItem = document.getElementById ("tnav" + CURR_MENU); if( navItem ) navItem.className = "white_n"; CURR_MENU = -1; var menu_div = document.getElementById("top_nav"); menu_div.style.display = 'none'; var shim = document.getElementById("shim"); shim.style.display = 'none'; return true; } function recomputeLayout(elem) { if( this.recalc ) { var width = window.document.body.clientWidth; if( width > MAX_WIDTH ) width = MAX_WIDTH; if( width > (this.width + this.left) ) this.left = elem.offsetLeft + LEFT_OFFSET_DEFAULT; else this.left = width - (this.width + RIGHT_OFFSET_DEFAULT); this.top = elem.offsetTop + TOP_MENU_OFFSET; p = elem.offsetParent; while(p) { if( width > (this.width + this.left) ) this.left += p.offsetLeft; else this.left = width - (this.width + RIGHT_OFFSET_DEFAULT); this.top += p.offsetTop; p = p.offsetParent; } this.recalc = false; } }; menuItem.prototype.show = showMenuItem; menuItem.prototype.hide = hideMenuItem; menuItem.prototype.layout = recomputeLayout; //***************************************************************************** // Menu functions //***************************************************************************** function displayitems(elem) { var idx = elem.id.replace( /tnav/, "" ); var anItem = menuItems[idx]; anItem.layout(elem); //identify clicked link so it can be highlighted if (CURR_MENU != idx) { // hide the old item if(CURR_MENU != -1) { var oldItem = menuItems[CURR_MENU]; if(oldItem) oldItem.hide(); var oldElem = document.getElementById ("tnav" + CURR_MENU); if( oldElem ) oldElem.className = "white_n"; } // load the html if (anItem.data == '') { var menu_div = document.getElementById("top_nav"); menu_div.style.display = 'block'; menu_div.style.width = anItem.width+"px"; menu_div.style.left = anItem.left+"px"; menu_div.style.top = anItem.top+"px"; menu_div.innerHTML = "Loading..."; var ajaxData = new Ajax; ajaxData.getXml("/include/top_nav_items.asp", "top_nav_id=" + anItem.searchIdx, anItem, loadMenuHtml) } else { anItem.show(); } elem.className = 'yellow'; CURR_MENU = idx; } else { anItem.hide(); } return false; } function loadMenuHtml(anItem, html) { html_response = html.responseText; if (html_response != "") { anItem.data = html_response; anItem.show(); } } function hidemenuitem() { if( CURR_MENU != -1 ) menuItems[CURR_MENU].hide(); } var oldResizeFunction = window.onresize; function handleResize() { if( menuItems ) { for (i = 0; i < menuItems.length; i++) { menuItems[i].recalc = true; } if( CURR_MENU != -1 ) { menuItems[CURR_MENU].hide(); } } if(oldResizeFunction) oldResizeFunction(); } window.onresize = handleResize; //***************************************************************************** // Search functions //***************************************************************************** function ConstructURL(u,remove,add) { var p = BuildURLArray(u); var n = ""; for (var i=0; i