TAB_FILTER = '';

$(document).ready(function() {

    //------------------------------------------------------------
    //  Hide info tabs except default, overview
    //------------------------------------------------------------
    var tabs=[ "overview", "features", "specs", "requirements", "faq", "videos" ];	
    $('#features').hide();
    $('#specs').hide();
    $('#faq').hide();
    $('#requirements').hide();
    $('#videos').hide();
    showTab( '0_tab');
    TAB_FILTER = tabs[0];
    
    //------------------------------------------------------------
    //  Show and hide product information
    //------------------------------------------------------------
    $('#subcategories .subcategory').each( function() {
    	$(this).click( function(event) {
    		$.each( tabs, function( i, val ) {
    			$('#' + val ).hide(); 
    		});
    		event.preventDefault();
    		var index = this.id.replace( '_tab', '');
    		var name = tabs[ index ];
    		$("#" + name ).show();
    		showTab( this.id );
    		
    		//------------------------------------------------------------
    		//  Build the url
    		//------------------------------------------------------------
    		TAB_FILTER = name;
    		//buildURL();
    	});
    });
    
    //------------------------------------------------------------
    //  Show 'tab' shape
    //------------------------------------------------------------
    function showTab( tabName ) {
    	hideTabs();
    	$("#" + tabName ).css( "background-color", "#282d33" );
    	$("a", "#" + tabName ).css( "color", "#d1143e" );
    }
    
    //------------------------------------------------------------
    //  Hide 'tab' shape
    //------------------------------------------------------------
    function hideTabs() {
    	$.each( tabs, function( i, val ) {
    		$("#" + i + "_tab" ).css( "background-color", '' );
    		$("a", "#" + i + "_tab" ).css( "color", '' );
    	});
    }
    
    //------------------------------------------------------------
    //  FAQ functionality
    //------------------------------------------------------------
	$('#faq li.question').each( function() {
		$( this ).css( "cursor", "pointer")
		$( 'li.answer', this ).hide();
	});
	
	$('#faq li.question').click( function( event) {
		if ( $( 'li.answer', this ).is(':hidden') ) {
			$( 'li.answer', this ).show();
		}
		else {
			$( 'li.answer', this ).hide();
		}
	});
});