/*********************************************************************************************************** * MODULE: JSCNMDefault.js [ CNM v1.050503.0 ] * Author: Christopher Sheldon [ MicroAge Consulting Services ] * Web: [ http://www.microagesolutions.com ] * Notes: Do not reproduce or distribute this code without express permission from MicroAge IT Solutions. **/ var iCNMChildHideDelay = 500; var iCNMParentZIndex = 10000; var iCNMCurrentChild = 0; var iCNMActiveParent = 0; var iCNMChildCount = 1; var bCNMChildDown = true; var bCNMChildRight = true; var oCNMParentCopy = new Object; var iCNMChildTimer; var sCNMClassCopy; // General Initialization bIsIE = (document.getElementById && document.all); bIsNS = (document.getElementById && !document.all); bIsNS4 = document.layers; /*********************************************************************************************************** * FUNCTION: fCNMOnLoad() * NOTES: This function calls the functions to start the navigation engine when the onLoad event is fired. **/ function fCNMOnLoad() { fCNMInitializeObjects(); fCNMShowParent(); fCNMPositionParent(); } /*********************************************************************************************************** * FUNCTION: fCNMOnResize() * NOTES: This function calls the parent positioning functions when an onResize event is fired. **/ function fCNMOnResize() { fCNMPositionParent(); } /*********************************************************************************************************** * FUNCTION: fCNMCheckChild() * NOTES: Checks if a child object exists and if not appends one to the document. **/ function fCNMCheckChild() { var oDocumentBody = document.body; var oCNMThisObject = document.getElementById('oCNMChild' + iCNMChildCount); if(!oCNMThisObject) { var oDiv = document.createElement('div'); oDocumentBody.appendChild(oDiv); oDiv.id='oCNMChild' + iCNMChildCount; oDiv.style.position='absolute'; oDiv.style.zindex=iCNMParentZIndex + iCNMParentZIndex + iCNMChildCount; } } /*********************************************************************************************************** * FUNCTION: fCNMInitializeObjects() * NOTES: Creates parent objects and some blank child objects. **/ function fCNMInitializeObjects() { var oDiv; var oDocumentBody = document.body; for(iCNMCounter = 0; iCNMCounter <= asCNMMenuData.length; iCNMCounter++) { oCNMThisObject = document.getElementById('oCNM' + asCNMParentName[iCNMCounter]); if(abCNMParentShow[iCNMCounter] && !oCNMThisObject) { oDiv = document.createElement('div'); oDocumentBody.appendChild(oDiv); oDiv.id='oCNM' + asCNMParentName[iCNMCounter]; oDiv.style.position='absolute'; oDiv.style.zindex=iCNMParentZIndex; } } for(iCNMCounter = 0; iCNMCounter < 10; iCNMCounter++) { oCNMThisObject = document.getElementById('oCNMChild' + iCNMCounter); if(!oCNMThisObject) { oDiv = document.createElement('div'); oDocumentBody.appendChild(oDiv); oDiv.id='oCNMChild' + iCNMCounter; oDiv.style.position='absolute'; oDiv.style.zindex=iCNMParentZIndex + iCNMCounter; } } } /*********************************************************************************************************** * FUNCTION: fCNMPositionChild(oCNMParentItem) * NOTES: Positions a child node based on parent object and menu style. **/ function fCNMPositionChild(oCNMParentItem) { var iCNMWindowWidth = (bIsIE ? document.body.clientWidth : window.innerWidth); var iCNMWindowHeight = (bIsIE ? document.body.clientHeight : window.innerHeight) - 20; var oCNMThisObject = document.getElementById('oCNMChild' + iCNMChildCount); if(iCNMChildCount == 2) { oCNMParentObject = document.getElementById('oCNM' + asCNMParentName[iCNMActiveParent]); } else { oCNMParentObject = document.getElementById('oCNMChild' + (iCNMChildCount - 1)); } var oCNMTempObject = oCNMParentObject; if(aiCNMParentStyle[iCNMActiveParent] == 0) { // Side Menu iCNMChildTop = parseInt(oCNMTempObject.style.top.slice(0, oCNMTempObject.style.top.length - 2)); iCNMChildHeight = oCNMThisObject.offsetHeight; if(iCNMChildTop + iCNMChildHeight > iCNMWindowHeight) { bCNMChildDown = false; } else if(iCNMChildTop < 1) { bCNMChildDown = true; } if(bCNMChildDown) { iCNMChildTop = oCNMParentObject.offsetTop + oCNMParentItem.offsetTop; } else { iCNMChildTop = oCNMParentObject.offsetTop - oCNMThisObject.offsetHeight + oCNMParentItem.offsetTop + oCNMParentItem.offsetHeight; } iCNMChildLeft = parseInt(oCNMTempObject.style.left.slice(0, oCNMTempObject.style.left.length - 2)); iCNMChildWidth = oCNMThisObject.offsetWidth; if((iCNMChildLeft + iCNMChildWidth * 2) > iCNMWindowWidth) { bCNMChildRight = false; } else if(iCNMChildLeft - iCNMChildWidth < 1) { bCNMChildRight = true; } if(bCNMChildRight) { iCNMChildLeft = oCNMTempObject.offsetLeft + oCNMParentItem.offsetLeft + oCNMParentItem.offsetWidth - aiCNMParentItemOverlapX[iCNMActiveParent]; } else { iCNMChildLeft = oCNMTempObject.offsetLeft - iCNMChildWidth; } } // Top menu if(aiCNMParentStyle[iCNMActiveParent] == 1) { iCNMChildTop = parseInt(oCNMTempObject.style.top.slice(0, oCNMTempObject.style.top.length - 2)); iCNMChildHeight = oCNMThisObject.offsetHeight; if(iCNMChildTop + iCNMChildHeight > iCNMWindowHeight) { bCNMChildDown = false; } else if(iCNMChildTop < 1) { bCNMChildDown = true; } if(bCNMChildDown) { if(iCNMChildCount == 2) { // Parent iCNMChildTop = oCNMParentObject.offsetTop + oCNMParentItem.offsetTop + oCNMParentItem.offsetHeight - aiCNMParentItemOverlapY[iCNMActiveParent]; } else { // Child iCNMChildTop = oCNMParentObject.offsetTop + oCNMParentItem.offsetTop + aiCNMChildItemOverlapY[iCNMActiveParent]; } } else { if(iCNMChildCount == 2) { // Parent iCNMChildTop = oCNMParentObject.offsetTop - oCNMThisObject.offsetHeight + aiCNMParentItemOverlapY[iCNMActiveParent]; } else { // Child iCNMChildTop = oCNMParentObject.offsetTop - oCNMThisObject.offsetHeight + oCNMParentItem.offsetTop + oCNMParentItem.offsetHeight - aiCNMParentItemOverlapY[iCNMActiveParent]; } } // Left / Right iCNMChildLeft = parseInt(oCNMTempObject.style.left.slice(0, oCNMTempObject.style.left.length - 2)); iCNMChildWidth = oCNMThisObject.offsetWidth; iCNMParentWidth = oCNMParentItem.offsetWidth; if((iCNMChildLeft + iCNMChildWidth + iCNMParentWidth) > iCNMWindowWidth) { bCNMChildRight = false; } else if(iCNMChildLeft - iCNMChildWidth < 1 && !bCNMChildRight) { bCNMChildRight = true; } if(bCNMChildRight) { if(iCNMChildCount == 2) { iCNMChildLeft = oCNMTempObject.offsetLeft + oCNMParentItem.offsetLeft + aiCNMParentItemOverlapX[iCNMActiveParent]; } else { iCNMChildLeft = oCNMTempObject.offsetLeft + oCNMParentItem.offsetLeft + oCNMParentItem.offsetWidth - aiCNMChildItemOverlapX[iCNMActiveParent]; } } else { if(iCNMChildCount == 2) { iCNMChildLeft = oCNMTempObject.offsetLeft + oCNMParentItem.offsetLeft + oCNMParentItem.offsetWidth - oCNMThisObject.offsetWidth; } else { iCNMChildLeft = oCNMTempObject.offsetLeft - oCNMParentItem.offsetWidth; } } } oCNMThisObject.style.top = iCNMChildTop; oCNMThisObject.style.left = iCNMChildLeft; } /*********************************************************************************************************** * FUNCTION: fCNMPositionParent() * NOTES: Positions parent objects and calculates for centered page designs **/ function fCNMPositionParent() { var iCNMWindowWidth = (bIsIE ? document.body.clientWidth : window.innerWidth - 15); var iCNMWindowHeight = (bIsIE ? document.body.clientHeight : window.innerHeight) - 20; for(iCNMCounter = 0; iCNMCounter <= asCNMParentName.length; iCNMCounter++) { if(abCNMParentShow[iCNMCounter]) { var oCNMThisObject = document.getElementById('oCNM' + asCNMParentName[iCNMCounter]); if(oCNMThisObject) { if(aiCNMParentOrientation[iCNMCounter] == 3) { // Bottom Right if(aiCNMParentStyle[iCNMCounter] == 0) { iCNMTop = iCNMWindowHeight - aiCNMParentTop[iCNMCounter] - oCNMThisObject.offsetHeight + 20; } else { iCNMTop = iCNMWindowHeight - aiCNMParentTop[iCNMCounter]; } if(aiCNMParentCentered[iCNMCounter] != 0 && iCNMWindowWidth >= aiCNMParentCentered[iCNMCounter]) { iCNMLeft = iCNMWindowWidth - (iCNMWindowWidth - aiCNMParentCentered[iCNMCounter]) / 2 - aiCNMParentLeft[iCNMCounter] - oCNMThisObject.offsetWidth - 2; } else { iCNMLeft = iCNMWindowWidth - aiCNMParentLeft[iCNMCounter] - oCNMThisObject.offsetWidth; } } else if(aiCNMParentOrientation[iCNMCounter] == 2) { // Bottom Left if(aiCNMParentStyle[iCNMCounter] == 0) { iCNMTop = iCNMWindowHeight - aiCNMParentTop[iCNMCounter] - oCNMThisObject.offsetHeight + 20; } else { iCNMTop = iCNMWindowHeight - aiCNMParentTop[iCNMCounter]; } if(aiCNMParentCentered[iCNMCounter] != 0 && iCNMWindowWidth >= aiCNMParentCentered[iCNMCounter]) { iCNMLeft = (iCNMWindowWidth - aiCNMParentCentered[iCNMCounter]) / 2 + aiCNMParentLeft[iCNMCounter] + 2; } else { iCNMLeft = aiCNMParentLeft[iCNMCounter]; } } else if(aiCNMParentOrientation[iCNMCounter] == 1) { // Top Right iCNMTop = aiCNMParentTop[iCNMCounter]; if(aiCNMParentCentered[iCNMCounter] != 0 && iCNMWindowWidth >= aiCNMParentCentered[iCNMCounter]) { iCNMLeft = iCNMWindowWidth - (iCNMWindowWidth - aiCNMParentCentered[iCNMCounter]) / 2 - aiCNMParentLeft[iCNMCounter] - oCNMThisObject.offsetWidth - 2; } else { iCNMLeft = iCNMWindowWidth - aiCNMParentLeft[iCNMCounter] - oCNMThisObject.offsetWidth; } } else { // Top Left (Default) iCNMTop = aiCNMParentTop[iCNMCounter]; if(aiCNMParentCentered[iCNMCounter] != 0 && iCNMWindowWidth >= aiCNMParentCentered[iCNMCounter]) { iCNMLeft = (iCNMWindowWidth - aiCNMParentCentered[iCNMCounter]) / 2 + aiCNMParentLeft[iCNMCounter] + 2; } else { iCNMLeft = aiCNMParentLeft[iCNMCounter]; } } oCNMThisObject.style.top = iCNMTop; oCNMThisObject.style.left = iCNMLeft; } } } } /*********************************************************************************************************** * FUNCTION: fCNMShowChild(oCNMParentItem, sCNMThisData) * NOTES: Executes the functions to create and display a child object based on a data string. **/ function fCNMShowChild(oCNMParentItem, sCNMThisData) { iCNMChildCount++; fCNMCheckChild(); var oCNMThisObject = document.getElementById('oCNMChild' + iCNMChildCount); if(oCNMThisObject) { oCNMThisObject.innerHTML = fCNMChildHTML(sCNMThisData); } else { alert('There was an error updating oCNMChild' + iCNMChildCount + '\nObject not found.'); } fCNMPositionChild(oCNMParentItem); } /*********************************************************************************************************** * FUNCTION: fCNMShowParent() * NOTES: Loops through and creates and displays parent menu objects. **/ function fCNMShowParent() { for(iCNMParentCounter = 0; iCNMParentCounter <= asCNMParentName.length; iCNMParentCounter++) { iCNMActiveParent = iCNMParentCounter; if(abCNMParentShow[iCNMParentCounter]) { var oCNMThisObject = document.getElementById('oCNM' + asCNMParentName[iCNMParentCounter]); if(oCNMThisObject) { oCNMThisObject.innerHTML = fCNMParentHTML(asCNMMenuData[iCNMParentCounter]); } else { alert('There was an error updating oCNM' + asCNMParentName[iCNMCounter] + '\nObject not found.'); } } } iCNMActiveParent = 0; } /*********************************************************************************************************** * FUNCTION: fCNMHideChildren() * NOTES: Cleans up child objects from the display. **/ function fCNMHideChildren() { clearTimeout(iCNMChildTimer); for(iCNMHideCounter = iCNMChildCount; iCNMHideCounter > iCNMCurrentChild; iCNMHideCounter--) { iCNMChildCount--; var oCNMThisObject = document.getElementById('oCNMChild' + iCNMHideCounter); oCNMThisObject.innerHTML = ''; } if(iCNMChildCount == 1) { if(sCNMClassCopy != '') { oCNMParentCopy.className = sCNMClassCopy; sCNMClassCopy = ''; } } } /*********************************************************************************************************** * FUNCTION: * NOTES: **/ function fCNMIconHTML(sCNMThisData) { } /*********************************************************************************************************** * FUNCTION: * NOTES: **/ function fCNMTreeHTML(sCNMThisData) { } /*********************************************************************************************************** * FUNCTION: fCNMChildHTML(sCNMThisData) * NOTES: Creates a string of HTML for the child menu. **/ function fCNMChildHTML(sCNMThisData) { var asCNMThisMenu = sCNMThisData.split('|' + iCNMChildCount); sCNMThisHTML = '
| ' + (asCNMThisItem[2] != '' ? ' |
| ' + (asCNMThisItem[2] != '' ? ' | ';
if(aiCNMParentStyle[iCNMActiveParent] == 0) {
sCNMThisHTML += ''; } sCNMThisHTML += ''; } if(aiCNMParentStyle[iCNMActiveParent] == 0 && aiCNMParentHeight[iCNMActiveParent] != 0) { sCNMThisHTML += ' |
' + asCNMParentName[iCNMActiveParent] + ' parent data not found. asCNMMenuData[' + iCNMActiveParent + '] is null.
'; return sCNMThisHTML; } }