//////////////////////////////////////////////////////////////////////////////////////////
// Menu Specification
// Copyright (c) Muhamed F. Mudawar
// King Fahd University of Petroleum and Minerals
// Last updated : September 8, 2007
//////////////////////////////////////////////////////////////////////////////////////////

HomeDIR  = "http://faculty.kfupm.edu.sa/ee/naffouri/";
CourseDIR  = "http://faculty.kfupm.edu.sa/ee/naffouri/courses/";
ImageDIR = "<img src="+HomeDIR+"images/";

//////////////////////////////////////////////////////////////////////////////////////////
// Global Parameters
//////////////////////////////////////////////////////////////////////////////////////////
waitTime      = 200;     // Time the menu stays out after the mouse goes out
menuIsStatic  = "yes";   // Whether menu should stay static on the screen or not
barWidth      = 25;      // Width of all menu side-bars that carries the identify(name) menu image 
staticYOffset = 15;       // Global Y-offset added to Y-offset of all menus shifting all menus down
VerSlideSpeed = 30;      // Speed of menu while sliding up or down .. i.e vertically
HorSlideSpeed = 3;       // Speed of menu while sliding right or left .. i.e horizontally
startZindex   = 100;     // z-Index of first menu .. starting top-menu

BarBorderSize  = 0;    // Border size of all menu bars
BarBorderColor = "";   // Border color of all menu bars

MenuCount = 0;         // Number of menus
Menu = new Array;      // Array of menu objects

//////////////////////////////////////////////////////////////////////////////////////////
// *************************** Menu Specification Starts Here ************************* //
//////////////////////////////////////////////////////////////////////////////////////////

// ------------------------------------------------------------------------------------ //
// Menu styles are created here and used by instantiation of an object from MenuStyleObj

// new MenuStyleObj(MenuCellSpacing, MenuBgColor, BarBgColor, BarTextColor, CellPadding)

// MenuBorderSize:  Size of menu border in pixels
// MenuBorderColor: Color of menu border
// BarBgColor:      Color of bar background ("" for transparent)
// BarTextColor:    Color of bar text (when title is not an image)
// CellPadding:     Padding used within menu item cells (in pixels)
// ------------------------------------------------------------------------------------ //
var MenuStyle = new MenuStyleObj(1, "white",   "", "", 2); //2

// ------------------------------------------------------------------------------------ //
// Menu item styles are created here and used below

// new ItemStyleObj(FontFamily, FontSize, Bold, Italic, Align)

// FontFamily: Font Family separated by commas
// FontSize:   Font size in points
// Bold:       "yes" if bold
// Italic:     "yes" if italic
// Align:      "left","center","right"
// ------------------------------------------------------------------------------------ //
var ItemStyle      = new ItemStyleObj("Verdana", 8, "No",  "No",  "left");
var SeparatorStyle = new ItemStyleObj("Verdana", 1, "No",  "No",  "left");
var TitleStyle     = new ItemStyleObj("Verdana", 8, "Yes", "No",  "center");
var FormMenuStyle  = new ItemStyleObj("Verdana", 8, "No",  "No",  "left");
var FormItemStyle  = new ItemStyleObj("Verdana", 8, "No",  "No",  "left");
var FormLabelStyle = new ItemStyleObj("Verdana", 8, "No",  "No",  "left");
var ButtonStyle    = new ItemStyleObj("Verdana", 8, "No",  "No",  "center");

// ------------------------------------------------------------------------------------ //
// Menu item colors are created here and used below

// new ItemColorObj(LowBg, HighBg, LowFont, HighFont)
// new ItemColorObj(FormItemBg, HighBg, FormItemFont, TitleFont)

// LowBg:    Background color when mouse is out
// HighBg:   Background color when mouse is over
// LowFont:  Font color when mouse is out
// HighFont: Font color when mouse is over
// ------------------------------------------------------------------------------------ //
var ItemColor      = new ItemColorObj("#DDDDDD", "Black", "Black", "Yellow");
var SeparatorColor = new ItemColorObj("Black",   "Black", "Yellow","Yellow");
var TitleColor     = new ItemColorObj("#444444", "Black", "White", "Yellow");
var FormItemColor  = new ItemColorObj("White",   "", "Black", "Brown");
var FormMenuColor  = new ItemColorObj("White",   "", "Black", "");
var ButtonColor    = new ItemColorObj("#CCCCCC", "", "Black", "");

