var tempHtml;
var tempString;
var tempString02;
var tempString03;
var tempArray = new Array();
var tempArray02 = new Array();
var pulldownW = 196;

if (section == null)	var section;
if (subSection == null)	var subSection;
if (level1 == null)	var level1;

var totalNum = sectionArray.length;
//var totalNum = 8;


/*tempHtml = '<div style="position:absolute; top:251px; width:153px; z-index:100;">';
tempHtml += '<img src="'+path+'images/'+sectionArray[section-1].id+'/title.gif" width="153" alt="'+sectionArray[section-1].name+'">';
tempHtml += '</div>';*/


tempHtml = '<div style="position:absolute; top:251px; width:153px; z-index:100;" onMouseOver="this.style.zIndex = \'10000\'" onMouseOut="this.style.zIndex = \'100\'">';



tempHtml += '<table width="153" border="0" cellspacing="0" cellpadding="0">';
tempHtml += '	<tr>';
tempHtml += '		<td><img src="'+path+'images/'+sectionArray[section-1].id+'/title.gif" width="153" alt="'+sectionArray[section-1].name+'"></td>';
tempHtml += '		<td width="100%"></td>';
tempHtml += '	</tr>';
tempHtml += '	<tr valign="top">';
tempHtml += '		<td colspan="1" style="background:url('+path+'images/common/left_shadow.gif) no-repeat right top;">';

tempHtml += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';

