/*! NV Tabs  <http://nvinteractive.co.nz>
	Copyright (c) NV Interactive
	
	References:
		jquery-1.3.x.js
		
	Release Notes:
*/


//
// create closure
//
(function($) {

//
// plugin definition
//
	$.fn.nvtabs = function(options) {
		debug(this);
		// build main options before element iteration
		var opts = $.extend({}, $.fn.nvtabs.defaults, options);
		
		// iterate and reformat each matched element
		return this.each(function(){$.fn.nvtabs.process(this, opts)});
	};
	
//
// private function for debugging
//
	function debug($obj) {
		if (window.console && window.console.log)
			window.console.log('nvtabs selection count: ' + $obj.size());
	};
	
//
// define and expose our format function
//
	$.fn.nvtabs.process = function(element, opts) {
		$this = $(element);
		// build element specific options
		$("dt", $this)
			.click( $.fn.nvtabs.click )
			.hover( function(){ $(this).addClass("over") }, function(){ $(this).removeClass("over") })
			.eq(0).click() //Show the first tab;
		
	};
	
//
// Events
//

$.fn.nvtabs.click = function(){

	if( $(this).hasClass("selected") )return;

	$(this)
		.siblings("dd").css("display", "none").end()
		.siblings("dt").removeClass("selected").end()
		.addClass("selected")
		.next()
		.fadeIn("fast");
}


	
//
// plugin defaults
//
	$.fn.nvtabs.defaults = {
  	};
//
// end of closure
//
})(jQuery);