var tempHtml;
var tempStr1;
var tempStr2;
var tempStr3;
if (section == null)	var section = 0;
if (level1 == null)	var level1 = "";
if (level2 == null)	var level2 = "";
if (level3 == null)	var level3 = "";
var id1 = null;
var id2 = null;
var id3 = null;


function genId() {

	var obj = sectionArray[section];
	if (level1 != "") {
		for (var i=0; i<obj.length; i++) {
			if (obj[i].id == level1) {
				id1 = i;
				if (level2 != "") {
					var obj1 = obj[i].subSection;
					if (typeof(obj1) == "undefined") break;
					for (var j=0; j<obj1.length; j++) {
						if (obj1[j].id == level2) {
							id2 = j;
							if (level3 != "") {
								var obj2 = obj1[j].subSection;
								if (typeof(obj2) == "undefined") break;
								for (var k=0; k<obj2.length; k++) {
									if (obj2[k].id == level3) {
										id3 = k;
										break;
									}
								}
							} else {
								break;
							}
						}
					}
				} else {
					break;
				}
			}
		}
	}
//alert("id1: "+id1+"   id2: "+id2+"   id3: "+id3);
}

genId();


var clientId = "";

function getClient() {
	var temp = location.href;
	var obj = clientArray;
	
	if (temp.indexOf('media/') > -1) {
		
		for (var i=0; i<obj.length; i++) {
			if (temp.indexOf((obj[i].id + "/")) > -1) {
				clientId = obj[i].id;
				
				break;
			}
		}
	}
	
	
	//alert("clientId: "+clientId);
}

getClient();


function genLang()
{
	var str = '';

	str += '<table cellpadding="0" cellspacing="0" border="0">';
	str += '<tr>';
	str += '<form action="'+path+'search/searchAction.jsp" method="post" name="searchForm">';
	str += '<td><span class="content_small">Search </span>';
  	str += '<input name="key" type="text" class="content_small" height="10" />';
  	str += '<a href="javascript:document.searchForm.submit();"><img src="'+path+'images/common/btn_search.gif" width="5" height="9" hspace="5" border="0"/></a></td>';
	str += '<td width="20">&nbsp;</td>';
	str += '<td><a href="javascript:changeLanguage(\'chi\')"><img src="'+path+'images/common/change_lang_tc.gif" border="0"></a></td>';
	str += '<td><img src="'+path+'images/common/change_lang_slash.gif"></td>';
	str += '<td><a href="javascript:changeLanguage(\'gb\')"><img src="'+path+'images/common/change_lang_sc.gif" border="0"></a></td>';
	str += '</form>';	
	str += '</tr>';
	str += '</table>';
	
	document.write(str);
}
function genTop() {
	var sect = section;
	var obj = sectionArray[sect];
	tempHtml = '<table border="0" cellspacing="0" cellpadding="0" width="961">';
	//tempHtml += '<tr>';
	//tempHtml += '	<td height="156" valign="top" style="background:url('+path+'images/other/'+sectionArray[section][id1].id+'_top_banner.jpg) no-repeat top;">';
	//tempHtml += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	//tempHtml += '	<tr>';
	//tempHtml += '		<td><img src="images/common/spacer.gif" width="1" height="12"></td>';
	//tempHtml += '	</tr>';
	tempHtml += '	<tr>';
	tempHtml += '	<td style="padding:0px 0px 0px 0px" height="80">';
	tempHtml += genFlashStr((path+'images/swf/logo.swf'), '145', '80', 'industry_flash', 'path='+path+'&section='+section+'&level1='+level1+'&level2='+level2+'&level3='+level3);
//	<a href="'+path+'index.htm"><img src="'+path+'images/common/eba_logo_v2.jpg" border="0"></a>
	tempHtml += '		</td>';
	tempHtml += '		<td align="right" valign="bottom">';
	
	tempHtml += '<table border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '	<tr>';
	
	for (var i=0; i<obj.length; i++) {
		if (typeof(obj[i])=="undefined") continue;
		if (sect == section && id1 == i) {
			tempStr1 = 'top_nav_'+(i+1)+'_f2.gif';
		} else {
			tempStr1 = 'top_nav_'+(i+1)+'.gif';
		}
		tempHtml += '		<td valign="top"><img src="'+path+'images/common/spacer.gif" width="20" height="1"></td>';
		tempHtml += '		<td id="navBtn_'+i+'">';
		tempHtml += pulldownGen(i);
		tempHtml += '		<a href="'+path+obj[i].link+'" onMouseOut="showPulldown('+i+', 0);MM_swapImgRestore();" onMouseOver="showPulldown('+i+', 1);MM_swapImage(\'top_nav_'+(i+1)+'\',\'\',\''+path+'images/common/top_nav_'+(i+1)+'_f2.gif\',1)" ><img src="'+path+'images/common/'+tempStr1+'" name="top_nav_'+(i+1)+'" border="0" alt="'+obj[i].name+'"></a></td>';
	}
	
	//tempHtml += '		<td><img src="'+path+'images/common/spacer.gif" width="36" height="1"></td>';
	tempHtml += '	</tr>';
	tempHtml += '	<tr><td colspan=12 style="padding:5px 0px 0px 0px" align="right"><img src="'+path+'images/common/nav_line_01.gif" width="450"></td></tr>';
	tempHtml += '</table>';
	
	//tempHtml += '				</td>';
	//tempHtml += '			</tr>';
	//tempHtml += '		</table>';
	tempHtml += '	</td>';
	tempHtml += '</tr>';
	tempHtml += '</table>';
	
	document.write(tempHtml);
}



