//###########################################################
//
// 	<title>NickLinks v2.0.9.14</title>
// 		Wednesday, 11th August 2004
//
//###########################################################
/*
	//Methods
		addlink   		- Add link. e.g.: myLinks.addlink("[Link 1 | page1.asp | target:_blank | javascript:alert('Javascript Alert!') ]")
		build     		- Build links
		showlinks 		- Show links
		hidelinks 		- Hide links
		links     		- Add multiple links as string. e.g.: myLinks.links( '[Link 1 | page1.asp][Link 2 | page2.asp][Link 3 | page3.asp]' )
		parameters 		- Pass multiple parameters as string.  e.g.: myLinks.parameters ('style:myStyle ; styleHover:myStyleHover ; styleHeader:myStyleHeader ; styleBackground:myStyleBackground ;')

	//Styles
		style           	- Style of menu
		styleHover      	- Style of menu (on mouse rollover)
		styleBackground 	- Border style of menus
		styleHeader     	- Submenu header style

	//Parameters
		startX			- Default starting horizontal position of links if no HTML element passed (default=0)
		startY			- Default starting vertical position of links if no HTML element passed (default=0)
		width			- Width of sublinks/submenus
		height			- Height of sublinks/submenus
		textPadding		- Horizontal text spacing from edge of menu
		offsetX			- Horizontal offset starting position of top level links from passed HTML element(default=0)
		offsetY			- Vertical offset starting position of top level links from passed HTML element (default=20)
		spacingX		- Horizontal spacing of lower level submenus from RHS of menu column (+/-)
		spacingY		- Vertical spacing of lower level submenus (+/-)
		maxRows			- Maximum number of vertical links in any submenu column (set to -1 for one column ONLY!)
		showHeader		- Display the title of any submenu(true/false)
		pageScroll		- Display links relative to page scroll (always on screen), NOT top of page
		imageBlank 		- Image path of blank spacer gif
		imageArrow		- Image path of submenu arrow gif
		hideDelay		- Delay (ms) to hide menus once moused out
		reverse			- Display links backwards (right to left, NOT left to right)
		linkWrap 		- Display links cascade backwards if links off edge of screen

*/



//############################################################################
//Global variables
	var NickLinks_DivCounter = 0
	var NickLinks_DivStatus = null
	var NickLinks_DivInfo = new Array()
	var NickLinks_RolloverInfo = new Array()
	var NickLinks_ScrTop = 0;


//############################################################################
function NickLinks(){

	//Create new links array and dummy populate
		this.linkArray = new Array();
			this.linkArray[0] = new Array(0);

	//Assign unique ID to this link structure
		NickLinks_DivCounter++
		this.divID = NickLinks_DivCounter

	//Default values
		this.startX = 0
		this.startY = 0
		this.width  = 150
		this.height = 20
		this.textPadding = 8
		this.offsetX = 0
		this.offsetY = 20
		this.spacingX = 0
		this.spacingY = 0
		this.maxRows = -1
		this.showHeader = true
		this.pageScroll = false
		this.reverse = false
		this.linkWrap = false
		this.imageBlank = (location.href+'').substring(0,(location.href+'').lastIndexOf('/')+1) + 'blank.gif'
		this.imageArrow = (location.href+'').substring(0,(location.href+'').lastIndexOf('/')+1) + 'arrow.gif'
		this.hideDelay = 1000

	//Default styles
		this.style           = 'style'
		this.styleHover      = 'styleHover'
		this.styleBackground = 'styleBackground'
		this.styleHeader     = 'styleHeader'

	//Methods
		this.addlink   		= NickLinks_Links;
		this.build     		= NickLinks_Build;
		this.showlinks 		= NickLinks_ShowLinks;
		this.hidelinks 		= NickLinks_HideLinks;
		this.links     		= NickLinks_Links;
		this.parameters 	= NickLinks_Params;

}


//############################################################################
function NickLinks_Links(Link_Str){
	aTemp = Link_Str.split(']')
	for(i=0;i<aTemp.length-1;i++){

		//Get link level and parameters
			iTemp = aTemp[i].indexOf('[')
			Link_ArrLen = (this.linkArray).length
			Link_Params = (aTemp[i].substring(iTemp+1)).split('|')

		//Add link paramenters to array
			this.linkArray[Link_ArrLen] = new Array()
			this.linkArray[Link_ArrLen][0] = Math.floor(iTemp/2)+1
			for(j=0;j<Link_Params.length;j++){
				//Trim parameter
					while(Link_Params[j].indexOf(' ')==0){ Link_Params[j]=Link_Params[j].substring(1) }
					while(Link_Params[j].lastIndexOf(' ')==Link_Params[j].length-1 && Link_Params[j].length>0  ){ Link_Params[j]=Link_Params[j].substring(0,Link_Params[j].length-1) }
				//Save parameter in link array
					this.linkArray[Link_ArrLen][j+1] = Link_Params[j]
			}

	}
}


