(function($) {

	/**
	* @param options
	*/
	$.fn.bgswap = function(options) {

		var settings = {
			bgs: [],
			selector: ".wrapper"
		};

		var options = $.extend(settings, options);

		return this.each(function(i, e) {
			return new BgSwap(e, options);
		});
	};

	/**
	* 
	*/
	function BgSwap(ele, settings) {
		this.e = ele;
		this.$e = $(ele);
		this.settings = settings;

		// Don't need to initialize anything
		// init.call(this);

		registerEvents.call(this);
	}

	/**
	* 
	*/
	function init() {
		var obj = this;
	}

	/**
	* 
	*/
	function registerEvents() {
		var obj = this;

		// Bind events
		$(document).bind("carousel:slide", function(event, data) {
			swap.call(obj, event, data);
		});
		$(document).bind("mainnav:slide", function(event, data) {
			swap.call(obj, event, data);
		});
	}

	/**
	* 
	*/
	function swap(event, data) {
		var obj = this;
		obj.$e.css({
			backgroundImage: "url(" + obj.settings.bgs[data.newIndex] + ")"
		});
	}
})(jQuery);