if (subSectionArray[section-1] != null)
	{
		for (i=1; i<=subSectionArray[section-1].length; i++) {
			tempHtml += '	<tr>';
			
			if (subSection != i) {
				tempString = '.gif';
			} else {
				tempString = '_f2.gif';
			}
			
			tempHtml += '<td>';
			
			tempHtml += '<div style="position:relative;">';
			tempHtml += '<div style="width:153px; cursor:pointer;" onMouseOver="leftBtnOver('+i+', 1);" onMouseOut="leftBtnOver('+i+', 0);">';
			
			tempHtml += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
			tempHtml += '<tr>';
			
			tempHtml += '<td style="padding:10px; padding-right:0px">';
			
			tempHtml += '<a href="'+path+subSectionArray[section-1][i-1].link+'" target="'+subSectionArray[section-1][i-1].target+'"><img src="'+path+'images/sidenav/'+sectionArray[section-1].id+'_'+subSectionArray[section-1][i-1].id+tempString+'" border="0" name="sub_'+sectionArray[section-1].id+'_'+subSectionArray[section-1][i-1].id+'" alt="'+subSectionArray[section-1][i-1].name+'"></a>';
			
			tempHtml += '</td><td width="6" bgColor="" id="rightLine_'+i+'"><img src="'+path+'images/common/spacer.gif" width="6" height="1"></td>';
			tempHtml += '</tr>'
			tempHtml += '</table>';
			
			tempHtml += '</div>';
			
			if (subSectionArray[section-1][i-1].pulldown) {
				
				
// Pulldown Start Here
		
		
				tempHtml += '<div id="subPulldown_'+i+'" style="position:absolute; left:153px; top:0px; width:'+pulldownW+'px; z-index:1000; visibility: hidden;" onMouseOver="leftBtnOver('+i+', 1);" onMouseOut="leftBtnOver('+i+', 0);">';
				
				tempHtml += '<table width="'+pulldownW+'" border="0" cellspacing="0" cellpadding="0">';
				tempHtml += '	<tr>';
				tempHtml += '		<td width="100%" style="padding:6px; padding-right:0px; border:1px solid '+colorArray[section-1][0]+'; border-left:3px solid '+colorArray[section-1][0]+'; background-color:'+colorArray[section-1][1]+';">';
				
				tempHtml += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
				
				//alert(eval(subSectionArray[section-1][i-1].id+"Array").length);
				
				tempArray = eval(sectionArray[section-1].id+"_"+subSectionArray[section-1][i-1].id+"Array");
				
				for (j=1; j<=tempArray.length; j++) {
					
					tempHtml += '<tr>';
					
					tempString03 = path+'images/sidenav/'+sectionArray[section-1].id+"_"+subSectionArray[section-1][i-1].id+'_'+tempArray[j-1].id;
					
					if (level1 != j) {
						tempString02 = tempString03 + '.gif';
					} else {
						tempString02 = tempString03 + '_f2.gif';
					}
					
					tempHtml += '<td style="padding-left:3px;" onMouseOver="subLeftBtnOver('+i+', '+j+', \''+tempString03+'\', 1);" onMouseOut="subLeftBtnOver('+i+', '+j+', \''+tempString03+'\', 0);"><a href="'+path+tempArray[j-1].link+'" target="'+tempArray[j-1].target+'" style="width:100%"><img src="'+tempString02+'" vspace="5" border="0" name="'+sectionArray[section-1].id+"_"+subSectionArray[section-1][i-1].id+j+'" alt="'+tempArray[j-1].name+'"></a></td>';
					
					tempHtml += '<td width="9" bgColor="" id="rightLine_'+i+'_'+j+'" valign="top" onMouseOver="subLeftBtnOver('+i+', '+j+', \''+tempString03+'\', 1);" onMouseOut="subLeftBtnOver('+i+', '+j+', \''+tempString03+'\', 0);">';
					
					
					
if (tempArray[j-1].pulldown) {
					
					
// Sub-Pulldown Start Here
		
		
	tempHtml += '<div style="position:absolute;"><div id="subPulldown_'+i+'_'+j+'" style="position:absolute; left:3px; top:0px; width:'+pulldownW+'px; z-index:1000; visibility: hidden;" onMouseOver="subLeftBtnOver('+i+', '+j+', 1);" onMouseOut="subLeftBtnOver('+i+', '+j+', 0);">';

	tempHtml += '<table width="'+pulldownW+'" border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '	<tr>';
	tempHtml += '		<td width="100%" style="padding:6px; border:1px solid '+colorArray[section-1][0]+'; border-left:3px solid '+colorArray[section-1][0]+'; background-color:'+colorArray[section-1][1]+';">';

	tempHtml += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';

	//alert(eval(subSectionArray[section-1][i-1].id+"Array").length);

	tempArray02 = eval(sectionArray[section-1].id+"_"+subSectionArray[section-1][i-1].id+"_"+tempArray[j-1].id+"Array");

	for (k=1; k<=tempArray02.length; k++) {
		
		tempHtml += '<tr>';
		
		tempString03 = path+'images/sidenav/'+sectionArray[section-1].id+"_"+subSectionArray[section-1][i-1].id+'_'+tempArray[j-1].id+'_'+tempArray02[k-1].id;
		
		if (level2 != k) {
			tempString02 = tempString03 + '.gif';
		} else {
			tempString02 = tempString03 + '_f2.gif';
		}
		
		tempHtml += '<td style="padding-left:3px;"><a href="'+path+tempArray02[k-1].link+'" target="'+tempArray02[k-1].target+'" onMouseOver="subSubLeftBtnOver('+i+', '+j+', '+k+', \''+tempString03+'\', 1);" onMouseOut="subSubLeftBtnOver('+i+', '+j+', '+k+', \''+tempString03+'\', 0);" style="width:100%"><img src="'+tempString02+'" vspace="5" border="0" name="'+sectionArray[section-1].id+"_"+subSectionArray[section-1][i-1].id+j+k+'" alt="'+tempArray02[k-1].name+'"></a></td>';
		
		tempHtml += '</tr>';
		
		if (k < tempArray02.length) {
			tempHtml += '<tr>';
			tempHtml += '	<td><img src="'+path+'images/common/spacer.gif" width="1" height="2"></td>';
			tempHtml += '</tr>';
			tempHtml += '<tr>';
			tempHtml += '	<td bgcolor="#DFDBD4"><img src="'+path+'images/common/spacer.gif" width="1" height="1"></td>';
			tempHtml += '</tr>';
			tempHtml += '<tr>';
			tempHtml += '	<td><img src="'+path+'images/common/spacer.gif" width="1" height="2"></td>';
			tempHtml += '</tr>';
		}
	}

	tempHtml += '</table>';
	tempHtml += '</td>';
	

	tempHtml += '<td width="6" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+path+'images/common/shadow_right.png\', sizingMethod=\'scale\')"><img src="'+path+'images/common/spacer.gif" width="6" height="1"></td>';

	tempHtml += '</tr>';

	tempHtml += '<tr>';
	tempHtml += '	<td colspan="2" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+path+'images/common/shadow_bottom_02.png\', sizingMethod=\'image\')"><img src="'+path+'images/common/spacer.gif" width="1" height="6"></td>';
	
	tempHtml += '</tr>';

	tempHtml += '</table>';

	tempHtml += '</div></div>';

// Sub-Pulldown End Here
					
}
					tempHtml += '<div style="position:absolute;"><img src="'+path+'images/common/spacer.gif" width="9" height="1"></td></div>';
					
					tempHtml += '</tr>';
					
					if (j < tempArray.length) {
						tempHtml += '<tr>';
						
						tempHtml += '	<td><img src="'+path+'images/common/spacer.gif" width="1" height="2"></td>';
						tempHtml += '</tr>';
						tempHtml += '<tr>';
						tempHtml += '	<td bgcolor="#DFDBD4"><img src="'+path+'images/common/spacer.gif" width="1" height="1"></td>';
						tempHtml += '</tr>';
						tempHtml += '<tr>';
						tempHtml += '	<td><img src="'+path+'images/common/spacer.gif" width="1" height="2"></td>';
						tempHtml += '</tr>';
					}
				}
				
				tempHtml += '</table>';
				tempHtml += '</td>';
				
				tempHtml += '<td width="6" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+path+'images/common/shadow_right.png\', sizingMethod=\'scale\')"><img src="'+path+'images/common/spacer.gif" width="6" height="1"></td>';
				
				tempHtml += '</tr>';
				
				tempHtml += '<tr>';
				tempHtml += '	<td colspan="2" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+path+'images/common/shadow_bottom_02.png\', sizingMethod=\'image\')"><img src="'+path+'images/common/spacer.gif" width="1" height="6"></td>';
				tempHtml += '</tr>';
				
				tempHtml += '</table>';
				
				tempHtml += '</div>';
	
// Pulldown End Here
				
			}
			
			tempHtml += '</div>';
			tempHtml += '</td>';
			
			tempHtml += '	</tr>';
			
			if (i<subSectionArray[section-1].length) {
				tempHtml += '	<tr>';
				tempHtml += '		<td colspan="2" style="padding-right:7px"><div style="width:146px; background-color:#EBEBEB;"><img src="'+path+'images/common/spacer.gif" width="1" height="1"></div></td>';

				tempHtml += '	</tr>';
			}
			
		}
} else {
	tempHtml += '	<tr>';
	tempHtml += '		<td><img src="'+path+'images/common/spacer.gif" width="1" height="8"></td>';
	tempHtml += '	</tr>';
}