//############################################################################
function NickLinks_Params(Param_Str){
	aTemp = Param_Str.split(';')
	for(i=0;i<aTemp.length-1;i++){

		//Get separate parameters
			Params_Elem = aTemp[i].split(':')

		//Trim parameter & values
			for(j=0;j<Params_Elem.length-1;j++){
					while(Params_Elem[j].indexOf(' ')==0){ Params_Elem[j]=Params_Elem[j].substring(1) }
					while(Params_Elem[j].lastIndexOf(' ')==Params_Elem[j].length-1 && Params_Elem[j].length>0  ){ Params_Elem[j]=Params_Elem[j].substring(0,Params_Elem[j].length-1) }
			}
		//Check passed data for parameter & value
			if(Params_Elem.length>=1){
				eval('this.' + Params_Elem[0] + '="' + Params_Elem[1] + '"') 		//Save value
			}

	}
}


//############################################################################
function NickLinks_Build(){
	//Close links array
		this.linkArray[(this.linkArray).length] = new Array(-1,'END')
	//Draw Links
		NickLinks_DrawLinks(this, 1, 1)
}


//############################################################################
function NickLinks_DrawLinks(obj, Link_ArrayStart, Link_Level){

	//Set Variables
		var Link_Str = ''				//Link text(HTML) to display
		var Link_SubMenuHeader = ''		//Sublink header text to display
		var Link_Cols = 1				//Number of columns displayed
		var Link_ItemsDisplayed = 0		//Count of items displayed

	//Loop through links array
		for(i=Link_ArrayStart;i<obj.linkArray.length;i++){
			if(obj.linkArray[i][0]<Link_Level){break}			//No more lower level links - Exit loop
			if(obj.linkArray[i][0]==Link_Level){				//Is this link level with requesting link?

				//Start new column if MaxRows have been displayed...
					if(Link_ItemsDisplayed%obj.maxRows==0 && obj.maxRows>0 && Link_ItemsDisplayed>0){
						Link_Str+='</table>'
						Link_Str+='</td>'
						Link_Str+='<td width="' + obj.width + '" class="' + obj.style + '" valign="top">'
						Link_Str+='<table width="100%" cellpadding="0" cellspacing="0" border="0">'
						Link_Cols++
					}

				//Start of link...
					//Has this item got sublinks?? - YES
					if(obj.linkArray[i+1][0]>Link_Level){
						Link_Str+='<tr ' + NickLinks_BuildNavigation(obj, i ) + ' ONMOUSEOVER="NickLinks_Rollover(this,\'' + obj.styleHover + '\',\'' + obj.style + '\',' + Link_Level + ');NickLinks_ShowLinks_Do(this,' + obj.divID + ',' + (i+1) + ',' + (Link_Level+1) + ',' + obj.startX + ',' + obj.startY + ',' + obj.spacingX + ',' + obj.spacingY + ',' + obj.width + ',' + obj.pageScroll + ',' + obj.linkWrap + ',' + obj.reverse + ', null);">'
							Link_Str+='<td width="' + obj.textPadding + '" nowrap style="cursor:hand;" class="' + obj.style + '"><img src="' + obj.imageBlank + '" width="' + obj.textPadding + '" height="' + obj.height + '" border="0"></td>'
							Link_Str+='<td nowrap style="cursor:hand;" class="' + obj.style + '">'
							Link_Str+=obj.linkArray[i][1]
							Link_Str+='&nbsp;</td>'
							Link_Str+='<td nowrap style="cursor:hand;" class="' + obj.style + '" align="right"><img src="' + obj.imageArrow + '" border="0"></td>'
						Link_Str+='</tr>'
					}
					//Has this item got sublinks?? - NO
					else{
							switch((obj.linkArray[i][1]).toLowerCase()){
								case '{br}':
									Link_Str+='<tr class="' + obj.style + '">'
										Link_Str+='<td><img src="' + obj.imageBlank + '" width="' + obj.textPadding + '" height="' + (obj.height*0.8) + '" border="0"></td>'
									Link_Str+='</tr>'
									break;
								case '{hr}':
									Link_Str+='<tr class="' + obj.style + '">'
										Link_Str+='<td width="' + obj.textPadding + '"><img src="' + obj.imageBlank + '" width="' + obj.textPadding + '" height="1" border="0"></td>'
										Link_Str+='<td><hr size="1" width="100%" style="margin:0;"></td>'
										Link_Str+='<td width="' + obj.textPadding + '"><img src="' + obj.imageBlank + '" width="' + obj.textPadding + '" height="1" border="0"></td>'
									Link_Str+='</tr>'
									break;
								default:
									Link_Str+='<tr ' + NickLinks_BuildNavigation(obj, i ) + ' ONMOUSEOVER="NickLinks_Rollover(this,\'' + obj.styleHover + '\',\'' + obj.style + '\',' + Link_Level + ');NickLinks_HideLinks(' + (obj.linkArray[i][0]+1) + ')">'
										Link_Str+='<td width="' + obj.textPadding + '" nowrap style="cursor:hand;" class="' + obj.style + '"><img src="' + obj.imageBlank + '" width="' + obj.textPadding + '" height="' + obj.height + '" border="0"></td>'
										Link_Str+='<td nowrap style="cursor:hand;" class="' + obj.style + '">'
										Link_Str+=obj.linkArray[i][1]
										Link_Str+='&nbsp;</td>'
										Link_Str+='<td width="' + obj.textPadding + '" nowrap style="cursor:hand;" class="' + obj.style + '"><img src="' + obj.imageBlank + '" width="' + obj.textPadding + '" height="' + obj.height + '" border="0"></td>'
									Link_Str+='</tr>'
							}
					}
				//End of link!

				//Increment displayed item count
					Link_ItemsDisplayed++

			}
		}//End of for loop...

	//Add sub menu header
		if(Link_Level>1 && obj.showHeader){
				Link_SubMenuHeader+='<tr><td colspan="' + Link_Cols + '"">'
				Link_SubMenuHeader+='<table width="100%" cellpadding="0" cellspacing="0" border="0">'
				Link_SubMenuHeader+='<tr style="cursor:default;" class="' + obj.styleHeader + '" ONMOUSEOVER="NickLinks_Rollout(' + Link_Level + ')">'
					Link_SubMenuHeader+='<td width="' + obj.textPadding + '" nowrap><img src="' + obj.imageBlank + '" width="' + obj.textPadding + '" height="' + obj.height + '" border="0"></td>'
					Link_SubMenuHeader+='<td nowrap>'
					Link_SubMenuHeader+=obj.linkArray[Link_ArrayStart-1][1]
					Link_SubMenuHeader+='</td>'
					Link_SubMenuHeader+='<td width="' + obj.textPadding + '" nowrap><img src="' + obj.imageBlank + '" width="' + obj.textPadding + '" height="' + obj.height + '" border="0"></td>'
				Link_SubMenuHeader+='</tr>'
				Link_SubMenuHeader+='</table>'
				Link_SubMenuHeader+='</td></tr>'
		}

	//Add containing div/table
		NickLinks_DivInfo[NickLinks_DivInfo.length] = new Array(obj.divID, Link_ArrayStart, Link_Level)
		Link_Str= '<div id="NickLinksDiv' + obj.divID + '-' + Link_ArrayStart + '" ONMOUSEOVER="NickLinks_DivOver()" ONMOUSEOUT="NickLinks_DivOut(' + obj.hideDelay + ')" style="position:absolute; z-index:' + (16384+NickLinks_DivInfo.length) + '; visibility:hidden; top:0px; left:0px; width:' + (obj.width*Link_Cols) + ';">' +
						'<table width="' + (obj.width*Link_Cols) + '" cellpadding="0" cellspacing="0" border="0" class="' + obj.styleBackground + '">' +
							Link_SubMenuHeader +
						'<tr><td width="' + obj.width + '" class="' + obj.style + '" valign="top">' +
							'<table width="100%" cellpadding="0" cellspacing="0" border="0">' +
								Link_Str +
							'</table>' +
						'</td></tr>' +
						'</table>' +
						'<table cellpadding="0" cellspacing="0" border="0"><tr><td></td></tr></table>' +	// Mac IE Fix
					'</div>'

	//Draw links Divs
		document.write(Link_Str)

	//Build sublink divs
		for(var sl=Link_ArrayStart;sl<obj.linkArray.length;sl++){
			if(obj.linkArray[sl][0]<Link_Level){break}
			if(obj.linkArray[sl][0]==Link_Level){ if(obj.linkArray[sl+1][0]>Link_Level){ NickLinks_DrawLinks(obj, sl+1, Link_Level+1) } }
		}

}//All Done!


