//<!--  VERSION 1.5 -->
//<!--  -----------------VARIABLES--------------- -->
var noItemsperRow = 8;		// Number of Items per row on main menu -  1
var url = "Pages.asp"
//var url2 = "http://www.poolmart.com.au/"
var url2 = ""
// title,Submenu?,Link,alt
var up=-1;
var items = new Array();
up++; items[up]=new Array('Pools','No',url+'?PageName=FamilyPools','Family Pools');
up++; items[up]=new Array('Spas','Yes','Spassub','Pools');
up++; items[up]=new Array('Equipment','Yes','Equipmentsub','Pools');
up++; items[up]=new Array('Accessories','Yes','Accessoriessub','Pools');
up++; items[up]=new Array('Spare Parts','Yes','Sparessub','Pools');
up++; items[up]=new Array('Chemicals','Yes','Chemicalssub','Pools');
up++; items[up]=new Array('Toys','Yes','Toyssub','Pools');
up++; items[up]=new Array('Problems','Yes','Problemssub','Pools');
//up++; items[up]=new Array('Pool Terms','No',url+'?PageName=PoolTerms','Pool Terms');
up++; items[up]=new Array('Home Page','No','main.html','Home Page');
up++; items[up]=new Array('About Us','No','aboutus.html','About Us');
//up++; items[up]=new Array('Search','No','search.html','Poolmart Search Engine');
//up++; items[up]=new Array('Web Designer','No','webdesigner.html','Website Designer & Creator');
up++; items[up]=new Array('Login','No','login.asp','Member Login');
up++; items[up]=new Array('Veiw Cart','No','VeiwCart.asp','Veiw Shopping Cart');
up++; items[up]=new Array('Test Water','No','WaterTest.asp','Use Poolmarts Online Water Analysis');

// sinc++; subs[sinc]=new Array('SubName (Only Entered Once)',"Title","Submenu?","HTML/SUBNAME","ALT"); 
var sinc=-1;
var subs= new Array();
//sinc++; subs[sinc]=new Array('Poolssub',"Family","No","FamilyPools","Family Pools","Splasher","No","SplasherPools","Splasher Pools","Economy","No","EconomyPools","Economy Pools");
sinc++; subs[sinc]=new Array('Equipmentsub',
		"Automatic Cleaners","No","AutomaticCleaners","Automatic Cleaners",
		"Chlorinators","Yes","Chlorinator1sub","Chlorinators",
//		"Heaters","No","Heaters","Pool and Spa Heaters",
		"Pool & Spa Filters","Yes","Equipment3sub","Pool And Spa Filters",
		"Pool and Spa Pumps","Yes","Equipment2sub","Pool and Spa Pumps"
		);
sinc++; subs[sinc]=new Array('Problemssub',
		"General Tips","Problem","General","General Safety Tips",
		"Spring","Problem","Spring","Spring Cleanup",
		"Summer","Problem","Summer","Summer",
		"Winter","Problem","Winter","Winter",
		"Blackspot Algae","Problem","Blackspot","BlackSpot Algae",
		"Blackspot Osmosis","Problem","Osmosis","BlackSpot Osmosis",
		"Cloudy Pool","Problem","Cloudypool","Cloudy Pool",
		"Green Algae","Problem","Greenalgae","Green Algae",
		"Hazy Pool","Problem","Hazzypool","Hazy Pool",
		"Leaky Pool","Problem","Leakypool","Leaky Pool",
		"Noisy Pump","Problem","Noisypump","Noisy Pump");