function showPulldown(id, f)
{
	var btnW = document.getElementById('navBtn_'+id).clientWidth;
	var pd = document.getElementById('pulldown_'+id);
	if (pd)
		{
			var tempBID = document.getElementById('top_nav_'+(id+1));
			var tempL = pd.clientWidth - btnW + 5;
			pd.style.position = "absolute";
			pd.style.left = "-" + tempL +"px";
			pd.style.top = (f)?'10px':'-500px';
			pd.style.visibility = (f)?'visible':'hidden';
		}
		
}


function pulldownGen(id)
{
	//return "";
 var str = '';
 var obj = sectionArray[section][id];
 var i = 0;
 
 if (typeof(obj) == "undefined") return str;
 if (typeof(obj.subSection) == "undefined") return str;
 	
 //var btnW = document.getElementById('navBtn_'+id).clientWidth;
 
 str += '<div style="position:absolute; overflow:visible;">';
 str += '<div style="position:absolute; top:-5000px; width:"200px"; visibility:hidden; z-index:100;" id="pulldown_'+id+'" onMouseOver="showPulldown('+id+', 1);" onMouseOut="showPulldown('+id+', 0);">'; 
//str += '<div style="position:absolute; top:-5000px; visibility:hidden; z-index:100;" id="pulldown_'+id+'" onMouseOver="showPulldown('+id+', 1);" onMouseOut="showPulldown('+id+', 0);">'; 
 

 str += '<table width="200" border="0" cellspacing="0" cellpadding="0">';
 str += '<tr><td width="100%" height="5"><img src="'+path+'images/common/spacer.gif"></td></tr>';

	str += '<tr>';
	str += '	<td width="100%" height="1" align="right"><img src="'+path+'images/common/spacer.gif"  height="1"></td>';
	str += '	<td width="100%" height="6" align="right"><img src="'+path+'images/common/nav_line_02.gif" border="0" height="100%" width="1" /></td>';
	str += '</tr>';
			
 for (var item in obj.subSection)
	{
			var sub = obj.subSection[item];
		
	//	var link = (sub.link.indexOf('http://') > -1) ? sub.link : (path + sub.id + '/' + sub.link);
		var link = (sub.link.indexOf('http://') > -1) ? sub.link : (path + sub.link);
		
		var tempStr1 = 'top_nav_'+(id+1)+'_'+(i+1);
		var tempStr2 = tempStr1;
		if (sub.id == level2)
			{
				
				tempStr2 = tempStr1 + '_f3';
			}
		
		str += '<tr>';
		str += '	<td width="100%" height="100%" align="right" valign="top">';
		if (sub.id != level2)
			{
				str += '<a href="'+link+'" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage(\''+tempStr1+'\',\'\',\''+path+'images/common/'+tempStr1+'_f2.gif\',1)" >';
			}
		str += '<img src="'+path+'images/common/'+tempStr2+'.gif" id="'+tempStr1+'" border="0" alt="'+sub.name+'">';
		if (sub.id != level2)
			{
				str += '</a>';
			}
		str += '	</td>';
		//str += '		<a href="'+link+'" target="'+sub.target+'">'+sub.name+'</a>';
		str += '		<td>';
		str += '		<img src="'+path+'images/common/spacer.gif" width="5"><img src="'+path+'images/common/nav_line_02.gif"  border="0" height="100%" width="1">';
		str += '	</td>';

		str += '</tr>';
		//str += '<tr><td height="2"><img src="'+path+'images/common/spacer.gif" width="1" height="2"></td></tr>';
		i++;
  }
	
 str += '</table>';
 
 str += '</div>';
 str += '</div>';
 
 return str;
}