// ------------------------------------------------------------------------------------ //
// AddMenu(TitleImg, MenuOffset, BarOffset, MenuWidth, MenuStyle)
// AddMenuItem(Title, URL, Target, Style, Color)
// AddForm(Name, Action, Target, Encoding, BgColor, cellpadding)
// AddFormItem(Category, Name, Action, Style, Color, Width, Values)
//
// Functions are documented under script.js
// ------------------------------------------------------------------------------------ //

// ------------------------------------------------------------------------------------ //
// ************************************ Menu [Home] *********************************** //
// ------------------------------------------------------------------------------------ //

	AddMenu(ImageDIR+"Home.gif", 0, 0, 100, MenuStyle);
  //AddMenuItem("Home Page",			HomeDIR+"index.htm",              "", ItemStyle, ItemColor);
  AddMenuItem("Home Page",			HomeDIR+"index.htm",              "", ItemStyle, ItemColor);		  
  AddMenuItem("Biography",			HomeDIR+"biography.html",     "", ItemStyle, ItemColor);		
  AddMenuItem("Education and Honors",	HomeDIR+"edu.html",            "", ItemStyle, ItemColor);
  AddMenuItem("Professional Experience",	HomeDIR+"professional.html",            "", ItemStyle, ItemColor);
  AddMenuItem("Schedule",				HomeDIR+"schedule.html",          "", ItemStyle, ItemColor);		

  // AddMenuItem("",  "",     "", SeparatorStyle, SeparatorColor);		  



// ------------------------------------------------------------------------------------ //
// ******************************** Menu [Research] ********************************** //
// ------------------------------------------------------------------------------------ //

AddMenu(ImageDIR+"Research.gif", 60, 60, 100, MenuStyle);
  AddMenuItem("Research Interests",       HomeDIR+"research.html",     "", ItemStyle, ItemColor);
  AddMenuItem("Publications",        		HomeDIR+"publications.html",     "", ItemStyle, ItemColor);
  AddMenuItem("Talks",      				HomeDIR+"talks.html",    "", ItemStyle, ItemColor);
  AddMenuItem("Projects",        			HomeDIR+"projects.html",     "", ItemStyle, ItemColor);
  AddMenuItem("Research Collaborators",   HomeDIR+"collaborators.html",     "", ItemStyle, ItemColor);


// ------------------------------------------------------------------------------------ //
// ********************************* Menu [Students] ********************************** //
// ------------------------------------------------------------------------------------ //

AddMenu(ImageDIR+"Students.gif", 140, 140, 100, MenuStyle);
  AddMenuItem("Group Memebers",       HomeDIR+"group_members.html",    "", ItemStyle, ItemColor);
  AddMenuItem("Info to Prospective Students",        HomeDIR+"info_pers.html",     "", ItemStyle, ItemColor);
  AddMenuItem("Students Comments",        HomeDIR+"comments.html",     "", ItemStyle, ItemColor);
  //AddMenuItem("&nbsp;",        "",     "", ItemStyle, ItemColor);*/

  //AddMenuItem("&nbsp;M.Sc. Theses",    "", "", ItemStyle, ItemColor);
  //AddMenuItem("&nbsp;Senior Projects", "", "", ItemStyle, ItemColor);


// ------------------------------------------------------------------------------------ //
// ************************************ Menu [Teaching] ********************************** //
// ------------------------------------------------------------------------------------ //

AddMenu(ImageDIR+"Teaching.gif", 220, 220, 100, MenuStyle);
  AddMenuItem("Courses taught",			HomeDIR+"courses_taught.html", 	"", ItemStyle, ItemColor);
  AddMenuItem("EE 662",			CourseDIR+"ee662.html", 	"", ItemStyle, ItemColor);
  AddMenuItem("EE 571",			CourseDIR+"ee571.html", 	"", ItemStyle, ItemColor);
  //AddMenuItem("&nbsp;EE 411",			"courses/ee370.html", 	"", ItemStyle, ItemColor);
  AddMenuItem("EE 400",			CourseDIR+"ee400.html", 	"", ItemStyle, ItemColor);
  AddMenuItem("EE 370",			CourseDIR+"ee370.html", 	"", ItemStyle, ItemColor);
  AddMenuItem("EE 242",			CourseDIR+"ee242.html", 	"", ItemStyle, ItemColor);
  AddMenuItem("EE 201",			CourseDIR+"ee201.html", 	"", ItemStyle, ItemColor);
  AddMenuItem("Student Projects",	HomeDIR+"stu_projects.html", 	"", ItemStyle, ItemColor);



// ------------------------------------------------------------------------------------ //
// ************************************ Menu [Service] ********************************** //
// ------------------------------------------------------------------------------------ //

