var tempHtml;
var tempString;
var tempString02;
var tempString03;

var tempArray = new Array();
var tempArray02 = new Array();
var tempArray03 = new Array();
var tempArray04 = new Array();
var tempArray05 = new Array();

if (section == null)	var section;
if (subSection == null)	var subSection;
if (level1 == null)	var level1;
if (hideLink==null) var hideLink=false;

var totalNum = sectionArray.length;
totalNum = 9;

function genTopBanner() {
	tempHtml = '<div style="position:absolute; width:770px; z-index:1;">';

	tempHtml += '<table width="770" border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '	<tr>';
	tempHtml += '		<td colspan="3"><img src="'+path+'images/common/spacer.gif" width="1" height="103"></td>';
	tempHtml += '	</tr>';
	tempHtml += '	<tr>';
	
	if (section == 5)
		{
			tempHtml += '		<td colspan="3"><img src="'+path+'images/'+sectionArray[section-1].id+'/'+subSectionArray[section-1][subSection-1].id+'_banner.jpg" width="770" height="148"></td>';
		}
	else
		{
			tempHtml += '		<td colspan="3"><img src="'+path+'images/'+sectionArray[section-1].id+'/banner.jpg" width="770" height="148"></td>';
		}	
	
	tempHtml += '	</tr>';
	tempHtml += '	<tr valign="top">';
	tempHtml += '		<td width="153"><img src="'+path+'images/common/spacer.gif" width="153" height="1"></td>';
	tempHtml += '		<td width="610">&nbsp;</td>';
	tempHtml += '		<td width="7"><img src="'+path+'images/common/right_shadow.gif" width="7" height="120"></td>';
	tempHtml += '	</tr>';
	tempHtml += '</table>';

	tempHtml += '</div>';

	document.write(tempHtml);
}


function genTitle(RSS) {
	tempHtml = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	
	tempHtml += '	<tr>';
	
	if (subSectionArray[section-1] == null | subSection == 0) {
		
		tempString = path+'images/'+sectionArray[section-1].id+'/'+sectionArray[section-1].id+'_title.gif';
		tempString02 = sectionArray[section-1].name;
	} else {
		
		tempArray = subSectionArray[section-1][subSection-1];
		
		if (level1 == 0) {
			
			tempString = path+'images/'+sectionArray[section-1].id+'/'+tempArray.id+'_title.gif';
			tempString02 = tempArray.name;
		} else {
			
			tempArray02 = eval(sectionArray[section-1].id+"_"+tempArray.id+"Array")[level1-1];
			
			if (level2 == 0) {
				
				tempString = path+'images/'+sectionArray[section-1].id+'/'+tempArray.id+"_"+tempArray02.id+'_title.gif';
				tempString02 = tempArray02.name;
			} else {
				
				tempArray03 = eval(sectionArray[section-1].id+"_"+tempArray.id+"_"+tempArray02.id+"Array")[level2-1];
				
				tempString = path+'images/'+sectionArray[section-1].id+'/'+tempArray.id+"_"+tempArray02.id+'_'+tempArray03.id+'_title.gif';
				tempString02 = tempArray03.name;
			}
		}
	}

	tempHtml += '		<td width="1" style="padding-top:15px; padding-bottom:3px; padding-right:5px; border-bottom:2px solid ' + colorArray[section-1][2] + ';"><img src="'+tempString+'" alt="'+tempString02+'"></td>';
	tempHtml += '		<td style="border-bottom:1px solid ' + colorArray[section-1][3] + ';">';
	
	
	if (RSS) {
		
		tempHtml += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
		tempHtml += '	<tr>';
		tempHtml += '		<td align="right" valign="bottom">';
		
		tempHtml += '<table border="0" cellspacing="0" cellpadding="0">';
  		tempHtml += '	<tr>';
		tempHtml += '		<td width="33"><img src="'+path +'images/common/icon_rss.gif"></td>';
		
		if (sectionArray[section-1].folder == "WMP0140")
			{
				tempHtml += '   	<td><a href="'+path+'page/'+sectionArray[section-1].folder+'/RSS/newsRss_tc.xml" target="_blank" class="content">RSS摘要</a></td>';
			}
		else
			{
				tempHtml += '   	<td><a href="'+path+'page/'+sectionArray[section-1].folder+'/RSS/fundsRss_tc.xml" target="_blank" class="content">RSS摘要</a></td>';
			}
		
		tempHtml += '   	<td width="16" align="center" class="content">|</td>';
		tempHtml += '   	<td><a href="javascript:NewWindow(\''+path +'page/news_popup.htm\', \'invest\', \'673\', \'500\', \'yes\', \'no\')" class="content">何謂RSS?</a></td>';
		tempHtml += '  </tr>';
		tempHtml += '</table>';
		
		tempHtml += '		</td>';
		tempHtml += '	</tr>';
		tempHtml += '</table>';
		
	} else {
		
		tempHtml += '<img src="'+path+'images/common/spacer.gif" width="1" height="1">';
		
	}
	
	
	tempHtml += '	</td>';
	
	tempHtml += '	</tr>';
	tempHtml += '</table>';

	document.write(tempHtml);
}