function genBanner()
{
	var str = '';
	var p = sectionArray[section][id1];
	var s = "";
	var z = "";
	//var s = sectionArray[section][id1].subSection[id2];
	var img = "";
	
	if (typeof(banner) != "undefined")
		{
			img = path + "images/" + p.id + "/"+ banner;
		}
	else if ((level3 != "")
	&& (typeof(sectionArray[section][id1].subSection[id2]) != "undefined"))
		{
			s = sectionArray[section][id1].subSection[id2];
			
			if (typeof(sectionArray[section][id1].subSection[id2].subSection) != "undefined")
				{
					z = sectionArray[section][id1].subSection[id2].subSection[id3];
				}
			else
				{
				z = undefined;
				}
			if (typeof(z) == "undefined")
				{
					img = path + "images/" + p.id + "/topbanner_"+ s.id +".jpg";
				}
			else
				{
					img = path + "images/" + p.id + "/topbanner_"+ s.id + z.id +".jpg";
				}
		}
	else if (level2!= "")
		{
			s = sectionArray[section][id1].subSection[id2];
			img = path + "images/" + p.id + "/topbanner_"+ s.id + ".jpg";
		}
	else
		{
			img = path + "images/" + p.id + "/topbanner_"+ p.id + ".jpg";
		}
		
	str += '<tr>';
	str += '	<td style="padding:70px 0px 10px 0px">';
	str += '		<table cellpadding="0" cellspacing="0" border ="0">';
	str += '			<tr>';
	str += '				<td><img src="'+img+'" width="951" height="29" align="left"/></td>';
	str += '				<td></td>';
	str += '			</tr>';
	str += '		</table>';
	str += '	</td>';
	str += '</tr>';

	document.write(str);
}

function genThirdNav(ob)
{
	var str = '';
	if (typeof(ob) == "undefined")
		{
			var obj = sectionArray[section][id1].subSection[id2].subSection;
		}
	else
		{
			var obj = ob;
		}

	var tempStr = '';

	str += '<table cellpadding="0" cellspacing="0" border="0">';
	str += '	<tr>';

	for (var item in obj)
		{
			str += '<td style="padding:0px 20px 0px 0px" class="content">';
			str += '<span style="padding:0px 5px 0px 0px">';
			str += '<img src="'+path+'images/clients/pic_01.gif">';
			str += '</span>';
			
			var nam = obj[item].name;
			if (typeof(level3) != "undefined")
				{
					if (obj[item].id == level3)
						{
							nam = '<b><font color="#FF0000">' + obj[item].name + '</font></b>';
						}
				}
			str += '<a href="' + path + obj[item].link + '">' + nam + '</a>';
			str += '</td>';
		}

	str += '	</tr>';
	str += '</table>';
	
	document.write(str);
}

function genThirdNav2()
{
	var str = '';
	var obj = sectionArray[section][id1].subSection[id2].subSection;
	var tempStr = '';

	str += '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
	str += '	<tr  valign="top">';
	
	var tempP = 100/obj.length;
	
	for (var item in obj)
		{
			str += '<td align="center" width="'+tempP+'%">';
			str += '<table cellpadding="0" cellspacing="0" border="0">';
			str += '	<tr valign="top" >';
			str += '		<td valign="top" align="center" style="padding:1px 4px 0px 0px" class="content">';
			str += '			<img src="'+path+'images/clients/pic_01.gif">';
			str += '		</td>';
			str += '		<td align="left" class="content">';
			
			var nam = obj[item].name;
			if (typeof(level3) != "undefined")
				{
					if (obj[item].id == level3)
						{
							nam = '<b><font color="#D20005">' + obj[item].name + '</font></b>';
						}
				}
				
			
			var link;
			
			if (clientId != "") {
				link = "media/" + clientId + "/" + obj[item].link;
			} else {
				link = obj[item].link;
			}
			
			str += '			<a href="' + path + link + '" class="subNav">' + nam + '</a>';
			str += '		</td>';
			str += '	</tr>';
			str += '</table>';
			str += '</td>';
			
		}

	str += '	</tr>';
	str += '</table>';
	
	document.write(str);
}