sinc++; subs[sinc]=new Array('Spassub',"Poolmart Spas","Spa","PoolmartSpas","Poolmart Spas");//,"Duraspa","No","DuraSpa","Duraspa Spas");
sinc++; subs[sinc]=new Array('Accessoriessub',"Cleaning Equipment","No","CleaningEquipment","Cleaning Equipment","Pool Hoses","No","PoolHoses","Pool Hoses","Telescopic Poles","No","TelescopicPoles","Telescopic Poles","Test Kits","No","TestKits","Test Kits");
sinc++; subs[sinc]=new Array('Toyssub',"Flotation Devices","No","Floatation","Flotation Devices","Baby Seats","No","BabySeats","Baby Seats","Games","No","Games","Games And Toys","Lounges","No","Lounges","Lounges");
sinc++; subs[sinc]=new Array('Sparessub',"Automatic Spares","No","AutoSpares","Automatic Spares","Chlorinator Spares","No","ChlorinatorSpares","Chlorinator Spares","Misc Spares","No","MiscSpares","Misc Spare Parts");
sinc++; subs[sinc]=new Array('Chemicalssub',"Pool Chemicals","No","PoolChemicals","Pool Chemicals","Spa Chemicals","No","SpaChemicals","Spa Chemicals");
sinc++; subs[sinc]=new Array('Equipment3sub',"Sand Filters","No","SandFilters","Sand Filters","Cartridge Filters","No","CartridgeFilters","Cartridge Filters");
//,"Diatomaceous Earth","No","DiatomaceousEarthFilters","Diatomaceous Earth Filters");
sinc++; subs[sinc]=new Array('Equipment2sub'
//,"Spa Bath Pumps","No","SpaBathPumps","Spa Bath Pumps"
,"Pumps","No","Pumps","Pumps");

sinc++; subs[sinc]=new Array('Chlorinator1sub',
				"Standard","No","StandardChlorinators","Standard Chlorinators"
				);



//<!--  -----------------FUNCTIONS--------------- -->

function Highlight(name,classtitle){
	document.getElementById(name).className = classtitle;
	StopTimer()
}
function unHighlightAll(classtitle){
	for (var x=0; x<= up; x++)
		Highlight(items[x][0],classtitle);
}

function unHighlightSubs(classtitle){
	for (var x=0; x<= sinc; x++){
		for (var y=1; y< subs[x].length; y++){
			Highlight(subs[x][y],classtitle);
			Highlight(subs[x][y]+'Img',classtitle+'Img');
			y +=3
		}
	}
}

function HideAll(){
	HideAllMenus();
	HideAllSubMenus();
}
function HideAllMenus(){
	for (var x=0; x<= up; x++)
		if (items[x][1] == "Yes"){
			document.getElementById(items[x][2]).style.visibility = "hidden";
		}
}
function HideAllSubMenus(){
	for (var x=0; x< sinc; x++)
		for (var y=1; y<subs[x].length; y++){
			if (subs[x][y+1] == "Yes") {
				document.getElementById(subs[x][y+2]).style.visibility = "hidden";
			}
			y+=3;
		}
}

function getX(obj){ return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent)); }
function getY(obj){ return( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) ); }
function getBottomY(obj){ return ( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) ) + obj.offsetHeight; }
function getRightX(obj){ return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent) ) + obj.offsetWidth; }

function ShowMenu(item,name){
	unHighlightSubs("SubItem")
 	document.getElementById(name).style.top = getBottomY(item) + 1;
	document.getElementById(name).style.left = getX(item) ;
	document.getElementById(name).style.visibility = "visible";
}
function ShowSubMenu(item,name){
	document.getElementById(name).style.top = getY(item);
	document.getElementById(name).style.left = getRightX(item);
	document.getElementById(name).style.visibility = "visible";
}
var Selected;
function StopTimer(){
	clearTimeout(Selected);
}
function StartTimer(){
	Selected = setTimeout('HideAll(),unHighlightAll("Item")',1500);
}
function HideMenusSubs(title){
var length;
//alert (title);
	for (var x=0; x<sinc;x++){
		length = subs[x].length;
		if(subs[x][0] == title){
			for (var z=1; z<length;z++){
				if (subs[x][z + 1] == "Yes"){
					document.getElementById(subs[x][z + 2]).style.visibility = "hidden";
				}
				z += 3;
			}
		}
	}
}
function CreateMainMenu(URL,URL2){
url = URL;
url2 = URL2;
var Page='';
var SubPage ='';
	Page +='<Div><Center><Table Cellpadding="2" cellspacing="0" class="MenuTable">';
	Page += '<TR>';
	for (var x=0; x<= up; x++){
		Page+='<TD Class="Item" id="'+items[x][0]+'" ';
		if (items[x][1] == "Yes"){
			Page += 'onMouseOver="unHighlightAll(\'Item\'),HideAll(),StopTimer(),Highlight(\''+items[x][0]+'\',\'SelItem\'),ShowMenu(this,\''+items[x][2]+'\')" onMouseOut="StartTimer()">'+items[x][0];//onMouseOver="ShowMenu(this,\''+items[x][2]+'\',\'selItem\')" onMouseOut="Hide(\''+items[x][2]+'\'),unHighlight(\''+items[x][0]+'\',\'Item\')"
			SubPage += CreateMenu(items[x][2],null);//items[x][0]);
		}
		else {
			Page+= 'onMouseOver="unHighlightAll(\'Item\'),HideAll(),Highlight(\''+items[x][0]+'\',\'SelItem\')" onClick="document.location=\''+items[x][2]+'\'" onMouseOut="StartTimer()">'+items[x][0];//onMouseOver="HideAllMenus(),Highlight(\''+items[x][0]+'\',\'SelItem\')" onMouseOut="unHighlight(\''+items[x][0]+'\',\'Item\')"
		}
		if (items[x][1] == "Yes"){
			Page += '<img src="DownArrow.gif" height="12" width="12"/>';//' >>';
		}
		Page+='</TD>'
		if (x % noItemsperRow == 0 && x != 0 ) {
			Page += '</TR></Table>';
			Page += '<Table Cellpadding="2" cellspacing="0" class="MenuTable">';
		}
	}
	Page+='</Table></Center></Div>';
Page = "<Center><img id='banner' src='"+url2+"mainbanner.gif'></Center><P>" + Page;
document.write(Page);
document.write(SubPage);
}

