//v1.6

var tALIGN =	"center";	// main nav text align
var stALIGN =	"center";	// submenu text align


// find the inner width of the browser window

if (exclude == false) { 
var bWid;
if (ns4 || op5 || ns6 || mz7) { bWid = (window.innerWidth-16); }
else { bWid = document.body.clientWidth; }


// white line spacer width - used to determine the width of each sub-table
if (op5) { var imgW = 116; }
else { var imgW = 122 + (5-smPADDING)*2; }

// how many top links?
var ntl = 0;
for (intl=0;intl<5;intl++) { if (link[intl]!="") { ntl++; }}


// set variables for center or right alignment

var ralign=false; var centerMENU=false;

if (menuALIGN=='center') { centerMENU=true; }
if (menuALIGN=='right') { ralign=true; }
if (ralign) { 
	if (op5) { absLEFT = bWid-626; }
	else if (ns6) { absLEFT = bWid-710; }
	else if (mz7) { absLEFT = bWid-702; }
	else if (ns4) { absLEFT = bWid-700; }
	else { absLEFT = bWid-716; }
	
	//absLEFT+=10;
	
	if (bWid<(700-((imgW+15)*(5-ntl)))) { absLEFT = 0; }
	}

	
// set position values for alignment and menu stretching

var falseLEFT = false;
if (centerMENU && bWid < 700) { falseLEFT=true; centerMENU=false; absLEFT=0; }
var corABS = absLEFT; 
if (stretchMENU && (absLEFT<12)) { absLEFT = 0; }
if (ralign) { falseLEFT=true; }

// adjust figures for browser idiosyncrasies

var ht = 0;
if (centerMENU && (bWid > 700)) {
if (ie) { ht = -4; }
if (op5) { ht = 18; }
}
if (centerMENU && (bWid > 750)) {
if (ns4) { ht = 6; }
}

if (stretchMENU) { 
var strSTR='';
var spH = 26; if (ns4) { spH = 23; } if (op5) { spH = 15; } 
if (!ns4) {
	strSTR+='<table width="100%" cellpadding=0 cellspacing=0 border=0 class=menubarTDS style="position:absolute\; top:' + absTOP + 'px\; left:0px"><tr>'; 
	strSTR+='<td><img src="blank.gif" height=' + spH + '></td>'; 
	strSTR+='</tr></table>'; 
	document.write(strSTR);
	}
}

var bt=700;
if (ns4) { bt = 750; }
else if (op5) { bt = 650; }
else { bt = 726; }


var xSP = bWid - 700;
var cSP = xSP / 2;

if (centerMENU && (bWid > bt)) { if (ns4) { absLEFT=ht; } else { absLEFT=(cSP+ht); }}
var nsSPI; 
if (ns4 && centerMENU) { if (stretchMENU) { nsSPI = absLEFT; absLEFT = (0-ht); }}
}

// do nothing
function doNothing() { }
var csd = new Array('','','','','');
for (dn=0;dn<5;dn++) { if (url[dn] == "") { url[dn] = "javascript:doNothing()"; csd[dn] = "cursor:default\;" }}


// top link variables

var count = 0;
var num = 0;
var finished = false;

var linkCellOpen = '<td class=menubarTD';
if (op5) { var dividerCell = '<td align=center class=menubarTD onmouseover="clearMenus()"><img src="blank.gif" alt="" border=0 width=15 height=1><br class=br><span class=divide style="position:relative; top:1px;">|</span></td>'; }
else { var dividerCell = '<td align=center class=menubarTD><img src="blank.gif" alt="" border=0 width=15 height=1><br class=br><span class=divide>|</span></td>'; }

if (op5) { var emptyEndCell = '<td align=center class=menubarTD><img src="blank.gif" alt="" border=0 width=2 height=15'; }
else if (ns4) {	
	var nsBG='';
	if (stretchMENU) { nsBG =  ' bgcolor="' + mCOLOR + '"'; if (useIMG) { nsBG = ' background="' + mCOLOR + '"'; }}
	if (centerMENU) { 
		if (stretchMENU&&bWid>750) { 
			var emptyEndCell = '<td align=center class=menubarTDS' + nsBG + '><img src="blank.gif" alt="" border=0 width="' + (cSP-16) + '" height=15'; 
			} else {
			var emptyEndCell = '<td align=center class=menubarTDS' + nsBG + '><img src="blank.gif" alt="" border=0 width="' + (cSP-24) + '" height=15'; 
			}
		} else {
		var emptyEndCell = '<td align=center class=menubarTD' + nsBG + ' width=2000><img src="blank.gif" alt="" border=0 width="' + nsSPI + '" height=15'; 
		}
	var startCell = '<td align=center class=menubarTDS' + nsBG + '><img src="blank.gif" alt="" border=0 width="' + (absLEFT-10) + '" height=15></td>';
	}
