/*********************************************************************
	來原版權宣告

	Dyanmic HTML JavaScript 函式
	by Audi carousel@home.ab.net.tw
	所有程式碼在 IE4.x 及 Netscape 4.x 下測試
	本程式只經由原作者發行之書籍及 http://carousel.cjb.net 中發佈
	歡迎將本程式應用在您的網頁上，但請勿以任意形式轉載
	如有轉載需求，請與本人連繫
	
	程式修改 by elementalor elementalor@pchome.com.tw
	本程式測試於 IE5.5/6.0，MSNExplorer，Netcape 6.2 可執行。
	Netscape 4.x 系列未測試情況不明。
*********************************************************************/

/****************************************************************
			動態選單主程式區
****************************************************************/
// 共用變數
var DHTML = (document.getElementById || document.all || document.layers);
var _height = null;
var _width = null;
var colors = null;
var MenuTitle = null;
var MenuPic = null;
var BgPic = null;
var direction = null;
var fontSize;
var setcontentLayerSize_1024 = "950px";
var setcontentLayerSize_800 = "760px";
var NS = (navigator.appName == "Netscape") ? true : false;
var _width, _height;
var All_Left_DIV_width = "120px";
var All_Right_DIV_width = "100%";
var Master_email = "webmaster@isu.edu.tw";
var Update_Time = "2006/7/28 PM 06:42:13 ";


// 取得瀏覽器
var NS = (navigator.appName == "Netscape") ? true : false;

// 擷取用戶端瀏覽器變數(Object)
function getObj(name) {
  if (document.getElementById) {
	return document.getElementById(name);
  } else if (document.all) {
	return document.all[name];
  } else if (document.layers) {
   	return document.layers[name];
  }
}

// 擷取用戶端瀏覽器變數(Object.style)
function getObjSty(name) {
  if (document.getElementById) {
	return document.getElementById(name).style;
  } else if (document.all) {
	return document.all[name].style;
  } else if (document.layers) {
   	return document.layers[name];
  }
}

function setFontSize() {
	// 啟動預設
	if(NS) {
		_width=innerWidth;
		_height=innerHeight;
	} else {
		_width=document.body.clientWidth;
	}
	// 800x600 字體為預設值 9pt，其餘皆為 11pt
	if(_width > 800) {
		return "11pt";
	} else {
		return "9pt";
	}
}

function setDirection(dir) {
	switch(dir) {
		case "level1":
			qdir = "";
		break;
		case "level2":
			qdir = "../";
		break;
		case "level3":
			qdir = "../../";
		break;
	}
	
	return qdir;
}

function setLayer() {
	// 啟動預設
	if(NS) {
		_width=innerWidth;
		_height=innerHeight;
	} else {
		_width=document.body.clientWidth;
	}
		
	if(!DHTML) return;
	contentLyr = getObjSty('content');
	
	if(_width > 800) {
		contentLyr.width = setcontentLayerSize_1024;
	} else {
		contentLyr.width = setcontentLayerSize_800;
	}
}

function setFontColor(cname) {
	switch(cname) {
		case "0":
			colors = "#660000";
			MenuPic = "<img align=\"middle\" src=\"../images/man.gif\" border=\"0\" width=\"24\" height=\"16\" alt=\"\">";
			MenuTitle = "網路組即時訊息";
			BgPic = "tour_000";
			refDir = "network";
		  break;
		case "1":
			colors = "#339966";
			MenuPic = "<img align=\"middle\" src=\"../images/leaf.gif\" border=\"0\" width=\"24\" height=\"16\" alt=\"\">";
			MenuTitle = "系統即時訊息";
			BgPic = "tour_01";
			refDir = "system";
		  break;
		case "2":
			colors = "#3366cc";
			MenuPic = "<img align=\"middle\" src=\"../images/water.gif\" border=\"0\" width=\"24\" height=\"16\" alt=\"\">";
			MenuTitle = "綜合業務組即時訊息";
			BgPic = "tour_02";
			refDir = "all";
		break;
	}
	return colors;
}

// 控制寫入內容頁的 DIV 標籤與字型大小
function DIVcontent() {
	fontsize = setFontSize();
	document.write("<br><div style=\"font-size: " + fontsize + ";\">");
}

// 控制寫入內容頁的 SPAN 標籤與字型大小
function DIV2content() {
	fontsize = setFontSize();
	document.write("<div align=\"right\" style=\"font-size: " + fontsize + ";\">");
}


