<?php
//************************************************
//
// Tab Pane Class (alright, it's not a class yet)
//
// Created By:    Kenneth Brill <kbrill@multi.com>
// Javascript By: Erik Arvidsson
// Ported to PHP-Nuke By : Louis Lecaroz <louis.lecaroz@le-resistant.com>
//
// Copyright: 2002
// Website:www.multi.com/coding
//
// ToDo: Make it a class
//************************************************

// Global Varibles
$TabID=0;
$WinID=0;

class Tabs
{
	var $nTabs; 
	var $Height;
	
	function Tabs($WindowID, $Height=-1, $bUseCookie=0)
	{
		$this->nTabs=0;
		$this->WindowID=$WindowID;
		$this->Height=$Height;
		$this->bUseCookie=$bUseCookie;
	}

	function StartTabWindow() {
	  global $WinID;
	  $this->nTabs=0;
	  $WinID++;
	  $strWinID="TabPane" . $WinID;
	  echo "\n<div class='tab-pane' id='" . $strWinID . "'>\n"
	      ."<script type='text/javascript'>\n"
	      ."".$this->WindowID." = new WebFXTabPane( document.getElementById( \"" . $strWinID . "\" ),".$this->Height.",".$this->bUseCookie." );\n"
	      ."</script>\n\n";
	}

	function EndTabWindow() {
	   if($this->nTabs>0) echo "</div>";

	   echo "<script type='text/javascript'>\n"
	       ."".$this->WindowID.".closeTabPane( );\n"
	       ."</script>\n\n"
	       ."</div>\n";

	   $this->nTabs=0;
	}

	function AddTab($TabName) {
	   global $TabID;
	   if($this->nTabs>0) echo "</div>\n";

	   $TabID++;
	   $strTabID="Tab" . $TabID;
	   echo "<div class='tab-page' id='" . $TabName . "' style=\"overflow : auto; ".($this->Height!=-1?("height:".$this->Height."px;"):"")."\">\n"
	       ."<h2 class='tab'>" . $TabName . "</h2>\n"
	       ."<script type='text/javascript'>" . $this->WindowID . ".addTabPage( document.getElementById( \"" . $TabName . "\" ) );</script>\n";
	   $this->nTabs++;
	}
}