SELECTED_STYLE = 'background-color:#ffffff;color:#FF9900;font-family:MS P Gothic,osaka;font-size:10px;font-weight:bold;text-decoration:none;';
UNSELECTED_STYLE = 'color:#666666;font-family:MS P Gothic,osaka;font-size:10px;font-weight:bold;text-decoration:none;';

SPACERSRC = "../../images/spacer.gif";


function navObj(caption, url, tid, sid, sArray, pop, width, height, scroll, status, menubar, toolbar, location, directories) {
	this.c = caption;
	this.u = url;
	this.topid = tid;
	this.subid = sid;
	this.subarr = sArray;
	this.style = UNSELECTED_STYLE;
	this.mover = '';
	this.mout = '';
	this.html = '';
	this.width = width;
	this.height = height;
	this.pop = pop;
	this.scroll = scroll;
	this.status = status;
	this.menubar = menubar;
	this.toolbar = toolbar;
	this.location = location;
	this.directories = directories;
									
	if (pop=="yes") {
		this.u = 'javaScript:openWinDefault(\''+this.u+'\',\''+width+'\',\'' +height+'\',\'' +scroll+'\',\'' +status+'\',\'' +menubar+'\',\'' +toolbar+'\',\'' +location+'\',\'' +directories +'\')';
	} else if (pop=="gmj") {
        this.u = 'javaScript:openWinDefault(\''+this.u+'\')';
    }
	this.setHtml = navObj_setHtml;
}
			
function navObj_setHtml(current, tid) {//tid boolean
	
	spacerwidth='8'
	
	if(tid) {
		spacerwidth='13'
	}
	if(current && tid) {
		spacerwidth='12'
	}
		
	this.html = '<td';
	this.html += this.mover;
	this.html += this.mout;
	this.html += ' style="' + this.style + '" nowrap>';
				
	if(current){
		this.html += '<img src="../../images/p_cccccc.gif" width="1" height="25" border="0"/>'
			+ '<img src="' + SPACERSRC + '" width="' + spacerwidth + '" height="25" border="0"'
				+ this.mover + this.mout + '/></td><td';
	} else {
		this.html += '<img src="' + SPACERSRC + '" width="' + spacerwidth + '" height="25" border="0"'
			+ this.mover + this.mout + '/></td><td';
	}
				
	this.html += this.mover;
	this.html += this.mout;
	this.html += ' style="' + this.style + '" nowrap>';
				
	this.html += '<a style="' + this.style + '" href="' + this.u + '"';
	this.html += this.mover;
	this.html += this.mout;
	this.html += '>';
	this.html += this.c;
	this.html += '</a>';
	this.html += '</td>';
	this.html += '<td';
	this.html += this.mover;
	this.html += this.mout;
	this.html += ' style="' + this.style + '" nowrap>';
				
	if(current){
		this.html += '<img src="' + SPACERSRC + '" width="' + spacerwidth + '" height="25" border="0"'
			+ this.mover + this.mout + '/><img src="../../images/p_cccccc.gif" width="1" height="25" border="0"/></td>';
	} else {
		this.html += '<img src="' + SPACERSRC + '" width="' + spacerwidth + '" height="25" border="0"'
			+ this.mover + this.mout + '/></td>';
	}
}
			

htmlstring = '';

function clearNav() {
	htmlstring = '';
}
			
function initNav() {
	setVisibility("navhider", "visible");
	clearNav();
	writeFirstNav(CURRENT_TOPNAV);
	writeSecondNav(CURRENT_TOPNAV, CURRENT_SUBNAV);
}
			
function resetDefaultState() {
	doNavAction(CURRENT_TOPNAV, CURRENT_SUBNAV);
}
			
function doNavAction(tid, sid) {
	clearNav();
	
	if(!sid | sid==null | sid == 0){
		writeFirstNav(tid);
	}
	writeSecondNav(tid, sid);
}
	
function writeFirstNav(tid) {

	TABLE_START = '<table border="0" cellpadding="0" cellspacing="0"><tr>';
	TABLE_END = '</tr></table>\n';
	
	htmlstring += TABLE_START;
	
	for(var i=0;i<navArr.length;i++) {
		
		if(navArr[i].topid==tid) {
					
			navArr[i].style = SELECTED_STYLE + "cursor: default;";
			navArr[i].mover=' onmouseover="setOverTd(\'top\',1);"';
			navArr[i].mout=' onmouseout="setOverTd(\'top\',0);"';
			navArr[i].setHtml(true, tid);
		}
		else {

			navArr[i].style = UNSELECTED_STYLE + "cursor: default;";
			navArr[i].mover=' onmouseover="setOverTd(\'top\',1);doNavAction(' + navArr[i].topid + ',' + navArr[i].subid + ');"';
			navArr[i].mout=' onmouseout="setOverTd(\'top\',0);"';
			navArr[i].setHtml(false, tid);
		}
		
		htmlstring += navArr[i].html;
	}
	htmlstring += TABLE_END;
	reWriteLayer('topnav', htmlstring);
	htmlstring = "";
}
			
function writeSecondNav(tid, sid) {
	
	var align = (tid == navArr[0].topid  ||  tid == navArr[1].topid) ? "left" : "left";

	TABLE_START = ''
		+ '<table border="0" cellpadding="0" cellspacing="0" width="721">'
		+ '<tr>'
		+ '<td align="' + align + '" '
		+ 'onmouseover="setOverTd(\'sub\',1)" '
		+ 'onmouseout="setOverTd(\'sub\',0);"'
		+ '>'
		+ '<table border="0" cellpadding="0" cellspacing="0">'
		+ '<tr>';
	TABLE_END = ''
		+ '</tr>'
		+ '</table>'
		+ '</td>'
		+ '</tr>'
		+ '</table>\n';

	htmlstring += TABLE_START;
		
	for(var i=0;i<navArr.length;i++) {
		if(navArr[i].topid == tid) {
			for(var j=0;j<navArr[i].subarr.length;j++){
				if(navArr[i].subarr[j].subid==sid) {
					navArr[i].subarr[j].style = SELECTED_STYLE;
					navArr[i].subarr[j].mover=' onmouseover="setOverTd(\'sub\',1);"';
					navArr[i].subarr[j].mout=' onmouseout="setOverTd(\'sub\',0);"';
				}
				else {
					navArr[i].subarr[j].style = UNSELECTED_STYLE;
					navArr[i].subarr[j].mover=' onmouseover="setOverTd(\'sub\',1);doNavAction(' + navArr[i].subarr[j].topid + ',' + navArr[i].subarr[j].subid + ');"';
					navArr[i].subarr[j].mout=' onmouseout="setOverTd(\'sub\',0);"';
				}
				navArr[i].setHtml();
				navArr[i].subarr[j].setHtml();
				htmlstring += navArr[i].subarr[j].html;
			}
		}
	}
	htmlstring += TABLE_END;
	reWriteLayer('secondnav', htmlstring);
}
			
var topMenuOverTd = 0;
var subMenuOverTd = 0;
var menuCheckOver = 0;



function setOverTd (type, b)
{
	eval (type + "MenuOverTd = " + b);
	menuCheckOver = 1;
}


setInterval ("testNavReset()", 250);


function testNavReset()
{
	if ((yMousePos > 50  ||  xMousePos > 772)
		&&  menuCheckOver == 1)
	{
		menuCheckOver = 0;
		setTimeout ("doNavReset()", 500)
	}
}


function doNavReset ()
{
	if (yMousePos > 50  ||  xMousePos > 772)
	{
		initNav ();
	}
}

