//  loads ingredients info of kit items from a static file
function getIngredients(theSKU) {
	var xhr;
	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		xhr = new ActiveXObject("Msxml2.XMLHTTP");
	}
	else {
		throw new Error("Ajax is not supported by this browser");
	}
	xhr.onreadystatechange = function() {
	if (xhr.readyState == 4) {
		if (xhr.status >= 200 && xhr.status < 300) {
			document.getElementById('IngredientsList')
			.innerHTML = xhr.responseText;
			}
		}
	}
	xhr.open('GET','/content/ingredients/' + theSKU + '.html');
	xhr.send('');
}

//here you place the ids of every element you want.
var ids=new Array('pDescription','Reviews','pTalk','Recommend','Directions','Ingredients','AddlInfo','ShipInfo');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function switch2(span) {
	var option2=['prod_one','prod_two','prod_three','prod_four','prod_five','prod_six','prod_seven','prod_eight'];
	for(var i=0; i<option2.length; i++) {
		if (document.getElementById(option2[i])) {
			obj=document.getElementById(option2[i]);
			obj.style.background=(option2[i]==span)? "url(/resources/assets/product/prodTab_on.jpg) right bottom repeat-x" : "url(/resources/assets/product/prodTab_off.jpg) right bottom repeat-x";
		}
	}
}

function switch3(span) {
	var option3=['bump1','bump2','bump3','bump4','bump5','bump6','bump7','bump8'];
	for(var i=0; i<option3.length; i++) {
		if (document.getElementById(option3[i])) {
			obj=document.getElementById(option3[i]);
			obj.style.color=(option3[i]==span)? "#ffffff" : "";
		}
	}
}

function switch4(span) {
	var option4=['a-panel_1_start'];
	for(var i=0; i<option4.length; i++) {
		if (document.getElementById(option4[i])) {
			obj=document.getElementById(option4[i]);
			obj.id=(option4[i]==span)? "a-panel_1" : "";
		}
	}
}

// hides tabbed content on page load
function hideTabContent() {
	if(document.getElementById("Reviews")) { 
		var tab2content = document.getElementById("Reviews");
		tab2content.style.display = 'none'; }
	if(document.getElementById("pTalk")) { 
		var tab3content = document.getElementById("pTalk");
		tab3content.style.display = 'none'; }
	if(document.getElementById("Recommend")) { 
		var tab4content = document.getElementById("Recommend");
		tab4content.style.display = 'none'; }
	if(document.getElementById("Directions")) { 
		var tab5content = document.getElementById("Directions");
		tab5content.style.display = 'none'; }
	if(document.getElementById("Ingredients")) { 
		var tab6content = document.getElementById("Ingredients");
		tab6content.style.display = 'none'; }
	if(document.getElementById("ShipInfo")) { 
		var tab7content = document.getElementById("ShipInfo");
		tab7content.style.display = 'none'; }
	if(document.getElementById("AddlInfo")) { 
		var tab8content = document.getElementById("AddlInfo");
		tab8content.style.display = 'none'; }
}
