// JavaScript Document

function LeftNav(section)
{
	this._section = section;
	this._leftnav = "";
	this._pls = new MMC_PreloadImgStock();
	
	var lnd = new leftNavData();
	
	this.mkLeftNav = function (layer)
	{
		for ( var i = 0; i < eval("lnd._ln"+layer).length; i++ ) {
			var _overstate = "";
			var _outstate = "";
			
			// default over and out state and preload.
			_overstate = "MMC_swapImage('ln" + layer + i + "','','" + LOCAL_IMG_DIR + "/" + eval("lnd._ln"+layer)[i][1] + "',1);LeftNavPop_hideAll('0');";
			_outstate =  "MMC_swapImgRestore()";
			this._pls.addStock(LOCAL_IMG_DIR + "/" + eval("lnd._ln"+layer)[i][1]);
			
			var _url;
	
			if(eval("lnd._ln"+layer)[i][3].substr(0,7) == "http://" || eval("lnd._ln"+layer)[i][3].substr(0,7) == "javascr")
				_url = eval("lnd._ln"+layer)[i][3];
			else 
				_url = PATH + "/" + eval("lnd._ln"+layer)[i][3];
			
			this.isSelected(_url);
			
			// Popup?
			if( this.haveChildren(layer, i) && this.needChildren(layer, i) == false){
				_overstate += "MMC_showHideLayers('lp" + layer + i + "','','show','lp" + layer + i + "a' ,'','show');";
			}
			
			//if (this._section == layer + i) {
			if(this.isSelected(_url)) {
				this._leftnav += "<a href=\"javascript:void(0)\" onMouseOver=\"" + _overstate + "\"><img src=\"" + LOCAL_IMG_DIR + "/" + eval("lnd._ln"+layer)[i][1] + "\" name=\"ln" + layer + i + "\" border=\"0\"></a>";
				if (this.needChildren(layer, i)) {
					this.mkLeftNav(layer + i);
				}	
			} else {
				if (this.needChildren(layer, i)) {
					this._leftnav += "<a href=\"" + _url + "\" onMouseOver=\"" + _overstate + "\" onMouseOut=\"" + _outstate + "\"><img src=\"" + LOCAL_IMG_DIR + "/" + eval("lnd._ln"+layer)[i][2] + "\" name=\"ln" + layer + i + "\" border=\"0\"></a>";
					this.mkLeftNav(layer + i);
				} else {
					this._leftnav += "<a href=\"" + _url + "\" onMouseOver=\"" + _overstate + "\" onMouseOut=\"" + _outstate + "\"><img src=\"" + LOCAL_IMG_DIR + "/" + eval("lnd._ln"+layer)[i][0] + "\" name=\"ln" + layer + i + "\" border=\"0\"></a>";
				}
			}
		}
	}
	
	this.needChildren = function( ly, i)
	{
		if ( this._section.length < ly.length || ly.length > 1) {
			return false;
		}
		
		if (this._section.substr(0, ly.length + 1) == ly + i && this.haveChildren( ly, i)) {
			return true;
		} else {
			return false;
		}
	}
	
	this.haveChildren = function( ly, i )
	{
		if ( eval("lnd._ln"+ly)[i][4] != 0 ) {
			return true;
		} else {
			return false;
		}
	}
	
	this.isSelected = function(_url)
	{	
		var _loc = location.pathname.substr(location.pathname.length - 1) == "/" ? location.pathname + "index.html" : location.pathname;
		var _url = _url.substr(location.pathname.length - 1) == "/" ? _url+ "index.html" : _url;

		var re = new RegExp(_loc + "$");
		if(_url.match(re))
			return true;
		else
			return false;
	}
	
	this.mkLeftNav("0");
	this._pls.doLoad();

}


function LeftNavPop_hideAll(layer)
{
	var _lnd = new leftNavData();
	for ( var i = 0; i < eval("_lnd._ln"+layer).length; i++ ) {
		if( eval("_lnd._ln"+layer)[i][4] != 0 ) {
			MMC_showHideLayers('lp' + layer + i,'','hide','lp' + layer + i + "a",'','hide');
			LeftNavPop_hideAll(layer + i);
		}
	}
}