function CreateMenu(title,name){
var temp='';
var temp2='';
	for (var x=0; x<= sinc; x++){
		if (subs[x][0] == title){
			temp += '<Div class="SubMenu" id="'+title+'" onMouseOver="StopTimer();" onMouseout="StartTimer()"';
			temp += '>';//,Show(\''+title+'\')
			temp += '<Table Cellpadding="3" cellspacing="2">';
			for (var y=1; y<subs[x].length; y++){
				if (subs[x][y+1] == "Yes"){
					temp += '<TR onMouseOver="unHighlightSubs(\'SubItem\','+name+'),Highlight(\''+subs[x][y]+'\',\'SelSubItem\'),Highlight(\''+subs[x][y]+'Img\',\'SelSubItemImg\'),HideMenusSubs(\''+title+'\'),ShowSubMenu(this,\''+subs[x][y+2]+'\')">';
					temp2 += CreateMenu(subs[x][y+2],subs[x][y]);
				}
				else {
					if (name != null){
						temp += '<TR onMouseOver="unHighlightSubs(\'SubItem\'),Highlight(\''+name+'\',\'SelSubItem\'),Highlight(\''+name+'Img\',\'SelSubItemImg\'),Highlight(\''+subs[x][y]+'Img\',\'SelSubItemImg\'),Highlight(\''+subs[x][y]+'\',\'SelSubItem\')"';
					}
					else {
						temp += '<TR onMouseOver="unHighlightSubs(\'SubItem\'),Highlight(\''+subs[x][y]+'\',\'SelSubItem\'),Highlight(\''+subs[x][y]+'Img\',\'SelSubItemImg\')"';
					}
					if (subs[x][y+1] == "Link"){
						temp += 'onClick="document.location=\''+url2+subs[x][y+2]+'\'">';
					}
					else if (subs[x][y+1] == "Spa"){
						temp += 'onClick="document.location=\'Spa'+url+'?PageName='+subs[x][y+2]+'\'">';
					}
					else if (subs[x][y+1] == "Problem"){
						temp += 'onClick="document.location=\'Problem'+url+'?PageName='+subs[x][y+2]+'\'">';
					}
					else {
						temp += 'onClick="document.location=\''+url+'?PageName='+subs[x][y+2]+'\'">';
					}
				}
				temp += '<TD class="SubItemImg" ID="'+subs[x][y]+'Img">';
				if (subs[x][y+1] == "Yes"){
					temp += '<img src="RightArrow.gif" height="20" width="20"/>';//' >>';
				}
				else {
				//	temp += '<img src="Link.gif" height="20" width="20"/>';//' >>';
				}
				temp += '</TD><TD class="SubItem" ID="'+subs[x][y]+'">'+subs[x][y];
				temp += '</TD></TR>';
				y += 3;
			}
			temp += '</Table></Div>';
		}
	}
temp += temp2;	
return temp;
}