/* This script will add the dynamic functionality to the divs that are styled to be tabs */
$(document).ready(function () {
    var tabContainers = $('div.tabs > div');
                
    tabContainers.each(function(i, e) { $(e).attr('id', 'tabpane' + (i++))});
    
	// Space out the widths
	$('ul.tabNavigation li').each(function(i, e) {
         $(e).css('width', (100/tabContainers.length) + '%');
    });
	
	// Add the click functionality and disable tabs that are empty
    $('div.tabs ul.tabNavigation a').each(function(i, e) {
        
		if ($(tabContainers[i]).children().length==0) {
			$(e).addClass('disabled');
		}
		
        $(e).attr('href', '#tabpane' + i)
	
    }).click(function () {
    
        if (!$(this).hasClass('disabled'))
        {
            tabContainers.hide().filter(this.hash).show();
            
            $('div.tabs ul.tabNavigation a').removeClass('selected');
            $(this).addClass('selected');
        }
        
        return false;
    }).filter(':first').click();
});
