You could just use the tab as a button to set a Global Variable ($$ActiveTab), you could then just refer to that variable for any subsequent scripts that get called.
You can use this function:
GetLayoutObjectAttribute( "objectname" , "isFrontTabPanel" )
You could use a "Case" statement like this:
$Panel_Number = Case
GetLayoutObjectAttribute( "panel1name" , "isFrontTabPanel" ) ; 1 ;
GetLayoutObjectAttribute( "panel2name" , "isFrontTabPanel" ) ; 2 ;
GetLayoutObjectAttribute( "panel3name" , "isFrontTabPanel" ) ; 3 ;
One method of handleing this is to set each tab panel up with put an OnObjectModify script trigger. The script trigger sends the name of the tab panel to a Tab navigation script. The script can then use ( as suggested above) GetLayoutObjectAttribute( "objectname" , "isFrontTabPanel) in a series of if/elseif statements to set global variables or change layouts.