/* copyright 2005 Houston Chronicle ChronMenu.js - author: John StG to force a section add window.CurrentSection=[0..11] before this script */ var dom=document.getElementById&&!document.all;var mousex,mousey;var agt=navigator.userAgent.toLowerCase();var prefix='/new_nav/ChronMenu_rc1.html?';var _ISIE = document.all && window.ActiveXObject && (agt.indexOf("msie") > -1);var cMenus = new Array(12);var cSubMenus = new Array();var cFocusedMenu = null;var widthMarker = 0;var YFudge = _ISIE?1:0;var XFudge=(_ISIE)?0:-8; var IEsubmenu = new Array();var _ISOPERA=(agt.indexOf("opera") > -1);var _ISMAC=(agt.indexOf("mac") > -1);var appVer=parseFloat(navigator.appVersion);var _ISFF = (agt.indexOf('firefox') != -1);if(_ISFF){_ISFF=Number(agt.match(/firefox\/(\d\.?\d?)/)[1]);};var _ISMOZ=(agt.indexOf("mozilla") > -1);if(_ISMOZ){_ISMOZ=_ISIE?false:appVer;} var sections = new Array([['home'],0,'cmblue','','',''],[['news'],1,'cmblue','','',''], [['sports'],2,'cmblue','','',''], [['business'],3,'cmblue','','',''], [['entertainment','comics','dining','clubs','BandPub'],4,'cmblue','cmorange','Ent','cSuborange'], [['life'],5,'cmblue','','',''], [['travel'],6,'cmblue','','',''], [['blogs'],7,'cmblue','','',''], [['jobs'],8,'cmorange','','',''], [['realestate','homesource'],9,'cmorange','','',''], [['cars'],10,'cmorange','','',''],[['class'],11,'cmorange','','','']); function setupMenus() { var cmenu = getObj('chronMenu'); if (!cmenu) {return false;} var currSection = getCurrentSection(); var sectionClass = currSection[2]; var SectionStyle = currSection[4]; var cmHigh = ' high'+SectionStyle; var CurrentPos = currSection[1]; var i=0; var chronM=getObj('chronMenu'); for(i in chronM.childNodes) { var cm=chronM.childNodes[i]; if (cm.nodeName=='DIV') { cm.onmouseover=function(){cmShow(this);} cm.onmouseout=function(){this.className=this.className.replace(' hover','');} } } for (i=0;i=0) { var calcleft = (menu.cwidth-parseInt(menu.submenu.style.width)-3)+ 'px'; menu.submenu.style.left = calcleft; } if(_ISIE ||(_ISFF?_ISFF>=1.5:false)){createShim(menu);} /* Sorry opera and Mac users..and just about everyone else, didn't have the time to figure out how to shim flash for you. */ } function getCurrentSection() { var loc = document.location.toString(); if (!window.CurrentSection) { for (var i=0;i-1) {window.CurrentSection=i;} } } } if(!window.CurrentSection){ window.CurrentSection=0; } else if (window.CurrentSection ==-1) { var sect = [['home'],0,'cmblue','','','']; return sect; } return sections[window.CurrentSection]; } function cmShow(mvr) { mvr.className+=' hover'; var menu=cMenus[mvr.firstChild.firstChild.id]; if(!menu) {return;} if (menu.submenu && menu.submenuShim) { if (menu.submenuShim.height==300 || menu.xBounds.y1==menu.xBounds.y0) { menu.xBounds=getBounds(menu.submenu); var cheight=menu.submenu.offsetHeight; menu.submenuShim.height=cheight; if(menu.submenuShim2){ menu.submenuShim2.height=cheight; } } } if(_ISFF && _ISFF<1.5) { for (i=0;i<12;i++) { var clr=getObj('hover'+(i+1)); if(clr) { if(clr!=mvr) { clr.className=clr.className.replace(' hover',''); } } } } } function createShim(menu){ var div = menu.submenu; // var subm = (div.offsetParent)?div.offsetParent:div.parentNode; var obj=getObj('hover'+menu.pos); var shim=newNode('iframe'); shim.className="cshim"; shim.id="cShim_iframe"+menu.pos; shim.frameBorder="0" shim.scrolling="no" shim.height=parseInt(div.offsetHeight)||300; shim.width=div.offsetWidth||153; shim.style.left=div.style.left; obj.appendChild(shim); menu.submenuShim=shim; shim = getObj('cShim_flash'); if (shim) { shim2 = shim.cloneNode(true); shim2.style.left=div.style.left; obj.appendChild(shim2); menu.submenuShim2=shim2; } } function cAttachEvent(obj,evt,func) { if (obj.addEventListener) { obj.removeEventListener(evt,func, false); obj.addEventListener(evt,func, false); } else if (obj.attachEvent){ obj.detachEvent("on"+evt,func); // Bug fix line obj.attachEvent("on"+evt,func); } } function cShow(obj) { var theObj = getObj(obj); if (theObj) { if (!_ISIE && theObj.tagName.toUpperCase()=='TR') { theObj.style.display = "table-row"; } else if (theObj.getAttribute('displaytype')) { theObj.style.display = theObj.getAttribute('displaytype'); } else { theObj.style.display = 'block'; } theObj.style.visibility = "visible"; } } // Set the visibility of an object to hidden function cHide(obj) { var theObj = getObj(obj); if (theObj) { theObj.style.display = "none"; theObj.style.visibility = "hidden"; } } function getObj(obj) { if (!obj) {return null} var theObj=false; if (typeof obj == "string") { theObj = document.getElementById(obj); } else { // pass through object reference theObj = obj; } return theObj; } function newNode(tagnme) { var ele = document.createElement(tagnme); return ele; } function newText(txt) { var txtnode = document.createTextNode(txt); return txtnode; } function findPosX(obj){ var curleft = 0; if (obj.offsetParent||obj.parentNode){ while (obj.offsetParent||obj.parentNode){ curleft += (obj.style&&obj.style.left)?parseInt(obj.style.left):obj.offsetLeft; obj = obj.offsetParent||obj.parentNode; } } else if(obj.style && obj.style.left) { curleft = obj.style.left; } return curleft; } function findPosY(obj){ var curtop = 0; if (obj.offsetParent||obj.parentNode){ while (obj.offsetParent||obj.parentNode){ curtop += (obj.style&&obj.style.top)?parseInt(obj.style.top):obj.offsetTop; obj = obj.offsetParent||obj.parentNode; } } else if (obj.style && obj.style.top) { curtop = parseInt(obj.style.top); } return curtop; } function getBounds(ele,xAdj,yAdj) { xAdj=(xAdj)?xAdj:0;yAdj=(yAdj)?yAdj:0; var coords = new Array(); coords.x0 = findPosX(ele)+xAdj; coords.y0 = findPosY(ele)+yAdj; coords.x1 = coords.x0+(ele.offsetWidth||ele.style?parseInt(ele.style.width):0)-xAdj; coords.y1 = coords.y0+(ele.offsetHeight||0)-yAdj; return coords; }