function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
var sectionNav = {
	config:{
				tabbedID : 'productlist',
				theClass : 'section',
				mainSection : 'first',
				theElement : 'div',
				classAdd : 'active'
	          },
	          
	showSection : function (id, theLink) {
		var divs = document.getElementsByTagName(sectionNav.config.theElement);
		for (var i=0; i<divs.length; i++ ) {
			if (divs[i].className.indexOf(sectionNav.config.theClass) == -1) continue;
			divs[i].style.display = divs[i].getAttribute("id") != id ? "none" : "block";
		}
		var theContainer = document.getElementById(sectionNav.config.tabbedID);
		var theLinks = theContainer.getElementsByTagName("a");
		for (var j=0; j<theLinks.length; j++){
			if (theLinks[j].getAttribute("href").split("#")[1] == id){
  				theLinks[j].className=sectionNav.config.classAdd;
		 	}
  			else{
  				theLinks[j].className=" ";
		  	}
		}
	},

	prepareInternalnav : function() {
		if (!document.getElementsByTagName) return false;
		if (!document.getElementById) return false;
  
		//Make sure that the element we need is actually in the document
		if (!document.getElementById(sectionNav.config.tabbedID)) return false;
 
		var nav = document.getElementById(sectionNav.config.tabbedID);
		var links = nav.getElementsByTagName("a");
		for (var i=0; i<links.length; i++ ) {
			var sectionId = links[i].getAttribute("href").split("#")[1];
			var theLink = links[i];
			if (!document.getElementById(sectionId)) continue;
			if (sectionId != sectionNav.config.mainSection){
				document.getElementById(sectionId).style.display = "none";
			}
			else{
				links[i].className=sectionNav.config.classAdd;
			}
			links[i].destination = sectionId;
			links[i].onclick = function() {
				sectionNav.showSection(this.destination, theLink);
				return false;
			}
		}
	}
}

addLoadEvent(sectionNav.prepareInternalnav);