/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "images/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("butt1up.png","butt2up.png","butt3up.png","butt4up.png","butt5up.png","butt6up.png");
overSources = new Array("butt1dn.png","butt2dn.png","butt3dn.png","butt4dn.png","butt5dn.png","butt6dn.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();
SubInfo[6] = new Array();
SubInfo[7] = new Array();
SubInfo[8] = new Array();
SubInfo[9] = new Array();
SubInfo[10] = new Array();
SubInfo[11] = new Array();
SubInfo[12] = new Array();
SubInfo[13] = new Array();
SubInfo[14] = new Array();
SubInfo[15] = new Array();

//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
SubInfo[1][1] = new Array("Product Comparison","compare.html","");
SubInfo[1][2] = new Array("CC1W/CC5W","ccxw.html","");
SubInfo[1][3] = new Array("H6CC","h6cc.html","");
SubInfo[1][4] = new Array("hipCC","hipcc.html","");
SubInfo[1][5] = new Array("Fatman", "fatman.html", "");
SubInfo[1][6] = new Array("Hyperboost","hboost.html","");
SubInfo[1][7] = new Array("Hyperbuck","hbuck.html","");
SubInfo[1][8] = new Array("MaxFlex", "maxflex.html", "");
SubInfo[1][9] = new Array("nFlex", "nflex.html", "");
SubInfo[1][10] = new Array("bFlex", "bflex.html", "");
SubInfo[1][11] = new Array("d2Flex", "d2flex.html", "");
SubInfo[1][12] = new Array("hipFlex", "hipflex.html", "");
SubInfo[1][13] = new Array("H6Flex", "h6flex.html", "");
SubInfo[1][14] = new Array("CCHIPO", "cchipo.html", "");
SubInfo[1][15] = new Array("Dome Module","dome.html","");

SubInfo[2][1] = new Array("CC1W/CC5W","techccxw.html","");
SubInfo[2][2] = new Array("H6CC","techh6cc.html","");
SubInfo[2][3] = new Array("hipCC","techhipcc.html","");
SubInfo[2][4] = new Array("Fatman","techfatman.html","");
SubInfo[2][5] = new Array("Hyperboost","techhboost.html","");
SubInfo[2][6] = new Array("Hyperbuck","techhbuck.html","");
SubInfo[2][7] = new Array("MaxFlex","techmaxflex.html","");
SubInfo[2][8] = new Array("nFlex","technflex.html","");
SubInfo[2][9] = new Array("bFlex","techbflex.html","");
SubInfo[2][10] = new Array("d2Flex", "techd2flex.html","");
SubInfo[2][11] = new Array("hipFlex", "techhipflex.html","");
SubInfo[2][12] = new Array("H6Flex", "techh6flex.html","");
SubInfo[2][13] = new Array("CCHIPO","techcchipo.html","");

SubInfo[4][1] = new Array("Vehicle","history.html","");
SubInfo[4][2] = new Array("Torches","torches.html","");
SubInfo[4][3] = new Array("D2DIM", "d2dim.html", "");
SubInfo[4][4] = new Array("D2DIM Technical","techd2dim.html","");
SubInfo[4][5] = new Array("uFlex","uflex.html","");
SubInfo[4][6] = new Array("uFlex Technical","techuflex.html","");
SubInfo[4][7] = new Array("FlexiLED","flexiled.html","");
SubInfo[4][8] = new Array("VIP","techvip.html","");

//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 0;
var ySubOffset = 20;


//*** 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('onMouseOut="overSub=false;');
		document.write('setTimeout(\'hideSubMenu(\\\'submenu' + (x+1) + '\\\')\',delay);">');

		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>');
}

// PRELOAD MAIN MENU BUTTON IMAGES
for ( x=0; x<totalButtons; x++ ) {
	buttonUp = new Image();
	buttonUp.src = buttonFolder + upSources[x];
	buttonOver = new Image();
	buttonOver.src = buttonFolder + overSources[x];
}

//*** MAIN MENU FUNCTIONS ***//
// SET MOUSEOVER BUTTON
function setOverImg(But) {
	document.getElementById('button' + But).src = buttonFolder + overSources[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg(But) {
	document.getElementById('button' + But).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),-400, 100 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu(subID) {
	if ( overSub == false ) {
		moveObjectTo(subID,-400, 100);
	}
}

