(function($){
	$.fn.button = function () {
		var args = arguments[0];
		return this.each(function () {
			var _this = $(this);
			if (_.isUndefined(args) || _.isNull(args)) {
				args = {};
			}
			var handlers = {
				mouseover: function (e) {
					$("body").css("cursor", "pointer");
					$(this).addClass("hover");
					if (!_.isUndefined(args.mouseover)) {
						args.mouseover.call(_this);
					}
				},
				mouseleave: function (e) {
					$("body").css("cursor", "auto");
					$(this).removeClass("hover");
					if (!_.isUndefined(args.mouseout)) {
						args.mouseout.call(_this);
					}
				},
				mousedown: function (e) {
					e.preventDefault();
				},
				click: function (e) {
					if ( $(this).data('buttondata').active ) {
						$(this).data('buttondata').active = false;
						$(this).removeClass("active").addClass("inactive");
					} else {
						$(this).addClass("active").removeClass("inactive");
						$(this).data('buttondata').active = true;
					}
					if (!_.isUndefined(args.callback) && _.isFunction(args.callback)) {
						args.callback.call(_this);
					} else {
						if (!_.isUndefined($(this).attr('data-href'))) {
							window.location = $(this).attr('data-href');
						}
					}
				}
			};
			args.handlers = handlers;
			$(this).data("buttondata", args);
			$(this).bind(handlers);
		});
	};
	$.fn.center = function () {
		return this.each(function () {
			var x = ($(window).width() - $(this).outerWidth()) / 2;
			var y = ($(window).height() - $(this).outerHeight()) / 2 + $(window).scrollTop();
			$(this).css({
				"position": "absolute",
				"top": y + "px",
                "left": x + "px"
			});
		});
    };
	$.fn.centerHorizontal = function () {
		return this.each(function () {
			var x = ($(window).width() - $(this).outerWidth()) / 2;
			$(this).css({
				"position": "absolute",
				"left": x + "px"
			});
		});
	};
	$.fn.centerVertical = function () {
		return this.each(function () {
			var y = ($(window).height() - $(this).outerHeight()) / 2 + $(window).scrollTop();
			$(this).css({
				"position": "absolute",
				"top": y + "px"
			});
		});
	};
})(jQuery);