tempHtml += '</table>';
tempHtml += '</td><td colspan="2">';


tempHtml += '	<tr>';
tempHtml += '		<td colspan="2" height="75" style="background:url('+path+'images/common/account_bg.gif) no-repeat;"><img src="'+path+'images/common/spacer.gif" width="1" height="1">';

//Your Online Account Starts
tempHtml += '<table width="100%" border="0" cellspacing="0" cellpadding="0" cellpadding="0" id="loginBoxTable">';
tempHtml += '	<tr>';
tempHtml += '		<form name="selectOption">';
tempHtml += '		<td align="left" width="100%" style="padding-top:20px; padding-bottom:2px; padding-left:9px;">';
tempHtml += '			<select width="100%" name="planMenu" class="selectBox" style="width:135;" onMouseOut="javascript:shrinkComboWidth(this);" onMouseOver="javascript:enlargeComboWidth(this);" onClick="javascript:setComboFocus(1);" onBlur="javascript:shrinkComboWidth(this, 0);" onChange="javascript:shrinkComboWidth(this, 0);"><font size=9px>';
tempHtml += '			</font></select>';
//tempHtml += '		<div id="loginMsg" style="visibility:hidden" class="white01"></div>';
tempHtml += '		</td>';
tempHtml += '		</form>';
tempHtml += '	</tr>';
tempHtml += '	<tr valign="bottom">';
//tempHtml += '		<td style="padding-left:10px; padding-bottom:11px;"></td>';
tempHtml += '		<td style="padding-left:78px; align="left"><div id="loginButton"><a href="#" onclick="loginPath()" onMouseOver="MM_swapImage(\'btn_login\',\'\',\''+path+'images/common/btn_login_f2.gif\',1);" onMouseOut="MM_swapImgRestore();"><img src="'+path+'images/common/btn_login.gif" width="70" height="31" border="0" name="btn_login"></a></div></td>';
tempHtml += '	</tr>';
tempHtml += '</table>';


