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

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.gif","button2up.gif","button3up.gif","button4up.gif","button5up.gif","button6up.gif","button7up.gif");

overSources = new Array("button1over.gif","button2over.gif","button3over.gif","button4over.gif","button5over.gif","button6over.gif","button7over.gif");

// 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();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//

//*** Home Drop Down Configuration ***//

subInfo[1][1] = new Array(" PDC Home","http://www.powerdistributioncenter.com","_parent");
subInfo[1][2] = new Array(" Quality Power Division","http://www.powerdistributioncenter.com/quality/quality.html","_parent");
subInfo[1][3] = new Array(" MiAREA","http://www.powerdistributioncenter.com/miarea.html","_parent");

//*** Learn Drop Down Configuration ***//

subInfo[2][1] = new Array(" What do I need for my home?","http://www.powerdistributioncenter.com/learn/home/home.html","_parent");
subInfo[2][2] = new Array(" What do I need for my business?","http://www.powerdistributioncenter.com/learn/business/business.html","_parent");
subInfo[2][3] = new Array(" Benefits/Rebates/Tax Incentives","http://www.powerdistributioncenter.com/learn/benefits/benefits.html","_parent");
subInfo[2][4] = new Array(" MiAREA","http://www.powerdistributioncenter.com/miarea.html","_parent");
subInfo[2][5] = new Array(" Exciting News About Alternative Energy","http://www.powerdistributioncenter.com/learn/news/news.html","_parent");
subInfo[2][6] = new Array(" Tools to Help You Calculate/Estimate","http://www.powerdistributioncenter.com/learn/tools/tools.html","_parent");
subInfo[2][7] = new Array(" Frequently Asked Questions","http://www.powerdistributioncenter.com/learn/faqs/faqs.html","_parent");
subInfo[2][8] = new Array(" Events Happening with PDC & Alternative Energy","http://www.powerdistributioncenter.com/company/events/events.html","_parent");
subInfo[2][9] = new Array(" Portfolio & References","http://www.powerdistributioncenter.com/learn/references/references.html","_parent");

//*** Products Drop Down Configuration ***//

subInfo[3][1] = new Array(" Search Products By Energy Source","http://www.powerdistributioncenter.com/products/source.html","_parent");
subInfo[3][2] = new Array(" Complete List of All Products","http://www.powerdistributioncenter.com/products/index.html","_parent");
subInfo[3][3] = new Array(" Installation Of Our Products","http://www.powerdistributioncenter.com/learn/references/references.html","_parent");
subInfo[3][4] = new Array(" Rebates/Tax Incentives/Benefits","http://www.powerdistributioncenter.com/learn/benefits/benefits.html","_parent");

//*** Company Drop Down Configuration ***//

subInfo[4][1] = new Array(" Events Happening with PDC & Alternative Energy","http://www.powerdistributioncenter.com/company/events/events.html","_parent");
subInfo[4][2] = new Array(" Employment Opportunities","http://www.powerdistributioncenter.com/company/jobs/jobs.html","_parent");
subInfo[4][3] = new Array(" Our Qualifications","http://www.powerdistributioncenter.com/company/qualifications/qualifications.html","_parent");
subInfo[4][4] = new Array(" Contact Us","http://www.powerdistributioncenter.com/company/contact/contact.html","_parent");

//*** Join Drop Down Configuration ***//

subInfo[5][1] = new Array(" Requirements to Join","http://www.powerdistributioncenter.com/join/requirements/requirements.html","_parent");
subInfo[5][2] = new Array(" Current Dealer List","http://www.powerdistributioncenter.com/join/dealers/dealers.html","_parent");
subInfo[5][3] = new Array(" Applications to Become a Dealer","http://www.powerdistributioncenter.com/join/apply/apply.html","_parent");
subInfo[5][4] = new Array(" MiAREA","http://www.powerdistributioncenter.com/miarea.html","_parent");

//*** blog Drop Down Configuration ***//

subInfo[6][1] = new Array(" Our Blog", "http://www.powerdistributioncenter.com/blog.html","_parent");

//*** prefab Drop Down Configuration ***//

subInfo[7][1] = new Array(" Modular","http://www.lzarch.com/projects/prefab/modular/modular.html","_parent");
subInfo[7][2] = new Array(" Branch Banks","http://www.lzarch.com/projects/prefab/banks/banks.html","_parent");
subInfo[7][3] = new Array(" Control Room","http://www.lzarch.com/projects/prefab/control/control.html","_parent");
subInfo[7][4] = new Array(" Hospital","http://www.lzarch.com/projects/prefab/hospital/hospital.html","_parent");
subInfo[7][5] = new Array(" Housing","http://www.lzarch.com/projects/prefab/housing/housing.html","_parent");


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



//*** 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();