function PopLayer (ldata, lid, ltop, lleft, lwidth, lheight) 
{
	this._ly = "";
	this._ld = ldata;
	this._lid = lid;
	this._lt = ltop;
	this._ll = lleft;
	this._lw = lwidth;
	this._lh = lheight + 12;
	this._pls = new MMC_PreloadImgStock();
	
	this._ly += "<div id=\"" + this._lid + "\" style=\"position:absolute; left:" + this._ll + "px; top:" + this._lt + "px; width:" + (this._lw + 1) +"px; z-index:10; visibility: hidden;\" >";
	this._ly += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	this._ly += "<tr>";
	this._ly += "<td width=\"" + this._lw +"\" background = \"" + IMG_DIR + "/greydot01_2x2.gif\">";
	this._ly += "<img src=\"" + IMG_DIR + "/spacer.gif\" width=\"" + this._lw + "\" height=\"8\"></td>";
	this._ly += "<td width=\"1\" bgcolor=\"#999999\" rowspan=\"3\"><img src=\"" + IMG_DIR + "/spacer.gif\" width=\"1\" height=\"1\"></td>";
    this._ly += "</tr>";
	this._ly += "<tr><td width=\"" + this._lw +"\">";
		
	for (var _num = 0; _num < this._ld.length; _num++) {
		var _overstate = "MMC_swapImage('" + lid + "img" + _num + "','','" + LOCAL_IMG_DIR + "/" + this._ld[_num][6] + "',0)\"";
		var _outstate = "MMC_swapImgRestore()";
		
		var _url;
	
		if(this._ld[_num][8].substr(0,7) == "http://" || this._ld[_num][8].substr(0,7) == "javascr")
			_url = this._ld[_num][8];
		else 
			_url = PATH + "/" + this._ld[_num][8];
		
		this._pls.addStock(LOCAL_IMG_DIR + "/" + this._ld[_num][6]);
		this._ly += "<a href=\"" + _url + "\" onMouseOver=\"" + _overstate + "\"  onMouseOut=\"" + _outstate + "\">";
		this._ly += "<img src=\"" + LOCAL_IMG_DIR + "/" + this._ld[_num][5] + "\" name=\"" + lid + "img" + _num + "\" border=\"0\"></a>";
	}

	this._ly += "</td></tr>";
	this._ly += "<tr>";
	this._ly += "<td width=\"" + this._lw +"\" background = \"" + IMG_DIR + "/greydot01_2x2.gif\">";
	this._ly += "<img src=\"" + IMG_DIR + "/spacer.gif\" width=\"" + this._lw + "\" height=\"3\"></td>";
	this._ly += "</tr>";
    this._ly += "<tr>";;
	this._ly += "<td colspan=\"2\" height=1 bgcolor=\"#999999\"><img src=\"" + IMG_DIR + "/spacer.gif\" width=\"1\" height=\"1\"></td>";
    this._ly += "</tr>";
	this._ly += "</table>";
	this._ly += "</div>";

	this._ly += "<div id=\"" + this._lid + "a\" style=\"position:absolute; left:" + this._ll + "px; top:" + (this._lt - 15) + "px; width:" + (this._lw + 15) + "px; z-index:1; visibility: hidden; height: " + (this._lh + 30) +"px;\">";
	this._ly += "<a href=\"JavaScript:void(0);\" onMouseOver=\"MMC_showHideLayers('" + this._lid + "','','hide', '" + this._lid + "a', '', 'hide');\" onMouseOut=\"MMC_showHideLayers('" + this._lid + "','','hide', '" + this._lid + "a', '', 'hide');\">";
	this._ly += "<img src=\"" + IMG_DIR + "/spacer.gif\" width=\"" + (this._lw + 15) + "\" height=\"" + (this._lh + 30) + "\" border=0></a>"
	this._ly += "</div>";
	
	this._pls.doLoad();
	
	this.getPopLayer = function()
	{
		return this._ly;
	}
}

function LeftNavPop()
{
	this._lnd = new leftNavData();
	//this._topBase = 163;
	this._ln = "";
	
	// dummy layer
	this._ln += "<div id=\"dummy\" style=\"visibility: hidden;\" >";
	this._ln += "</div>";
	
	var _tmp = [new PopLayer(this._lnd._ln02, "lp02", 117, 128, 128, (this._lnd._ln02.length * 20)),
				new PopLayer(this._lnd._ln022, "lp022", 141+57, 128, 158, (this._lnd._ln022.length * 20)),
				new PopLayer(this._lnd._ln023, "lp023", 163+57, 128, 158, (this._lnd._ln023.length * 20)),
				new PopLayer(this._lnd._ln024, "lp024", 184+57, 128, 158, (this._lnd._ln024.length * 20)),
				new PopLayer(this._lnd._ln025, "lp025", 206+57, 128, 158, (this._lnd._ln025.length * 20)) ];

	for(var i = 0; i < _tmp.length; i++) {
		this._ln += _tmp[i].getPopLayer();
	}
	
	document.write(this._ln);
	

}


MMC_reloadPage(true);