function genTreeLink() {
	
	if( !hideLink )
	{

	tempHtml = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	
	tempHtml += '	<tr>';
	tempHtml += '		<td align="right" style="padding-top:7px; padding-bottom:8px; background:url('+path+'images/common/dash_01.gif) repeat-x bottom;"><div id="treeLink" class="gray02">';
	
	tempHtml += '<a href="'+path+'index.jsp" class="gray02">主頁</a>';
	tempHtml += ' / ';
	tempHtml += '<a href="'+path+sectionArray[section-1].link+'" target="'+sectionArray[section-1].target+'" class="gray02">'+sectionArray[section-1].name+'</a>';
	
	if (subSectionArray[section-1] != null && subSection > 0)
		{
			tempArray = subSectionArray[section-1][subSection-1];
			
			tempHtml += ' / ';
			
			tempHtml += '<a href="'+path+tempArray.link+'" target="'+tempArray.target+'" class="gray02">'+tempArray.name+'</a>';
			
			
			if (level1 > 0) {
				
				tempArray02 = eval(sectionArray[section-1].id+"_"+tempArray.id+"Array")[level1-1];
				
				tempHtml += ' / ';
				
				tempHtml += '<a href="'+path+tempArray02.link+'" target="'+tempArray02.target+'" class="gray02">'+tempArray02.name+'</a>';
				
				
				if (level2 > 0) {
					
					tempArray03 = eval(sectionArray[section-1].id+"_"+tempArray.id+"_"+tempArray02.id+"Array")[level2-1];
					
					tempHtml += ' / ';
					
					tempHtml += '<a href="'+path+tempArray03.link+'" target="'+tempArray03.target+'" class="gray02">'+tempArray03.name+'</a>';
				}
			}
		}
	
	tempHtml += '</div></td>';
	
	tempHtml += '	</tr>';
	
	tempHtml += '	<tr>';
	tempHtml += '		<td><img src="'+path+'images/common/spacer.gif" width="1" height="1"></td>';
	tempHtml += '	</tr>';
	
	tempHtml += '</table>';

	document.write(tempHtml);
	}
}