else { var endCOLOR = "";
       var useBG = '';
       if (stretchMENU || (ns6&&ralign)) { useBG = 'style="' + bgColor + '"'; }
       var emptyEndCell = '<td align=center ' + useBG + ' width=2000><img width=2 height=15 src="blank.gif" alt="" border=0';
       }


var MAINstr = "";
var blankSP = '<img src="blank.gif" alt="" border=0 width=100 height=1><br class=br>';



//top and left relative position of subtables
var SUBabsTOP = 0; var SUBabsLEFT = 0;
if (ie) { SUBabsTOP = (absTOP+26+tweak); SUBabsLEFT = ((absLEFT+13)+ht); }
else if (op5) { SUBabsTOP = (absTOP+23+tweak); SUBabsLEFT = ((absLEFT+11)+ht); }
else if (ns6 || mz7) { 
	SUBabsTOP = (absTOP+26+tweak); 
	SUBabsLEFT = ((absLEFT+13)+ht); 
	}
else if (ns4) { 
	SUBabsTOP = (absTOP+14+tweak); 
	SUBabsLEFT = (absLEFT+13+ht); 
	if (centerMENU && (bWid > 750)) { 
		if (stretchMENU) { SUBabsLEFT = cSP+ht+1; }
		else { SUBabsLEFT = (cSP+(ht*2)-1); }
		}
	}


// object array - submenu ID values
var subID = new Array(5);
subID[0] = "submenu0";
subID[1] = "submenu1";
subID[2] = "submenu2";
subID[3] = "submenu3";
subID[4] = "submenu4";



//this gets me out of a couple of sticky spots
function clearMenus() {
if (ns4) { for(j=0;j<5;j++)	{ document.layers[subID[j]].visibility="hide"; }}
else if (ns6 || mz7) { for(j=0;j<5;j++) { document.getElementById(subID[j]).style.display="none"; }}
else if (op5) { for(j=0;j<5;j++) { document.getElementById(subID[j]).style.visibility="hidden"; }}
else { 
if (ie4) { 
	for(j=0;j<5;j++) { document.all[subID[j]].style.visibility="hidden"; }
	} else {
	for(j=0;j<5;j++) { document.all[subID[j]].style.visibility="hidden"; }
	}
}
}



// submenu variables
var SUBstr0 = "";
var SUBstr1 = "";
var SUBstr2 = "";
var SUBstr3 = "";
var SUBstr4 = "";

var SUBlinkCellOpen = '<tr><td class=SUBmenubarTD';
var nsBR = ""; if (ns6) { nsBR = "<br class=br>"; }
var space = "";
if (ns6) { space = " height=22"; }
if (op5) { space = " height=20"; }
var shiftUP = '';

var trigger = onmouseover="this.visibility='show'";


// link target simulation for IE4

var ieTARGET;

if (ie4) { 

if (linkTARGET == "") { linkTARGET = "_self"; }
else if (linkTARGET == "_self") { ieTARGET = "self"; }
else if (linkTARGET == "_blank") { ieTARGET = "var newwin = window.open\(\'\',\'newwin\'\)\; newwin" }
else if (linkTARGET == "_top") { ieTARGET = "top"; }
else if (linkTARGET == "_parent") { ieTARGET = "parent"; }
else { ieTARGET = "top." + linkTARGET; }

}



//****//****//

