// THIS FUNCTION IS COPYRIGHT BY BABYSOFT
// NO CHANGE, MOTIFY, RE-DISTRIBUTE, COPY OR RESELL IS ALLOWED
// BUG REPORT: its@babysoft.ca
// BABYSOFT CONTACT: 1-905-940-5379

// THE MAIN ARRAY CONTAINS ALL DROPDOWN LIST DATA
var MENU;
var FOCUS_WORD;
var FOCUS;
var OUT_WORD;
var OUT;

// Initial all the required value for the dropdown menu
// param1: the background color when the mouse focus the cell
// param2: the color of the word when the mouse focus the cell
// param3: the background color when the mouse leave the cell
// param4: the color of the word when the mouse leave the cell
function init(f_bg,f_w,o_bg,o_w){
    MENU = new Array();
    FOCUS_WORD = f_w;
    FOCUS = f_bg;
    OUT_WORD = o_w;
    OUT = o_bg;
    return;
}


// Add the menu element into the array. 
// if ypos is 0, that will be the main category in the array
// param1: the x-coordinate of the menu in the matrix
// param2: the y-coordinate of the menu in the matrix
// param3: the display name of the element
// param4: the url which the element point to 
// param5: the title tooltip when the cursor point to it
function addElement(xpos, ypos, title, url, tooltip){
    if (MENU[xpos] == null){
	MENU[xpos] = new Array();
    }
    if (MENU[xpos][ypos] == null){
	MENU[xpos][ypos] = new Array(3);
    }

    MENU[xpos][ypos][0] = title;
    MENU[xpos][ypos][1] = url;
    MENU[xpos][ypos][2] = tooltip;

    return;

}

// show the menu when calling this function
// Param1: the count indicate which menu should be display, from left to right
function showMenu(count){
    document.getElementById("menu_" + count).style.visibility = "visible";
//alert ("TEST: " + "menu_" + count + " " + document.getElementById("menu_" + count));
}

// hidden the menu when calling this function
// Param1: the count indicate which menu should be hidden, from left to right
function hiddenMenu(count){
    document.getElementById("menu_" + count).style.visibility = "hidden";
}


// display the full menu
// if the parameter is true, the menu will automatically plug into the 
// id called "BABY_DROPDOWN_MENU", Otherwise, it will return the full 
// menu in html format
// Param: flag indicate should it return the HTML of the menu, or it
//        should return automatically plug into BABY_DROPDOWN_MENU
// Return: the html format of the menu if the parameter is true, otherwise
//         return null
function displayMenu(flag){
    var html = '';

    html += '<table cellspacing=0 cellpadding=0>';
    // ADD THE MAIN (FIRST LINE) MENU ELEMENT
    html += '<tr><td width="10"><img src="http://graphics.babysoft.ca/icons/leftCircle.jpg" border=0 /></td>';
    for (var i=0; i < MENU.length; i++){
	if (MENU[i][0][1] == ''){
	if ( i == 0 ){
	    html += '<td class="BABYMENU_topLeftElement" title="' + MENU[i][0][2] + '" valign=center onmouseover=style.backgroundColor="' +FOCUS+ '";style.color="'+FOCUS_WORD+'";showMenu(' + i + '); onmouseout=style.backgroundColor="' +OUT+ '";style.color="'+OUT_WORD+'";hiddenMenu(' + i + ');>';
	}else{
	    html += '<td class="BABYMENU_topElement" title="' + MENU[i][0][2] + '" valign=center onmouseover=style.backgroundColor="' +FOCUS+ '";style.color="'+FOCUS_WORD+'";showMenu(' + i + '); onmouseout=style.backgroundColor="' +OUT+ '";style.color="'+OUT_WORD+'";hiddenMenu(' + i + ');>';
	}
	}else{
	if ( i == 0 ){
	    html += '<td class="BABYMENU_topLeftElement" onclick=location.href="'+MENU[i][0][1] +'"; title="' + MENU[i][0][2] + '" valign=center onmouseover=style.backgroundColor="' +FOCUS+ '";style.color="'+FOCUS_WORD+'";showMenu(' + i + '); onmouseout=style.backgroundColor="' +OUT+ '";style.color="'+OUT_WORD+'";hiddenMenu(' + i + ');>';
	}else{
	    html += '<td class="BABYMENU_topElement" onclick=location.href="'+MENU[i][0][1] +'"; title="' + MENU[i][0][2] + '" valign=center onmouseover=style.backgroundColor="' +FOCUS+ '";style.color="'+FOCUS_WORD+'";showMenu(' + i + '); onmouseout=style.backgroundColor="' +OUT+ '";style.color="'+OUT_WORD+'";hiddenMenu(' + i + ');>';
	}
	}
        html += '<span>&nbsp;&nbsp;'+ MENU[i][0][0] +'&nbsp;&nbsp;</span>';
	html += '</td>';
    }
    html += '<td width="10"><img src="http://graphics.babysoft.ca/icons/rightCircle.jpg" border=0 /></td></tr>';

    // NOW ADD THE DROPDOWN LIST ELEMENT
    html += '<tr height=0><td></td>';
    for (var i=0; i < MENU.length; i++){
        html += '<td>';
	html += '<table id="menu_'+ i +'" class="BABYMENU_dropdownList" cellspacing=0 cellpadding=0 onmouseover=showMenu(' + i + '); onmouseout=hiddenMenu(' + i + ');>';

	for (var j=1; j < MENU[i].length; j++){
	    html += '<TR>';
	    if (MENU[i][j][1] == ''){
	        html += '<TD title="' + MENU[i][j][2] + '" valign=center class="BABYMENU_dropdownElement" onmouseover=style.backgroundColor="' +FOCUS+ '";style.color="'+FOCUS_WORD+'"; onmouseout=style.backgroundColor="' +OUT+ '";style.color="'+OUT_WORD+'";>';
	    }else{
	        html += '<TD onclick=location.href="'+MENU[i][j][1] +'"; title="' + MENU[i][j][2] + '" valign=center class="BABYMENU_dropdownElement" onmouseover=style.backgroundColor="' +FOCUS+ '";style.color="'+FOCUS_WORD+'"; onmouseout=style.backgroundColor="' +OUT+ '";style.color="'+OUT_WORD+'";>';
	    }
            html += '<span>&nbsp;&nbsp;'+ MENU[i][j][0] +'&nbsp;&nbsp;</span>';
	    html += '</td></tr>';
	}

	html += '</table>';
	html += '</td>';
    }
    html += '<td></td></tr>';
    html += '</table>';


    // Now html variable contains the whole table for the dropdown list
    // put it into the BABY_DROPDOWN_MENU if the flag is true, otherwise return the html variable
    if (flag == true){
	document.getElementById("BABY_DROPDOWN_MENU").innerHTML = html;
	return;
    }else{
	return html;
    }
    return;

}


