function getLv4MenuHTML(url)
{
	httpRequest.open('get',url, true);
	httpRequest.onreadystatechange = parseInfo;
	httpRequest.send(null);
}

function parseInfo()
{
	if(httpRequest.readyState == 1)
	{
		if (document.getElementById && document.getElementById('a'))
		{
			x = document.getElementById('a');
			// x.innerHTML = '<div id="a"></div>';
			x.innerHTML = '載入第四層選單中 ...';
		}
	}
	if (httpRequest.readyState == 4)
	{
		if(httpRequest.status == 200)
		{
			if (document.getElementById && document.getElementById('Lv4TabMenu'))
			{
				x = document.getElementById('Lv4TabMenu');
				// x.innerHTML = '<div id="Lv4TabMenu"></div>';
				x.innerHTML = httpRequest.responseText;
				if ( document.getElementById('lv4menu_'+pchannelId) && document.getElementById('lv4menu_close'))
					document.getElementById('lv4menu_close').style.visibility = 'visible';
			}
		} 
		else 
		{
			alert("Error loading page\n"+ httpRequest.status +":"+ httpRequest.statusText);
		}
	}        
}

function switch_notice(flg, lv4menuId){

	if (  !(document.all || document.getElementById)  )
		return false;
	
	if (flg == null)
	var flg = "close";
	
	if (flg == "close"){
		document.getElementById(lv4menuId).style.visibility = "hidden";
		showLv4Div(lv4menuId, false);
		document.getElementById("lv4menu_close").style.visibility = "visible";
	}else{
		document.getElementById(lv4menuId).style.left = "0px";
		document.getElementById(lv4menuId).style.visibility = "visible";
		showLv4Div(lv4menuId, true);
		document.getElementById("lv4menu_close").style.visibility = "hidden";
	}
}

function clickRedirect(pageUrl, linktype, channelid, pchannelid, lchannelid, pagetypeid, parameter) {
	
	var popupwin="";
	var tmp_url="";
	
 	//內部JSP 
	if(linktype=="0") {  
		if (pageUrl.indexOf("?") == -1)
			tmp_url= pageUrl + "?channelId=" + channelid + "&pchannelId=" + pchannelid + "&lchannelId=" + lchannelid + "&pageTypeId=" + pagetypeid + "&switchMenu=1&" + linkString + "&" + parameter;
		else
			tmp_url= pageUrl + "&channelId=" + channelid + "&pchannelId=" + pchannelid + "&lchannelId=" + lchannelid + "&pageTypeId=" + pagetypeid + "&switchMenu=1&" + linkString + "&" + parameter;
	
		// alert(tmp_url);
		document.location.href = tmp_url;
	} else if(linktype=="1") { // POPUP
		if (pageUrl.indexOf("?") == -1)
			tmp_url= pageUrl + "?channelId=" + channelid + "&pchannelId=" + pchannelid + "&lchannelId=" + lchannelid + "&pageTypeId=" + pagetypeid + "&switchMenu=1&" + linkString + "&" + parameter; 
		else
			tmp_url= pageUrl + "&channelId=" + channelid + "&pchannelId=" + pchannelid + "&lchannelId=" + lchannelid + "&pageTypeId=" + pagetypeid + "&switchMenu=1&" + linkString + "&" + parameter; 

		popupwin = window.open(tmp_url,"popupwin","screenX=0,screenY=0,width=800,height=600,location=yes,menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,status=yes");
		popupwin.focus();
		eraseCookie('clickTab');
		eraseCookie('clickBar');
		eraseCookie('previousItemID');
		eraseCookie('previousIdx');
		eraseCookie('previousParentItemID');
	} 
}	

function doLv4MenuMouseOver (lv4div, channelid) {

	lv4div.style.background='#5AADA5';
	document.getElementById('div_'+channelid).style.color='#FFFFFF';
	document.getElementById('div_'+channelid).style.cursor='pointer';
}

function doLv4MenuMouseOut (lv4div, channelid) {

	lv4div.style.background='';
	document.getElementById('div_'+channelid).style.color='#4a4b4b';
}