function tabs(ulId, panelClass)
{
    var tabList = jQuery('ul#' + ulId);
    if (tabList) {
        tabList.children('LI').each(function(index, element) {
            var a = jQuery(this).children('A');
            if (a.hasClass('on')) {
            	var tabId = a.attr('href');
            	jQuery('div' + tabId).show();
            }
            a.bind('click', function() {
                var tabId = jQuery(this).attr('href');
                jQuery('div.' + panelClass).hide();
                jQuery('div' + tabId).show();
                
                tabList.children('LI').each(function(index, element) {
                    jQuery(this).removeClass('on');
                    jQuery(this).children('A').each(function(index, element) {
                        jQuery(element).removeClass('on');
                    });
                });
                jQuery(this).addClass('on');
                jQuery(this).parent('LI').addClass('on');
                
                if (jQuery(this).attr('timer') == 1) {
                	jQuery(this).attr('timer', 0);
                } else {
                	if (nextTabIntervalId) {
						clearInterval(nextTabIntervalId);
						nextTabIntervalId = 0;
                	}
                }
                
                return false;
            });
        });
    }
}

var firstTabIndex = 0;
var currentTabIndex = firstTabIndex;
var nextTabIntervalId = 0;

function nextTab(ulId)
{
	var tabList = jQuery('ul#' + ulId);
	if (tabList) {
		var maxIndex = tabList.children('LI').length;
		var nextTab = currentTabIndex + 1;
		if (nextTab >= maxIndex) {
			nextTab = firstTabIndex;
		}
		tabList.children('LI').each(function(index, element) {
				if (index == nextTab) {
					var a = jQuery(this).children('A');
					a.attr('timer', 1);
					a.trigger('click');
				}
		});
		currentTabIndex = nextTab;
	}
}