// 控制寫入內容頁的 TABLE 標籤與字型大小
function TABLEcontent() {
	fontsize = setFontSize();
	document.write("<td align=\"left\" class=\"news\" style=\"font-size: " + fontsize + ";\">");
}

function TABLEcontent2() {
	fontsize = setFontSize();
	document.write("<td align=\"left\" class=\"news2\" style=\"font-size: " + fontsize + ";\">");
}

// 控制寫入 NEWS3 的 TABLE 標籤與字型大小(背景用)
function NEWS3content() {
	fontsize = setFontSize();
	document.write("<td class=\"button\" align=\"center\" style=\"font-size: " + fontsize + ";\">");
}

// 控制寫入 NEWS2 的 TABLE 標籤與字型大小(無框)
function NEWS2content() {
	fontsize = setFontSize();
	document.write("<td align=\"left\" valign=\"top\" style=\"padding: 5px; font-size: " + fontsize + ";\">");
}

// 控制寫入 NEWS 的 TABLE 標籤與字型大小(有框)
function NEWScontent() {
	fontsize = setFontSize();
	document.write("<td align=\"left\" valign=\"top\" style=\"padding: 5px; font-size: " + fontsize + ";\">");
}

// 控制寫入 服教成績 的 TABLE 標籤與字型大小
function SERVScontent() {
	fontsize = setFontSize();
	document.write("<td align=\"left\" valign=\"top\" style=\"font-size: " + fontsize + "; border: 1px solid #dddddd;\">");
}

// 控制寫入 校園資訊NEWS_1 的 TABLE 標籤與字型大小(有框)
function NEWS_1content() {
	fontsize = setFontSize();
	document.write("<td align=\"left\" valign=\"top\" style=\"padding: 5px; font-size: " + fontsize + ";\" onmouseover=\"this.style.background='#efefef';\" onmouseout=\"this.style.background='transparent'\">");
}

// 控制寫入 校園資訊online 的 TABLE 標籤與字型大小(有框)
function ONLINEcontent() {
	fontsize = setFontSize();
	document.write("<td align=\"left\" valign=\"top\" style=\"padding: 0px; font-size: " + fontsize + ";\">");
}

// 控制寫入 OVREVIEW 的 TABLE 標籤與字型大小
function TABLECOLcontent() {
	fontsize = setFontSize();
	document.write("<td colspan=\"6\" align=\"left\" valign=\"bottom\" style=\"font-size: " + fontsize + ";\">");
}

// 控制寫入 SHOWDOC 的 TABLE 標籤與字型大小
function SHOWDOCcontent() {
	fontsize = setFontSize();
	document.write("<td align=\"left\" valign=\"top\" style=\"font-size: " + fontsize + "; border-right: 1px solid #cccccc; padding-right: 5px; padding-left: 10px;\" width=\"100%\">");
}

// 控制寫入 SITEMAPE 的 TABLE 標籤與字型大小
function SITEMAPcontent() {
	fontsize = setFontSize();
	document.write("<td style=\"width: 50%; padding: 5px; font-size: " + fontsize + ";\">");
}

// 控制寫入 校園資訊SITEMAPE_1 的 TABLE 標籤與字型大小
function SITEMAP_1content() {
	fontsize = setFontSize();
	document.write("<td style=\"width: 50%; padding: 5px; font-size: " + fontsize + ";\" onmouseover=\"this.style.background='#efefef';\" onmouseout=\"this.style.background='transparent'\">");
}

// 控制寫入 STAFF 的 TABLE 標籤與字型大小
function STAFFcontent() {
	fontsize = setFontSize();
	document.write("<td valign=\"top\" width=\"200\" style=\"font-size: " + fontsize + "; border: 1px solid #dddddd;\">");
}

// 控制寫入 SERVPOSS 的 TABLE 標籤與字型大小
function SERVPOSScontent() {
	fontsize = setFontSize();
	document.write("<td valign=\"top\" width=\"120\" style=\"font-size: " + fontsize + "; border: 1px solid #dddddd;\">");
}


// 控制寫入 BUOTTON 的 BUTTON 標籤與字型大小
function BUTTONcontent() {
	fontsize = setFontSize();
	document.write("<td align=\"left\" valign=\"middle\" style=\"font-size: " + fontsize + "; background:  top left fixed no-repeat #eeeeee; padding-left: 21pt;\" onmouseover=\"this.style.background='top left fixed no-repeat #eeeeee';\" onmouseout=\"this.style.background='top left fixed no-repeat #eeeeee';\">");
}