function drawSubMenu() {
//tedious mucking about for ns6 and mozilla to ensure correct table positioning
var mzTOP = (SUBabsTOP - 35); var mzTOPcl = (SUBabsTOP - 25);
for (i=0;i<=9;i++) { if (Hurl[i] != "" && Llink[i] != "") { mzTOP-=24; mzTOPcl-=22;}}
//compile sub menu
if (ns4) { 	subSTR[count] += '<layer name=' + subID[count] + ' visibility=hide top=' + SUBabsTOP + ' left=' + SUBabsLEFT + ' onmouseover="this.visibility=\'show\'" onmouseout="this.visibility=\'hide\'">'; }
subSTR[count] += '<table cellpadding=' + smPADDING + ' cellspacing=0 border=0 class=SUBmenubar ';
if (!ns4) { subSTR[count] += ' id="' + subID[count] + '"'; }
if (ie) { subSTR[count] += ' style="visibility:hidden; position:absolute; top:' + SUBabsTOP + 'px; left:' + SUBabsLEFT + 'px;" onmouseover="document.all[\'' + subID[count] + '\'].style.visibility=\'visible\'" onmouseout="document.all[\'' + subID[count] + '\'].style.visibility=\'hidden\'">'; }
else if (op5) { subSTR[count] += ' style="visibility:hidden; position:absolute; top:' + SUBabsTOP + 'px; left:' + SUBabsLEFT + 'px; width:' + (imgW+6) + 'px" onmouseover="document.getElementById(\'' + subID[count] + '\').style.visibility=\'visible\';">';  }
else if (mz7 || ns6) { subSTR[count] += ' style="display:none; position:absolute; left:' + SUBabsLEFT + 'px; top:' + SUBabsTOP + 'px; z-index:1">';  }
else                {   subSTR[count] += '>'; }

if (ns4||op5) { subSTR[count] += '<tr><td align=center><img src="blank.gif" alt="" width=' + imgW + ' height=' + (2 + ((5-smPADDING)*2)) + ' border=0></td></tr>'; }

if (ie4) { 
	for (i=0;i<ulen;i++) { if (Hurl[i] != "" && Llink[i] != "") { subSTR[count] += SUBlinkCellOpen + space +' align=' + stALIGN + ' width="' + (imgW + 2) + '" onclick="javascript:' + ieTARGET + '.document.location=\'' + Hurl[i] + '\'"><a style="cursor:hand\; text-decoration:' + aDEC + '\; font-weight:' + fWEIGHT + '\;">' + Llink[i] + '</a></td></tr>'; }}
	} else if (ns4) { 
	for (i=0;i<ulen;i++) { if (Hurl[i] != "" && Llink[i] != "") { subSTR[count] += SUBlinkCellOpen + space +' align=' + stALIGN + ' width="' + (imgW + 2) + '"><a href="' + Hurl[i] + '"' + shiftUP + ' target="' + linkTARGET + '" style="color:' + saLINK + '">' + Llink[i] + '</a></td></tr>'; }}
	} else { 
	for (i=0;i<ulen;i++) { if (Hurl[i] != "" && Llink[i] != "") { subSTR[count] += SUBlinkCellOpen + space +' align=' + stALIGN + ' width="' + (imgW + 2) + '"><a href="' + Hurl[i] + '"' + shiftUP + ' target="' + linkTARGET + '" style="color:' + saLINK + '" onmouseover="this.style.color=\'' + shLINK + '\'\; this.style.textDecoration=\'' + shDEC + '\'" onmouseout="this.style.color=\'' + saLINK + '\'\; this.style.textDecoration=\'' + saDEC + '\'">' + Llink[i] + '</a></td></tr>'; }}
	}

subSTR[count] += '</table>';
if (ns4) { 	subSTR[count] += '</layer>'; }
//actually draw it
if (exclude == false) { document.write(subSTR[count]); }
}


// object array - document.write string identifiers
var subSTR = new Array(5);
subSTR[0] = SUBstr0;
subSTR[1] = SUBstr1;
subSTR[2] = SUBstr2;
subSTR[3] = SUBstr3;
subSTR[4] = SUBstr4;



// reuseable arrays for compiling submenu link and linkname arrays
var Hurl = new Array(10);
var Llink = new Array(10);
var count; var ulen;

// increase top and left position function
function nextPosition() {
if (ie) { SUBabsLEFT+=135; }
else if (op5) { SUBabsLEFT+=123; }
else if (ns6) { SUBabsLEFT+=135; }
else if (ns4 || mz7) { SUBabsLEFT+=135; }
}



//zeroth submenu
count=0; ulen=url0.length;
for (hh=0;hh<=ulen;hh++) { Hurl[hh] = url0[hh]; }
for (hl=0;hl<=ulen;hl++) { Llink[hl] = link0[hl]; }
drawSubMenu();



