<?PHP
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Free Web Based Training System                           |
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Plate-forme de téléformation gratuite et en open source  |
// +----------------------------------------------------------------------------|
// | Copyright (C) 2001-2003  Anéma Formation  <http://www.anema.fr/>           |
// +----------------------------------------------------------------------------+
// |           Developer : Georges CALDEIRA <gcaldeira@anemalab.org>            |
// +----------------------------------------------------------------------------+
// |              Infos on project <http://anemalab.org/>                       |
// +----------------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify       |
// | it under the terms of the GNU General Public License as published by       |
// | the Free Software Foundation; either version 2 of the License, or          |
// | (at your option) any later version.                                        |
// |                                                                            |
// | This program is distributed in the hope that it will be useful,            |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of             |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              |
// | GNU General Public License for more details.                               |
// |                                                                            |
// | You should have received a copy of the GNU General Public License          |
// | along with this program; if not, write to the Free Software                |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   |
// +----------------------------------------------------------------------------+

/**
* Gestion des headers
*
* @author		Georges Caldeira <gcaldeira@anemalab.org>
* @package		GaneshaInc
*/

	/**
	* Affiche le header 
	* @access	private
	*/
	
	function GaneshaHeader() {
		global $guser, $header, $TheDate, $headercolor, $titre_profil, $guserid, $ClsMembre, $header, $color2 ;
		$type = $ClsMembre->GetTypeMembre($guserid) ;
		put('
	<table width="100%" border="0" cellspacing="0" cellpadding="5" bgcolor="'.$headercolor.'">
	  <tr>
	    <td width="30%" valign="middle"><a href="'.HTTP_MAIN.'index.php" target="_top" onMouseOver="window.status=\''.$header['exit'].' Ganesha\';return true;" onMouseOut="window.status=\'Ganesha '.VERSION.'\';return true;" >
		    <img src="'.HTTP_IMAGES.'logo_small.gif" border="0" alt="'.$header['exit'].' Ganesha" /></a>
	    </td>
	    <td width="40%">
			<table width="100%" border="0" cellspacing="0" cellpadding="0" >
			<tr>
			  <td width="10%"><IMG src="'.HTTP_IMAGES.'profil_'.$type.'.gif" border="0" ></td>
			  <td width="90%"><b><font color="'.$color2.'">'.$titre_profil[$type].'</font></b><br /><b>'.$header['hello'].' '.CSS($guser).'</b></td>
			</tr>
			</table>
	    </td>
	    <td width="30%" valign="bottom">
			<div align="right"><a href="http://www.anemalab.org" target="_blank" onMouseOver="window.status=\'Ganesha by AnemaLab.org\';return true;" onMouseOut="window.status=\'Ganesha '.VERSION.'\';return true;" >
				<img src="'.HTTP_IMAGES.'ganesha_small_white.gif" alt="Ganesha" border="0" /></a>
				<br><i class="comment">'.VERSION.'</i>
				<br />
				<b>'.$TheDate.'</b><br />
		    </div>
	    </td>
	  </tr>
	</table>');
	
	}
	
	/**
	* Commence le tableau du menu Header
	* @access	private
	*/
	function BeginHeader() {
		global $color2;
		put('		  <table width="100%" border="0" cellspacing="0" cellpadding="4" bgcolor="'.$color2.'">');
		if(OPT_MENU_GRAPH_ACTIVE) {
			put('			  <tr valign="middle" align="right" >');
		} else {
			put('			  <tr valign="middle" align="center" >');
		}
	}
	
	/**
	* Commence la ligne du header
	* @access	private
	*/
	function BeginRow() {
		put('<td>');
	}
	
	/**
	* termine la ligne du header
	* @access	private
	*/
	function CloseRow() {
		put('</td>');
	}
	
	/**
	* termine le tableau du menu Header
	* @access	private
	*/
	function CloseHeader() {
		put('			  </tr>');
		put('		   </table>');
	}
	
	/**
	* Affiche un element du menu principal
	* @param	integer	$index	Id associe au menu
	* @param	string	$titre	Valeur du menu
	* @param	string	$url	URL correspondant au menu
	* @param	string	$img	image a afficher
	* @param	string	$target	cible du chargement de la page
	* @access	private
	*/
	function AddMenu($index=0,$titre='',$url='',$img='',$target='_top'){
	 global $color2, $connexion, $menu, $color1, $color2, $st_menu ;
		if ( $menu == MENU_EMPTY ) { $menu = MENU_TDB ; }
		$bgcolor = 	($index == $menu ? $color1: $color2 )	;
		$class   =  ($index == $menu ? "HEADER2": "HEADER1");
		$over = 'onMouseOver="window.status=\''.Replace($titre).'\';return true;"'; 
		$out  = 'onMouseOut="window.status=\'Ganesha '.VERSION.'\';return true;"';
		$url  = ($url==""?"":$url.'?menu='.$index.'&connexion='.$connexion) ;
		if ( $img != '' ) {
			put( '<td valign="middle" align="right" bgcolor="'.$bgcolor.'"><a href="'.$url.'" target="'.$target.'" class="'.$class.'" '.$over.' '.$out.'>'.$img.'</a></td>');
		}
		if ( $titre == "" ) {
			put('<td valign="middle" align="left" bgcolor="'.$bgcolor.'">&nbsp;</td>');
		} else {
			$link = '<a href="'.$url.'" target="'.$target.'" class="'.$class.'" '.$over.' '.$out.'>'.$titre.'</a>';
			put('<td valign="middle" align="left" bgcolor="'.$bgcolor.'">'.$link.'</td>');
		}
	}
	
	/**
	* Affiche un element du menu principal
	* @param	integer	$index	Id associe au menu
	* @param	string	$url	URL correspondant au menu
	* @param	string	$img	URL correspondant a une image
	* @access	private
	*/
	function AddMenu2($index,$titre,$url,$img='',$target='_top'){
	 global $color2, $connexion, $menu, $color1, $color2 ;
	 	$menu = ( $menu == MENU_EMPTY ? MENU_TDB : $menu );
		$over = 'onMouseOver="window.status=\''.Replace($titre).'\';return true;"'; 
		$out  = 'onMouseOut="window.status=\'Ganesha '.VERSION.'\';return true;"';
		$url  = ($url==""?"":$url.'?menu='.$index.'&connexion='.$connexion) ;
		$link = '<a href="'.$url.'" target="'.$target.'" '.$over.' '.$out.'>'.$img.'</a>';
		put($link);
	}
	
	/**
	* Affiche un element du menu principal
	* @param	integer	$index	Id associe au menu
	* @param	string	$width	Taille de la cellule
	* @param	string	$titre	Valeur du menu
	* @param	string	$url	URL correspondant au menu
	* @access	private
	*/
	function AddMenu3($index,$width,$titre,$url,$img='',$target='_top'){
	 global $color2, $connexion, $menu, $color1, $color2, $st_menu ;
		if ( $menu == MENU_EMPTY ) { $menu = MENU_TDB ; }
		$bgcolor = 	($index == $menu ? $color1: $color2 )	;
		$class   =  ($index == $menu ? "HEADER2": "HEADER1");
		$over = 'onMouseOver="window.status=\''.Replace($titre).'\';return true;"'; 
		$out  = 'onMouseOut="window.status=\'Ganesha '.VERSION.'\';return true;"';
		$url  = ($url==""?"":$url.'?menu='.$index.'&connexion='.$connexion) ;
		if ( $titre == "" ) {
			put('<td valign="middle" width="'.$width.'"  bgcolor="'.$bgcolor.'">&nbsp;</TD>');
		} else {
			$link = '<a href="'.$url.'" target="'.$target.'" class="'.$class.'" '.$over.' '.$out.'>'.$img.$titre.'</a>';
			put('<td valign="middle" width="'.$width.'"  bgcolor="'.$bgcolor.'">'.$link.'</td>');
		}
	}
		
	/**
	* Affiche le menu du profil Stagiaire
	* @access	public
	*/
	function HeaderStagiaire() {
	 global $connexion, $color1, $color2, $ext ;
	 global $st_menu ;
		BeginHeader();
	
		if ( !OPT_MENU_GRAPH_ACTIVE ) {
			AddMenu(0,$st_menu['quit'],HTTP_MAIN.'index'.$ext,MENU_IMG_QUIT)	;
			AddMenu(1,$st_menu['tdb'],HTTP_GANESHA.'index'.$ext,MENU_IMG_TDB)		;
			AddMenu(2,$st_menu['mess'],HTTP_GANESHA.'index'.$ext,MENU_IMG_MESS);
			AddMenu(3,$st_menu['forum'],HTTP_GANESHA.'index'.$ext,MENU_IMG_FORUM)	;
			if ( OPT_WINDOW_CHAT ) {
				AddMenu(4,$st_menu['chat'],HTTP_CHAT.'index'.$ext,MENU_IMG_CHAT,'_blank')	;
			} else {
				AddMenu(4,$st_menu['chat'],HTTP_GANESHA.'index'.$ext,MENU_IMG_CHAT)		;
			}
			AddMenu(5,$st_menu['doc'],HTTP_GANESHA.'index'.$ext,MENU_IMG_DOC)	;
			AddMenu(6,$st_menu['aide'],HTTP_GANESHA.'index'.$ext,MENU_IMG_AIDE)		;
		} else {
			BeginRow();
			AddMenu2(0,$st_menu['quit'],HTTP_MAIN.'index'.$ext,MENU_IMG_QUIT )		;
			AddMenu2(1,$st_menu['tdb'],HTTP_GANESHA.'index'.$ext,MENU_IMG_TDB)		;
			AddMenu2(2,$st_menu['mess'],HTTP_GANESHA.'index'.$ext,MENU_IMG_MESS);
			AddMenu2(3,$st_menu['forum'],HTTP_GANESHA.'index'.$ext,MENU_IMG_FORUM)	;
			if ( OPT_WINDOW_CHAT ) {
				AddMenu2(4,$st_menu['chat'],HTTP_GANESHA.'index'.$ext,MENU_IMG_CHAT,'_blank')	;
			} else {
				AddMenu2(4,$st_menu['chat'],HTTP_GANESHA.'index'.$ext,MENU_IMG_CHAT)	;
			}
			AddMenu2(5,$st_menu['doc'],HTTP_GANESHA.'index'.$ext,MENU_IMG_DOC)	;
			AddMenu2(6,$st_menu['aide'],HTTP_GANESHA.'index'.$ext,MENU_IMG_AIDE)		;
			CloseRow();
		}
		CloseHeader();
	}
	
	/**
	* Affiche le menu du profil Tuteur
	* @access	public
	*/
	function HeaderTuteur() {
	 global $connexion, $color1, $color2, $ext ;
	 global $tu_menu ;
		BeginHeader();
		if ( !OPT_MENU_GRAPH_ACTIVE ) {
			AddMenu(0,$tu_menu['quit'],HTTP_MAIN.'index'.$ext,MENU_IMG_QUIT ) 	;
			AddMenu(1,$tu_menu['tdb'],HTTP_GANESHA.'index'.$ext,MENU_IMG_TDB )		;
			AddMenu(2,$tu_menu['mess'],HTTP_GANESHA.'index'.$ext,MENU_IMG_MESS );
			AddMenu(3,$tu_menu['forum'],HTTP_GANESHA.'index'.$ext,MENU_IMG_FORUM )	;
			AddMenu(4,$tu_menu['chat'],HTTP_GANESHA.'index'.$ext,MENU_IMG_CHAT )		;
			AddMenu(5,$tu_menu['doc'],HTTP_GANESHA.'index'.$ext,MENU_IMG_DOC );
			AddMenu(6,$tu_menu['ques'],HTTP_GANESHA.'index'.$ext,MENU_IMG_AIDE );
		} else {
			BeginRow();
			AddMenu2(0,$tu_menu['quit'],HTTP_MAIN.'index'.$ext,MENU_IMG_QUIT ) 	;
			AddMenu2(1,$tu_menu['tdb'],HTTP_GANESHA.'index'.$ext,MENU_IMG_TDB )		;
			AddMenu2(2,$tu_menu['mess'],HTTP_GANESHA.'index'.$ext,MENU_IMG_MESS );
			AddMenu2(3,$tu_menu['forum'],HTTP_GANESHA.'index'.$ext,MENU_IMG_FORUM )	;
			AddMenu2(4,$tu_menu['chat'],HTTP_GANESHA.'index'.$ext,MENU_IMG_CHAT )		;
			AddMenu2(5,$tu_menu['doc'],HTTP_GANESHA.'index'.$ext,MENU_IMG_DOC );
			AddMenu2(6,$tu_menu['ques'],HTTP_GANESHA.'index'.$ext,MENU_IMG_AIDE );
			CloseRow();
		}
		CloseHeader();
	}

?>