
// A global variable contains a list of side menu items
var SIDEBAR_MENU = new Array();

// Add side menu item (one by one) into the side menu array
// Param1: The drop down item display name
// Param2: The drop down item action when onclick occur
// Param3: The flag to identify this sidebar Menu item
// Return: Null
function sidebar_add(name, action, flag){

    var size = SIDEBAR_MENU.length;

    SIDEBAR_MENU[size] = new Array();
    SIDEBAR_MENU[size][0] = name;
    SIDEBAR_MENU[size][1] = action;
    SIDEBAR_MENU[size][2] = flag;

    return;

}



// The main function which create a new side bar menu
// This function will automatically put the menu into an object id=sideBar
// Param1: (Opt.) flag indicate which page I am currently display
function createSidebarMenu(flag){

    /////////////////////////////////////////////////////////
    ////     White Panel  Setup sideMenu                 ////
    /////////////////////////////////////////////////////////
    
    var layout = '';
    var size = SIDEBAR_MENU.length;

    layout = "<table border=0 width=250 cellspacing=0 cellpadding=0>\
	      <tr height=20><td valign=top align=left>\
	      <font size=2>\
	      <b></b></font></td></tr>";


    layout += '<tr height=22><td align=left><font size=2>&nbsp;&nbsp;<b>Shortcuts</b></font></td></tr>';


    for (var i=0; i < size; i++){
      if (flag == SIDEBAR_MENU[i][2]){
    	layout += '<tr class="sideMenu" height=22 onmouseover="style.backgroundColor=' + "'" + '#C8D0D3' + "'" + '; style.color=' + "'" + '#000000' + "'" + '" onmouseout="style.backgroundColor=' + "'" + '#FFFFFF' + "'" + '; style.color=' + "'" + '#4366D3' + "'" + '" onclick=' + "'" + 'return ' + SIDEBAR_MENU[i][1] + "'" + '><td valign=center align=left><font size=2>&nbsp;&nbsp;>> <b>'+SIDEBAR_MENU[i][0]+'</b></font></td></tr>';
      }else{
        layout += '<tr class="sideMenu" height=22 onmouseover="style.backgroundColor=' + "'" + '#C8D0D3' + "'" + '; style.color=' + "'" + '#000000' + "'" + '" onmouseout="style.backgroundColor=' + "'" + '#FFFFFF' + "'" + '; style.color=' + "'" + '#4366D3' + "'" + '" onclick=' + "'" + 'return ' + SIDEBAR_MENU[i][1] + "'" + '><td valign=center align=left><font size=2>&nbsp;&nbsp; '+SIDEBAR_MENU[i][0]+'</font></td></tr>';
      }
    }


    layout += '<tr><td></td></tr></table>';

    if (document.getElementById('sideBar') != null){
      document.getElementById('sideBar').innerHTML = layout;
    }

}


// Sample Main:
// function sideBarControl(){
//   flag = '';
// 
//   // Must use double quote (") within value
//   sidebar_add("Display Name 1",'senddata("testname")','displayname1');
//   sidebar_add("Display Name 2",'senddata("testname2")','displayname2');
// 
//   createSidebarMenu(flag);
// 
// }
