
// Setup namespace
if(!argos) var argos = {};
if (!argos.product) argos.product = {};

// begin: argos.product.details
if (!argos.product.details) argos.product.details = {};
argos.product.details.Tabs = {

	init : function() {
		// get defensive (exit if no headings found)
		if ($("#producttabs h4").length == 0) return;
		// manage the display of JavaScript tabs
		// add click events to elements

		// A class is added to this wrappper to allows the css to target the javascript enabled  styles
		// Add JS Wrapper
		$("#tabwrapper").addClass("jstabs");
		//$("#producttabs").wrap('<div id="jstabs"></div>');
		// Add additional class to JS tabs 
		$(".jstabs #producttabs h4").addClass("jstabstyle");
		
		// Position Special Offers Tab for no credit options scenario
		if(!$("#tab4")[0]) {
			$("h4#tab3").addClass("twotabs");
		}
		
		// Hide all but the default tab
		//$(".tab1").hide(); 
		// default: remove underline
		$(".jstabs h4#tab1").addClass("active");
		$(".tab2").hide();
		$(".tab3").hide();
		$(".tab4").hide();
		$(".tab5").hide();
		
		//add cursor
		$("#producttabs h4").css(
			{cursor : 'pointer'}
		);
		
		argos.product.details.Tabs.addEvents();
		$("h4#tab1").unbind();
		
		// END: Tab Script
		
		// Show Special Offers Tab 
		$("#showspecialoffers").click( 
			function() { 
				wrong_s_objectID='specialoffers'; 
				argos.product.details.Tabs.hideAllTabs(); 
				argos.product.details.Tabs.showTab("tab3"); 
			}
		);
		
		// Show Credit Details Tab
		$("#showcreditinfo").click( 
			function() { 
				argos.product.details.Tabs.hideAllTabs(); 
				argos.product.details.Tabs.showTab("tab4"); 
			}
		);
	}, // end init()
	
	addEvents : function(){
		// add click events to headings
		$("#producttabs h4").click(
			function() {
				 argos.product.details.Tabs.removeEvents(); 
				 argos.product.details.Tabs.hideAllTabs(); 
				 argos.product.details.Tabs.showTab(this.id);
			}
		);
	},
	
	hideAllTabs : function() {
		$(".tab1").hide(); 
		$(".tab2").hide(); 
		$(".tab3").hide(); 
		$(".tab4").hide(); 
		$(".jstabs h4#tab1").removeClass("active");
		$(".jstabs h4#tab2").removeClass("active");
		$(".jstabs h4#tab3").removeClass("active");
		$(".jstabs h4#tab4").removeClass("active");
	},
	
	/** eg: showTab("tab3") */
	showTab : function(sTabName) {
		$(".jstabs h4#"+sTabName).addClass("active");
		$("."+sTabName).show(); 
		argos.product.details.Tabs.addEvents();
		$("h4#"+sTabName).unbind();
	},
	
	removeEvents : function(){
		$("h4#tab1").unbind(); 
		$("h4#tab2").unbind(); 
		$("h4#tab3").unbind(); 
		$("h4#tab4").unbind();
	} // END: removeEvents 

}; // end argos.productDetails.tabs (namespace)


// START: Jquery Tabs
$(document).ready(
	function() {
		argos.product.details.Tabs.init();
	}
); // end domready