function genThirdNav3(ob)
{
	var str = '';
	
	if (typeof(ob) == "undefined")
		{
			var obj = sectionArray[section][id1].subSection[id2].subSection;
		}
	else
		{
			var pnam = sectionArray[section][id1].subSection[id2].subSection[id3].name;
			var obj = ob;
		}

	var tempStr = '';

	str += '<table cellpadding="0" cellspacing="0" border="0">';
	str += '	<tr>';

	for (var item in obj)
		{
			str += '<td style="padding:0px 20px 0px 0px" class="content">';
			str += '<span style="padding:0px 5px 0px 0px">';
			str += '<img src="'+path+'images/clients/pic_01.gif">';
			str += '</span>';
			
			var nam = obj[item].name;
			if (typeof(level3) != "undefined")
				{
					if (obj[item].id == level3)
						{
							nam = '<b><font color="#FF0000">' + pnam + ' - ' + obj[item].name + '</font></b>';
						}
				}
			str += '<a href="' + path + obj[item].link + '">' + nam + '</a>';
			str += '</td>';
		}

	str += '	</tr>';
	str += '</table>';
	
	document.write(str);
}

function clickToThirdLv(id)
{
	var str = '';
//alert(section + " : " + id1 + " : " + id2 + " : " + id);
	var obj = sectionArray[section][id1].subSection[id2].subSection[id];
//	alert(obj.link + " : " + obj.name);
window.location.href = path + obj.link;
	//str += obj[id].link;
//	document.write(str);

}

function genFooter()
{
	var str = '';
	
	
	str += '<a href ="'+path+'sitemap/sitemap.htm" class="footer">Sitemap</a> | <span style="padding:5px 2px 0px 3px"><img src="'+path+'images/common/at.jpg" border="0"></span>2009 EBA Communications Ltd';

	document.write(str);
}

function genFooter2()
{
	var str = '';
	
	
	str += '<a href ="'+path+'sitemap/sitemap.htm" class="footer">Sitemap</a> | <span style="padding:5px 2px 0px 3px"><img src="'+path+'images/common/at.jpg" border="0"></span>2009 EBA Communications Ltd';

	document.write(str);
}


function genLogo()
{
	var str = '';
	
	str += '<table width="213" border="0" cellpadding="0" cellspacing="0">';
	str += '  <tr>';
	str += '    <td width="220" height="150" align="center" bgcolor="#FFFFFF" style="padding:0px 0px 0px 0px"><img src="'+path+'images/media/logo/logo_'+clientId+'.jpg"></td>';
	str += '   </tr>';
	str += '  <tr>';
	str += '    <td style="background:url('+path+'images/common/dash.gif) repeat-x"></td>';
	str += '   </tr>';
	str += '</table>';
	
	document.write(str);
}


function genBack()
{
	var str = '';
	var file;
	
	if (level3 == "releases") {
		file = "news";
	} else if (level3 == "photos") {
		file = "gallery";
	} else {
		file = level3;
	}
	
	str += '<table width="20%" border="0" cellspacing="1" cellpadding="0">';
	str += '	<tr>';
	str += '		<td width="10%"><a href="'+file+'00.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'btn_back\',\'\',\''+path+'images/media/btn_back_f2.gif\',1)"><img src="'+path+'images/media/btn_back.gif" alt="back" name="btn_back" width="33" height="10" hspace="0" vspace="2" border="0" id="btn_back" /></a></td>';
	
/*		<!--
<td width="2%" valign="top"><span class="footer">|</span></td>
<td width="15%"><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('btn_recent','','../../images/common/btn_recent_f2.jpg',1)"><img src="../../images/common/btn_recent.jpg" alt="recent" name="btn_recent" width="83" height="12" hspace="5" vspace="2" border="0" id="btn_be12" /></a></td>
<td width="2%" valign="top" class="footer">|</td>
<td width="71%"><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('btn_earlier','','../../images/common/btn_earlier_f2.jpg',1)"><img src="../../images/common/btn_earlier.jpg" alt="earlier" name="btn_earlier" width="48" height="12" hspace="5" vspace="2" border="0" id="btn_earlier" /></a></td>
-->*/
	
	str += '	</tr>';
	str += '</table>';
	
	document.write(str);
}