/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder_ = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources_ = new Array("button1up_.png","button2up_.png","button3up_.png","button4up_.png","button5up_.png");

overSources_ = new Array("button1over_.png","button2over_.png","button3over_.png","button4over_.png","button5over_.png");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo_ = new Array();
subInfo_[1] = new Array();
subInfo_[2] = new Array();
subInfo_[3] = new Array();
subInfo_[4] = new Array();
subInfo_[5] = new Array();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
//*** subInfo_[5][1] = new Array("Customer Login","http://www.fingerbox.com/manager","blank");

subInfo_[1][1] = new Array("About Us","./aboutus.htm","");
subInfo_[1][2] = new Array("Eco-Commitment","./eco-commit.htm","");
subInfo_[1][3] = new Array("Hong Kong Holidays","./hk_holiday.htm","");
subInfo_[1][4] = new Array("Work@Fingerbox","./works.htm","");
subInfo_[1][5] = new Array("Games","./games.htm","");

//subInfo_[2][2] = new Array("ECS Services","./ECS.htm","");
subInfo_[2][1] = new Array("Web Hosting","./WebHosting.htm","");
subInfo_[2][2] = new Array("Web Design","./Web_design.htm","");
//subInfo_[2][3] = new Array("I.T Services","./ITServices.htm","");
subInfo_[2][3] = new Array("Data Centre","./DataCentre.htm","");
subInfo_[2][4] = new Array("IDCS","./IDCservice.htm","");

//subInfo_[3][1] = new Array("I.T Accessories","http://www.webshop.hk/companypromo.aspx?id=FB000001&lang=1","blank");
//subInfo_[3][1] = new Array("E-Centre Service","http://forum.fingerbox.hk","blank");
subInfo_[3][1] = new Array("DocuMatic","./DMSolution.htm","");
subInfo_[3][2] = new Array("Email Promoter","./fbpromoter.htm","");
subInfo_[3][3] = new Array("RecruitMATE","./recruitmate.htm","");
//subInfo_[3][3] = new Array("HP Laser Printer","./hp_printer.htm","");
//subInfo_[3][4] = new Array("IBM Products","./ibm_prod.htm","");
//subInfo_[3][5] = new Array("Network Equipment","./nusoft_prod.htm","");

subInfo_[4][1] = new Array("Sales People","./Contactsales.htm","");
subInfo_[4][2] = new Array("Support People","./Contactsupport.htm","");
subInfo_[4][3] = new Array("Contact Information","./ContactInfo.htm","");
//subInfo_[4][4] = new Array("China Contact","./ContactInfocn.htm","");

subInfo_[5][1] = new Array("Customer Login","http://login.fingerbox.com.hk","blank");
subInfo_[5][2] = new Array("Support Forum","http://forum.fingerbox.hk","blank");
subInfo_[5][3] = new Array("Form Download","./form_download.htm","");

//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset_ = 1;
var ySubOffset_ = 18;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub_ = false;
var delay_ = 1000;
totalButtons_ = upSources_.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons_; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo_[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '_">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		document.write('<div id="submenu' + (x+1) + '_" class="dropmenu_" ');
		document.write('onMouseOver="overSub_=true;');
		document.write('setOverImg_(\'' + (x+1) + '\',\'_\');"');
		document.write('onMouseOut="overSub_=false;');
		document.write('setTimeout(\'hideSubMenu_(\\\'submenu' + (x+1) + '_\\\')\',delay_);');
		document.write('setOutImg_(\'' + (x+1) + '\',\'_\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo_[x+1].length-1; k++ ) {
			document.write('<li>');
			document.write('<a href="' + subInfo_[x+1][k+1][1] + '" ');
			document.write('target="' + subInfo_[x+1][k+1][2] + '">');
			document.write( subInfo_[x+1][k+1][0] + '</a>');
			document.write('</li>');
		}
		document.write('</ul>');
	}
	document.write('</div>');
}





//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload_() {
	for ( x=0; x<totalButtons_; x++ ) {
		buttonUp_ = new Image();
		buttonUp_.src = buttonFolder_ + upSources_[x];
		buttonOver_ = new Image();
		buttonOver_.src = buttonFolder_ + overSources_[x];
	}
}

// SET MOUSEOVER BUTTON
function setOverImg_(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_ + overSources_[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg_(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_ + upSources_[But-1];
}



//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement_(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft_(id) { 
	var el = getElement_(id);
	if (el) { 
		xPos = el.offsetLeft;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		} 
		return xPos;
	} 
} 

// GET Y COORDINATE
function getRealTop_(id) {
	var el = getElement_(id);
	if (el) { 
		yPos = el.offsetTop;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return yPos;
	}
}

// MOVE OBJECT TO COORDINATE
function moveObjectTo_(objectID,x,y) {
	var el = getElement_(objectID);
	el.style.left = x;
	el.style.top = y;
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu_(subID, buttonID) {
	hideAllSubMenus_();
	butX = getRealLeft_(buttonID);
	butY = getRealTop_(buttonID);
	moveObjectTo_(subID,butX+xSubOffset_, butY+ySubOffset_);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus_() {
	for ( x=0; x<totalButtons_; x++) {
		moveObjectTo_("submenu" + (x+1) + "_",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu_(subID) {
	if ( overSub_ == false ) {
		moveObjectTo_(subID,-500, -500);
	}
}



//preload_();


