$(document).ready(function(){

	// HIDE EACH LI
	$("div.parts-extras-header ul li").hide();
	
	
	// IF Table esists, show its corresponding LI
	if ( $('table.parts-extras-header-accessories').length ) {$("div.parts-extras-header ul li#accessories").show();}
	if ( $('table.parts-extras-header-upgrades').length ) {$("div.parts-extras-header ul li#upgrades").show();}
	if ( $('table.parts-extras-header-options').length ) {$("div.parts-extras-header ul li#options").show();}
	if ( $('table.parts-extras-header-alternatives').length ) {$("div.parts-extras-header ul li#alternatives").show();}
	if ( $('table.parts-extras-header-replacements').length ) {$("div.parts-extras-header ul li#replacements").show();}


	//PRE=Set first LI  (or selected tab value) to activer and show corresponding table
	var firsttable = $("div.parts-extras-header ul li:first").attr("id");

	var tab=window.location.hash;

	if (tab=="#REPL")
		tab="replacements";
	else if (tab=="#ACCE")
		tab="accessories";
	else if (tab=="#OPT")
		tab="options";
	else if (tab=="#UPGR")
		tab="upgrades";
	else if (tab=="#ALTR")
		tab="alternatives";
	else
		tab=firsttable;

	//$("div.parts-extras-header ul li:first").addClass("active");
	//$('div.parts-extras div.parts-extras-table-' + firsttable).show();
	$("div.parts-extras-header ul li#"+tab).addClass("active");
	$('div.parts-extras div.parts-extras-table-' + tab).show();
	fixProductDetailsRow();     
	
	//ON LI hover change background
	$("div.parts-extras-header ul li").hover(
		function () { $(this).addClass("hover") }, 
		function () { $(this).removeClass("hover") }
		);		
 
 
 	//WHEN LI is clicked, change active state
	$("div.parts-extras-header ul li").click(function(){
		$("div.parts-extras-header ul li").removeClass("active");
		$(this).addClass("active");
		});
		
		
	//WHEN LI is clicked, hide all tables and show corresponding table
	$("div.parts-extras-header ul li#accessories").click(function(){ $('div.parts-extras-table').hide(); $('div.parts-extras-table-accessories').show(); fixProductDetailsRow();      });
	$("div.parts-extras-header ul li#upgrades").click(function(){ $('div.parts-extras-table').hide(); $('div.parts-extras-table-upgrades').show(); fixProductDetailsRow();            });
	$("div.parts-extras-header ul li#options").click(function(){ $('div.parts-extras-table').hide(); $('div.parts-extras-table-options').show(); fixProductDetailsRow();           });
	$("div.parts-extras-header ul li#alternatives").click(function(){ $('div.parts-extras-table').hide(); $('div.parts-extras-table-alternatives').show();  fixProductDetailsRow();           });
	$("div.parts-extras-header ul li#replacements").click(function(){ $('div.parts-extras-table').hide(); $('div.parts-extras-table-replacements').show();     fixProductDetailsRow();       });
									
});