AddMenu(ImageDIR+"Service.gif", 300, 300, 100, MenuStyle);
  AddMenuItem("Committees",				HomeDIR+"committees.html", 	"", ItemStyle, ItemColor);
  AddMenuItem("Conference Organization",	HomeDIR+"confs.html", 	"", ItemStyle, ItemColor);
  AddMenuItem("IEEE Responsibilities",	HomeDIR+"ieee.html", 	"", ItemStyle, ItemColor);
  AddMenuItem("Continuing Education",	HomeDIR+"continuing_edu.html", 	"", ItemStyle, ItemColor);
  //AddMenuItem("&nbsp;",							"", 	"", ItemStyle, ItemColor);



//////////////////////////////////////////////////////////////////////////////////////////
// ---------------------------- End of Menu Specification ----------------------------- //
//////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////
// Create a new menu object and count it [AddMenu] which parameters are as follows:

// Menu Array starts at offset=0, where every array entry is created
// Menu: Global Var that forms an array of menu objects
// MenuCount: Global Var that forms an index array of menu objects and incremented after every successfull creation.
// MenuObj: is a function that is responsible for Menu creation with its parameters list
// The parameter list of [AddMenu] is the same as the [MenuObj] function 

// TitleImg:     Title or image of menu ("<IMG src=filename")
// MenuOffset:   Vertical offset of menu
// BarOffset:    Vertical offset of bar
// MenuWidth:    Width of menu in pixels
// MenuStyle:    Menu Style Object
//////////////////////////////////////////////////////////////////////////////////////////
function AddMenu( TitleImg,MenuOffset,BarOffset,MenuWidth,MenuStyle ) 
{
  Menu[MenuCount] = new MenuObj( TitleImg,MenuOffset,BarOffset,MenuWidth,MenuStyle );
  MenuCount++;
}//end-AddMenu()


//////////////////////////////////////////////////////////////////////////////////////////
// Create a new Menu item object and count it [AddMenuItem] which parameters are as follows:
// Menu item is added to last menu object

// We access the Menu element via its index , targeted menu, as to access tis ItemCount field 
// in order to create the MenuItemObject with its parameter list (Title, URL, Target, Style, Color)
// After Creation of Menu Item object element inside the array of Menu Item array field, we increment 
// the ItemCounter index field of the targeted menu object. 

// Title:  Title of menu item
// URL:    URL of menu item
// Target: Target of menu item
// Style:  Style object of menu item
// Color:  Color object of menu item
//////////////////////////////////////////////////////////////////////////////////////////
function AddMenuItem( Title,URL,Target,Style,Color ) 
{

  var MenuIndex = MenuCount - 1; // gets the [MenuIndex] via the [MenuCount-1] as to hold the last active menu object index
  var ItemCount = Menu[MenuIndex].ItemCount; // gets the targeted Menu object via its index and accessing its ItemCount field

  Menu[MenuIndex].Item[ItemCount] = new MenuItemObj(Title, URL, Target, Style, Color);
  Menu[MenuIndex].ItemCount++;
}//end-AddMenuItem()


//////////////////////////////////////////////////////////////////////////////////////////
// Create a new Form object and count it [AddForm] which parameters are as follows:
// Form is added as an item to last menu

// We access the Menu element via its index , targeted menu, as to access tis ItemCount field 
// in order to create the MenuFormObject with its parameter list (Name, Action, Target, Encoding, BgColor, cellpadding
// After Creation of Menu Form object element inside the array of Menu Item array field, we increment 
// the ItemCounter index field of the targeted menu object. 

// Name:        Form Name (identification)
// Action:      Form action (URL, javascript)
// Target:      Form Target
// Encoding:    Form Encoding
// BgColor:     Form Background color
// cellpadding: Padding used in form item cells
//////////////////////////////////////////////////////////////////////////////////////////
function AddForm( Name,Action,Target,Encoding,BgColor,cellpadding ) 
{

  var MenuIndex = MenuCount - 1; // gets the [MenuIndex] via the [MenuCount-1] as to hold the last active menu object index
  var ItemCount = Menu[MenuIndex].ItemCount; // gets the targeted Menu object via its index and accessing its ItemCount field
  
  Menu[MenuIndex].Item[ItemCount] = new MenuFormObj(Name, Action, Target, Encoding, BgColor, cellpadding);
  Menu[MenuIndex].ItemCount++;
}//end-AddForm()


//////////////////////////////////////////////////////////////////////////////////////////
// Creates a new Form Item object and count it [AddFormItem] which parameters are as follows:
// Form item is added to last form

