var navMenu = 
'<table width=774 border=0 cellpadding=0 cellspacing=0>'+
'<tr>'+
'<td width=233 height=76 rowspan=2><img src="images/fire_fightings_template_07.jpg" width=233 height=76></td>'+
'<td width=209 height=76 rowspan=2><img src="images/fire_fightings_template_08.jpg" width=209 height=76></td>'+
'<td width=96 height=76 rowspan=2><img src="images/fire_fightings_template_09.jpg" width=96 height=76></td>'+
'<td width=236 height=48 colspan=3><img src="images/fire_fightings_template_10.jpg" width=236 height=48></td>'+
'</tr>'+
'<tr>'+
'<td width=81 height=28><a href="http://www.tkblearning.com.tw/web/serviceField/class_order.jsp" target="_blank"><img src="images/fire_fightings_template_11.jpg" width=81 height=28 border=0></a></td>'+
'<td width=68 height=28><a href="index.htm" target="_top"><img src="images/fire_fightings_template_12.jpg" width=68 height=28 border=0></a></td>'+
'<td width=87 height=28><a href="mailto:marketing@tkblearning.com.tw"><img src="images/fire_fightings_template_13.jpg" width=87 height=28 border=0></a></td>'+
'</tr>'+
'</table>'+
'<table width=774 border=0 cellpadding=0 cellspacing=0 id="root">'+
'<tr>'+
'<td width=17 height=32><img src="images/fire_fightings_template_21.jpg" width=17 height=32></td>'+
'##btn0##'+
'<td width=22 height=32><img src="images/fire_fightings_template_22.jpg" width=22 height=32></td>'+
'##btn1##'+
'<td width=23 height=32><img src="images/fire_fightings_template_23.jpg" width=23 height=32></td>'+
'##btn2##'+
'<td width=23 height=32><img src="images/fire_fightings_template_24.jpg" width=23 height=32></td>'+
'##btn3##'+
'<td width=24 height=32><img src="images/fire_fightings_template_25.jpg" width=24 height=32></td>'+
'##btn4##'+
'<td width=22 height=32><img src="images/fire_fightings_template_26.jpg" width=22 height=32></td>'+
'##btn5##'+
'<td width=23 height=32><img src="images/fire_fightings_template_27.jpg" width=23 height=32></td>'+
'##btn6##'+
'<td width=58 height=32><img src="images/fire_fightings_template_28.jpg" width=58 height=32></td>'+
'</tr>'+
'</table>';
var navBtn1 = '<td><a href="##url##" target="##target##" onMouseOver="showDropMenu(\'dp##id##\',true)" onMouseOut="showDropMenu(\'dp##id##\',false)"><img src="images/fire_fightings_template_##file##.jpg" name="menu##id##" border=0 id="menu##id##"></a></td>';
var navBtn2 = '<td><img src="images/fire_fightings_template_##file##.jpg" name="menu##id##" border=0 id="menu##id##"></td>';

var dops0 = 
'<div id="dp0" style="position:absolute; left:0px; top:103px; width:84px; height:62px; z-index:1; padding-top:5;display:none" onMouseOver="showDropMenu(\'dp0\',true)" onMouseOut="showDropMenu(\'dp0\',false)">'+
'<div id="content1" style="position:absolute; left:0px; top:4px; width:84px; height:62px; z-index:2; ">'+
'<table width="85" border="0" cellpadding="3" cellspacing="1" bgcolor="#999999">'+
'<tr>'+
'<td bgcolor="#FFFFFF"><table border="0" cellpadding="0" cellspacing="0" class="text12">'+
'<tr>'+
'<td><a href="http://www.tkblearning.com.tw/web/courseInfoField/class_CourseShow.jsp?eType=3&eKind=309&eClass=就業證照區" target="_blank"><img src="images/icon_01.gif" border="0" >消防設備師</a></td>'+
'</tr>'+
'<tr>'+
'<td background="images/line_01.gif"><img src="images/spacer.gif" width="5" height="5"></td>'+
'</tr>'+
'<tr>'+
'<td height="18" valign="bottom"><img src="images/icon_01.gif" border="0" ><a href="http://www.tkblearning.com.tw/web/courseInfoField/class_CourseShow.jsp?eType=3&eKind=310&eClass=就業證照區" target="_blank">消防設備士</a></td>'+
'</tr>'+
'</table></td>'+
'</tr>'+
'</table>'+
'</div>'+
'<div id="bg1" style="position:absolute; left:0px; top:0px; width:84px; height:62px; z-index:1; "><img src="images/spacer.gif" width="85" height="40"></div>'+
'</div>';