// EDIT THIS FUNCTION TO CUSTOMIZE YOUR OWN MENU
function controlMenu(){
    // Initial the requried value and color behaviour when mouse highlight
    init("#FBEFD7","#CC9933","#CC9933","#FFFFFF");
	
    addElement(0,0,"Networking Solution","http://www.babysoft.ca/networking.html","Networking Solution from BABYSOFT");
    addElement(0,1,"Linux/Unix Networking","http://www.babysoft.ca/networking_linux.html","Linux/Unix Networking Solution");
    addElement(0,2,"Windows NT Networking","http://www.babysoft.ca/networking_windows.html","Windows NT Networking Solution");
    addElement(0,3,"Sysadmin Service","http://www.babysoft.ca/networking_sysadmin.html","BABYSOFT System Administration Service");
    // addElement(0,4,"Case Studies","http://www.babysoft.ca/caseStudies.html#networking","Real BABYSOFT Networking Solution Customer's Story");

    addElement(1,0,"Software Solution","http://www.babysoft.ca/software.html","Software Solution from BABYSOFT");
    addElement(1,1,"White Panel Solutions","http://whitepanel.com","Babysoft White Panel Solution");
    addElement(1,2,"Design & Development","http://www.babysoft.ca/software_development.html","Software Design and Development from BABYSOFT");
    addElement(1,3,"Consultant Service","http://www.babysoft.ca/software_consultant.html","Software consultant service from BABYSOFT");
    addElement(1,4,"E-Business Partner","http://www.babysoft.ca/partner_ebusiness.html","About BABYSOFT E-Business Partners");
    // addElement(1,5,"Case Studies","http://www.babysoft.ca/caseStudies.html#software","Real BABYSOFT Software Solution Customer's Story");

    addElement(2,0,"Telecommunications","http://www.babysoft.ca/voip.html","Telecommunications Solution");
    addElement(2,1,"Professional PBX","http://www.babysoft.ca/voip_pbxProfessional.html","Professional Telecommunication Solution");
    addElement(2,2,"Babysoft VoSet","http://www.voset.com","Cost Effective and most innovative phone system packages");
    addElement(2,3,"Standard Feature List","http://www.babysoft.ca/voip_featureList.html","BABYSOFT Telecom Standard Feature List");
    addElement(2,4,"Telecom Buying Tips","http://www.babysoft.ca/voip_buyingTips.html","Buy Smart, choose a right phone system");
    // addElement(2,5,"Case Studies","http://www.babysoft.ca/caseStudies.html#voip","Real BABYSOFT PBX Phone Systems Customer's Story");

    addElement(3,0,"Business Partner","http://www.babysoft.ca/partner.html","Become BABYSOFT Business Partner");
    addElement(3,1,"Reseller Partner","http://www.babysoft.ca/partner_reseller.html","About BABYSOFT Reseller Partners");
    addElement(3,2,"E-Business Partner","http://www.babysoft.ca/partner_ebusiness.html","About BABYSOFT E-Business Partners");
    addElement(3,3,"Partner Sign Up","http://www.babysoft.ca/partner_signUp.html","Sign Up as a BABYSOFT Business Partner");
    // addElement(3,4,"Case Studies","http://www.babysoft.ca/caseStudies.html#partner","Real BABYSOFT Business Partner's Story");



    displayMenu(true);

}