// We access the Menu element via its index , targeted menu, as to access tis ItemCount field 
// in order to create the FormItemObj with its parameter list (Category, Name, Action, Style, Color, Width, Values)
// After Creation of Form Item Object element inside the array of Menu Form Item array field, we increment 
// the FormItemCounter index field of the targeted menu object. 

// Category: "B", "C", "H", "L", "M", "P", "R", "S", or "T"
//           "B" for a Button
//           "C" for a Check Box
//           "H" for a Hidden field
//           "L" for a Label
//           "M" for a drop-down menu
//           "P" for a Password field
//           "R" for a Radio Box
//           "S" for a Submit button
//           "T" for a Text field

// Name:     Name of form item (identification)
// Action:   Action of form item
// Style:    Styles of form item
// Color:    Colors of form item
// Width:    Width of form item in pixels
//           Should be less than menu width
// Values:   Array of values
//           Used with "C", "M", and "R" form items
//////////////////////////////////////////////////////////////////////////////////////////
function AddFormItem( Category,Name,Action,Style,Color,Width,Values )  
{

  var MenuIndex = MenuCount - 1; // gets the [MenuIndex] via the [MenuCount-1] as to hold the last active menu object index
  var ItemCount = Menu[MenuIndex].ItemCount-1; // gets the targeted Menu object via its index and accessing its ItemCount field
  var FormItemCount = Menu[MenuIndex].Item[ItemCount].FormItemCount;

  Menu[MenuIndex].Item[ItemCount].FormItem[FormItemCount] = new FormItemObj(Category, Name, Action, Style, Color, Width, Values);
  Menu[MenuIndex].Item[ItemCount].FormItemCount++;
}//end-AddFormItem()



//////////////////////////////////////////////////////////////////////////////////////////
// Constructor of a menu style object [MenuStyleObj] which parameters are as follows:

// MenuBorderSize:  Size of menu border in pixels
// MenuBorderColor: Color of menu border
// BarBgColor:      Color of bar background ("" for transparent)
// BarTextColor:    Color of bar text (when title is not an image)
// CellPadding:     Padding used within menu item cells (in pixels)
//////////////////////////////////////////////////////////////////////////////////////////
function MenuStyleObj( MenuBorderSize,MenuBorderColor,BarBgColor,BarTextColor,CellPadding ) 
{

  this.MenuBorderSize  = MenuBorderSize;
  this.MenuBorderColor = MenuBorderColor;
  this.BarBgColor      = BarBgColor;
  this.BarTextColor    = BarTextColor;
  this.CellPadding     = CellPadding; 
}//end-MenuStyleObj()


//////////////////////////////////////////////////////////////////////////////////////////
// Constructor of an item style object [ItemStyleObj] which parameters are as follows:

// FontFamily: Font Family separated by commas
// FontSize:   Font size in points
// Bold:       "yes" if bold
// Italic:     "yes" if italic
// Align:      "Left", "Center", or "Right"
//////////////////////////////////////////////////////////////////////////////////////////
function ItemStyleObj( FontFamily,FontSize,Bold,Italic,Align ) 
{

  this.FontFamily = FontFamily;
  this.FontSize   = FontSize;
  this.Bold       = Bold;
  this.Italic     = Italic;
  this.Align      = Align; 
}//end-ItemStyleObj()


//////////////////////////////////////////////////////////////////////////////////////////
// Constructor of an item Color object [ItemColorObj] which parameters are as follows:

// LowBg:    Background color when mouse is out
// HighBg:   Background color when mouse is over
// LowFont:  Font color when mouse is out
// HighFont: Font color when mouse is over
//////////////////////////////////////////////////////////////////////////////////////////
function ItemColorObj( LowBg,HighBg,LowFont,HighFont) 
{

  this.LowBg    = LowBg;
  this.HighBg   = HighBg;
  this.LowFont  = LowFont;
  this.HighFont = HighFont;
}//end-ItemColorObj()

//////////////////////////////////////////////////////////////////////////////////////////
// Constructor function of a menu object [MenuObj] which parameters are as follows:

// TitleImg:     Title or image of menu ( <IMG src = "filename.gif"> )
// Y_Offset:     Vertical offset of menu
// MenuWidth:    Width of menu in pixels
// MenuStyle:    Menu Style object: consists of:

			  // MenuBorderSize:   Size of menu border in pixels
			  // MenuBorderColor:  Color of menu border
			  // BarBgColor:       Color of bar background ("" for transparent)
			  // BarTextColor:     Color of bar text (when title is not an image)
			  // CellPadding:      Padding used within menu item cells
