/**************************************************************************************************************************
	 Author              :      PA
	 Version		     :	    1.0
	 Date Created	     :         
	 Change history      :
	
    Task/Bug 				   Date(mm-dd-yyyy) 	  Author 		 Change Description 
	 
	Anthro Bazzar Voice 2009   03-09-2009             PVeedu         Modified page for Anthro Bazzar Voice 2009
			 
***************************************************************************************************************************/	
	
	/**BREAK OUT INTO A NEW JS FILE          
	   tabbed-navigation.js
	**/
	
	function addLoadEvent(func){
		var oldonload = window.onload;
		if(typeof window.onload != 'function') {
			window.onload = func;
		} else{
			window.onload = function() {
				oldonload();
				func();
			}
		}
	}
	
	// showing/hiding particular div sections for tab nav
	function showProductSection(id){
		var divs = document.getElementsByTagName("div");
		for (var i=0; i<divs.length; i++){
			if(divs[i].className.indexOf("product-section") == -1) continue;
			if (divs[i].getAttribute("id") != id){
				divs[i].style.display = "none";
			} else{
				divs[i].style.display = "block";
			}
		}
	}
	
	//showing/hiding particular div sections for tab nav
	function showSkuSection(id){
		var divs = document.getElementsByTagName("div");
		for (var i=0; i<divs.length; i++){
			if(divs[i].className.indexOf("sku-section") == -1) continue;
			if (divs[i].getAttribute("id") != id){
				divs[i].style.display = "none";
			} else{
				divs[i].style.display = "block";
			}
		}
	}
	
	//initialize
	function prepareProductTabs(){
		if (!document.getElementsByTagName) return false;
		if (!document.getElementById) return false;
		if(!document.getElementById("productNav")) return false;
		var nav = document.getElementById("productNav");
		
		var links = nav.getElementsByTagName("a");
		for(var i=0; i<links.length; i++){
			var sectionId = links[i].getAttribute("href").split("#")[1];
			document.getElementById(sectionId).style.display ="none";
			links[i].destination = sectionId;
			links[i].onclick = function(){
				showProductSection(this.destination);
				return false;
			}
		}
		showProductSection("product-details");
	}
	
	function prepareSkuTabs(){
		if (!document.getElementsByTagName) return false;
		if (!document.getElementById) return false;
		if(!document.getElementById("skuNav")) return false;
		var nav = document.getElementById("skuNav");
		var links = nav.getElementsByTagName("a");
		for(var i=0; i<links.length; i++){
			var sectionId = links[i].getAttribute("href").split("#")[1];
			document.getElementById(sectionId).style.display ="none";
			links[i].destination = sectionId;
			links[i].onclick = function(){
				showSkuSection(this.destination);
				return false;
			}
		}
		showSkuSection("regular");
	}
	
	addLoadEvent(prepareProductTabs);
	addLoadEvent(prepareSkuTabs);
	