var mU = new Array();
var urlFile;
var storeBg = "";
var alter = 1;
var mOverr = "";
var mOutt = "";
var sameDirectory = false;	
var tgif = '<img src="/hf_img/t.gif" alt="" '
var fsstylie = '';
var fstable = '<table border="0" cellpadding="0" cellspacing="0" width="125">'
charArray = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");	
var thePathname = location.toString()
var thePathnameShort = thePathname.slice(0,thePathname.lastIndexOf("/")-1)

function hereIsh(text)
{
shortText = text.slice(0, text.lastIndexOf("/"))
if(window.location.href.indexOf(shortText) != -1)
	{return true}
else
	{return false}
}
function here(text)
{
if (text.indexOf("?")!=-1){
	text = text.slice(0,text.indexOf("?"))
}
if(thePathname.indexOf(text) != -1) {
	return true
	}
else
	{return false}
}
function hereSub(text)
{
if(text.indexOf(thePathname) != -1){
	if (thePathname.charAt(thePathname.length-1)!="/"){
		return true
	}
	else{
		return false
	}
}
else{
	return false
}
}

function removeBlanks(){
	var count = 0;
	for (i=0;i<mUmain.length;i++){
		if (mUmain[i]) {
			mU[count] = mUmain[i];
			count++;
		}
	}
}
function say(txt)
	{window.status = txt}
function checkHex(code1,which) {
	if (which=="up") {
		alter = 1;
	}
	else {
		alter = -1;
	}
	for (i=1;i<charArray.length-1;i++) {
		if (code1 == charArray[i]) {
		code1 = charArray[i+alter];
		break;
		}
	}
	return code1;
}


function lighten(colour,which) {
	var oldColour = colour.substring(colour.indexOf("#")+1);
	var rgb = new Array();
	var newColour = "#"
	for (r=0;r<=5;r++) {
		rgb[r] = oldColour.charAt(r);
		rgb[r] = checkHex(rgb[r],which);
		newColour += rgb[r];
	}
	return newColour;
}	
	
function mOverAndOut(num,inorout,morrc) {
	if (document.getElementById) {
		var td3 = document.getElementById(morrc+"tdc"+num);
		var td2 = document.getElementById(morrc+"tdb"+num);
		var td1 = document.getElementById(morrc+"td"+num);
		var alink1 = document.getElementById(morrc+"a"+num);
		var newBgColor = "notset";
		var imgSrc=eval('document.images.'+morrc+'cmimg'+num+'.src');
		if (inorout=="in") {
			if (morrc == "") {
			say(mU[num].say);
			}
			else if (morrc == "r") {
			say(document.fs.relChan[num].title);
			}
			if (imgSrc.indexOf("whitearrow1.gif")==-1) {
				eval('document.images.'+morrc+'cmimg'+num+'.src = col.dothi');
			}
			var oldBgColor = td2.style.backgroundColor.toString();
			storeBg = oldBgColor;
			if (oldBgColor.length==7) {
				newBgColor = lighten(oldBgColor,"up");	
			}
			alink1.style.textDecoration = "underline";
		}
		else {
			say("be Freeserve");
			if (imgSrc.indexOf("whitearrow1.gif")==-1) {
				eval('document.images.'+morrc+'cmimg'+num+'.src = col.dot');
			}
			if (morrc=="") {
				var dsfg = mU[num]
			}
			else if (morrc == "r") {
				var dsfg = document.fs.relChan[num]
			}
			if (dsfg.style) {
				//var oldBgColor = td2.style.backgroundColor.toString();
				if (storeBg.length==7) {
					newBgColor = storeBg;
				}
			}
			else {
				newBgColor = col.norm;
				if (morrc == "r") {
					newBgColor = rccol.norm;
				}
			}
			alink1.style.textDecoration = "none";
		}
		if(newBgColor!="notset"){
			td3.style.backgroundColor = newBgColor;
			td2.style.backgroundColor = newBgColor;
			td1.style.backgroundColor = newBgColor;
			alink1.style.backgroundColor = newBgColor;
		}
	}
}	
	
