// 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;
var FONTCLASSSUFFIX = '';

// 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.marginLeft = document.getElementById("mainframe_" + count).offsetLeft;
//    document.getElementById("menu_" + count).style.marginTop = 0;
    document.getElementById("menu_" + count).style.visibility = "visible";
}

// 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";
    document.getElementById("menu_" + count).style.marginLeft = 0;
}


// 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 border=0 cellspacing=0 cellpadding=0>';
    // ADD THE MAIN (FIRST LINE) MENU ELEMENT
    html += '<tr id="mainframe">';
    for (var i=0; i < MENU.length; i++){
	if (MENU[i][0][1] == ''){
	if ( i == 0 ){
	    html += '<td id="mainframe_'+ i +'" class="BABYMENU_topLeftElement'+FONTCLASSSUFFIX+'" 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 id="mainframe_'+ i +'" class="BABYMENU_topElement'+FONTCLASSSUFFIX+'" 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 id="mainframe_'+ i +'" class="BABYMENU_topLeftElement'+FONTCLASSSUFFIX+'" 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 id="mainframe_'+ i +'" class="BABYMENU_topElement'+FONTCLASSSUFFIX+'" 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;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
	html += '</td>';
    }
    html += '</tr>';

    // NOW ADD THE DROPDOWN LIST ELEMENT
    html += '<tr height=0>';
    html += '<td colspan="' + MENU.length + '">';
    for (var i=0; i < MENU.length; i++){
	html += '<table border=0 id="menu_'+ i +'" class="BABYMENU_dropdownList'+FONTCLASSSUFFIX+' mytransparent" 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'+FONTCLASSSUFFIX+'" onmouseover=style.backgroundColor="' +FOCUS+ '";style.color="'+FOCUS_WORD+'"; onmouseout=style.backgroundColor="' +OUT+ '";style.color="'+OUT_WORD+'";>';
	    }else{
	        html += '<TD onclick="'+MENU[i][j][1]+'"; title="' + MENU[i][j][2] + '" valign=center class="BABYMENU_dropdownElement'+FONTCLASSSUFFIX+'" onmouseover=style.backgroundColor="' +FOCUS+ '";style.color="'+FOCUS_WORD+'"; onmouseout=style.backgroundColor="' +OUT+ '";style.color="'+OUT_WORD+'"; >';
	    }
            html += '<span style="padding:0px;position:relative;z-index:10;">&nbsp;&nbsp;'+ MENU[i][j][0] +'&nbsp;&nbsp;</span>';
	}

	html += '</table>';
    }
    html += '</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") != null){
	document.getElementById("BABY_DROPDOWN_MENU").innerHTML = html;
	return;
    }else{
	return html;
    }
    return;

}









