Okay, so I have come up with a solution to my problem. Here is the JavaScript that I came up with:
Code:
// -- Product Tab Hide/Show --
function changeClass(currClass) {
var obj = document.getElementById('product-nav-buttons').getElementsByTagName('a');
for (var x=0; x < obj.length; x++) {
if (obj[x].className.search(/-on/) > -1) {
obj[x].className = obj[x].className.replace(/-on/, "-off");
} else if (obj[x].className == currClass) {
obj[x].className = obj[x].className.replace(/-off/, "-on");
}
}
}
// -- Hide Product Divs --
function hideDivs() {
var divs = document.getElementById('content-wrapper').getElementsByTagName('div');
for (var i=0; i < divs.length; i++) {
if (divs[i].id.search(/nav-/) > -1) {
if (document.getElementById) {
divs[i].style.display = "none";
}
else if (document.all) {
document.all[divs[i]].style.display = "none";
}
else if (document.layers) {
document.layers[divs[i]].display = "none";
}
}
}
}
// -- Show Product Div --
function showDiv(whichLayer) {
if (document.getElementById) {
// this is the way the standards work
document.getElementById(whichLayer).style.display = "block";
}
else if (document.all) {
// this is the way old msie versions work
document.all[whichlayer].style.display = "block";
}
else if (document.layers) {
// this is the way nn4 works
document.layers[whichLayer].display = "block";
}
}
The reason it is so custom is because I needed to have specific images that were stored in a class be turned "on" and "off". The way I designated this was with CSS classes:
Code:
#product-nav-buttons {
margin: 0;
padding: 0;
height: 56px;
background: transparent url('/site-layout/gfx/products/bg-product-information.gif') repeat 0 0;
}
#product-nav-buttons ul {
margin: 0;
margin-left: 10px;
padding: 0;
}
#product-nav-buttons ul li {
margin: 0;
padding: 0;
display: inline;
list-style-type: none;
}
#product-nav-buttons ul li a {
margin: 0;
margin-right: 5px;
padding: 0;
height: 47px;
display: block;
float: left;
}
#product-nav-buttons ul li a.nav-product-details-on {width: 106px; background: transparent url('/site-layout/gfx/products/btn-product-details-on.gif') repeat 0 0;}
#product-nav-buttons ul li a.nav-product-details-off {width: 106px; background: transparent url('/site-layout/gfx/products/btn-product-details-off.gif') repeat 0 0;}
#product-nav-buttons ul li a.nav-markets-on {width: 73px; background: transparent url('/site-layout/gfx/products/btn-markets-on.gif') repeat 0 0;}
#product-nav-buttons ul li a.nav-markets-off {width: 73px; background: transparent url('/site-layout/gfx/products/btn-markets-off.gif') repeat 0 0;}
#product-nav-buttons ul li a.nav-photo-gallery-on {width: 97px; background: transparent url('/site-layout/gfx/products/btn-photo-gallery-on.gif') repeat 0 0;}
#product-nav-buttons ul li a.nav-photo-gallery-off {width: 97px; background: transparent url('/site-layout/gfx/products/btn-photo-gallery-off.gif') repeat 0 0;}
#product-nav-buttons ul li a.nav-guides-literature-on {width: 125px; background: transparent url('/site-layout/gfx/products/btn-guides-literature-on.gif') repeat 0 0;}
#product-nav-buttons ul li a.nav-guides-literature-off {width: 125px; background: transparent url('/site-layout/gfx/products/btn-guides-literature-off.gif') repeat 0 0;}
Finally, the HTML code utilizing these to create the look:
Code:
<div id="product-nav-buttons">
<ul>
<li><a href="#" onClick="changeClass(this.className); hideDivs(); showDiv('nav-product-details'); return false;" class="nav-product-details-on"></a></li>
<li><a href="#" onClick="changeClass(this.className); hideDivs(); showDiv('nav-markets'); return false;" class="nav-markets-off"></a></li>
<li><a href="#" onClick="changeClass(this.className); hideDivs(); showDiv('nav-guides-literature'); return false;" class="nav-guides-literature-off"></a></li>
<li><a href="#" onClick="changeClass(this.className); hideDivs(); showDiv('nav-photo-gallery'); return false;" class="nav-photo-gallery-off"></a></li>
</ul>
</div>
Bookmarks