//############################################################################
function NickLinks_ShowLinks(elemID, elemAlign){
	NickLinks_ShowLinks_Do(elemID, this.divID, 1, 1, this.startX, this.startY, this.offsetX, this.offsetY, this.width, this.pageScroll, this.linkWrap, this.reverse, elemAlign)
}
function NickLinks_ShowLinks_Do(elemID, divID, divSubID, divLinkLevel, objStartX, objStartY, objSpaceX, objSpaceY, objWidth, objPageScroll, objlinkWrap, objReverse, objAlign){

	//Mouse over... Clear hide timeout
		NickLinks_DivOver()
	//Hide all lower level links
		NickLinks_HideLinks(divLinkLevel)

	//No width offset if top level link
		if(divLinkLevel==1 && elemID!=null){ objWidth=0 }

	//Display links from right to left?
		if(objReverse){ objWidth=-objWidth+1 }

	//If no element passed set X & Y pos as startup co-ords,else calculate X & Y pos.
		if(elemID==null){ var tmpX = objStartX ; var tmpY = objStartY }	//Absolute
		else{
			var tmpX = NickLinks_GetXPos(elemID) + objWidth + objSpaceX - 1
			var tmpY = NickLinks_GetYPos(elemID) + objSpaceY - 1
			if(objAlign!=null){
				if((objAlign.toLowerCase()).indexOf('x')==0){ var tmpY = objStartY }
				if((objAlign.toLowerCase()).indexOf('y')==0){ var tmpX = objStartX }
			}
		}

	//Adjust vertical position of link if page scrolled (and pageScroll = true)
		if(divLinkLevel==1 && objPageScroll){ tmpY += (document.all?document.body.scrollTop:pageYOffset) }

	//Adjust horizontal position of link if off edge of screen
		if(objlinkWrap && (8+tmpX<=0 || (8+tmpX+objWidth)>=(document.all?document.body.clientWidth:self.innerWidth))){ tmpX -= (objWidth*2) + (objSpaceX*2) }

	//Position links
		if(document.layers){
			var LayerID=document.layers['NickLinksDiv'+divID+'-'+divSubID].left = tmpX;
			var LayerID=document.layers['NickLinksDiv'+divID+'-'+divSubID].top = tmpY;
			var LayerID=document.layers['NickLinksDiv'+divID+'-'+divSubID].visibility = 'show';
		}
		else if(document.all){
			document.all['NickLinksDiv'+divID+'-'+divSubID].style.left = tmpX;
			document.all['NickLinksDiv'+divID+'-'+divSubID].style.top = tmpY;
			document.all['NickLinksDiv'+divID+'-'+divSubID].style.visibility='visible';
		}
		else{
			document.getElementById('NickLinksDiv'+divID+'-'+divSubID).style.left = tmpX;
			document.getElementById('NickLinksDiv'+divID+'-'+divSubID).style.top = tmpY;
			document.getElementById('NickLinksDiv'+divID+'-'+divSubID).style.visibility='visible';
		}

}


