﻿/*** 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","button8up.gif","button9up.gif","button10up.gif");

overSources = new Array("button1over.gif","button2over.gif","button3over.gif","button4over.gif","button5over.gif","button6over.gif","button7over.gif","button8over.gif","button9over.gif","button10over.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();
subInfo[8] = new Array();
subInfo[9] = new Array();
subInfo[10] = new Array();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//

subInfo[1][1] = new Array("Home","http://www.deckfailure.com/index.html","");
subInfo[1][2] = new Array("MLC Websites","http://www.deckfailure.com/MLCSites.html","");

subInfo[2][1] = new Array("Inspections","http://www.deckfailure.com/Inspections.html","");
subInfo[2][2] = new Array("ORDER","http://www.deckfailure.com/Order.html","");

subInfo[3][1] = new Array("Deck Failures","http://www.deckfailure.com/Failures.html","");
subInfo[3][2] = new Array("Railing Failures","http://www.deckfailure.com/FailuresRailings.html","");
subInfo[3][3] = new Array("FULL LIST","http://www.deckfailure.com/Failures.html","");
subInfo[3][4] = new Array("Introduction","http://www.deckfailure.com/Inspections.html#Anchor-INTRODUCTIO-53620","");
subInfo[3][5] = new Array("Life & Death","http://www.deckfailure.com/PDBInspections.html","");
subInfo[3][6] = new Array("Seattle Death","http://www.deckfailure.com/FSeattle.html","");
subInfo[3][7] = new Array("Montana","http://www.deckfailure.com/FMontana.html","");
subInfo[3][8] = new Array("Mountain Cabin","http://www.deckfailure.com/FMountainCabin.html","");
subInfo[3][9] = new Array("Kiddie Pool","http://www.deckfailure.com/FKiddiePool.html","");
subInfo[3][10] = new Array("San Jose","http://www.deckfailure.com/FSanJose.html","");
subInfo[3][11] = new Array("Vancouver","http://www.deckfailure.com/FVancouver.html","");
subInfo[3][12] = new Array("Virginia","http://www.deckfailure.com/FVirginia.html","");
subInfo[3][13] = new Array("Oregon","http://www.deckfailure.com/FOregonDeath.html","");
subInfo[3][14] = new Array("Oregon Condo","http://www.deckfailure.com/FKaten.html","");
subInfo[3][15] = new Array("Utah 18 Hurt","http://www.deckfailure.com/FUtah.html","");
subInfo[3][16] = new Array("My Neighbor","http://www.deckfailure.com/FNeighbor.html","");
subInfo[3][17] = new Array("London Pool","http://www.deckfailure.com/FOntarioPool.html","");
subInfo[3][18] = new Array("New Jersey","http://www.deckfailure.com/FNewJerseyAtheletes.html","");
subInfo[3][19] = new Array("FULL LIST","http://www.deckfailure.com/Failures.html","");


subInfo[4][1] = new Array("FAQ’s","http://www.deckfailure.com/FAQs.html","");
subInfo[4][2] = new Array("Top 10","http://www.deckfailure.com/TopTen.html","");
subInfo[4][3] = new Array("In The News","http://www.deckfailure.com/News.html","");
subInfo[4][4] = new Array("Legal View","http://www.deckfailure.com/LLegal.html","");
subInfo[4][5] = new Array("ARTICLES  ","http://www.deckfailure.com/Articles.html","");
subInfo[4][6] = new Array("--Failures ","http://www.deckfailure.com/Articles.html#Anchor-DEC-60442","");
subInfo[4][7] = new Array("--Inspector","http://www.deckfailure.com/Articles.html#Anchor-HOM-47401","");
subInfo[4][8] = new Array("--Industry","http://www.deckfailure.com/Articles.html#Anchor-DEC-10647","");
subInfo[4][9] = new Array("--HOA Issues","http://www.deckfailure.com/Articles.html#Anchor-HOM-39338","");
subInfo[4][10] = new Array("--City","http://www.deckfailure.com/Articles.html#Anchor-CIT-19898","");
subInfo[4][11] = new Array("--State","http://www.deckfailure.com/Articles.html#Anchor-CIT-19898","");
subInfo[4][12] = new Array("--Federal","http://www.deckfailure.com/Articles.html#Anchor-CIT-19898","");
subInfo[4][13] = new Array("----CPSC","http://www.deckfailure.com/Articles.html#Anchor-CPS-35930","");
subInfo[4][14] = new Array("----FEMA","http://www.deckfailure.com/Articles.html#Anchor-FEM-59501","");

subInfo[5][1] = new Array("Failure Gallery","http://www.deckfailure.com/Gallery.html","");
subInfo[5][2] = new Array("Hall of Shame","http://www.deckfailure.com/HallofShame.html","");

subInfo[6][1] = new Array("GUIDELINES","http://www.deckfailure.com/Guidelines.html","");
subInfo[6][2] = new Array("Commentary","http://www.deckfailure.com/Guidelines.html#Anchor-Commentar-43654","");
subInfo[6][3] = new Array("Building Codes","http://www.deckfailure.com/Guidelines.html#Anchor-IR-56696","");
subInfo[6][4] = new Array("State","http://www.deckfailure.com/Guidelines.html#Anchor-STAT-62952","");
subInfo[6][5] = new Array("Industry","http://www.deckfailure.com/Guidelines.html#Anchor-MANUA-61907","");
subInfo[6][6] = new Array("Manufacturer","http://www.deckfailure.com/Guidelines.html#Anchor-MANUFACTURE-32625","");
subInfo[6][7] = new Array("HOA Issues","http://www.deckfailure.com/Guidelines.html#Anchor-HOM-24956","");
subInfo[6][8] = new Array("FEMA","http://www.deckfailure.com/Guidelines.html#Anchor-FEM-40331","");
subInfo[6][9] = new Array("CPSC","http://www.deckfailure.com/Guidelines.html#Anchor-CPS-7665","");

subInfo[7][1] = new Array("Solutions","http://www.deckfailure.com/Solutions.html","");

subInfo[8][1] = new Array("Products","http://www.deckfailure.com/Products.html","");

subInfo[9][1] = new Array("Order","http://www.deckfailure.com/Order.html","");
subInfo[9][2] = new Array("Guarantee","http://www.deckfailure.com/Guarantee.html","");

subInfo[10][1] = new Array("Contact Us","http://www.deckfailure.com/Contact.html","");
subInfo[10][2] = new Array("MLC Websites","http://www.deckfailure.com/MLCSites.html","");
subInfo[10][3] = new Array("TheHomeInspector","http://www.TheHomeInspector.com","_blank");
subInfo[10][4] = new Array("TheCommercialInsp","http://www.TheCommercialInspector.com","_blank");
subInfo[10][5] = new Array("TheStuccoInspector","http://www.TheStuccoInspector.com","_blank");
subInfo[10][6] = new Array("TheMethInspector","http://www.TheMethInspector.com","_blank");
subInfo[10][7] = new Array("DeckFailure.com","http://www.DeckFailure.com","_blank");
subInfo[10][8] = new Array("WaterEntry.com","http://www.WaterEntry.com","_blank");
subInfo[10][9] = new Array("Kickout.info","http://www.kickout.info","_blank");
subInfo[10][10] = new Array("Diptube.info","http://www.diptube.info","_blank");


//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 115;
var ySubOffset = 3;



//*** 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();