//Your Online Account Ends

tempHtml += '	</td>';
tempHtml += '	</tr>';

//E-newsletter Subscription Starts

tempHtml += '	<tr>';
tempHtml += '		<td style="border-bottom:1px solid #EBEBEB; padding-top:5px; padding-bottom:5px;"><a href="'+path+'page/WMP0600/subscribe.jsp"><img src="'+path+'images/common/btn_enewsletter.gif" width="142" height="44" border="0" alt="訂閱e-通訊"></a></td>';
tempHtml += '	</tr>';

//E-newsletter Subscription Ends
tempHtml += '</td>';
tempHtml += '	</tr>';
tempHtml += '</table>';
tempHtml += '</div>';
document.write(tempHtml);
makeRequestLeft(path+'specialnotice.xml');

if (subSectionArray[section-1] != null) {
	for (i=1; i<=subSectionArray[section-1].length; i++) {

		if (document.getElementById('subPulldown_'+i))
		{
			document.getElementById('subPulldown_'+i).style.visibility = 'hidden';
			document.getElementById('subPulldown_'+i).style.display = 'none';
		}

	}
}

var comboF = 0;
function setComboFocus(f)
{
	comboF = f;
}

function enlargeComboWidth(item)
{
	if (isInternetExplorer)
		{
			item.style.width = "260";
		}
}

function shrinkComboWidth(item, f)
{
	if (f!=undefined)
		{
			comboF = f;
		}
	if (!comboF)
		{
			item.style.width = 135;
		}
	comboF = 0;
}

function leftBtnOver(i, over) {

	//alert(document.getElementById('subPulldown_'+i).style.display);
	if (over == 1)
		{
			if (subSection != i) 
				{
				var tmpName = 'sub_'+sectionArray[section-1].id+'_'+subSectionArray[section-1][i-1].id;
				eval(tmpName).src = path+'images/sidenav/'+sectionArray[section-1].id+'_'+subSectionArray[section-1][i-1].id+'_f2.gif';
//					document.getElementById('sub_'+sectionArray[section-1].id+'_'+subSectionArray[section-1][i-1].id).src = path+'images/sidenav/'+sectionArray[section-1].id+'_'+subSectionArray[section-1][i-1].id+'_f2.gif';
				}
			if (document.getElementById('subPulldown_'+i))
				{
					document.getElementById('subPulldown_'+i).style.display = 'block';
					document.getElementById('subPulldown_'+i).style.visibility = 'visible';
					document.getElementById('rightLine_'+i).bgColor = colorArray[section-1][0];
				}
		}
	else
		{
			if (subSection != i) 
				{
				var tmpName = 'sub_'+sectionArray[section-1].id+'_'+subSectionArray[section-1][i-1].id;
				eval(tmpName).src = path+'images/sidenav/'+sectionArray[section-1].id+'_'+subSectionArray[section-1][i-1].id+'.gif';
				}
			if (document.getElementById('subPulldown_'+i))
				{
					document.getElementById('subPulldown_'+i).style.display = 'none';
					document.getElementById('subPulldown_'+i).style.visibility = 'hidden';
					document.getElementById('rightLine_'+i).bgColor = '';
				}
		}
}