// 控制寫入 ServClub 的 TABLE 標籤與字型大小
function SERVCLUBcontent() {
	fontsize = setFontSize();
	document.write("<td align=\"left\" valign=\"top\" width=\"100\" style=\"padding: 5px; font-size: " + fontsize + "; width: 83%;\">");
}

// 控制寫入 ServClub 的 TABLE 標籤與字型大小
function SERVCLUBDATEcontent() {
	fontsize = setFontSize();
	document.write("<td align=\"center\" valign=\"middle\" style=\"font-size: " + fontsize + ";\">");
}

// 控制寫入 Counsel online 標籤與字型大小
function COUNSELonline() {
	fontSize = setFontSize();
	document.write("<td align=\"left\" valign=\"top\" style=\"padding-left: 12px; padding-right: 12px; font-size: " + fontsize + ";\">");
}

// 控制背景大小
function setBackground(dir) {
	fontsize = setFontSize();
	colors = setFontColor(dir);
	
	if(_width > 800) {
		document.write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\" fixed no-repeat top left #ffffff;\">");
	} else {
		document.write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\" fixed no-repeat top left #ffffff;\">");
	}
}



// 陣列
function menuArray(names, urls) {
	this.menu = names;
	this.urls = urls;
}

// 寫入各組組別詳細鏈結內容
function setMenu(dept_id, deptname, dept_mno) {
	
	var MenuList = new Array();

	fontsize = setFontSize();
	colors = setFontColor(dept_id);

	var menu_str1 = "<div align=\"left\" style=\"width: " + All_Left_DIV_width + "; color: " + colors + "; font-size: " + fontsize + "; border: 0px solid " + colors + ";\">";
	var menu_str2 = "<span style=\"padding: 4px 0px 2px 4px; background-color: " + colors + "; color: #ffffff; width: 100%; height: 11pt;\">";
	var menu_str3 = "</span><div style=\"line-height: 150%; text-align: left; padding: 4px 0px 0px 4px; color: " + colors + ";\">";

	with(document) {


		write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"padding-right: 2px;\">");
		write("<tr style=\"padding-bottom: 3px;\"><td valign=\"top\" align=\"right\"></td><td valign=\"top\" align=\"left\" style=\"font-size: " + fontsize + ";\">&nbsp;<a href=\"overview.php?dept_mno="+ dept_mno+"\" target=\"_top\">回到首頁</a></td></tr>");

		for(var i=0;i<=MenuList.length-1;i++) {
			if(MenuList[i].urls.substr(0,4)=="http") {
				write("<tr style=\"padding-bottom: 3px;\"><td valign=\"top\" align=\"right\"</td><td valign=\"top\" align=\"left\" style=\"font-size: " + fontsize + ";\">&nbsp;<a href=\"" + MenuList[i].urls + "\" target=\"_blank\">" + MenuList[i].menu + "</a></td></tr>");
			} else {
				write("<tr style=\"padding-bottom: 3px;\"><td valign=\"top\" align=\"right\"></td><td valign=\"top\" align=\"left\" style=\"font-size: " + fontsize + ";\">&nbsp;<a href=\"" + MenuList[i].urls + "\" target=\"_top\">" + MenuList[i].menu + "</a></td></tr>");
			}
		}
		write("</table>");
		// no end
	}
}
// 連接上面的程式使用，即各組左欄menu
function setMenu2(dept_id, levelids, levelname, block , dept_mno , types) {
	colors = setFontColor(dept_id);
	document.write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"padding-right: 2px;\">");
	if(block=='0' && types<3) {
		document.write("<tr style=\"padding-bottom: 3px;\"><td valign=\"top\" align=\"right\"></td><td valign=\"top\" align=\"left\" style=\"font-size: " + fontsize + ";\">&nbsp;<a href=\"../interface/showdoc.php?dept_id=" + dept_id + "&levelid=" + levelids + "&deptmon=" + deptmon + "\" target=\"_top\">" + levelname + "</a></td></tr>");
	} else if(types==3) {
		document.write("<tr style=\"padding-bottom: 3px;\"><td valign=\"top\" align=\"right\"></td><td valign=\"top\" align=\"left\" style=\"font-size: " + fontsize + ";\">&nbsp;<a href=\"../interface/deptphotos.php?dept_id=" + dept_id + "&levelid=" + levelids + "&deptmon=" + deptmon + "\" target=\"_top\">" + levelname + "</a></td></tr>");
	} else {
		document.write("<tr style=\"padding-bottom: 3px;\"><td valign=\"top\" align=\"right\"></td><td valign=\"top\" align=\"left\" style=\"font-size: " + fontsize + ";\">");
		if (block.substr(0,4)=="http"){
			document.write("&nbsp;<a href=\"" + block + "\" target=\"_blank\">");
		}else if(block.substr(0,13)=="../interface/"){
			document.write("&nbsp;<a href=\"" + block + "\" target=\"_top\">");
		}else if(levelids.length <4){
			document.write("&nbsp;<a href=\"../interface/showdoc.php?dept_id="+ dept_id +"&levelid="+ levelids + "&dept_mno=" + dept_mno + "\" target=\"_top\">");
		}else {
			document.write("&nbsp;<a href=\"../interface/showdoc.php?dept_id="+ dept_id +"&levelid="+ block + "&dept_mno=" + dept_mno + "\" target=\"_top\">");
		}
		document.write(levelname+"</a></td></tr>");
	}
	document.write("</table>");
}

