<?php

global  $gn_tab_id;

//  get functions
require_once( dirname(__FILE__) . '/tab_panel.php' );

$body_color					= get_option( 'gn_body_color' );
$body_background		= get_option( 'gn_body_background' );
$wrapper_background	= get_option( 'gn_wrapper_background' );

global 	$tab_feature_b1,
 	      $tab_feature_b2,
 	      $tab_count_b1,
   	    $tab_count_b2,
				$tab_b1_titles,
				$tab_b2_titles,
				$panel_1_active_tab_id,
				$panel_2_active_tab_id;

global  $wp_registered_sidebars;




//  check if tab_id's are set - if not set to default
if ( !$_SESSION["gn_tab_1"] )
{
  $_SESSION["gn_tab_1"] = '1'; 
}
if ( !$_SESSION["gn_tab_2"] )
{
  $_SESSION["gn_tab_2"] = '1'; 
}



//  check if any tab is choosen
$query_string = $_SERVER['QUERY_STRING'];
if ( $query_string )
{
  $gn_pos = strpos( $query_string, 'ab_id=');

  if ( $gn_pos )
  {
    $gn_tab_id = substr( $query_string, $gn_pos + 6);

    if ( substr($gn_tab_id, 0, 1) == '1' )
	  {
		   $panel_1_active_tab_id = substr( $gn_tab_id, 2);
		   $_SESSION["gn_tab_1"] = $panel_1_active_tab_id;
	  }
	  else
	  {
		   $panel_2_active_tab_id = substr( $gn_tab_id, 2);
		   $_SESSION["gn_tab_2"] = $panel_2_active_tab_id;
	  }
  }
}
else
{
}


//
//
//  print bottom bars and tab panels
//
//

  echo '<div id="bottom_container">';
	echo '<div id="sidebar_b1">';

	if  ( $tab_feature_b1 == 'on' )
	{
    if ( $_SESSION["gn_tab_1"] )
    {
      $panel_1_active_tab_id = $_SESSION["gn_tab_1"]; 
    }
	  print_tab_panel_1($panel_1_active_tab_id);
	}
	else
	{
		echo '<ul class="sidebar_b1_ul">';
				/* Widgetized sidebar, if you have the plugin installed. */
				if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('BottomBar-1') ) :
 	    		echo '<ul> </ul>';
				endif;
		echo '</ul>';
	}

	echo	'</div>';


	echo	'<div id="sidebar_b2">';


	if  ($tab_feature_b2 == 'on')
	{
    if ( $_SESSION["gn_tab_2"] )
    {
      $panel_2_active_tab_id = $_SESSION["gn_tab_2"]; 
    }
	  print_tab_panel_2($panel_2_active_tab_id);
	}
	else
	{
		echo '<ul class="sidebar_b2_ul">';
		
		//	calculate sidebar id
	  $id = count($wp_registered_sidebars);

		/* Widgetized sidebar, if you have the plugin installed. */
		if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('BottomBar-2') ) :
  		echo '<ul> </ul>';
		endif;

		echo '</ul>';
	}


	echo	'</div>';
	echo  '</div>';

?>