/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.png","button2up.png","button3up.png","button4up.png","button5up.png","button6up.png","button7up.png","button8up.png","button9up.png","button10up.png","button11up.png","button12up.png");

overSources = new Array("button1over.png","button2over.png","button3over.png","button4over.png","button5over.png","button6over.png","button7over.png","button8over.png","button9over.png","button10over.png","button11over.png","button12over.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();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//


subInfo[3][1] = new Array("ATV UTV Tires By Size","http://kgmotorcycletires.com/atv_tires_by_size.htm","");
subInfo[3][2] = new Array("Motorcycle Tires By Size","http://kgmotorcycletires.com/motorcycle_by_size.htm","");
subInfo[3][3] = new Array("Off Road Cycle Tires By Size","http://kgmotorcycletires.com/mx_enduro_by_size.htm","");
subInfo[3][4] = new Array("Find Your Models Tire Size","http://kgmotorcycletires.com/find_your_size.htm","");
subInfo[3][5] = new Array("Tire Size Conversion Charts","http://kgmotorcycletires.com/size_conversion_charts.htm","");

subInfo[4][1] = new Array("Tires","http://kgmotorcycletires.com/ATV_Tires.htm","");
subInfo[4][2] = new Array("Wheels","http://kgmotorcycletires.com/atv_wheels.htm","");
subInfo[4][3] = new Array("Tire Wheel Kits","http://kgmotorcycletires.com/atv_wheel_kits.htm","");
subInfo[4][4] = new Array("Wheel Spacers","http://kgmotorcycletires.com/atv_wheel_spacers.htm","");
subInfo[4][5] = new Array("Lift Kits","http://kgmotorcycletires.com/atv_lift_kits.htm","");
subInfo[4][6] = new Array("Brakes ","http://kgmotorcycletires.com/atv_brakes.htm","");
subInfo[4][7] = new Array("Snow Plow Kits","http://kgmotorcycletires.com/atv_snow_plow_kits.htm","");
subInfo[4][8] = new Array("Winches","http://kgmotorcycletires.com/atv_winch_utv_winch.htm","");
subInfo[4][9] = new Array("Exhausts","http://kgmotorcycletires.com/atv_exhausts.htm","");
subInfo[4][10] = new Array("Belts/Chains","http://kgmotorcycletires.com/chains_and_belts.htm","");
subInfo[4][11] = new Array("Axles","http://kgmotorcycletires.com/sti_atv_axles.htm","");
subInfo[4][12] = new Array("Sound Systems","http://kgmotorcycletires.com/atv_utv_sound_systems.htm","");
subInfo[4][13] = new Array("VP Fuel Jugs","http://kgmotorcycletires.com/vp_fuel_jugs.htm","");
subInfo[4][14] = new Array("Inner Tubes","http://kgmotorcycletires.com/cheng_shin_atv_tubes.htm","");
subInfo[4][15] = new Array("Goggles","http://kgmotorcycletires.com/motorcycle_goggles.htm","");
subInfo[4][16] = new Array("More ATV Products","http://kgmotorcycletires.com/atv_products.htm","");

subInfo[5][1] = new Array("Tires","http://kgmotorcycletires.com/ATV_Tires.htm","");
subInfo[5][2] = new Array("Wheels","http://kgmotorcycletires.com/atv_wheels.htm","");
subInfo[5][3] = new Array("Tire Wheel Kits","http://kgmotorcycletires.com/atv_wheel_kits.htm","");
subInfo[5][4] = new Array("Roofs","http://kgmotorcycletires.com/utv_sxs_vehicle_roofs.htm","");
subInfo[5][5] = new Array("Windshields","http://kgmotorcycletires.com/utv_sxs_windshields.htm","");
subInfo[5][6] = new Array("Doors","http://kgmotorcycletires.com/utv_door_kits.htm","");
subInfo[5][7] = new Array("Seats","http://kgmotorcycletires.com/utv_seats.htm","");
subInfo[5][8] = new Array("Seat Belts","http://kgmotorcycletires.com/utv_harness_belts.htm","");
subInfo[5][9] = new Array("Enclosures","http://kgmotorcycletires.com/utv_enclosure_kits.htm","");
subInfo[5][10] = new Array("Sound Systems","http://kgmotorcycletires.com/atv_utv_sound_systems.htm ","");
subInfo[5][11] = new Array("Wheel Spacers","http://kgmotorcycletires.com/atv_wheel_spacers.htm","");
subInfo[5][12] = new Array("Lift Kits","http://kgmotorcycletires.com/atv_lift_kits.htm","");
subInfo[5][13] = new Array("Snow Plow Kits","http://kgmotorcycletires.com/utv_sxs_snow_plows.htm","");
subInfo[5][14] = new Array("Winches","http://kgmotorcycletires.com/atv_winch_utv_winch.htm","");
subInfo[5][15] = new Array("Exhausts","http://kgmotorcycletires.com/utv_sxs_exhausts.htm","");
subInfo[5][16] = new Array("Brakes","http://kgmotorcycletires.com/atv_brakes.htm","");
subInfo[5][17] = new Array("Batteries","http://kgmotorcycletires.com/yuasa_batteries.htm","");
subInfo[5][18] = new Array("Drive Belts","http://kgmotorcycletires.com/drive_belts_atv_utv_sxs.htm ","");
subInfo[5][19] = new Array("More UTV Products","http://kgmotorcycletires.com/utv_accessories.htm","");

subInfo[6][1] = new Array("Tires","http://kgmotorcycletires.com/Street_tire.htm","");
subInfo[6][2] = new Array("Exhausts","http://kgmotorcycletires.com/motorcycle_exhausts.htm","");
subInfo[6][3] = new Array("Brakes","http://kgmotorcycletires.com/street_brakes.htm","");
subInfo[6][4] = new Array("Air Filters","http://kgmotorcycletires.com/KN_Air_Filters.htm","");
subInfo[6][5] = new Array("Batteries","http://kgmotorcycletires.com/yuasa_batteries.htm","");
subInfo[6][6] = new Array("Chains","http://kgmotorcycletires.com/d_i_d_racing_chain.htm","");
subInfo[6][7] = new Array("Covers","http://kgmotorcycletires.com/motorcycle_covers.htm","");
subInfo[6][8] = new Array("Inner Tubes","http://kgmotorcycletires.com/cheng_shin_motorcycle_tubes.htm","");
subInfo[6][9] = new Array("More Motorcycle Products","http://kgmotorcycletires.com/motorcycle_accessories.htm","");

subInfo[7][1] = new Array("Tires Dirt","http://kgmotorcycletires.com/MX_Offroad_Motorcycle_Tires.htm","");
subInfo[7][2] = new Array("Tires Dual Sport","http://kgmotorcycletires.com/enduro_dual_sport_motorcycle_tires.htm","");
subInfo[7][3] = new Array("Tires Sand","http://kgmotorcycletires.com/motorcycle_sand_paddles.htm","");
subInfo[7][4] = new Array("Exhaust","http://kgmotorcycletires.com/drd_motorcycle_exhausts.htm","");
subInfo[7][5] = new Array("Radiators","http://kgmotorcycletires.com/off_road_mx_radiators.htm","");
subInfo[7][6] = new Array("Chains","http://kgmotorcycletires.com/d_i_d_mx_motorcycle_chains.htm","");
subInfo[7][7] = new Array("Brakes","http://kgmotorcycletires.com/mx_enduro_brakes.htm","");
subInfo[7][8] = new Array("Batteries","http://kgmotorcycletires.com/yuasa_batteries.htm","");
subInfo[7][9] = new Array("Air Filters","http://kgmotorcycletires.com/KN_Air_Filters.htm","");
subInfo[7][10] = new Array("Inner Tubes","http://kgmotorcycletires.com/inner_tubes.htm","");
subInfo[7][11] = new Array("VP Fuel Jugs","http://kgmotorcycletires.com/vp_fuel_jugs.htm","");
subInfo[7][12] = new Array("Goggles","http://kgmotorcycletires.com/motorcycle_goggles.htm","");
subInfo[7][13] = new Array("More Off Road Products","http://kgmotorcycletires.com/offroad_cycle_products.htm","");

subInfo[8][1] = new Array("Bridgestone Tires","http://kgmotorcycletires.com/bridgestone_scooter.htm","");
subInfo[8][2] = new Array("Kenda Tires","http://kgmotorcycletires.com/kenda_scooter.htm","");
subInfo[8][3] = new Array("Brakes","http://kgmotorcycletires.com/street_brakes.htm","");
subInfo[8][4] = new Array("Covers","http://kgmotorcycletires.com/motorcycle_covers.htm","");
subInfo[8][5] = new Array("Inner Tubes","http://kgmotorcycletires.com/cheng_shin_motorcycle_tubes.htm","");
subInfo[8][6] = new Array("Batteries","http://kgmotorcycletires.com/yuasa_batteries.htm","");
subInfo[8][7] = new Array("More Scooter Products","http://kgmotorcycletires.com/scooter_Products.htm","");






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



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