// 使用者登入
function userlogin() {
	var u_str1 = "<div align=\"left\" style=\"width: " + All_Left_DIV_width + "; color: #ff9999; font-size: " + fontsize + "; border: 1px solid #ff9999;\">";
	var u_str2 = "<span style=\"padding: 4px 0px 2px 4px; background-color:#FAA819; color: #ffffff; width: 100%; height: 11pt; cursor: hand;\" onClick=\"window.open('../admin/login.php','Administrator','scrollbars=yes, resizable=yes, status=yes');\"><img align=\"middle\" src=\"../images/note_icon.gif\" border=\"0\" width=\"15\" height=\"15\" alt=\"\">&nbsp;網站維護</a></span></div>";

	with(document) {
		write(u_str1);
		write(u_str2);
	}
}



// 各組別資訊
function deptmenu(name) {

	fontsize = setFontSize();
	colors = setFontColor(name);

	var u_str1 = "<div align=\"left\" style=\"width: " + All_Right_DIV_width + "; color: " + colors + "; font-size: " + fontsize + "; border: 1px solid " + colors + ";\">";
	var u_str2 = "<span style=\"padding: 4px 0px 2px 4px; background-color: " + colors + "; color: #ffffff; width: 100%; height: 11pt; text-align: left; font-weight: bold;\"><img align=\"middle\" src=\"../images/note_icon.gif\" border=\"0\" width=\"15\" height=\"15\" alt=\"\">&nbsp;" + MenuTitle + "</a></span><div style=\"padding: 4px;\">";
	var u_str3 = "<marquee scrollamount=\"2\" scrolldelay=\"0\" direction=\"up\" width=\"95%\" id=\"wxiaoqing\" height=\"45\" onmouseover=\"wxiaoqing.stop();\" onmouseout=\"wxiaoqing.start();\">";

	with(document) {
		write(u_str1);
		write(u_str2);
		write(u_str3);
	}
}


// 共用介面陣列
function directionURLs(names, dirs, urls) {
	this.dirname = names;
	this.dir = dirs;
	this.url = urls;
}

// 共用介面陣列 2
function deptImg(names, w, h) {
	this.names = names;
	this.w = w;
	this.h = h;
}


// 共用介面陣列
dirLevel = new Array();
dirLevel[0] = new directionURLs("重要公告/首頁","interface","overview.php");
dirLevel[1] = new directionURLs("線上導覽","interface","interview.php");
dirLevel[2] = new directionURLs("線上服務資源","online","index.php");
dirLevel[3] = new directionURLs("網路作業組","network","index.php");
dirLevel[4] = new directionURLs("系統發展組","system","index.php");
dirLevel[5] = new directionURLs("綜合業務組","all","index.php");
//dirLevel[6] = new directionURLs("生活輔導組","affair","index.php");
//dirLevel[7] = new directionURLs("服務教育組","service","index.php");
//dirLevel[8] = new directionURLs("課外活動組","extact","index.php");
//dirLevel[9] = new directionURLs("諮商輔導組","counsel","index.php");
//dirLevel[10] = new directionURLs("衛生保健組","health","index.php");
//dirLevel[11] = new directionURLs("畢業生就業輔導組","career","index.php");


deptIS = new Array();
deptIS[0] = new deptImg("leader.gif",115,29);
deptIS[1] = new deptImg("military.gif",84,29);
deptIS[2] = new deptImg("sport.gif",86,29);
deptIS[3] = new deptImg("affair.gif",146,28);
deptIS[4] = new deptImg("service.gif",147,29);
deptIS[5] = new deptImg("extact.gif",147,26);
deptIS[6] = new deptImg("counsel.gif",147,28);
deptIS[7] = new deptImg("health.gif",148,27);
deptIS[8] = new deptImg("career.gif",237,29);
deptIS[9] = new deptImg("",0,0);
deptIS[10] = new deptImg("",0,0);
deptIS[11] = new deptImg("",0,0);