// EDIT THIS FUNCTION TO CUSTOMIZE YOUR OWN MENU (SAMPLE)
function controlMenu(){
   // Initial the requried value and color behaviour when mouse highlight
   init("#AFBCC0","#FFFFFF","#E8ECF9","#000000");
	
   addElement(0,0,"Home","?","Back to home");
   addElement(0,1,"Hot Deals","location.href='?e=hotdealList'","Hot Deals");
   addElement(0,2,"Early Bird Specials","location.href='?e=earlybirdList'","Early Bird Specials");
   addElement(0,3,"Special Cruise Tours","location.href='?e=cruisetourList'","Special Cruise Tours");
   addElement(0,4,"Frequently Ask Questions","location.href='?e=faq'","Frequently Ask Questions");
   addElement(0,5,"About Us","location.href='?e=aboutus'","About UCruising.com");


   addElement(1,0,"Cruising Experience","","Cruising Experience from cruise lines");

   addElement(1,1,"Alaska - Princess","window.open('http://www.princess.com/video/dvd/AlaskaCE09.html','Princess')","Alaska - Princess");
   addElement(1,2,"Alaska Lodges - Princess","window.open('http://www.princess.com/video/dvd/AlaskaLodgesCE09.html','Princess')","Alaska Lodges - Princess");
   addElement(1,3,"Australia / New Zealand - Princess","window.open('http://www.princess.com/video/dvd/AustraliaNewZealandCE09.html','Princess')","Australia / New Zealand - Princess");
   addElement(1,4,"Canada / New England - Princess","window.open('http://www.princess.com/video/dvd/CanadaNewEnglandCE09.html','Princess')","Canada / New England - Princess");
   addElement(1,5,"Caribbean - Princess","window.open('http://www.princess.com/video/dvd/CaribbeanCE09.html','Princess')","Caribbean - Princess");
   addElement(1,6,"Europe - Princess","window.open('http://www.princess.com/video/dvd/EuropeCE09.html','Princess')","Europe - Princess");
   addElement(1,7,"Asia / Africa - Princess","window.open('http://www.princess.com/video/dvd/AsiaAfricaCE09.html','Princess')","Asia / Africa - Princess");
   addElement(1,8,"Hawaii / Tahiti - Princess","window.open('http://www.princess.com/video/dvd/HawaiiTahitiCE09.html','Princess')","Hawaii / Tahiti - Princess");
   addElement(1,9,"Mexican Riviera - Princess","window.open('http://www.princess.com/video/dvd/MexicanRivieraCE09.html','Princess')","Mexican Riviera - Princess");
   addElement(1,10,"Panama Cannel - Princess","window.open('http://www.princess.com/video/dvd/PanamaCanalCE09.html','Princess')","Panama Cannel");
   addElement(1,11,"South America - Princess","window.open('http://www.princess.com/video/dvd/SouthAmericaCE09.html','Princess')","South America - Princess");
   addElement(1,12,"Experience in Europe - Celebrity","window.open('http://www.celebrityseurope.com/?type=personalized&accountID=VHVHFPEAT','Celebrity')","Experience in Europe - Celebrity");
   addElement(1,13,"Europe Videos - Royal Caribbean","window.open('http://www.royalcaribbean.com/multimedia/popup/flash/destination.do;jsessionid=0000cxI5yzVPnkQ0lNOClK0D0OC:13hldcgo7?dest=EUROP','RCCL')","Europe Videos - Royal Caribbean");
   addElement(1,14,"Australia / New Zealand Videos - Royal Caribbean","window.open('http://www.royalcaribbean.com/multimedia/popup/flash/destination.do;jsessionid=0000cxI5yzVPnkQ0lNOClK0D0OC:13hldcgo7?dest=AUSTL','RCCL')","Australia / New Zealand Videos - Royal Caribbean");


   addElement(2,0,"Cruise Lines","","Our Cruise Line Partners");
   addElement(2,1,"Princess Cruises","window.open('http://www.princesscruises.com','');","Princess Cruises");
   addElement(2,2,"Cunard Cruises","window.open('http://www.cunard.com','');","Cunard Cruises");
   addElement(2,3,"Royal Caribbean Cruise Line","window.open('http://www.rccl.com','');","Royal Caribbean Cruise Line");
   addElement(2,4,"Celebrity Cruises","window.open('http://www.celebritycruises.com','');","Celebrity Cruises");
   addElement(2,5,"Azamara Cruises","window.open('http://www.azamaracruises.com','');","Azamara Cruises");
   addElement(2,6,"Holland America Line","window.open('http://www.hollandamerica.com','');","Holland America Line");
   addElement(2,7,"Carnival Cruise Line","window.open('http://www.carnival.com','');","Carnival Cruise Line");
   
   
   displayMenu(true);
}


