(function ($) {
	
	$.globalNav = function (options) {
		return $.globalNav.impl.init(options);
	};
	
	$.fn.globalNav = function (options) {
		return $.globalNav.impl.init(this, options);
	};
	
	/*
	 * nav default options
	 */
	$.globalNav.defaults = {
	    
	};
	
	$.globalNav.impl = {
		
		/*
		 * nav options
		 */
		opts: null,
		
		/*
		 * nav helper
		 */
		helper: {},
		
		/*
		 * Initialize the nav
		 */
		init: function (list, options) {
            
            var self = this;
            
            self.opts = $.extend({}, $.globalNav.defaults, options);
            
            // create the helper objects
            self.helper.list   = $(list);
            
            // prevent default and update swf
            self.helper.list.children().each(function(i, item){
                
                var $a = $(item).children('a');
                
//                if ($a.attr('href').split('#')[1] == SWFAddress.getValue())
//                {
//                    $a.addClass('active');
//                    SWFAddress.setTitle($a.attr('title') + ' | 10 Cane Rum');
//                }
//                else
//                {
//                    $a.removeClass('active');
//                }
                
                // bind click event
//                $a.click(function(e){
//                    e.preventDefault();
//                    
//                    if (!$(this).hasClass('active'))
//                    {
//                        $(this).addClass('active').parent().siblings().children('a').removeClass('active');
//                        
//                        SWFAddress.setValue($(this).attr('href').split('#')[1]);
//                        SWFAddress.setTitle($(this).attr('title') + ' | 10 Cane Rum');
//                    }
//                    
//                });
                
            });
            
            // listen for swfaddress change event
//            SWFAddress.addEventListener(SWFAddressEvent.CHANGE, function(e){
//                
//                var $a = self.helper.list.find('a[href="/en/#' + e.value + '"]');
//                
//                $a.addClass('active').parent().siblings().children('a').removeClass('a');
//                
//            });
            
			return self;
		}
		
	};
})(jQuery);