﻿(function ($) {

	function Tabs(domNode, options) {
		this._el = $(domNode);
		this._init(options || {});
	}

	Tabs.prototype = {

		options: {},

		_init: function (options) {
			this.options = $.extend({}, $.defaults, options);
			this._initTabs();
		},
		_initTabs: function () {
			var $this = this;

			$($this.options.tabs).each(function () {
				var $tab = this;
				$this._el.find($tab.selector).bind('click', function () {
					window.location.href = $tab.link;
				});
			});
		}
	};

	$.fn.cmstabs = function (options) {
		return this.each(function () {
			var el = $(this);
			if (!el.data('cmstabs'))
				el.data("cmstabs", new Tabs(this, options));
		});
	};

	$.defaults = {
		tabselector: '.cmsnav',
		tabs: []
	};

	$.tabs = function (el) {
		return $(el).eq(0).data('cmstabs');
	};
})(jQuery);