// The Dropdown menu (Chinese Version) //
function controlMenu_ch(){
    // Initial the requried value and color behaviour when mouse highlight
    init("#AFBCC0","#FFFFFF","#E8ECF9","#000000");
    FONTCLASSSUFFIX = '_ch';
    
    addElement(0,0,"主頁","?","Back to home");
    addElement(0,1,"熱門精選推介","location.href='?e=hotdealList'","Hot Deals");
    addElement(0,2,"晨鳥優惠推介","location.href='?e=earlybirdList'","Early Bird Specials");
    addElement(0,3,"岸上觀光團精選推介","location.href='?e=cruisetourList'","Special Cruise Tours");
    addElement(0,4,"常見問題","location.href='?e=faq'","Frequently Ask Questions");
    addElement(0,5,"關于我們","location.href='?e=aboutus'","About UCruising.com");
    
    
    addElement(1,0,"郵輪親身體驗","","Cruising Experience from cruise lines");
    
    addElement(1,1,"阿拉斯加冰川風光之旅(公主郵輪)","window.open('http://www.princess.com/video/dvd/AlaskaCE09.html','Princess')","Alaska - Princess");
    addElement(1,2,"阿拉斯加田園風情之旅(公主郵輪)","window.open('http://www.princess.com/video/dvd/AlaskaLodgesCE09.html','Princess')","Alaska Lodges - Princess");
    addElement(1,3,"澳洲紐西蘭海岸之旅(公主郵輪)","window.open('http://www.princess.com/video/dvd/AustraliaNewZealandCE09.html','Princess')","Australia / New Zealand - Princess");
    addElement(1,4,"加拿大新英格蘭追尋歷史之旅(公主郵輪)","window.open('http://www.princess.com/video/dvd/CanadaNewEnglandCE09.html','Princess')","Canada / New England - Princess");
    addElement(1,5,"加勒比海繽紛色彩之旅(公主郵輪)","window.open('http://www.princess.com/video/dvd/CaribbeanCE09.html','Princess')","Caribbean - Princess");
    addElement(1,6,"歐洲古國文明浪漫之旅(公主郵輪)","window.open('http://www.princess.com/video/dvd/EuropeCE09.html','Princess')","Europe - Princess");
    addElement(1,7,"亞洲五光十色 / 非洲神秘探索之旅(公主郵輪)","window.open('http://www.princess.com/video/dvd/AsiaAfricaCE09.html','Princess')","Asia / Africa - Princess");
    addElement(1,8,"夏威夷/大溪地熱帶天堂之旅(公主郵輪)","window.open('http://www.princess.com/video/dvd/HawaiiTahitiCE09.html','Princess')","Hawaii / Tahiti - Princess");
    addElement(1,9,"墨西哥獨特魅力之旅(公主郵輪)","window.open('http://www.princess.com/video/dvd/MexicanRivieraCE09.html','Princess')","Mexican Riviera - Princess");
    addElement(1,10,"巴拿馬運河壯麗史詩之旅(公主郵輪)","window.open('http://www.princess.com/video/dvd/PanamaCanalCE09.html','Princess')","Panama Cannel");
    addElement(1,11,"南美洲熱情桑巴之旅(公主郵輪)","window.open('http://www.princess.com/video/dvd/SouthAmericaCE09.html','Princess')","South America - Princess");
    addElement(1,12,"品味歐洲文明(菁英郵輪)","window.open('http://www.celebrityseurope.com/?type=personalized&accountID=VHVHFPEAT','Celebrity')","Experience in Europe - Celebrity");
    addElement(1,13,"歐洲城市風光(皇家加勒比海郵輪)","window.open('http://www.royalcaribbean.com/multimedia/popup/flash/destination.do;jsessionid=0000cxI5yzVPnkQ0lNOClK0D0OC:13hldcgo7?dest=EUROP','RCCL')","Europe Videos - Royal Caribbean");
    addElement(1,14,"澳洲紐西蘭城市風光(皇家加勒比海郵輪)","window.open('http://www.royalcaribbean.com/multimedia/popup/flash/destination.do;jsessionid=0000cxI5yzVPnkQ0lNOClK0D0OC:13hldcgo7?dest=AUSTL','RCCL')","Australia / New Zealand Videos - Royal Caribbean");
    
    
    addElement(2,0,"郵輪公司","","Our Cruise Line Partners");
    addElement(2,1,"公主郵輪公司","window.open('http://www.princesscruises.com','');","Princess Cruises");
    addElement(2,2,"冠達郵輪公司","window.open('http://www.cunard.com','');","Cunard Cruises");
    addElement(2,3,"皇家加勒比海郵輪公司","window.open('http://www.rccl.com','');","Royal Caribbean Cruise Line");
    addElement(2,4,"菁英郵輪公司","window.open('http://www.celebritycruises.com','');","Celebrity Cruises");
    addElement(2,5,"精鑽郵輪公司","window.open('http://www.azamaracruises.com','');","Azamara Cruises");
    addElement(2,6,"荷美郵輪公司","window.open('http://www.hollandamerica.com','');","Holland America Line");
    addElement(2,7,"嘉年華郵輪公司","window.open('http://www.carnival.com','');","Carnival Cruise Line");
    
    
    displayMenu(true);


}




