﻿/*** 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","button11up.gif","button12up.gif","button13up.gif","button14up.gif","button15up.gif","button16up.gif","button17up.gif","button18up.gif");

overSources = new Array("button1over.gif","button2over.gif","button3over.gif","button4over.gif","button5over.gif","button6over.gif","button7over.gif","button8over.gif","button9over.gif","button10over.gif","button11over.gif","button12over.gif","button13over.gif","button14over.gif","button15over.gif","button16over.gif","button17over.gif","button18over.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();
subInfo[11] = new Array();
subInfo[12] = new Array();
subInfo[13] = new Array();
subInfo[14] = new Array();
subInfo[15] = new Array();
subInfo[16] = new Array();
subInfo[17] = new Array();
subInfo[18] = new Array();
subInfo[19] = new Array();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
subInfo[1][1] = new Array("Home","http://www.diptube.info/index.html","");
subInfo[1][2] = new Array("MLC Websites","http://www.diptube.info/sites.html","");

subInfo[2][1] = new Array("Inspections","http://www.diptube.info/inspections.html","");

subInfo[3][1] = new Array("Credentials","http://www.diptube.info/credentials.html","");

subInfo[4][1] = new Array("Order","http://www.diptube.info/order.html","");

subInfo[5][1] = new Array("Hot Topics","http://www.diptube.info/topics.html","");

subInfo[6][1] = new Array("Class Action","http://www.diptube.info/classaction.html","");
subInfo[6][2] = new Array("--Bradford White","http://www.diptube.info/SBradford.html","");
subInfo[6][3] = new Array("--Client Complaint","http://www.diptube.info/SComplaint.html","");
subInfo[6][4] = new Array("--Lawyer Solicitation","http://www.diptube.info/LSolicitation.html","");
subInfo[6][5] = new Array("--Maryland","http://www.diptube.info/SettlementMaryland.html","");
subInfo[6][6] = new Array("--AO Smith Rejection","http://www.diptube.info/DipTube4AOSmith.html","");

subInfo[7][1] = new Array("Remedies","http://www.diptube.info/remedies.html","");
subInfo[7][2] = new Array("--Water Flow Test","http://www.diptube.info/remedies.html","");
subInfo[7][3] = new Array("--Check Aerators","http://www.diptube.info/remedies.html","");
subInfo[7][4] = new Array("--Replace Dip Tube","http://www.diptube.info/replacement.html","");
subInfo[7][5] = new Array("--Replace Anode Rod","http://www.diptube.info/ReplacementAnode.html","");

subInfo[8][1] = new Array("Service Area","http://www.diptube.info/area.html","");

subInfo[9][1] = new Array("Feedback","http://www.diptube.info/feedback.html","");

subInfo[10][1] = new Array("Gallery","http://www.diptube.info/gallery.html","");

subInfo[11][1] = new Array("MLC Websites","http://www.diptube.info/sites.html","");
subInfo[11][2] = new Array("TheHomeInspector","http://www.TheHomeInspector.com","_blank");
subInfo[11][3] = new Array("TheCommercialInspector","http://www.TheCommercialInspector.com","_blank");
subInfo[11][4] = new Array("TheStuccoInspector","http://www.TheStuccoInspector.com","_blank");
subInfo[11][5] = new Array("TheMethInspector","http://www.TheMethInspector.com","_blank");
subInfo[11][6] = new Array("DeckFailure.com","http://www.DeckFailure.com","_blank");
subInfo[11][7] = new Array("WaterEntry.com","http://www.WaterEntry.com","_blank");
subInfo[11][8] = new Array("Kickout.info","http://www.kickout.info","_blank");
subInfo[11][9] = new Array("Diptube.info","http://www.diptube.info","_blank");

subInfo[12][1] = new Array("Links","http://www.diptube.info/links.html","");
subInfo[12][2] = new Array("MLC Websites","http://www.diptube.info/sites.html","");

subInfo[13][1] = new Array("Newsletter","http://www.diptube.info/newsletter.html","");

subInfo[14][1] = new Array("Contact Us","http://www.diptube.info/contact.html","");
subInfo[14][2] = new Array("MLC Websites","http://www.diptube.info/sites.html","");



//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 125;
var ySubOffset = 4;



//*** 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();

