// JavaScript Document
	
function initTabs(){
	var products_description = document.getElementById('products_description');
	var products_where = document.getElementById('products_where');
	var products_ingredients = document.getElementById('products_ingredients');
	var products_ingredients_main = document.getElementById('products_ingredients_main');
	var products_ingredients_hero = document.getElementById('products_ingredients_hero');
	var products_ingredients_not = document.getElementById('products_ingredients_not');
	var products_reviews = document.getElementById('products_reviews');
	var products_how = document.getElementById('products_how');
	
	var tabbox = document.getElementById('product-collateral');
	tabbox.style.height = '200px';
	var navlinks = document.getElementById('productlinks');
	
	if (products_description != null){
		var products_description_link = document.createElement('a');
		var products_description_linktext = document.createTextNode('learn more');
		products_description_link.onclick = function(){ showBlock('products_description', this); };
		products_description_link.style.color = '#199F49';
		products_description_link.appendChild(products_description_linktext);
		navlinks.appendChild(products_description_link);
	}
	
	if (products_where != null){
		var products_where_link = document.createElement('a');
		var products_where_linktext = document.createTextNode('where is it from');
		products_where_link.onclick = function(){ showBlock('products_where', this); };
		products_where_link.appendChild(products_where_linktext);
		navlinks.appendChild(products_where_link);
		products_where.style.display = 'none';
	}
	
	if (products_ingredients_main != null || products_ingredients_hero != null || products_ingredients_not != null){
		var products_ingredients_link = document.createElement('a');
		var products_ingredients_linktext = document.createTextNode('ingredients');
		products_ingredients_link.onclick = function(){ showBlock('products_ingredients', this); };
		products_ingredients_link.appendChild(products_ingredients_linktext);
		navlinks.appendChild(products_ingredients_link);
		products_ingredients.style.display = 'none';
		$subtabs = products_ingredients.getElementsByTagName('div');
		if (products_ingredients_not != null){
			var ingredients_not_link = document.createElement('a');
			var ingredients_not_linktext = document.createTextNode('what\'s not in it');
			ingredients_not_link.onclick = function(){ showSubBlock('products_ingredients_not', this); };
			ingredients_not_link.appendChild(ingredients_not_linktext);
			ingredients_not_link.className = 'subtablink';
			//products_ingredients.appendChild(ingredients_not_link);
			products_ingredients.insertBefore(ingredients_not_link, products_ingredients.firstChild);
			if($subtabs.length > 1) products_ingredients_not.style.display = 'none';
		}
		if (products_ingredients_hero != null){
			var ingredients_hero_link = document.createElement('a');
			var ingredients_hero_linktext = document.createTextNode('hero ingredients');
			ingredients_hero_link.onclick = function(){ showSubBlock('products_ingredients_hero', this); };
			ingredients_hero_link.appendChild(ingredients_hero_linktext);
			ingredients_hero_link.className = 'subtablink';
			//products_ingredients.appendChild(ingredients_hero_link);
			products_ingredients.insertBefore(ingredients_hero_link, products_ingredients.firstChild);
			if($subtabs.length > 1) products_ingredients_hero.style.display = 'none';
		}
		if (products_ingredients_main != null){
			var ingredients_main_link = document.createElement('a');
			var ingredients_main_linktext = document.createTextNode('full ingredient list');
			ingredients_main_link.onclick = function(){ showSubBlock('products_ingredients_main', this); };
			ingredients_main_link.style.color = '#199F49';
			ingredients_main_link.appendChild(ingredients_main_linktext);
			ingredients_main_link.className = 'subtablink';
			//products_ingredients.appendChild(ingredients_main_link);
			products_ingredients.insertBefore(ingredients_main_link, products_ingredients.firstChild);
		}
	}
	
	if (products_reviews != null){
		var products_reviews_link = document.createElement('a');
		var products_reviews_linktext = document.createTextNode('reviews');
		products_reviews_link.onclick = function(){ showBlock('products_reviews', this); };
		products_reviews_link.appendChild(products_reviews_linktext);
		navlinks.appendChild(products_reviews_link);
		products_reviews.style.display = 'none';
	}
	
	if (products_how != null){
		var products_how_link = document.createElement('a');
		var products_how_linktext = document.createTextNode('how to use');
		products_how_link.onclick = function(){ showBlock('products_how', this); };
		products_how_link.appendChild(products_how_linktext);
		navlinks.appendChild(products_how_link);
		products_how.style.display = 'none';
	}
	
}

function showSubBlock(block, currentLink){
	var products_ingredients = document.getElementById('products_ingredients');
	var products_ingredients_main = document.getElementById('products_ingredients_main');
	var products_ingredients_hero = document.getElementById('products_ingredients_hero');
	var products_ingredients_not = document.getElementById('products_ingredients_not');

	if (products_ingredients_main != null) products_ingredients_main.style.display = 'none';
	if (products_ingredients_hero != null) products_ingredients_hero.style.display = 'none';
	if (products_ingredients_not != null) products_ingredients_not.style.display = 'none';
	document.getElementById(block).style.display = 'block';
	
	var subtablinks = products_ingredients.getElementsByTagName('a');
	for(i=0;i<subtablinks.length;i++){
		if(subtablinks.item(i).className == 'subtablink') subtablinks.item(i).style.color = '#8BC53F';
	}
	currentLink.style.color = '#199F49';
}

function showBlock(block, currentLink){
	var products_description = document.getElementById('products_description');
	var products_where = document.getElementById('products_where');
	var products_ingredients = document.getElementById('products_ingredients');
	var products_ingredients_main = document.getElementById('products_ingredients_main');
	var products_ingredients_hero = document.getElementById('products_ingredients_hero');
	var products_ingredients_not = document.getElementById('products_ingredients_not');
	var products_reviews = document.getElementById('products_reviews');
	var products_how = document.getElementById('products_how');

	if (products_description != null) products_description.style.display = 'none';
	if (products_where != null) products_where.style.display = 'none';
	if (products_ingredients != null) products_ingredients.style.display = 'none';
	if (products_reviews != null) products_reviews.style.display = 'none';
	if (products_how != null) products_how.style.display = 'none';
	document.getElementById(block).style.display = 'block';
	
	var tablinks = document.getElementById('productlinks').getElementsByTagName('a');
	for(i=0;i<tablinks.length;i++) tablinks.item(i).style.color = '#8BC53F';
	currentLink.style.color = '#199F49';
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

addLoadEvent(initTabs);