//first submenu
count=1; ulen=url1.length;
for (hh=0;hh<=ulen;hh++) { Hurl[hh] = url1[hh]; }
for (hl=0;hl<=ulen;hl++) { Llink[hl] = link1[hl]; }
nextPosition();
drawSubMenu();



//second submenu
count=2; ulen=url2.length;
for (hh=0;hh<=ulen;hh++) { Hurl[hh] = url2[hh]; }
for (hl=0;hl<=ulen;hl++) { Llink[hl] = link2[hl]; }
nextPosition();
drawSubMenu();



//third submenu
count=3; ulen=url3.length;
for (hh=0;hh<=ulen;hh++) { Hurl[hh] = url3[hh]; }
for (hl=0;hl<=ulen;hl++) { Llink[hl] = link3[hl]; }
nextPosition();
drawSubMenu();



//fourth submenu
count=4; ulen=url4.length;
for (hh=0;hh<=ulen;hh++) { Hurl[hh] = url4[hh]; }
for (hl=0;hl<=ulen;hl++) { Llink[hl] = link4[hl]; }
nextPosition();
drawSubMenu();







// draw top links

function drawTopLinkTrigger() { 
if (ns4) { MAINstr += linkCellOpen + ' align=' + tALIGN + '>' + blankSP + '<a href="' + url[topID] + '"  onmouseover="clearMenus()\; document.layers.' + subID[topID] + '.visibility=\'show\'" target="' + linkTARGET + '">' + link[topID] + '</a></td>'; }
else if (ie) { MAINstr += linkCellOpen + ' align=' + tALIGN + ' onmouseover="clearMenus(); document.all[\'' + subID[topID] + '\'].style.visibility=\'visible\'">' + blankSP + '<a href="' + url[topID] + '" style="' + csd[topID] + '\; color:' + aLINK + '" target="' + linkTARGET + '" onmouseover="this.style.color=\'' + hLINK + '\'\; this.style.textDecoration=\'' + hDEC + '\'" onmouseout="this.style.color=\'' + aLINK + '\'\; this.style.textDecoration=\'' + aDEC + '\'">' + link[topID] + '</a></td>'; }																																																														//*****BUG FIX 30/1 - a stupid mistake that allowing nonlinked top items exposed
else if (op5) { MAINstr += linkCellOpen + ' align=' + tALIGN + ' onmouseover="clearMenus(); document.getElementById(\'' + subID[topID] + '\').style.visibility=\'visible\'" onmouseout="document.getElementById(\'' + subID[topID] + '\').style.visibility=\'visible\'">' + blankSP + '<a href="' + url[topID] + '" style="' + csd[topID] + '\; color:' + aLINK + '\; position:relative\; top:1px" target="' + linkTARGET + '" onmouseover="this.style.color=\'' + hLINK + '\'\; this.style.textDecoration=\'' + hDEC + '\'" onmouseout="this.style.color=\'' + aLINK + '\'\; this.style.textDecoration=\'' + aDEC + '\'">' + link[topID] + '</td>'; }
else if (ns6 || mz7) { MAINstr += linkCellOpen + ' align=' + tALIGN + '>' + blankSP + '<a href="' + url[topID] + '" onmouseover="this.style.textDecoration=\'' + hDEC + '\'\; this.style.color=\'' + hLINK + '\'\; clearMenus(); document.getElementById(subID[' + topID + ']).style.display=\'\'" target="' + linkTARGET + '" style="' + csd[topID] + '\; color:' + aLINK + '" onmouseout="this.style.color=\'' + aLINK + '\'\; this.style.textDecoration=\'' + aDEC + '\'">' + link[topID] + '</a></td>'; }
}