function genSitemap(sectNum, classTitle, thick, thin) {
	
	var classArray = new Array('green', 'orange', 'blue');
	var thickLineArray = new Array('#5A7542', '#F48709', '#347CA5');
	var thinLineArray = new Array('#CDD5C8', '#FCDBB5', '#C2D7E4');
	
	tempHtml = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '	<tr>';
/*	tempHtml += '		<td class="'+classArray[classTitle-1]+'Title" style="padding-top:15px; padding-bottom:3px; padding-right:5px; border-bottom:2px solid '+thickLineArray[thick-1]+'"><a href="'+path+sectionArray[sectNum-1].link+'" class="'+classArray[classTitle-1]+'Title">'+sectionArray[sectNum-1].name+'</a></td>';*/
	tempHtml += '		<td width="1%" class="'+classArray[classTitle-1]+'Title" style="padding-top:15px; padding-bottom:3px; padding-right:5px; border-bottom:2px solid '+thickLineArray[thick-1]+'"><a href="'+path+sectionArray[sectNum-1].link+'" class="'+classArray[classTitle-1]+'Title"><img src="'+path+'images/'+sectionArray[sectNum-1].id+'/'+sectionArray[sectNum-1].id+'_title.gif" border="0" alt="'+sectionArray[sectNum-1].name+'"></a></td>';
	tempHtml += '		<td style="border-bottom:1px solid '+thinLineArray[thin-1]+'"><img src="'+path+'images/common/spacer.gif" width="1" height="1"></td>';
	tempHtml += '	</tr>';
	if (subSectionArray[sectNum-1] != null) {
		tempHtml += '	<tr>';
		tempHtml += '		<td colspan="2" style="padding-top:10px">';
		tempHtml += '			<table width="100%" border="0" cellspacing="0" cellpadding="0">';
		
		//alert(sectionArray.length);
			for (j=1; j<=subSectionArray[sectNum-1].length; j++) {
				tempHtml += '				<tr>';
				tempHtml += '					<td width="5%" valign="top" style="padding-left:3px; padding-top:8px"><img src="'+path+'images/common/pt_'+classArray[classTitle-1]+'.gif" width="3" height="3"></td>';
				tempHtml += '					<td class="content"><a href="'+path+subSectionArray[sectNum-1][j-1].link+'" class="content">'+subSectionArray[sectNum-1][j-1].name+'</a></td>';
				tempHtml += '				</tr>';
				tempHtml += '				<tr>';
				tempHtml += '					<td colspan="2">';
				tempHtml += '						<table width="100%" border="0" cellspacing="0" cellpadding="0">';
				
				if (subSectionArray[sectNum-1][j-1].pulldown) { 
				tempArray04 = eval(sectionArray[sectNum-1].id+"_"+subSectionArray[sectNum-1][j-1].id+"Array");
					for (k=1; k<=tempArray04.length; k++) {
						tempHtml += '							<tr>';
						tempHtml += '								<td width="15%" valign="top" class="content" align="right" style="padding-right:5px">-</td>';
						tempHtml += '								<td valign="top" class="content"><a href="'+path+tempArray04[k-1].link+'" class="content">'+tempArray04[k-1].name+'</a></td>';
						tempHtml += '							</tr>';
						tempHtml += '				<tr>';
						tempHtml += '					<td colspan="2">';
						tempHtml += '						<table width="100%" border="0" cellspacing="0" cellpadding="0">';
						
						if (tempArray04[k-1].pulldown) { 
						tempArray05 = eval(sectionArray[sectNum-1].id+"_"+subSectionArray[sectNum-1][j-1].id+"_"+tempArray04[k-1].id+"Array");
							for (l=1; l<=tempArray05.length; l++) {
								tempHtml += '							<tr>';
								tempHtml += '								<td width="25%" valign="top" class="content" align="right" style="padding-right:5px">-</td>';
								tempHtml += '								<td valign="top" class="content"><a href="'+path+tempArray05[l-1].link+'" class="content">'+tempArray05[l-1].name+'</a></td>';
								tempHtml += '							</tr>';
							}
						}
						
						tempHtml += '						</table>';
						tempHtml += '					</td>';
						tempHtml += '				</tr>';
					}
				}
				
				tempHtml += '						</table>';
				tempHtml += '					</td>';
				tempHtml += '				</tr>';
			}
		tempHtml += '			</table>';
		tempHtml += '		</td>';
		tempHtml += '	</tr>';
		}
	tempHtml += '</table>';
	document.write(tempHtml);	
}

function genNewTitle(title, desc) {

	tempHtml = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '	<tr>';
	
	if (subSectionArray[section-1] == null | subSection == 0) {
		if( sectionArray[section-1].id == "news" )
			tempString = path+'images/'+sectionArray[section-1].id+'/'+title;
		else 
			tempString = path+'images/'+sectionArray[section-1].id+'/'+sectionArray[section-1].id+'_title.gif';
		tempString02 = desc;
	}
	
	tempHtml += '		<td width="1" style="padding-top:15px; padding-bottom:3px; padding-right:5px; border-bottom:2px solid ' + colorArray[section-1][2] + ';"><img src="'+tempString+'" alt="'+tempString02+'"></td>';
	tempHtml += '		<td style="border-bottom:1px solid ' + colorArray[section-1][3] + ';">';
	tempHtml += '			<img src="'+path+'images/common/spacer.gif" width="1" height="1">';
	tempHtml += '		</td>';
	tempHtml += '	</tr>';
	tempHtml += '</table>';
	
	document.write(tempHtml);
}

function genTitleTags() {
	if( !hideLink )	{
		tempHtml = '<title>'+sectionArray[section-1].name;
/*		if (subSectionArray[section-1] != null && subSection > 0){
			tempHtml = '<title>'+subSectionArray[section-1][subSection-1].name;

			if (subSectionArray[section-1] != null && subSection > 0){
				tempArray = subSectionArray[section-1][subSection-1];
				tempHtml = '<title>'+tempArray.name;
				if (level1 > 0) {
					tempArray02 = eval(sectionArray[section-1].id+"_"+tempArray.id+"Array")[level1-1];
					tempHtml = '<title>'+tempArray02.name;
					if (level2 > 0) {
						tempArray03 = eval(sectionArray[section-1].id+"_"+tempArray.id+"_"+tempArray02.id+"Array")[level2-1];
						tempHtml = '<title>'+tempArray03.name;
					}
				}
			}
		}
*/		tempHtml += ' - BCT</title>';
	} else {
		tempHtml = '<title>BCT</title>';
	}
	
	tempHtml += ' <link REL="SHORTCUT ICON" HREF="' + path + 'favicon.ico">';
	
	document.write(tempHtml);
}
