// bigTarget.js - A jQuery Plugin
// Version 1.0.0
// Written by Leevi Graham - Technical Director - Newism Web Design & Development
// http://newism.com.au

// create closure
(function($) {
	// plugin definition
	$.fn.bigTarget = function(options) {
		debug(this);
		// build main options before element iteration
		var opts = $.extend({}, $.fn.bigTarget.defaults, options);
		// iterate and reformat each matched element
		return this.each(function() {
			var $this = $(this);
			// build element specific options
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
			// update element styles
			$this.parents(o.clickZone)
				.hover(function() {
					$(this).addClass(o.hoverClass);
				}, function() {
					$(this).removeClass(o.hoverClass);
				})
				// click
				.click(function() {
					// if the link is external
					if($this.is('[rel*=external]')){
						window.open( $this.attr('href') );
						return false;
					}
					else {
						window.location = $this.attr('href');
					}
				});
		});
	};
	// private function for debugging
	function debug($obj) {
		if (window.console && window.console.log)
		window.console.log('bigTarget selection count: ' + $obj.size());
	};
	// plugin defaults
	$.fn.bigTarget.defaults = {
		'hoverClass' : 'hover',
		'clickZone'	 : 'li:eq(0)'
	};
	// end of closure
})(jQuery);