function drawTopLink() {
if (ns4) {	MAINstr += linkCellOpen + ' align=' + tALIGN + '>' + blankSP + '<a href="' + url[topID] + '" target="' + linkTARGET + '" onmouseover="clearMenus()">' + link[topID] + '</a></td>'; }
else if (ie) { MAINstr += linkCellOpen + ' align=' + tALIGN + '>' + blankSP + '<a href="' + url[topID] + '" target="' + linkTARGET + '" style="' + csd[topID] + '" onmouseover="clearMenus()\; this.style.color=\'' + hLINK + '\'\; this.style.textDecoration=\'' + hDEC + '\'" onmouseout="this.style.color=\'' + aLINK + '\'\; this.style.textDecoration=\'' + aDEC + '\'">' + link[topID] + '</a></td>'; }
else if (op5) {	MAINstr += linkCellOpen + ' align=' + tALIGN + '>' + blankSP + '<a href="' + url[topID] + '" target="' + linkTARGET + '" onmouseover="clearMenus()" style="' + csd[topID] + '\; position:relative\; top:1px">' + link[topID] + '</a></td>'; }
else if (ns6 || mz7) {	MAINstr += linkCellOpen + ' align=' + tALIGN + '>' + blankSP + '<a href="' + url[topID] + '" target="' + linkTARGET + '" style="' + csd[topID] + '" onmouseover="clearMenus()\; this.style.color=\'' + hLINK + '\'\; this.style.textDecoration=\'' + hDEC + '\'" onmouseout="this.style.color=\'' + aLINK + '\'\; this.style.textDecoration=\'' + aDEC + '\'">' + link[topID] + '</a></td>'; }
}



// draw framework

if (exclude == false) { 
if (ns4) { 
	var nsl = corABS; if (centerMENU) { nsl = absLEFT+ht; } if (stretchMENU) { nsl = 0; }
	MAINstr += '<layer name="menubar" visibility=show top=' + absTOP + ' left=' + nsl + '>'; 
	}
if (ns4) { MAINstr += '<table cellpadding=5 cellspacing=0 border=0 width=' + (700-((imgW+15)*(5-ntl))) + ' id="menubar" class=menubar><tr>'; }
else if (op5) {    MAINstr += '<table cellpadding=5 cellspacing=0 border=0 width=' + (642-((imgW+9)*(5-ntl))) + ' id="menubar" class=menubar style="z-index:2; position:absolute; top:' + absTOP + 'px; left:' + (absLEFT+ht) + 'px;"><tr>'; }
else {			   MAINstr += '<table cellpadding=5 cellspacing=0 border=0 width=' + (700-((imgW+15)*(5-ntl))) + ' id="menubar" class=menubar style="z-index:2; position:absolute; top:' + absTOP + 'px; left:' + (absLEFT+ht) + 'px;"><tr>'; }
if (ns4) { 
	if (centerMENU && (bWid > 750)) { MAINstr += emptyEndCell + '></td>'; }
	if (stretchMENU && (absLEFT>=12)) { MAINstr += startCell; }
	}
MAINstr += dividerCell;
if (link[0] != "") { 
if (url0[0] != "" && link0[0] != "") { topID = 0; drawTopLinkTrigger(); } else { topID = 0; drawTopLink(); }
MAINstr += dividerCell;
}
if (link[1] != "") {
if (url1[0] != "" && link1[0] != "") { topID = 1; drawTopLinkTrigger(); } else { topID = 1; drawTopLink(); }
MAINstr += dividerCell;
}
if (link[2] != "") {
if (url2[0] != "" && link2[0] != "") { topID = 2; drawTopLinkTrigger(); } else { topID = 2; drawTopLink(); }
MAINstr += dividerCell;
}
if (link[3] != "") {
if (url3[0] != "" && link3[0] != "") { topID = 3; drawTopLinkTrigger(); } else { topID = 3; drawTopLink(); }
MAINstr += dividerCell;
}
if (link[4] != "") {
if (url4[0] != "" && link4[0] != "") { topID = 4; drawTopLinkTrigger(); } else { topID = 4; drawTopLink(); }
MAINstr += dividerCell;
}
if (ns4 && stretchMENU) { 
	if (!centerMENU) { MAINstr += emptyEndCell + ' hspace=' + ((xSP-absLEFT)/2) + '></td>'; }
	else { MAINstr += emptyEndCell + ' hspace=6></td>'; }
	}	
else { if (!ralign) { 
	if ((ie&&!centerMENU)||(!ie&&centerMENU)) { 
		MAINstr += emptyEndCell + '></td>'; 
		}
	} 
if (ns6||(mz7&&!ralign)) { MAINstr += emptyEndCell + '></td>'; }
}


MAINstr += '</tr></table>';
if (ns4) { MAINstr += '</layer>'; }

document.write(MAINstr); 
}



document.onclick = clearMenus; 




// resize / reload trap

function nsinit() { setTimeout("window.onresize = redo", 1000); }
function redo() { window.location.reload(); }
if (ns4 || mz7) { window.onload = nsinit; }
else { if (centerMENU  || falseLEFT) { window.onresize=new Function("window.location.reload()") }}





