/* * tabswitcher.js -- Version 06-May-2006 * * Copyright (c) 2006 Jochen Kupperschmidt * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * The above license is the MIT License. It was copied from the website of the * Open Source Initiative: http://www.opensource.org/licenses/mit-license.php * _ _ * | |_ ___ _____ ___ _ _ _ ___ ___| |_ * | | . | | ._| | | | . | _| . / * |_|_|___|_|_|_|___|_____|___|_| |_|_\ * http://homework.nwsnet.de/ * * History: * 23-Jan-2006: First release. * 04-Feb-2006: Rewrote it to be object-oriented, try..catch used. * 06-May-2006: Major improvements allowing for easier usage an less markup. * * This piece of JavaScript allows to switch (i.e. show one, hide the others) * between grouped XHTML elements. That kind of behaviour is widely used in * graphical applications and was adopted for use in websites. * * Include it in a website's section like this (adjust the path): * */ // A tab group class. function TabGroup(tabContainerId) { // --- initialization --- var tabBar = document.getElementById(tabContainerId); if (! tabBar) { return; } this.targetIds = new Array(); var group = this; // Find anchor elements. var aElems = tabBar.getElementsByTagName('a'); for (var i in aElems) { if (! aElems[i].href) { continue; } // Find target element's id. var id = getTargetId(aElems[i]); if (id) { this.targetIds.push(id); } // Add event handler to link. aElems[i].onclick = function () { group.show(getTargetId(this)); } } // --- functions to control content box visibility --- // Show the specified box. this.show = function (targetId, hideOthers) { if (! hideOthers) { this.hideAll(); } try { document.getElementById(targetId).style.display = ''; } catch (e) {} } // Hide the specified box. this.hide = function (targetId) { try { document.getElementById(targetId).style.display = 'none'; } catch (e) {} } // Hide all boxes of this group. this.hideAll = function () { for (var i in this.targetIds) { this.hide(this.targetIds[i]); } } // --- final preparation --- // Make the tab bar visible. tabBar.style.display = 'block'; // Display the first tab content. this.show(this.targetIds[0]); } // Return the target element id part of an anchor. function getTargetId(anchor) { try { return anchor.href.split('#')[1]; } catch (e) {} } /* * This function is to hide RSS Feed Section Tabs On index Page load */ function hideTabsOnload() { document.getElementById("health").style.display = "none"; document.getElementById("finance").style.display = "none"; document.getElementById("entertainment").style.display = "none"; document.getElementById("sports").style.display = "none"; document.getElementById("concierge").style.display = "none"; } /* * This function is to Switch between the RSS Feed Section Tabs On index Page * Based on click of specific tab */ function tabSwitch(divName) { if("health" == divName) { document.getElementById("health").style.display = "block"; document.getElementById("finance").style.display = "none"; document.getElementById("entertainment").style.display = "none"; document.getElementById("sports").style.display = "none"; document.getElementById("concierge").style.display = "none"; document.getElementById("top-stories").style.display = "none"; } if("finance" == divName) { document.getElementById("health").style.display = "none"; document.getElementById("finance").style.display = "block"; document.getElementById("entertainment").style.display = "none"; document.getElementById("sports").style.display = "none"; document.getElementById("concierge").style.display = "none"; document.getElementById("top-stories").style.display = "none"; } if("entertainment" == divName) { document.getElementById("health").style.display = "none"; document.getElementById("finance").style.display = "none"; document.getElementById("entertainment").style.display = "block"; document.getElementById("sports").style.display = "none"; document.getElementById("concierge").style.display = "none"; document.getElementById("top-stories").style.display = "none"; } if("sports" == divName) { document.getElementById("health").style.display = "none"; document.getElementById("finance").style.display = "none"; document.getElementById("entertainment").style.display = "none"; document.getElementById("sports").style.display = "block"; document.getElementById("concierge").style.display = "none"; document.getElementById("top-stories").style.display = "none"; } if("concierge" == divName) { document.getElementById("health").style.display = "none"; document.getElementById("finance").style.display = "none"; document.getElementById("entertainment").style.display = "none"; document.getElementById("sports").style.display = "none"; document.getElementById("concierge").style.display = "block"; document.getElementById("top-stories").style.display = "none"; } if("top-stories" == divName) { document.getElementById("health").style.display = "none"; document.getElementById("finance").style.display = "none"; document.getElementById("entertainment").style.display = "none"; document.getElementById("sports").style.display = "none"; document.getElementById("concierge").style.display = "none"; document.getElementById("top-stories").style.display = "block"; } } /* * This function is to Switch between the Category Alphabets Section Tabs On index Page * Based on click of specific tab */ function healthTabSwitch(divName) { if(divName==""){ divName=0; } var AZ = document.getElementById('boxes'); if(AZ){ var AZContentItems = AZ.getElementsByTagName('div'); for (var x = 0; x < AZContentItems.length; x++) { if (x == 26) { return; } if (x != divName) { AZContentItems[x].style.display = 'none'; } } AZContentItems[divName].style.display = ''; } }