You can buy this project and download/modify it how often you want.
#foreach($tab in $control.tabs) #set($counter = $control.getCounter($foreach.index)) $tab.title #end #foreach($tab in $control.tabs) #if($tab.name == $control.activeTabName) $insert.control($tab.name) #else #end #end