/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder_top_menu = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources_top_menu = new Array("button1up_top_menu.png","button2up_top_menu.png","button3up_top_menu.png","button4up_top_menu.png","button5up_top_menu.png","button6up_top_menu.png","button7up_top_menu.png");

overSources_top_menu = new Array("button1over_top_menu.png","button2over_top_menu.png","button3over_top_menu.png","button4over_top_menu.png","button5over_top_menu.png","button6over_top_menu.png","button7over_top_menu.png");

// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo_top_menu = new Array();
subInfo_top_menu[1] = new Array();
subInfo_top_menu[2] = new Array();
subInfo_top_menu[3] = new Array();
subInfo_top_menu[4] = new Array();
subInfo_top_menu[5] = new Array();
subInfo_top_menu[6] = new Array();
subInfo_top_menu[7] = new Array();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//

subInfo_top_menu[2][1] = new Array("FLOOR COVERING OVERVIEW  ","floor_coverings.html","");
subInfo_top_menu[2][2] = new Array("AREA RUGS  ","area_rugs.html","");
subInfo_top_menu[2][3] = new Array("QUALITY CARPET  ","quality_carpets.html","");
subInfo_top_menu[2][4] = new Array("HARDWOOD  ","hardwood.html  ","");
subInfo_top_menu[2][5] = new Array("LAMINATE  ","laminate.html  ","");
subInfo_top_menu[2][6] = new Array("TILE  ","tile.html   ","");
subInfo_top_menu[2][7] = new Array("STAIR FASHIONS  ","accessories.html  ","");

subInfo_top_menu[3][1] = new Array("SERVICES OVERVIEW  ","services.html","");
subInfo_top_menu[3][2] = new Array("RUG CLEANING  ","rug_cleaning.html","");
subInfo_top_menu[3][3] = new Array("RESTORATION SERVICES  ","restoration.html ","");
subInfo_top_menu[3][4] = new Array("FLOOR COVERING SALES		","floor_coverings.html","");






//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset_top_menu = 121;
var ySubOffset_top_menu = 7;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub_top_menu = false;
var delay_top_menu = 1000;
totalButtons_top_menu = upSources_top_menu.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons_top_menu; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo_top_menu[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '_top_menu">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		document.write('<div id="submenu' + (x+1) + '_top_menu" class="dropmenu_top_menu" ');
		document.write('onMouseOver="overSub_top_menu=true;');
		document.write('setOverImg_top_menu(\'' + (x+1) + '\',\'_top_menu\');"');
		document.write('onMouseOut="overSub_top_menu=false;');
		document.write('setTimeout(\'hideSubMenu_top_menu(\\\'submenu' + (x+1) + '_top_menu\\\')\',delay_top_menu);');
		document.write('setOutImg_top_menu(\'' + (x+1) + '\',\'_top_menu\');">');


		document.write('<ul>');
		for ( k=0; k<subInfo_top_menu[x+1].length-1; k++ ) {
			document.write('<li>');
			document.write('<a href="' + subInfo_top_menu[x+1][k+1][1] + '" ');
			document.write('target="' + subInfo_top_menu[x+1][k+1][2] + '">');
			document.write( subInfo_top_menu[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_top_menu() {
	for ( x=0; x<totalButtons_top_menu; x++ ) {
		buttonUp_top_menu = new Image();
		buttonUp_top_menu.src = buttonFolder_top_menu + upSources_top_menu[x];
		buttonOver_top_menu = new Image();
		buttonOver_top_menu.src = buttonFolder_top_menu + overSources_top_menu[x];
	}
}

// SET MOUSEOVER BUTTON
function setOverImg_top_menu(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_top_menu + overSources_top_menu[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg_top_menu(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder_top_menu + upSources_top_menu[But-1];
}



//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement_top_menu(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft_top_menu(id) { 
	var el = getElement_top_menu(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_top_menu(id) {
	var el = getElement_top_menu(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_top_menu(objectID,x,y) {
	var el = getElement_top_menu(objectID);
	el.style.left = x;
	el.style.top = y;
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu_top_menu(subID, buttonID) {
	hideAllSubMenus_top_menu();
	butX = getRealLeft_top_menu(buttonID);
	butY = getRealTop_top_menu(buttonID);
	moveObjectTo_top_menu(subID,butX+xSubOffset_top_menu, butY+ySubOffset_top_menu);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus_top_menu() {
	for ( x=0; x<totalButtons_top_menu; x++) {
		moveObjectTo_top_menu("submenu" + (x+1) + "_top_menu",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu_top_menu(subID) {
	if ( overSub_top_menu == false ) {
		moveObjectTo_top_menu(subID,-500, -500);
	}
}



//preload_top_menu();