//############################################################################
function NickLinks_HideLinks(lLevel){
	if(lLevel==null){ lLevel = 1 }
	for(i=0;i<NickLinks_DivInfo.length;i++){
		//Restore CSS style of old rollover elements
		if(NickLinks_DivInfo[i][2]>lLevel){
			NickLinks_Rollout(i)
		}
		//Hide this & lower level links
		if(NickLinks_DivInfo[i][2]>=lLevel){
			if(document.layers){ var LayerID=document.layers['NickLinksDiv'+NickLinks_DivInfo[i][0]+'-'+NickLinks_DivInfo[i][1]].visibility = 'hide';  }
			else if(document.all){ document.all['NickLinksDiv'+NickLinks_DivInfo[i][0]+'-'+NickLinks_DivInfo[i][1]].style.visibility='hidden'; }
			else{ document.getElementById('NickLinksDiv'+NickLinks_DivInfo[i][0]+'-'+NickLinks_DivInfo[i][1]).style.visibility='hidden'; }
		}
	}
}


//############################################################################
function NickLinks_Rollover(linkElem,linkStyle,linkStyleOut,lnkLevel){
	if(document.layers){return;}
	//Restore CSS style of last rollover at this & sub level
		NickLinks_Rollout(lnkLevel)
		NickLinks_Rollout(lnkLevel+1)
	//Save this rollover info
		NickLinks_RolloverInfo[lnkLevel] = new Array(linkElem,linkStyleOut)
	//Change CSS style of child elements
	    var linkElemchild=linkElem.childNodes;
		for(j=0;j<linkElemchild.length;j++){linkElemchild[j].className = linkStyle; }
}
function NickLinks_Rollout(linkLvl){
	if(document.layers){return;}
	//Restore CSS style of old rollover elements
		if(NickLinks_RolloverInfo[linkLvl]!=null){
		    var linkElemchild=NickLinks_RolloverInfo[linkLvl][0].childNodes;
			for(j=0;j<linkElemchild.length;j++){linkElemchild[j].className = NickLinks_RolloverInfo[linkLvl][1]; }
			NickLinks_RolloverInfo[linkLvl] = null
		}
}


