
(function($){

	"use strict";

	$(document).ready(function(){

		/* setup tab. */
		$('#tab')
			.idTabs(function(id, list, set){
				/* switch active tab. */
				$('a', set).each(function(){
					if (this.hash === id) {
						$(this).closest('li').addClass('selected');
					} else {
						$(this).closest('li').removeClass('selected');
					}
				});

				/* show & hide tab contents. */
				for (var i in list) {
					$(list[i]).hide();
				}
				$(id)
					.stop(false, true)
					.fadeIn('fast')
				;
			})

			/* setup tab item handler. */
			.find('li')
				.css('cursor', 'pointer')
				.hover(
					function(){
						$(this).addClass('on');
					},
					function(){
						$(this).removeClass('on');
					}
				)
				.click(function(){
					$('a', this).trigger('click');
					return false;
				})
				.filter('.current')
					.removeClass('current')
					.trigger('click')
				.end()
			.end()
		;

	});

})(jQuery);

