<?php

//
//
//    this php source code file builds the tabs inside the 
//    bottom bars
//    and is called from bottom_bars.php through the functions:
//
//    print_tab_panel_1
//    print_tab_panel_2
//  
//

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;





function  print_tab_panel_1( $active_tab_id = '1' )
{
	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;



	if ( $active_tab_id == '' )
	{
	  $active_tab_id = 1;
	}
	
  $panel_1_active_tab_id = $active_tab_id;
  
	$output_line = '';
	
	$output_line = '<div class="tab_panel_container">
	                	<div class="tab_panel_tabs_container">';

	echo $output_line;

  get_tab_b1_titles();

	$output_line = '';

	if ( $_SERVER['QUERY_STRING'] == '' )
		$uri_script = 'index.php';
	else
	  $uri_script = '';

	$gn_strpos 			= strpos( $_SERVER['REQUEST_URI'], '?tab_id=');
	if ( $gn_strpos == false )
	{
		$gn_request_uri = $_SERVER['REQUEST_URI'];
	}
	else
	{
		$gn_strlen 			= strlen( $_SERVER['REQUEST_URI'] );
		$gn_request_uri = substr( $_SERVER['REQUEST_URI'], 0, ($gn_strpos ));
	}

	//  print tabs
	foreach ( $tab_b1_titles as $index => $title )
	{
	  if ( $index == $active_tab_id )
	  {
			$class = ' tab_active" ';
	  }
	  else
	  {
	    $class = ' tab_inactive" ';
		}

	  $output_line	= '<div class="tab_panel_tab' . $class . '>';
	  $output_line .= '<a href="'. $gn_request_uri . $uri_script . '?tab_id=1_' . $index . '">' . $title . '</a>';
	  $output_line .= '</div>';
	  
		echo $output_line;
	}
	                	
	$output_line = ' 	</div>
	                	<div class="tab_panel_body">';

  echo $output_line;

  $name = 'BottomBar-1 Tab-' . $active_tab_id;

							echo '<ul>';
							/* Widgetized sidebar, if you have the plugin installed. */
							if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar( $name ) )
							{
 	    					echo '<ul> </ul>';
							}
							echo '</ul>';

	$output_line = ' 	</div>
	               </div>';
					
	echo $output_line;
	
	return;
}




function  print_tab_panel_2( $active_tab_id = '1' )
{
	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;

	if ( $active_tab_id == '' )
	{
	  $active_tab_id = 1;
	}

  $panel_2_active_tab_id = $active_tab_id;

	$output_line = '';

	$output_line = '<div class="tab_panel_container">
	                	<div class="tab_panel_tabs_container">';

	echo $output_line;

  get_tab_b2_titles();

	$output_line = '';

	if ( $_SERVER['QUERY_STRING'] == '' )
		$uri_script = 'index.php';
	else
	  $uri_script = '';

	$gn_strpos 			= strpos( $_SERVER['REQUEST_URI'], '?tab_id=');
	if ( $gn_strpos == false )
	{
		$gn_request_uri = $_SERVER['REQUEST_URI'];
	}
	else
	{
		$gn_strlen 			= strlen( $_SERVER['REQUEST_URI'] );
		$gn_request_uri = substr( $_SERVER['REQUEST_URI'], 0, ($gn_strpos ));
	}

	//  print tabs
	foreach ( $tab_b2_titles as $index => $title )
	{
	  if ( $index == $active_tab_id )
	  {
			$class = ' tab_active" ';
	  }
	  else
	  {
	    $class = ' tab_inactive" ';
		}

	  $output_line	= '<div class="tab_panel_tab ' . $class . '>';
	  $output_line .= '<a href="'. $gn_request_uri . $uri_script . '?tab_id=2_' . $index . '">' . $title . '</a>';
	  $output_line .= '</div>';

		echo $output_line;
	}

	$output_line = ' 	</div>
	                	<div class="tab_panel_body">';

	echo $output_line;

	if ( $tab_feature_b1 == 'on' )
	{
	  $sidebar_index = 2 + $tab_count_b1 + $active_tab_id;
	}
	else
	{
	  $sidebar_index = 3 + $active_tab_id;
	}

  $name = 'BottomBar-2 Tab-' . $active_tab_id;

							echo '<ul>';
							/* Widgetized sidebar, if you have the plugin installed. */
							if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar( $name ) )
							{
 	    					echo '<ul> </ul>';
							}
							echo '</ul>';

	$output_line = ' 	</div>
	               </div>';

	echo $output_line;

	return;
}

?>