"use strict";

(function($) {  	
	function initializeEvents(button, opts) {
		$(button).each(function() {
			var link = $(this).find('a').attr('href');
			
			if (opts.addClickEvent && $(this).find('a').attr('target') != "_blank") {
				$(this).click(function(event) {
					if (event.target.nodeName != 'A'){
						window.location = link;
					}
				});
			}
			$(this).hover(function() {
					$(this).addClass(opts.hoverClass);
				}, function() {
					$(this).removeClass(opts.hoverClass);
			});
		});
	}
	
    $.fn.ufcButtons = function(options) {
        var opts = $.extend({}, $.fn.ufcButtons.defaults, options);
        return this.each(function() {
        	initializeEvents($(this),opts);
        });
    };

    $.fn.ufcButtons.defaults = {
    	'hoverClass': "hover",
    	'addClickEvent': true
    };
})(jQuery);
