function getAbsoluteLeft(ref){
	e = document.getElementById(ref);
	var left = e.offsetLeft;
	while(e=e.offsetParent){
		left += e.offsetLeft;
	}
	return left;
}

function getAbsoluteWidth(ref){
	return document.getElementById(ref).offsetWidth;
}

function getAbsoluteTop(ref){
	e = document.getElementById(ref);
	var top = e.offsetTop;
	while(e=e.offsetParent){
		top += e.offsetTop;
	}
	return top;
}

function mainMenuOver(id, className){
	document.getElementById("mainMenu" + id).className = className;
	
	subDiv = document.getElementById("subMenuDiv" + id);
	if(subDiv != null){
		menuObject = document.getElementById("mainMenu" + id);
		h = menuObject.offsetHeight;
		x = 0;
		y = 0;
		do{x+=menuObject.offsetLeft; y+=menuObject.offsetTop}while(menuObject=menuObject.offsetParent);
		subDiv.style.visibility = 'visible';
		subDiv.style.top = y;
		subDiv.style.left = x + 150;
		subDiv.style.width = 150;
	}
	
	/*
	im = document.getElementById("menuImage" + id);
	if(im != null){
		im.src = 'images/expand_on.gif';
		// imv.innerHTML = '<img style="border-style:none;z-index:-1;" id=" menuImage"' + id +' src="images/expand_on.gif">';
	}
	*/
}

function mainMenuOut(id, className){
	document.getElementById("mainMenu" + id).className = className;
	
	subDiv = document.getElementById("subMenuDiv" + id);
	if(subDiv != null){
		subDiv.style.visibility = 'hidden';
	}
	/*
	imv = document.getElementById("menuImageDiv" + id);
	if(imv != null){
		imv.innerHTML = '<img  style="border-style:none;z-index:-1;" id="menuImage"' + id +' src="images/expand_default.gif">';
	}
	im = document.getElementById("menuImage" + id);
	
	if(im != null){
		im.src = 'images/expand_default.gif';
		// imv.innerHTML = '<img style="border-style:none;z-index:-1;" id=" menuImage"' + id +' src="images/expand_on.gif">';
	}
	*/
}

function mainMenuInit(ids, width){
	ids = ids.split(',');
	
	for(i = 0; i < ids.length; i++){
		imV = document.getElementById("menuImageDiv" + ids[i]);
		if(imV != null){
			menuO = document.getElementById("mainMenu" + ids[i]);
			h = menuO.offsetHeight;
			
			x = getAbsoluteLeft("mainMenu" + ids[i]);
			y = getAbsoluteTop("mainMenu" + ids[i]);

			imV.innerHTML = '<img id="menuImage"' + ids[i] +' src="images/expand_default.gif">';
			imV.style.top = y + (h/2) - 4;
			imV.style.left = x + 150 - 12;
			imV.style.visibility = 'visible';

		}
	}
	
}

function menuLink(url){
	window.location = url;
}


function subMenuOver(id, className){
	document.getElementById("subMenu" + id).className = className;
}

function subMenuOut(id, className){
	document.getElementById("subMenu" + id).className = className;
}


/* added by tony 2006-8-10 */
function getAbsoluteHeight(ref){
	return document.getElementById(ref).offsetHeight;
}

var hitSubtItem = false;
function customSelectMainItemClick(index){
	var mainObject = document.getElementById("main1");
	var subDivObject = document.getElementById("subDiv1");
	
	if(hitSubtItem == false){
		if(subDivObject.style.visibility == 'hidden'){
			subDivObject.style.visibility = 'visible';
		}else{
			subDivObject.style.visibility = 'hidden';
		}
	}else{
		hitSubtItem = false;
	}
	
	x = 0;
	y = 0;
	w = 0;
	h = 0;
	x = getAbsoluteLeft("main"+index);
	y = getAbsoluteTop("main"+index);
	w = getAbsoluteWidth("main"+index);
	h = getAbsoluteHeight("main"+index);
	subDivObject.style.left = x;
	subDivObject.style.top = y + h - 3;
	subDivObject.style.width = w;
}

function customSelectMainItemOver(index){
	
}

function customSelectSubItemClick(value){
	document.getElementById("subDiv1").style.visibility = 'hidden';
	document.getElementById("mainText1").innerHTML = value;
	hitSubtItem = true;
}

function customSelectSubItemOver(id){
	document.getElementById(id).className = 'subItemHover';
	document.getElementById(id + "_link").className = 'customSubLinkHover';
}

function customSelectSubItemOut(id){
	document.getElementById(id).className = 'subItem';
	document.getElementById(id + "_link").className = 'customSubLink';
}
/* added by tony 2006-8-10 eof */