/***
@title:
Super Simple Tabs

@version:
1.1

***/
jQuery.fn.superSimpleTabs = function (selected) {

//	var listItem = $('#selected');
	var sel = $('#selected').index('.my-account-taburi li') || 0;
	if(sel==-1) {sel=0;}
	sel++;

	return this.each(function () {
		var ul	= jQuery(this);
		var ipl	= 'a[href^=#]';

		// Go through all the in-page links in the ul
		// and hide all but the selected's contents
		ul.find(ipl).each(function (i) {
			var link = jQuery(this);

			if ((i + 1) === sel) {
				link.addClass('selected-tab');
			}
			else {
				jQuery(link.attr('href')).hide();
			}
		});

		// When clicking the UL (or anything within)
		ul.click(function (e) {
			var clicked	= jQuery(e.target);
			var link	= false;

			if (clicked.is(ipl)) {
				link = clicked;
			}
			else {
				var parent = clicked.parents(ipl);

				if (parent.length) {
					link = parent;
				}
			}

			if (link) {
				var selected = ul.find('a.selected-tab');

				if (selected.length) {
					jQuery(selected.removeClass('selected-tab').attr('href')).hide();
				}

				jQuery(link.addClass('selected-tab').attr('href')).show();

				return false;
			}
		});
	});
};
