(function ($) {
	
	$.footerNav = function (options) {
		return $.footerNav.impl.init(options);
	};
	
	$.fn.footerNav = function (options) {
		return $.footerNav.impl.init(this, options);
	};
	
	/*
	 * footerNav default options
	 */
	$.footerNav.defaults = {
	    
	};
	
	$.footerNav.impl = {
		
		/*
		 * footerNav options
		 */
		opts: null,
		
		/*
		 * footerNav helper
		 */
		helper: {},
		
		/*
		 * Initialize the footerNav
		 */
		init: function (list, options) {
            
            var self = this;
            
            self.opts = $.extend({}, $.footerNav.defaults, options);
            
            // create the helper objects
            self.helper.list            = $(list);
            self.helper.footer          = $('div.footer-container');
            self.helper.terms           = $('div.terms-container');
            self.helper.privacy         = $('div.privacy-container');
            //self.helper.overlay         = $('<div class="modal-overlay"></div>');
		    
		    // bind terms click
		    self.helper.list.find('a.open-terms').click(function(e){
		        e.preventDefault();
		        
		        self.helper.terms
		            .css({
		                display:    'block',
		                opacity:    '0.00',
		                left:       $(this).offset().left + $(this).width() - self.helper.terms.width() + 'px',
		                top:        $(this).offset().top - self.helper.terms.height() - 5 + 'px'
		            })
		            ;
		        
		        self.helper.terms.find('div.scrollable')
		            .jScrollPane({
                        scrollbarWidth: 7,
                        scrollbarMargin: 20,
                        wheelSpeed: 32
                    })
                    ;
                
                self.helper.terms
                    //.fadeTo(300, '1.00');
                    .css({
                        opacity:    '1.00'
                    })
                    ;
		        
//		        self.helper.overlay
//		            .insertBefore(self.helper.terms)
//		            .css({
//		                display:    'block',
//		                opacity:    '0.00'
//		            })
//		            .fadeTo(300, '0.60');
//		            ;
		        
		        // bind close click
		        $('a.close-terms').unbind().click(function(e){
		            e.preventDefault();
		            self.helper.terms
		                //.fadeOut(300)
		                .css({
		                    display:  'none'
		                })
		                ;
//		            self.helper.overlay
//		                .fadeOut(300)
//		                ;
		        });
		        
		    });
		    
		    // bind privacy click
		    self.helper.list.find('a.open-privacy').click(function(e){
		        e.preventDefault();
		        
		        self.helper.privacy
		            .css({
		                display:    'block',
		                opacity:    '0.00',
		                left:       $(this).offset().left + $(this).width() - self.helper.privacy.width() + 'px',
		                top:        $(this).offset().top - self.helper.privacy.height() - 5 + 'px'
		            })
		            ;
		        
		        self.helper.privacy.find('div.scrollable')
		            .jScrollPane({
                        scrollbarWidth: 7,
                        scrollbarMargin: 20,
                        wheelSpeed: 32
                    })
                    ;
                
                self.helper.privacy
                    .css({
                        opacity:    '1.00'
                    })
                    //.fadeTo(300, '1.00');
                    ;
		        
//		        self.helper.overlay
//		            .insertBefore(self.helper.privacy)
//		            .css({
//		                display:    'block',
//		                opacity:    '0.00'
//		            })
//		            .fadeTo(300, '0.60');
//		            ;
		        
		        // bind close click
		        $('a.close-privacy').unbind().click(function(e){
		            e.preventDefault();
		            self.helper.privacy
		                .css({
		                    display:    'none'
		                })
		                //.fadeOut(300)
		                ;
//		            self.helper.overlay
//		                .fadeOut(300)
//		                ;
		        });
		        
		    });
            
			return self;
		}
		
	};
})(jQuery);