
var isCSS, isW3C, isIE4, isNN4, isIE6CSS;

//function initDHTMLAPI() {
//	if(document.images) {
//		isCSS = ((document.body && document.body.style) ? true : false);
//		isW3C = ((isCSS && document.getElementById) ? true : false);
//		// var ver4 = parseInt(navigator.appVersion)>=4;
//		// var isNN4 = navigator.appName == "Netscape";
//		// var isIE4 = navigator.appName.substring(0,9) == "Microsoft";
//		isIE4 = (isCSS && document.all) ? true : false;
//		isNN4 = (document.layers) ? true : false;
//		isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
//	}
//}

var _sUnpopular_ = "unpopular";
var _sEllipses_  = "ellipses";

var semi = ";";
var styleStr = "<style type='text/css'>";
if(isNN4){
	styleStr += "div.forpos {position:relative" +semi+ "}";
	styleStr += "div.expand0 {visibility:hidden" +semi+ "}";
	styleStr += "div.expand1 {visibility:hidden" +semi+ "}";
	styleStr += "div.expand2 {visibility:hidden" +semi+ "}";
	styleStr += "div.expand3 {visibility:hidden" +semi+ "}";
	styleStr += "div.expand4 {visibility:hidden" +semi+  "}";
}else{
	styleStr += "div.expand0 {display:inline" +semi+ "}";
	//styleStr += "div.expand1 {display:inline" +semi+ "cursor: HAND" +semi+ "}";
	styleStr += "div.expand1 {display:inline" +semi+ "cursor: pointer" +semi+ "}";
	styleStr += "div.expand2 {display:none" +semi+ "}";
	styleStr += "div.expand3 {display:none" +semi+ "}";
	styleStr += "div.expand4 {display:none" +semi+ "}";
	styleStr += "div.unpopular {display:none"   + semi +  "}";
	//styleStr += "div.ellipses  {display:inline" + semi +  "}";
}
styleStr += "</" + "style>";
document.write(styleStr);

if(isNN4) var menuTop = document.layers.dummy.pageY;
var expander = new Array();
function reloadme(){window.location.reload();}
function init(){
	initDHTMLAPI();
	var n = 0 , lay , i;
	if(isW3C){
		var oDivs = document.getElementsByTagName("DIV");
		var nTotalLen = oDivs.length;
		for(i=0; i < nTotalLen; i++){
			lay = oDivs[i];
			if(lay.className.indexOf("expand")>=0){
				lay.index = n++;
				expander[lay.index] = lay;
			}
		}
		//document.onmousedown = expandIE;
		document.onclick = expandIE;
	}
	else if(isNN4){
		for(i=0; i<document.layers.length; i++){
			lay = document.layers[i];
			if(lay.id.indexOf("menu")>=0){
				lay.captureEvents(Event.MOUSEDOWN);
				//lay.onmousedown = selectIt;
				lay.onclick = selectIt;
				lay.index = n++;
				expander[lay.index] = lay;
				if(lay.id.length<=6) lay.visibility = "show";
			}
		}
		setTimeout("window.onresize = reloadme",1000);
		expandIt();
	}else{
		for(i=0; i<document.all.tags("div").length; i++){
			lay = document.all.tags("div")[i];
			if(lay.className.indexOf("expand")>=0){
				lay.index = n++;
				expander[lay.index] = lay;
			}
		}
		//document.onmousedown = expandIE;
		document.onclick = expandIE;
	}
}
function expandIt(){
	var totalTop = menuTop , i , lay;
	for( i=0; i<expander.length; i++){
		lay = expander[i];
		if(!lay.hidden){
			lay.top = totalTop;
			totalTop += lay.clip.height;
		}
	}
}
function selectIt(e){
	var myName , len , ind , i , lay ;

	if(e.target.constructor == window.Url) return true;
	myName = this.id;
	len = myName.length;
	ind = this.index;
	for(i=(ind+1); i<expander.length; i++){
		lay = expander[i];
		if(lay.id.indexOf(myName)>=0){
			if(!lay.hidden){
				lay.visibility = "hidden";
			}else{
				if(lay.id.indexOf("_",len) == lay.id.lastIndexOf("_"))
				lay.visibility = "show";
			}
		}
	}
	expandIt();
	return false;
}
function expandIE(evt){
	evt = (evt) ? evt :event;
	var el = (evt.target) ? evt.target : evt.srcElement;
	if(el.tagName == "IMG" || el.tagName == "SPAN") { el = el.parentNode; }
	var myName = el.id;
	var myBaseName, mySubName , lay , layCName;

	var arrNameSplit = myName.split("_");
	myBaseName = (arrNameSplit[0] ? arrNameSplit[0] : myName);
	mySubName  = (arrNameSplit[1] ? arrNameSplit[1] : "");

	var bRet = true;
	var myClass = el.className;
	var myBaseClass = el.className.substr(0,7);
	if(myClass.indexOf("expand")>=0){
//		var classLevel = eval(myClass.charAt(6));
		var classLevel = parseInt(myClass.charAt(6),10);
		if(myClass.indexOf(_sEllipses_) < 0) {
// 5.3.1.0 (2011/01/01)
//			var bInHideMenu = false;
			for(i=el.index+1; i<expander.length; i++){
				lay = expander[i];
	            layCName = lay.className;
// 5.3.1.0 (2011/01/01)
//				if(lay.id.indexOf(myName)>=0){
				if(lay.id.indexOf(myName+"_")>=0){
					if(lay.style.display != "block" && lay.style.display != "inline"){
						if(layCName.indexOf("expand"+(classLevel+1)) >= 0 && layCName.indexOf(_sUnpopular_) < 0) {
// 5.3.1.0 (2011/01/01)
//	                        if(!bInHideMenu || layCName.indexOf(_sEllipses_) < 0 ) {
								lay.style.display = "block";
//							}
						}
					}else{
						lay.style.display = "none";
// 5.3.1.0 (2011/01/01)
//	                    bInHideMenu = true;
					}
				}
			}
		}
		else
		{
			el.style.display = "none";
			el.className	= myClass.replace(_sEllipses_, _sUnpopular_);
			for(i = (el.index -1); i >= 0; i--){
				lay = expander[i];
// 5.3.1.0 (2011/01/01)
//				if("" == mySubName	|| lay.id.indexOf(myBaseName)>=0){
				if("" == mySubName	|| lay.id.indexOf(myBaseName+"_")>=0){
					if(lay.className.indexOf(myBaseClass) >= 0 && lay.className.indexOf(_sUnpopular_) >= 0)
					{
						   //lay.className = myBaseClass;
// 5.3.1.0 (2011/01/01)
//						   lay.style.display = "inline";
						   lay.style.display = "block";
						   lay.className     = lay.className.replace(_sUnpopular_, "");
					}
				}
			}
		}
		bRet = false;
	}
	return bRet;
}
if(isNN4){
	var totalHeight = menuTop;
	for(i=0; i<document.layers.length; i++){
		var lay = document.layers[i];
		if(lay.id.indexOf("menu")>=0) totalHeight += lay.clip.height;
	}
	document.write("<layer top=" +(totalHeight+20)+ "></layer>");
}
window.onload = init;