var cprs = 
'<table width="774" border="0" cellspacing="0" cellpadding="0">'+
'<tr>'+
'<td><img src="images/fire_fightings_template_02.jpg" width=249 height=7><img src="images/fire_fightings_template_03.jpg" width=525 height=7></td>'+
'</tr>'+
'</table>'+
'<table width="774" border="0" cellpadding="0" cellspacing="0" bgcolor="#C41616">'+
'<tr>'+
'<td width="22">&nbsp;</td>'+
'<td width="224"><a href="http://www.tkb.com.tw" target="_blank"><img src="images/fire_fightings_template_04.jpg" width="56" height="63" border="0"></a><a href="http://www.tkblearning.com.tw" target="_blank"><img src="images/fire_fightings_template_05.gif" width="119" height="63" border="0"></a></td>'+
'<td width="528" valign="top"><img src="images/fire_fightings_template_06.gif" width="490" height="32">##cprsTxt##</td>'+
'</tr>'+
'</table>';

function initMainMenu(){//主選單
	/*
	url 陣列，公版地址原始碼字串
	obj 字串，輸出物件ID名稱
	*/
	
	var obj = 'navArea';
	var url = ['http://www.tkblearning.com.tw/web/courseInfoField/class_CourseShow.jsp?eType=3&eKind=310&eClass=就業證照區','introduction.htm','mark.htm','training.htm','future.htm','join.htm','teacher.htm'];
	var target = ['_blank','_self','_self','_self','_self','_self','_self']
	var tmpKey = [];
	var tmpObj = [];
	var ok = navMenu;
	for (var i = 0;i<url.length;i++){
		if (url[i] == '#'){
			var insertVar = [i+14,i];
			var insertKey = ['##file##','##id##'];
			var tmp = replaceStr(navBtn2,insertKey,insertVar);
			tmpKey.push('##btn' + i + '##');
			tmpObj.push(tmp);
		} else {
			var insertVar = [url[i],target[i],i+14,i];
			var insertKey = ['##url##','##target##','##file##','##id##'];
			var tmp = replaceStr(navBtn1,insertKey,insertVar);
			tmpKey.push('##btn' + i + '##');
			tmpObj.push(tmp);
		}
	}
	var ok = replaceStr(ok,tmpKey,tmpObj);
	exportObject(obj,ok);
}

function initDrops(){
	setFollowLayer('dp0','root',20);
}

//考慮跨IE與NetScape瀏覽器核心使用
function setFollowLayer(subobj,tarobj,xpadding){
/*
*	作者：無能為力的王德安
*	時間：20050805的颱風假
*	功能：讓以MICROSOFT INTERNET EXPLORER與NETSCAPE核心的瀏覽器上的Lyaer選單，可隨置中的網頁內容浮動。
*	參數：如下
*	subobj：字串。欲浮動對齊的物件。
*	trobj：字串。標的網頁內容目標物件。在IE上為最外層或排列第一個的Table的ID名稱。在NetScape上則取得該物件的寬度後，與innerWidth作運算。
*	xpadding：欲標的物件的X方向補正
*	注意：這個JS的功能還不完整
*/
	var AP = navigator.appName.toUpperCase();//取得瀏覽器核心名稱
	if (AP.indexOf('EXPLORER')>=0){
		document.getElementById(subobj).style.left = parseInt(document.getElementById(tarobj).offsetLeft + xpadding) + 'px';
		//document.getElementById(subobj).style.top = document.getElementById(tarobj).offsetTop + ypadding;
	} else if(AP.indexOf('NETSCAPE')>=0){
		var oW = this.innerWidth;
		var tW = document.getElementById(tarobj).width;
		document.getElementById(subobj).style.left = (oW-tW)/2 + xpadding - 9  + 'px';//9是一個補正常數
	} else {
		alert('無法判斷的瀏覽器，網頁將有部分JS失效');
		return
	}
}

function initCPRS(obj,cprsTxt){//版權
	/*
	cprsTxt 字串，公版地址原始碼字串
	obj 字串，輸出物件ID名稱
	*/
	var insertKey = ['##cprsTxt##'];
	var insertVar = [cprsTxt];
	var ok = replaceStr(cprs,insertKey,insertVar);
	exportObject(obj,ok);
}

function replaceStr(model,Key,Var){
	/*
	model 字串，樣版字串
	Key 陣列，取代鎖定標籤
	Var 陣列，代入值
	*/
	var ok = model;
	for (var i = 0;i<Key.length;i++){
		var regX = new RegExp (Key[i], 'g') ;
		ok = ok.replace(regX,Var[i]);
	}
	return ok;
}
function exportObject(obj,value){
	/*
	obj 字串，輸出物件名稱
	value 字串，輸出內容(HTML code)
	*/
	if (document.getElementById(obj)){
		MM_setTextOfLayer(obj,'',value);
	} else {
		alert('找不到'+obj);
	}
	traceInHtml('對'+obj + '輸出：' +'\n'+value);
}
function traceInHtml(str){
	/*
	str 輸出值，以字串輸出
	*/
	if (!document.getElementById('traceTxt')){
		return;
	}
	var out = document.getElementById('traceTxt');
	out.value += str + '\n';
}

function showDropMenu(obj,bol){
	if(!document.getElementById(obj)){return;}
	var wobj = document.getElementById(obj);
	
	if(bol){
		wobj.style.display = '';
	} else {
		wobj.style.display = 'none';
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