function alphabetize(arg1, arg2){
	if (arg1.title<arg2.title)
	return -1;
	if (arg1.title>arg2.title)
	return 1;
}
function loopLinks(wAr,lnum,morrc) {
	if (morrc == "r") {
		document.write('<tr><td nowrap align="center" valign="top" width="15" id="'+morrc+'td'+lnum+'" onMouseover="mOverAndOut('+lnum+',\'in\',\''+morrc+'\')"  onMouseout="mOverAndOut('+lnum+',\'out\',\''+morrc+'\')"')
		if (wAr[lnum].style && !document.layers) {
			document.write(' style="'+wAr[lnum].style+'" ');
		}
		else if (!document.layers) {
			document.write(' style="background-color: '+rccol.norm+';"')
		}
		else {
			document.write(' class="DLK" ');
		}
		document.write('><a ');
		if (wAr[lnum].target) {
			document.write(' target="'+wAr[lnum].target+'" ');
		}
		document.write(' onMouseOut="'+mOutt+'" onMouseOver="'+mOverr+';return true" href="'+wAr[lnum].url+'"><img name="'+morrc+'cmimg'+lnum+'" alt="'+wAr[lnum].say+'" border="0" src="'+col.dot+'" width="9" height="13"></a> </td><td valign="middle" width="105" id="'+morrc+'tdb'+lnum+'" onMouseover="mOverAndOut('+lnum+',\'in\',\''+morrc+'\')"  onMouseout="mOverAndOut('+lnum+',\'out\',\''+morrc+'\')"');
		if (wAr[lnum].style && !document.layers) {
			document.write('style="'+wAr[lnum].style+'" ');
			fsstylie = wAr[lnum].style;
		}
		else if (!document.layers) {
			document.write('style="background-color: '+rccol.norm+';" ')
			fsstylie = 'font-family: TiresiasScreenfont, Arial, Helvetica, sans-serif ; text-decoration:none ; color:' + rccol.textcolour;
		}
		else {
			document.write(' class="DLK" ');
		}
		
		
		document.write('><a  ')
		if (wAr[lnum].target) {
			document.write(' target="'+wAr[lnum].target+'" ');
		}
		document.write(' id="'+morrc+'a'+lnum+'" onMouseOut="'+mOutt+'" onMouseOver="'+mOverr+';return true"');
		if (!document.layers) {
			document.write('style="font-size: 12px;font-weight: bold;'+fsstylie+'"');
		}
		else {
			document.write(' class="DLK" ');
		}
		document.write(' href="'+wAr[lnum].url+'" ><b>'+wAr[lnum].title+'</b></a></td><td id="'+morrc+'tdc'+lnum+'" width="5" ')
		if (!document.layers) {
			if (!wAr[lnum].style) {
				document.write('style="background-color: '+rccol.norm+';" ')
			}
			else {
				document.write('style="'+wAr[lnum].style+'" ')
			}
		}
		else {
			document.write(' class="DLK" ');
		}
		
		document.write('>'+tgif+' width="5" height="15"></td></tr>');
	}
	else {
		document.write('<tr><td nowrap align="center" valign="top" width="15" id="'+morrc+'td'+lnum+'" onMouseover="mOverAndOut('+lnum+',\'in\',\''+morrc+'\')"  onMouseout="mOverAndOut('+lnum+',\'out\',\''+morrc+'\')"')
		if (wAr[lnum].style && !document.layers) {
			document.write(' style="'+wAr[lnum].style+'" ');
		}
		else if (!document.layers) {
			document.write(' style="background-color: '+col.norm+';"')
		}
		else {
			document.write(' class="DLK" ');
		}
		document.write('><a ');
		if (wAr[lnum].target) {
			document.write(' target="'+wAr[lnum].target+'" ');
		}
		document.write(' onMouseOut="'+mOutt+'" onMouseOver="'+mOverr+';return true" href="'+wAr[lnum].url+'"><img name="'+morrc+'cmimg'+lnum+'" alt="'+wAr[lnum].say+'" border="0" src="'+col.dot+'" width="9" height="13"></a> </td><td valign="middle" width="105" id="'+morrc+'tdb'+lnum+'" onMouseover="mOverAndOut('+lnum+',\'in\',\''+morrc+'\')"  onMouseout="mOverAndOut('+lnum+',\'out\',\''+morrc+'\')"');
		if (wAr[lnum].style && !document.layers) {
			document.write('style="'+wAr[lnum].style+'" ');
			fsstylie = wAr[lnum].style;
		}
		else if (!document.layers) {
			document.write('style="background-color: '+col.norm+';" ')
			fsstylie = 'font-family: TiresiasScreenfont, Arial, Helvetica, sans-serif ; text-decoration:none ; color:' + col.textcolour ;
		}
		else {
			document.write(' class="DLK" ');
		}
		
		
		document.write('><a  ')
		if (wAr[lnum].target) {
			document.write(' target="'+wAr[lnum].target+'" ');
		}
		document.write(' id="'+morrc+'a'+lnum+'" onMouseOut="'+mOutt+'" onMouseOver="'+mOverr+';return true"');
		if (!document.layers) {
			document.write('style="font-size: 12px;font-weight: bold;'+fsstylie+'"');
		}
		else {
			document.write(' class="DLK" ');
		}
		document.write(' href="'+wAr[lnum].url+'" ><b>'+wAr[lnum].title+'</b></a></td><td id="'+morrc+'tdc'+lnum+'" width="5" ')
		if (!document.layers) {
			if (!wAr[lnum].style) {
				document.write('style="background-color: '+col.norm+';" ')
			}
			else {
				document.write('style="'+wAr[lnum].style+'" ')
			}
		}
		else {
			document.write(' class="DLK" ');
		}
		
		document.write('>'+tgif+' width="5" height="15"></td></tr>');
	}
}
function showChannelMenu(nest) {
	document.write('<style>')
	document.write('.DLK{ background-color: '+col.norm+';font-size: 11px;font-family:TiresiasScreenfont, arial,sans-serif;font-weight: bold; color:#000066;text-decoration:none}\n')
	document.write('.cmheadcol{ background-color: '+col.cmheadcol+';font-size: 11px;font-family:TiresiasScreenfont, arial,sans-serif;font-weight: bold; color:#ffffff;text-decoration:none}\n')
	document.write('.rccmheadcol{ background-color: '+rccol.cmheadcol+';font-size: 11px;font-family:TiresiasScreenfont, arial,sans-serif;font-weight: bold; color:#ffffff;text-decoration:none}\n')
	document.write('</style>')
	document.write(fstable);
	if (!col.top) {
		document.write('<tr><td class="cmheadcol" colspan="3"> '+colText+'</td></tr>')
	}
	else {
		document.write('<tr><td align="right" colspan="3" class="fswhite"><img src="'+col.top+'"  alt=""></td></tr>')
	}
	removeBlanks();
	if (sortItAlph) {
		mU.sort(alphabetize);
	}
	for (mi=0; mi<mU.length;mi++) {
		if (mU[mi]) {
			if ((mU[mi].title.indexOf(" Home")!=-1)&&(mU[mi].title.indexOf(" Homes")==-1)){
				mU[mU.length] = mU[mi];
				mU[mi] = null;
				break;
			}
		}
	}
	for (mi=0; mi<mU.length;mi++) {
		if(mU[mi]) {
			mOverr = "say('"+mU[mi].say+"')";
			mOutt =	"say(' ')";
			urlDir = mU[mi].url;
			
			if (nest == mi+1) {
				sameDirectory = true;
			}
			else {
				sameDirectory = false;
			}
			if (mi == (mU.length-1) && (mU[mi].title.indexOf(" Home")!=-1)) {
				document.write ('<tr><td colspan="3" bgcolor="'+col.norm+'">'+tgif+' height="20" width="125"></td></tr>')
			}
			loopLinks(mU,mi,"");
			if (!sameDirectory ) {
				if (!mU[mi].separator) {
					document.write('<tr><td colspan="3" bgcolor="#ffffff">'+tgif+' height="1" width="1"></td></tr>')
				}
				else {
					document.write('<tr><td colspan="3">'+mU[mi].separator+'</td></tr>');
				}
			}
			else if (mU[mi].sub[0]) {
				
				document.write('<tr><td bgcolor="'+col.dotborder+'" colspan="3">'+tgif+' width="125" height="1"></td></tr>')
				for (si=0;si<mU[mi].sub.length;si+=2) {
				
					theSubStyle='';
					if (!document.layers){
						if (col.subMenuStyle){
							theSubStyle=" style=\""+col.subMenuStyle+"\"";
						}
					}

					urlFile = mU[mi].sub[si];
					document.write('<tr><td colspan="3">'+fstable+'<tr><td width="1" bgcolor="'+col.dotborder+'">'+tgif+' width="1" height="1"></td>');
					
					if (!hereSub(urlFile)) {
						document.write('<td width="20"'+theSubStyle+'><img src="'+col.dotsub+'" width="20" height="7"></td><td width="103"'+theSubStyle+'><a style="font-size: 10px; font-family:TeresiasScreenfont,arial,helvetica; color:#333333;" href="'+mU[mi].sub[si]+'">'+mU[mi].sub[si+1]+'</a>');
					}
					else {
						document.write('<td width="20"'+theSubStyle+'><img src="'+col.dotsubhi+'" width="20" height="7"></td><td width="103"'+theSubStyle+'><span style="font-size: 10px; font-family:TeresiasScreenfont,arial,helvetica; color:#333333;">'+mU[mi].sub[si+1]+'</span>');
					}
					document.write('</td><td width="1" bgcolor="'+col.dotborder+'">'+tgif+' width="1" height="1"></td></tr></table></td></tr>');
					document.write('<tr><td bgcolor="'+col.dotborder+'" colspan="3">'+tgif+' width="125" height="1"></td></tr>')
				}
				eval('document.images.cmimg'+mi+'.src = imgDir + "/cm/whitearrow1.gif"');
			}
			else {
				if (!mU[mi].separator) {
					document.write('<tr><td colspan="3" bgcolor="#ffffff">'+tgif+' height="1" width="1"></td></tr>')
				}
				else {
					document.write('<tr><td colspan="3">'+mU[mi].separator+'</td></tr>');
				}
				
			}
			if (mi == nest-1) {
					eval('document.images.cmimg'+mi+'.src = imgDir + "/cm/whitearrow1.gif"');
			}
		}
		
	}
	if (col.bot) {
		document.write('<tr><td align="right" colspan="3" class="cmheadcol"><img src="'+col.bot+'"  alt=""></td></tr>')
	}
	document.write('</table>')
	
	if (document.fs){
		if (document.fs.relChan){
			document.write(fstable);
			document.write('<tr><td colspan="3">'+tgif+' width="5" height="5"></td></tr>');
			document.write('<tr><td class="rccmheadcol" colspan="3"> '+ document.fs.relChan[0].title +'</td></tr>');

			for (ri=1; ri < document.fs.relChan.length; ri++){
				if(document.fs.relChan[ri]){
					if (document.fs.relChan[ri].title.indexOf(" Home")!=-1) {
						document.write ('<tr><td colspan="3" bgcolor="'+rccol.norm+'">'+tgif+' height="20" width="125"></td></tr>')
					}
					mOverr = "say('"+document.fs.relChan[ri].title+"')";
					mOutt =	"say(' ')";
					loopLinks(document.fs.relChan,ri,"r");
					if (!document.fs.relChan[ri].separator) {
					document.write('<tr><td colspan="3" bgcolor="#ffffff">'+tgif+' height="1" width="1"></td></tr>')
					}
					else {
						document.write('<tr><td colspan="3">'+document.fs.relChan[ri].separator+'</td></tr>');
					}
				}
			}
			document.write('</table>');
		}
		if (document.fs.advert){
	 		document.write(fstable+'<tr><td>'+tgif+' width="5" height="5">')
	 		for (i=0; i<document.fs.advert.length; i++){
	  			if (document.fs.advert[i]){
	   			document.write('</td></tr><tr><td><a href="'+document.fs.advert[i].url+'"><img src="'+document.fs.advert[i].img+'" width="'+document.fs.advert[i].width+'" height="'+document.fs.advert[i].height+'" border="0" alt="'+document.fs.advert[i].alt+'"></a></td></tr><tr><td>'+tgif+' width="5" height="5">')
	  			}
	 		}
			document.write('</td></tr></table>')
		}
		if (document.fs.cmExtra){
			document.write(document.fs.cmExtra)
		}
	}
}
 