//############################################################################
function NickLinks_BuildNavigation(obj, LinkID){
	var Link_URL = Link_Target = Link_JS = ''
	//Loop through (3) paramters
	for(k=4;k>=2;k--){
		//If parameter exists...
		if(obj.linkArray[LinkID][k]!=null){
			//Get parameter
				tmpStr = (obj.linkArray[LinkID][k]).toLowerCase()
			//Detect parameter type and store as required
				if(tmpStr.indexOf('target:')>=0){ Link_Target = (obj.linkArray[LinkID][k]).substring(7) }
				else if(tmpStr.indexOf('javascript:')>=0){ Link_JS += (obj.linkArray[LinkID][k]).substring(11) + ';' }
				else{ Link_URL = (obj.linkArray[LinkID][k]) }
		}
	}
	//Return results
	return 'ONCLICK="' + Link_JS + 'NickLinks_Navigate(\'' + Link_URL + '\',\'' + Link_Target + '\')"'
}


//############################################################################
function NickLinks_Navigate(URL,frame_Name){
	if(frame_Name==null){ frame_Name='' }
	//Detect reserved HTML target and action as necessary
		switch(frame_Name){
			case '':
				//Navigate self to URL
				location.href = URL
				break;
			case '_blank':
				//open new window
				window.open(URL ,'','')
				break;
			case '_parent':
				//Navigate parent frame to URL
				parent.location.href = URL
				break;
			case '_self':
				//Navigate self to URL
				location.href = URL
				break;
			case '_top':
				//Navigate top frame to URL
				top.location.href = URL
				break;
			default:
				//Navigate frame to URL
				for(i=0;i<parent.frames.length;i++){
					if(parent.frames[i].name==frame_Name){ parent.frames[i].location.href = URL; }
				}
		}
}


//############################################################################
function NickLinks_GetXPos(obj) {
	var x = 0
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE = document.all && !onWindows
		var par = obj;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			//if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE ? par.parentElement : par.offsetParent;
		}
	} else if (obj.x) x += obj.x;
	return x;
}
function NickLinks_GetYPos(obj) {
	var y = 0
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE = document.all && !onWindows
		var par = obj;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			//if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE ? par.parentElement : par.offsetParent;
		}
	} else if (obj.y >= 0) y += obj.y;
	return y;
}


//############################################################################
function NickLinks_DivOver(){
	//Clear hidelinks delay
		if(NickLinks_DivStatus!=null){ clearTimeout(NickLinks_DivStatus) }
		NickLinks_DivStatus=null
}
function NickLinks_DivOut(delayMs){
	//Set hidelinks delay
		NickLinks_DivStatus = setTimeout("NickLinks_DivTimeOut()", delayMs)
}
function NickLinks_DivTimeOut(){
	//Hide links if mouse not over
		if(NickLinks_DivStatus!=null){ NickLinks_HideLinks(); }
}


//############################################################################
function NickLinks_ScrollPage(){
	var tmp_ScrTop = (document.all?document.body.scrollTop:pageYOffset)
	if(NickLinks_ScrTop!=tmp_ScrTop){NickLinks_ScrTop = tmp_ScrTop;NickLinks_HideLinks()}
	setTimeout('NickLinks_ScrollPage()',25)
}
//window.onload = NickLinks_ScrollPage;


