/**
 * The navigation.js JavaScript file contains functionality to handle site navigation.
 * 
 * @author		Mattias Johansson, 2008
 * @copyright	Euroway Media, 2008
 */

var open_category = 0;

// Load the toggle information images when the document is ready.
var more_info_down;
var more_info_up;
$( document ).ready( function() {
	more_info_down	= new Image( 16, 16 );
	more_info_up	= new Image( 16, 16 );
	
	more_info_down.src	= root + 'images/more_info_down.png';
	more_info_up.src	= root + 'images/more_info_up.png';
} );

/**
 * Toggle the category in the left menu.
 * 
 * @param	{int}	category_id	Category id
 */
function toggleCategory( category_id ) {
	if( open_category > 0 ) {
		$( '#cat' + open_category ).hide();
	}
	$( '#cat' + category_id ).show();
	open_category = category_id;
}

/**
 * Toggle the information for a customer.
 * 
 * @param	{Image}	image		Information toggle image
 * @param	{int}	customer_id	Customer id
 */
function toggleCustomerInfo( image, customer_id ) {
	var hidden = $( '#customer_more_info' + customer_id ).hasClass( 'hidden' );
	$( '#customer_more_info' + customer_id ).toggleClass( 'hidden' );
	if( hidden ) {
		image.src = more_info_up.src
		image.title = 'Dölj information';
	} else {
		image.src = more_info_down.src;
		image.title = 'Visa mer information';
	}
}

/**
 * Toggle the information for an order.
 * 
 * @param	{Image}	image		Information toggle image
 * @param	{int}	order_id	Order id
 */
function toggleOrderInfo( image, order_id ) {
	var hidden = $( '#order_more_info' + order_id ).hasClass( 'hidden' );
	$( '#order_more_info' + order_id ).toggleClass( 'hidden' );
	if( hidden ) {
		image.src = more_info_up.src
		image.title = 'Dölj information';
	} else {
		image.src = more_info_down.src;
		image.title = 'Visa mer information';
	}	
}