//////////////////////////////////////////////////////////////////////////////////////////
function MenuObj( TitleImg,MenuOffset,BarOffset,MenuWidth,MenuStyle ) 
{
  this.Item            = new Array();
  this.ItemCount       = 0;
  this.DivID           = "Menu"+MenuCount;
  
  this.TitleImg        = TitleImg;   // input paramaeter TitleImg
  this.MenuOffset      = MenuOffset; // input paramaeter MenuOffset
  this.BarOffset       = BarOffset;  // input paramaeter BarOffset
  this.MenuWidth       = MenuWidth;  // input paramaeter MenuWidth
  
  // input paramaeter MenuStyle
  this.MenuBorderSize  = MenuStyle.MenuBorderSize;   // input paramaeter MenuStyle.MenuBorderSize
  this.MenuBorderColor = MenuStyle.MenuBorderColor;  // input paramaeter MenuStyle.MenuBorderColor
  this.BarBgColor      = MenuStyle.BarBgColor;       // input paramaeter MenuStyle.BarBgColor
  this.BarTextColor    = MenuStyle.BarTextColor;     // input paramaeter MenuStyle.BarTextColor	
  this.cellpadding     = MenuStyle.CellPadding;      // input paramaeter MenuStyle.CellPadding
}// end-MenuObj()


//////////////////////////////////////////////////////////////////////////////////////////
// Constructor function of a menu item object [MenuItemObj] which parameters are as follows:

// Title:  Title of menu item
// URL:    URL of menu item
// Target: Target of menu item
// Style:  Style object of menu item
// Color:  Color object of menu item
//////////////////////////////////////////////////////////////////////////////////////////
function MenuItemObj( Title,URL,Target,Style,Color ) 
{
  // Menu item kind can be "I" or "F"
  // "I" represents a menu [Item Object]	  
  
  this.kind   = "I";     // Kind = "I" if this Menu Object is of Type Item 
  
  this.Title  = Title;   // input paramaeter Title
  this.URL    = URL;     // input paramaeter URL
  this.Target = Target;  // input paramaeter Target
  this.Style  = Style;   // input paramaeter Style
  this.Color  = Color;   // input paramaeter Color
}//end-MenuItemObj()


//////////////////////////////////////////////////////////////////////////////////////////
// Constructor function of a menu form object [MenuFormObj] which parameters are as follows:
// Name:        Name of the menu form
// Action:      Form action (URL, javascript)
// Target:      Form Target
// Encoding:    Form Encoding
// BgColor:     Form Background color
// cellpadding: Padding used in form item cells
//////////////////////////////////////////////////////////////////////////////////////////
function MenuFormObj( Name,Action,Target,Encoding,BgColor,cellpadding ) 
{
   // Menu item kind can be "I" or "F"
   // "F" represents a menu [Form Object]

  this.kind          ="F";          // Kind = "F" if this Menu Object is of Type Form
  
  this.Name          = Name;        // input paramaeter Name
  this.Action        = Action;      // input paramaeter Action
  this.Target        = Target;      // input paramaeter Target  
  this.Encoding      = Encoding;    // input paramaeter Encoding 
  this.BgColor       = BgColor;     // input paramaeter BgColor
  this.cellpadding   = cellpadding; // input paramaeter cellpadding
  
  this.FormItem      = new Array();
  this.FormItemCount = 0;  
}//end-MenuFormObj()



//////////////////////////////////////////////////////////////////////////////////////////
// Constructor function of a form item object [FormItemObj] which parameters are as follows:

// Category: "B", "C", "H", "L", "M", "P", "R", "S", or "T"
//           "B" for a Button
//           "C" for a Check Box
//           "H" for a Hidden field
//           "L" for a Label
//           "M" for a drop-down menu
//           "P" for a Password field
//           "R" for a Radio Box
//           "S" for a Submit button
//           "T" for a Text field

// Name:     Name of form item for identification
// Action:   Action of form item
// Style:    Styles of form item
// Color:    Colors of form item
// Width:    Width of form item in pixels (< menu width)

// Values:   Array of values
//           Used with "C", "M", and "R" form items
//////////////////////////////////////////////////////////////////////////////////////////
function FormItemObj( Category,Name,Action,Style,Color,Width,Values ) 
{

  this.Category = Category;  // input paramaeter Category
  this.Name     = Name;      // input paramaeter Name
  this.Action   = Action;    // input paramaeter Action
  this.Style    = Style;     // input paramaeter Style
  this.Color    = Color;     // input paramaeter Color
  this.Width    = Width;     // input paramaeter Width
  this.Values   = Values     // input paramaeter Values
}//end-FormItemObj()



