var layerID=5;
var layerShown=false;
function getlayerID() {
	if (layerID == 6) {
		layerID=1;
		return 1;
	} else {
		layerID++;
		return layerID;
	}
}
function showLayer(layerID) {
	layerShown=true;
	var l=getlayerID();
	var promoLayer="promo"+l;
	var x =document.getElementById(promoLayer).innerHTML;
	document.getElementById("bannerAdds").innerHTML = x;
	Effect.BlindDown("bannerAdds");
	setTimeout("closeLayer(1);",7000);
}
function closeLayer(layerID) {
	var l=getlayerID();
	var promoLayer="promo"+l;
	var x =document.getElementById(promoLayer).innerHTML;
	document.getElementById("bannerAdds").innerHTML = x;
	Effect.BlindDown("bannerAdds");
	setTimeout("closeLayer('1');",7000);
	layerShown=false;
}
function closeLayers() {
	if (layerShown) {
	Effect.BlindUp('promo1');
	Effect.BlindUp('promo2');
	Effect.BlindUp('promo3');
	Effect.BlindUp('promo4');
	Effect.BlindUp('promo5');
	Effect.BlindUp('promo6');
	}
}
var dom = document.getElementById? 1 : 0;
var ie  = document.all? 1 : 0;
var ns  = document.layers? 1 : 0;
function showObject(objList){var a = objList.split(',');for(var i = 0; i < a.length; i++){show(a[i]);}}
function hideObject(objList){var a = objList.split(',');for(var i = 0; i < a.length; i++){hide(a[i]);}}
function show(obj){obj = findObj(obj);if(!obj) return;if (dom || ie){obj.style.visibility = "visible";obj.style.display = "";}else if (ns){if(document.layers[obj]){obj.visibility = "show";obj.display = "";}}}
function hide(obj){obj = findObj(obj);if(!obj) return;if (dom || ie){obj.style.visibility = "hidden";obj.style.display = "none";}else if (ns){if(document.layers[obj]){obj.visibility = "hide";obj.display = "none";}}}
function findObj(obj){var p, i, found, doc;doc = document;if(!(found = doc[obj]) && ie){found = doc.all[obj];}for (i=0; !found && i < doc.forms.length; i++){found = doc.forms[i][obj];}for(i=0; !found && ns && i < doc.layers.length; i++){found = find(obj,doc.layers[i].document);}if(!found && dom){found = document.getElementById(obj);}return found;}
function getObj(name) {
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}
function isDHTML() {
	var DHTML = (document.getElementById || document.all || document.layers);
	return DHTML;
}
function showHide(obj_id) {
	if (!isDHTML()) return;
	var x = new getObj(obj_id);
	var x2="show"+obj_id;
	var x3="hide"+obj_id;
	vis = x.style.display;
	if (vis == "") 	{
		hide(obj_id);
		hide(x3);
		show(x2);
	} 	else 	{
		show(obj_id);
		show(x2);
		hide(x3);
	}
}
function HideSection(obj_id) {
	if (!isDHTML()) return;
	var x2="show"+obj_id;
	hide(obj_id);	
	show(x2);
}
function ShowSection(obj_id) {
	if (!isDHTML()) return;	
	var x2="show"+obj_id;
	show(obj_id);
	hide(x2);	
}
var buttonFolder = "http://mymastercraft.com/buttons/";
upSources = new Array("button1up.gif","button2up.gif","button4up.gif","button5up.gif","button6up.gif","button7up.gif","button8up.gif","button9up.gif");
overSources = new Array("button1over.gif","button2over.gif","button4over.gif","button5over.gif","button6over.gif","button7over.gif","button8over.gif","button9over.gif");
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[1][1] = new Array("Cleaners","http://mymastercraft.com/parts.cfm?cat=CLEANERS","");
subInfo[1][2] = new Array("Engine","http://mymastercraft.com/parts_choice.cfm?cat=ENGINE","");
subInfo[1][3] = new Array("General Parts","http://mymastercraft.com/parts.cfm?cat=GENERAL","");
subInfo[1][4] = new Array("Graphics","http://mymastercraft.com/parts_choice.cfm?cat=GRAPHICS","");
subInfo[1][5] = new Array("Upholstery","http://mymastercraft.com/parts.cfm?cat=Upholstery","");