// 共用介面 1
function common(dir) {
	fontsize = setFontSize();
	
	with(document) {
		write("<hr size=\"1\" style=\"color: #dddddd;\">");
		write("<table border=\"0\" width=\"100%\"><tr><td width=\"496\"><font color=\"#333333\" size=\"2\">義 守 大 學<br>高 雄 縣 大 樹 鄉 學 城 路 一 段 一 號<br>T e l ： 8 8 6 - 7 - 6 5 7 7 7 1 1</font></td><td width=\"496\"><p align=\"right\"><font color=\"#333333\" size=\"2\">此 網 頁 由 電 算 中 心 製 作<br>如 有 任 何 問 題 ， 請 至  <b>");
		write("<a href=/bug/project01>訊 息 回 報 中 心</a></b>反應<br>")
		write("<b><SCRIPT language=JavaScript>document.write(Update_Time)</SCRIPT>更 新</font></td></tr></table>");
	}
}

// 共用介面 2 上方Banner區
function common2(dir) {
	setLayer();
	fontsize = setFontSize();

 		switch(dir) {
		case "level1":
			direction = "";
		break;
		case "level2":
			direction = "../";
		break;
		case "level3":
			direction = "../../";
		break;
	}

	with(document) {
		
		write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"left\">\
		<tr><td valign=\"bottom\" style=\"padding-top: 0px; margin: 0px;\" width=\"743\">");
		
		for(var i =3; i<=dirLevel.length-1;i++) {
			write("<a href=\"" + direction + dirLevel[i].dir + "/" + dirLevel[i].url + "\" target=\"_self\"><font color=\"#000000\" style=\"font-size: 12px;\">&nbsp;" + dirLevel[i].dirname + "</font></a>");
		}
		
		write("</td><td align=\"right\" background=\"../images/title.gif\" width=\"249\"><embed src=\"../images/student.swf\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" name=\"obj1\" width=\"249\" height=\"97\" quality=\"High\" wmode=\"transparent\"></td></tr></table></div>");
		write("<form style=\"margin: 0px;\" id=\"table_search\" name=\"table_search\" action=\"../interface/sasearch.php\" method=\"post\">\
		<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"right\">\
		<tr><td>\
		<input style=\"color: #000000; background-color: #ffffff; margin-bottom: 2px; border-left: 1px solid #aaaaaa; border-top: 1px solid #aaaaaa; border-bottom: 2px solid #aaaaaa; border-right: 2px solid #aaaaaa;\" type=\"text\" name=\"keyword\" id=\"keyword\" size=\"25\" value=\"\">\
		<!-- 分類分組 -->\
		<input type=\"hidden\" name=\"searchclass\" id=\"searchclass\" value=\"null\">\
		<input type=\"hidden\" name=\"searchdept\" id=\"searchdept\" value=\"null\">\
		<input type=\"hidden\" name=\"listlimit\" id=\"listlimit\" value=\"0\">\
		<input type=\"hidden\" name=\"searchlevel\" id=\"searchlevel\" value=\"0\">\
		<input type=submit value=站內搜尋 name=B1 style=border: 1px solid #000000; background-color: #FFFFFF>\
		</td></tr></table></form>");
		
	}
}

function common3(deptid) {
	document.write("<img src=\"../images/" + deptIS[deptid].names + "\" border=\"0\" width=\"" + deptIS[deptid].w + "\" height=\"" + deptIS[deptid].h + "\" alt=\"\">");
}

/****************************************************************************
			底色變換程式碼
****************************************************************************/
function overBG(e) {
	e.style.background = "#ff9999";
}

function outBG(e) {
	e.style.background = "transparent";
}
/**
 * 自動調整頁面高度 避免覆蓋 
 */ 

function cleanStyle(){
  var left_height   = document.getElementById("utility").clientHeight;
  var obj_rpanel =  document.getElementById("rpanel");
  var obj_center =  document.getElementById("content");
  if(obj_rpanel){
     var right_height = obj_rpanel.clientHeight;
  } else {
     var right_height = 0;
  };
  obj_content_wrap = document.getElementById("content-wrap");
  if (left_height > obj_center.clientHeight){
     obj_center.style.height = left_height;
  } 
  if (right_height > obj_center.clientHeight){
     obj_center.style.height = right_height;
  } 
  if (obj_content_wrap.clientHeight < 350 ){
     obj_center.style.height = 350;
  }
}