function subLeftBtnOver(i, j, imageName, over) {
	//alert(tempSectionArray[i-1].id+'_'+tempSubSectionArray[i-1][j-1].id)
	if (over == 1)
		{		
			if (level1 != j)
				{
					var tmpName = sectionArray[section-1].id+"_"+(subSectionArray[section-1][i-1].id+j);
					eval(tmpName).src = imageName+'_f2.gif';
//					document.getElementById(sectionArray[section-1].id+"_"+subSectionArray[section-1][i-1].id+j).src = imageName+'_f2.gif';
				}
			if (document.getElementById('subPulldown_'+i+'_'+j))
				{
					document.getElementById('subPulldown_'+i+'_'+j).style.display = 'block';
					document.getElementById('subPulldown_'+i+'_'+j).style.visibility = 'visible';
					document.getElementById('rightLine_'+i+'_'+j).bgColor = colorArray[section-1][0];
				}		
		}
	else
		{	
			if (level1 != j)
				{
					var tmpName = sectionArray[section-1].id+"_"+(subSectionArray[section-1][i-1].id+j);
					eval(tmpName).src = imageName+'.gif';
					//document.getElementById(sectionArray[section-1].id+"_"+subSectionArray[section-1][i-1].id+j).src = imageName+'.gif';
				}
			if (document.getElementById('subPulldown_'+i+'_'+j))
				{
					document.getElementById('subPulldown_'+i+'_'+j).style.display = 'none';
					document.getElementById('subPulldown_'+i+'_'+j).style.visibility = 'hidden';
					document.getElementById('rightLine_'+i+'_'+j).bgColor = '';
				}
		}
}

function subSubLeftBtnOver(i, j, k, imageName, over) {
	//alert(tempSectionArray[i-1].id+'_'+tempSubSectionArray[i-1][j-1].id)
	if (over == 1) {		
		if (level2 != k) {
			var tmpName = sectionArray[section-1].id+"_"+(subSectionArray[section-1][i-1].id+j+k);
			eval(tmpName).src = imageName+'_f2.gif';
			//document.getElementById(sectionArray[section-1].id+"_"+subSectionArray[section-1][i-1].id+j+k).src = imageName+'_f2.gif';
		}
		
	} else {	
		if (level2 != k) {
			var tmpName = sectionArray[section-1].id+"_"+(subSectionArray[section-1][i-1].id+j+k);
			eval(tmpName).src = imageName+'.gif';
			//document.getElementById(sectionArray[section-1].id+"_"+subSectionArray[section-1][i-1].id+j+k).src = imageName+'.gif';
		}
	}
}

function makeRequestLeft(url) {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = alertContentsLeft;
        http_request.open('GET', url, true);
        http_request.send(null);
        
    }

function alertContentsLeft() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                return parseMessagesLeft(http_request.responseXML);
            } else {
                alert('There was a problem with the request.');
            }
        }

    }

function parseMessagesLeft(responseXML) {
	var noticeData = responseXML.getElementsByTagName("noticedata")[0];
	var countNumber = 0;
	var isHaveValue = false;
	var loginBoxTable = document.all["loginBoxTable"];
	var row;
    var nameCell;
    var isIE;
    
    selobj = document.selectOption.planMenu;
    
    if (window.XMLHttpRequest) {
        isIE = false;
    } else if (window.ActiveXObject) {
        isIE = true;
    }
    
    for(i=0;i<selobj.length;i++)
    	selobj.options[i] = null;
    selobj.options[0]=new Option("請選擇計劃", "#");
    
    for (loop = 0; loop < noticeData.childNodes.length; loop++)
    {
        var notice = noticeData.childNodes[loop];
	   	if( notice.nodeName == "login" )
        {
        	var id = notice.getElementsByTagName("path")[0];
	        var description = notice.getElementsByTagName("description")[0];
	        selobj.options[loop+1*1]=new Option(description.childNodes[0].nodeValue, id.childNodes[0].nodeValue);
	        isHaveValue = true;
	    }
	    else
	    {
	    	if( !isHaveValue )
	    	{
		    	selobj.style.setAttribute("visibility", "hidden");
				loginBoxTable.removeChild(loginBoxTable.childNodes[0]);
		        if (isIE)
		        {
		        	row = loginBoxTable.insertRow(loginBoxTable.rows.length);
		        	nameCell = row.insertCell(0);
		        }
		        else
		        { 
		        	row = document.createElement("tr");
		        	nameCell = document.createElement("td");
		        	row.appendChild(nameCell);
			        loginBoxTable.appendChild(row);
		        }
		        
		        nameCell.className = "white03";
		        nameCell.style.paddingTop = "20px";
		        nameCell.style.paddingBottom = "2px";
		        nameCell.style.paddingLeft = "5px";
		        nameCell.style.paddingRight = "5px";
    	        nameCell.setAttribute("valign", "top");
			    var errorMsg = notice.getElementsByTagName("message")[0];
		        nameCell.appendChild(document.createTextNode(errorMsg.childNodes[0].nodeValue));
		        
		    }
		}
    }
}
