
// PRODUCT DETAIL TABS

function toggle( id ) {

	collapseDivs(); // first hide all the tabs
	doButtons();
	
	// then open the tab that is clicked
	var loc = document.getElementById( id );
	if( loc.className == 'hide' ) {
		loc.className = 'show';
	} else {
		loc.className = 'hide';
	}

	// changed the class of the selected tab heading
	var button = id  + '-button';
	var loc_button = document.getElementById( button );
	if( loc_button.className == '' ) {
	 	loc_button.className = 'selected';
	} else {
	 	loc_button.className = '';
	}
	
	// expand all divs within the selected tab	
	var allDivs = document.getElementById( id ).getElementsByTagName( 'div' );
	for ( var i = 0; i < allDivs.length; i++ ) {
		allDivs[i].className = 'show';
  }
	
}

// collapse all divs within tab-content
function collapseDivs() { 
  var allDivs = document.getElementById( 'tab-content' ).getElementsByTagName( 'div' );
	for ( var i = 0; i < allDivs.length; i++ ) {
		allDivs[i].className = 'hide';
  }
}
function doButtons() {
	var deselectTabs = document.getElementById( 'tab-headings' ).getElementsByTagName( 'a' );
	for ( var i = 0; i < deselectTabs.length; i++ ) {
		deselectTabs[i].className = '';
  }
}