subInfo[2][1] = new Array("Audio Equipment","http://mymastercraft.com/parts.cfm?cat=Stereo","");
subInfo[2][2] = new Array("Exterior","http://mymastercraft.com/parts_choice.cfm?cat=EXTERIOR","");
subInfo[2][3] = new Array("Interior","http://mymastercraft.com/parts_choice.cfm?cat=INTERIOR","");
subInfo[2][4] = new Array("Mini Tower","http://mymastercraft.com/parts.cfm?cat=Mini Tower","");
subInfo[2][5] = new Array("Tower Accessories","http://mymastercraft.com/parts_choice.cfm?cat=TowerAccessories","");
subInfo[2][6] = new Array("Tow Vehicle","http://mymastercraft.com/parts_choice.cfm?cat=TOW_VEHICLE","");
subInfo[2][7] = new Array("Towing","http://mymastercraft.com/parts_choice.cfm?cat=TOWING","");

subInfo[3][1] = new Array("Skis","http://trinityboardshop.com/ProShop/products.cfm?product_type=skis","");
subInfo[3][2] = new Array("Wakeboards","http://trinityboardshop.com/ProShop/products.cfm?product_type=Wakeboards","");
subInfo[3][3] = new Array("Bindings","http://trinityboardshop.com/ProShop/products.cfm?product_type=Bindings","");
subInfo[3][4] = new Array("Ropes/Handles","http://trinityboardshop.com/ProShop/products.cfm?product_type=Ropes/Handles","");

subInfo[4][1] = new Array("Used Boats","http://charlotte.mastercraft.com/","");

subInfo[5][1] = new Array("Build","http://mymastercraft.com/build1.cfm","");

subInfo[6][1] = new Array("Charlotte MasterCraft Recognized at annual Presidents Award ","http://mymastercraft.com/2004President.cfm","");
subInfo[6][2] = new Array("MasterCraft ProStar 209 Certified Record Capable ","http://mymastercraft.com/209.cfm","");
subInfo[6][3] = new Array("X-Star Voted Rider’s Choice! ","http://mymastercraft.com/xstarwins.cfm","");

subInfo[7][1] = new Array("Lake Lure Adventure Company ","http://www.lakelureadventurecompany.com/","_blank");

subInfo[8][1] = new Array("MasterCraft Pro WaterSki Championship","http://mymastercraft.com/champ.cfm","");

var xSubOffset = 160;
var ySubOffset = 3;

var overSub = false;
var delay = 1000;
totalButtons = upSources.length;

for ( x=0; x<totalButtons; x++) {
	if ( subInfo[x+1].length < 1 ) { 
		document.write('<div id="submenu' + (x+1) + '">');
	} 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>');
}
function preload() {
	for ( x=0; x<totalButtons; x++ ) {
		buttonUp = new Image();
		buttonUp.src = buttonFolder + upSources[x];
		buttonOver = new Image();
		buttonOver.src = buttonFolder + overSources[x];
	}
}
function setOverImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + overSources[But-1];
}
function setOutImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + upSources[But-1];
}
function getElement(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}
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;
	} 
} 
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;
	}
}
function moveObjectTo(objectID,x,y) {
	var el = getElement(objectID);
	el.style.left = x;
	el.style.top = y;
}
function showSubMenu(subID, buttonID) {
	hideAllSubMenus();
	butX = getRealLeft(buttonID);
	butY = getRealTop(buttonID);
	moveObjectTo(subID,butX+xSubOffset, butY+ySubOffset);
}
function hideAllSubMenus() {
	for ( x=0; x<totalButtons; x++) {
		moveObjectTo("submenu" + (x+1) + "",-500, -500 );
	}
}
function hideSubMenu(subID) {
	if ( overSub == false ) {
		moveObjectTo(subID,-500, -500);
	}
}