/* Default Argument */
var ajaxfilemanagerURI = "/jslib/tiny_mce/plugins";
var DataRPCerror = '資料傳送失敗, 請連絡站台管理人員 lover (at) 520net.to, 謝謝!!';
var BrowserType = getBrowserType();
var thisPageRem = new Array;
var dtp;
/* Default Javascript */
function nl2br(str) {
	return str.replace(/([^>])\n/g, '$1＜br /＞\n');
}
function getBrowserType() {
	if (window.XMLHttpRequest) {
		if (window.ActiveXObject) {
			return 2;
		} else {
			return 3;
		}
	} else {
		return 1;
	}
	return;
}
function $(element) {
	if (!chkEmpty(element)) {
		return eval("document.getElementById('"+element+"')");
	}
	return;
}
function showColorPicker(vf, io, df) {
	OpenWindow=window.open("", "newwin", "height=470, width=610,toolbar=no,scrollbars=yes,menubar=no");
	OpenWindow.document.write('<body topmargin="1" leftmargin="1">');
	OpenWindow.document.write('<script> function ColorPickerSet() { var ColorValue = this.document.getElementById(\'ColorPickerValue\').value; var oo = opener.document.getElementById(\''+io+'\'); oo.value = ColorValue; '+((df)?'':'oo.style.backgroundColor = ColorValue;')+' window.close(); } function ColorPickerInput(vl) { this.document.getElementById(\'ColorPickerValue\').value = vl; this.document.getElementById(\'ColorPickerValue\').style.backgroundColor = vl; }</script>');
	OpenWindow.document.write('<br><center><font size="2">HEX色碼:</font><input id="ColorPickerValue" style="background-color:'+vf+';" type="text" value="'+vf+'" size="5" onblur="ColorPickerInput(this.value);" maxlength="7">&nbsp;<input type="button" value="Click to Set" onclick="ColorPickerSet();"></center><p>');
	OpenWindow.document.write('<table border="0" cellspacing="0" cellpadding="0" width="100%">');
	var a,b,c,strA,strB,intF,intS;
	a=0; b=0; c=0;
	var intTmp=-1;
	OpenWindow.document.write('<tr>');
	for (a=0;a<=255;a=a+51){
		for (b=0;b<=255;b=b+51) {
			for (c=0;c<=255;c=c+51) {
				intTmp++;
				if (intTmp>10) {
					OpenWindow.document.write('</tr><tr>');
					intTmp=0;
				}
				var strH=chgHex(a) + chgHex(b) + chgHex(c);
				OpenWindow.document.write('<td style="text-align: center; vertical-align:middle;"><input type="button" value="#'+ strH +'" onclick="ColorPickerInput(this.value);" style="background:#'+ strH +'; padding: 0px 0px 0px 0px; border: 0px; font-size: 8pt; height: 20px; width:52px;"></td>');
			}
		}
	}
	OpenWindow.document.write('<td bgcolor="#FFFFFF"></td></tr></table></body></html>');
}
function chgHex2(numeric) {
	switch(numeric) {
		case 0:  strA='0'; break;
		case 1:  strA='1'; break;
		case 2:  strA='2'; break;
		case 3:  strA='3'; break;
		case 4:  strA='4'; break;
		case 5:  strA='5'; break;
		case 6:  strA='6'; break;
		case 7:  strA='7'; break;
		case 8:  strA='8'; break;
		case 9:  strA='9'; break;
		case 10: strA='A'; break;
		case 11: strA='B'; break;
		case 12: strA='C'; break;
		case 13: strA='D'; break;
		case 14: strA='E'; break; 
		case 15: strA='F'; break;
	}
	return strA;
}
function chgHex(numeric) {
	if(numeric<10) {
		strB='0' + numeric;
	} else if (numeric<16&&numeric>9) {
       strB='0' + chgHex2(numeric);
	} else {
		intF=0; intS=0;
		while (numeric>15) {
			numeric=numeric-15;
			numeric=numeric-1;
			intF++;
		}
		intS=numeric;
		strB=chgHex2(intF) + chgHex2(parseInt(intS));
	}
	return strB;
}
function chkConfirm(text) {
	if (!confirm(text)) { 
    	return false; 
    }
    return true;
}
function chkEmpty(vf) {
	if (!vf || vf==0 || vf=='undefined') {
		return true;
	}
	return false;
}
function chkObject(eo) {
	if (!chkEmpty(eo)) {
		if ($(eo)) {
			return true;
		}
	}
	return false;
}
function chkChecked(eo) {
	if (chkObject(eo)) {
		return $(eo).checked;
	}
	return false;
}
function innerHtml(eo, html, tf, df) {
	if (chkEmpty(html)) {
		var html = "";
	}
	if (chkObject(eo)) {
		switch (df) {
			case "f":
				html = html+getHtml(eo);
				break;
			case "b":
				
				html = getHtml(eo)+html;
				break;
		}
		if (chkEmpty(tf)) {
			$(eo).innerHTML = html;
		} else {
			set_innerHTML(eo, html);
		}
	}
}
/* innerhtml.js
 * Copyright Ma Bingyao <andot@ujn.edu.cn>
 * Version: 1.9
 * LastModified: 2006-06-04
 * This library is free.  You can redistribute it and/or modify it.
 * http://www.coolcode.cn/?p=117
 */
var global_html_pool = [];
var global_script_pool = [];
var global_script_src_pool = [];
var global_lock_pool = [];
var innerhtml_lock = null;
var document_buffer = "";
function set_innerHTML(obj_id, html, time) {
	if (innerhtml_lock == null) {
		innerhtml_lock = obj_id;
	} else if (typeof(time) == "undefined") {
		global_lock_pool[obj_id + "_html"] = html;
		window.setTimeout("set_innerHTML('" + obj_id + "', global_lock_pool['" + obj_id + "_html']);", 10);
		return;
	} else if (innerhtml_lock != obj_id) {
		global_lock_pool[obj_id + "_html"] = html;
		window.setTimeout("set_innerHTML('" + obj_id + "', global_lock_pool['" + obj_id + "_html'], " + time + ");", 10);
		return;
	}
    function get_script_id() {
		return "script_" + (new Date()).getTime().toString(36)
			+ Math.floor(Math.random() * 100000000).toString(36);
	}
    document_buffer = "";
	document.write = function (str) {
		document_buffer += str;
	}
	document.writeln = function (str) {
		document_buffer += str + "\n";
	}
	global_html_pool = [];
    var scripts = [];
	html = html.split(/<\/script>/i);
	for (var i = 0; i < html.length; i++) {
		global_html_pool[i] = html[i].replace(/<script[\s\S]*$/ig, "");
		scripts[i] = {text: '', src: '' };
		scripts[i].text = html[i].substr(global_html_pool[i].length);
		scripts[i].src = scripts[i].text.substr(0, scripts[i].text.indexOf('>') + 1);
		scripts[i].src = scripts[i].src.match(/src\s*=\s*(\"([^\"]*)\"|\'([^\']*)\'|([^\s]*)[\s>])/i);
		if (scripts[i].src) {
			if (scripts[i].src[2]) {
				scripts[i].src = scripts[i].src[2];
			} else if (scripts[i].src[3]) {
				scripts[i].src = scripts[i].src[3];
            } else if (scripts[i].src[4]) {
				scripts[i].src = scripts[i].src[4];
            } else {
				scripts[i].src = "";
			}
			scripts[i].text = "";
		} else {
			scripts[i].src = "";
			scripts[i].text = scripts[i].text.substr(scripts[i].text.indexOf('>') + 1);
			scripts[i].text = scripts[i].text.replace(/^\s*<\!--\s*/g, "");
		}
    }
	var s;
	if (typeof(time) == "undefined") {
		s = 0;
    } else {
		s = time;
	}
    var script, add_script, remove_script;
    for (var i = 0; i < scripts.length; i++) {
		var add_html = "document_buffer += global_html_pool[" + i + "];\n";
		add_html += "document.getElementById('" + obj_id + "').innerHTML = document_buffer;\n";
		script = document.createElement("script");
		if (scripts[i].src) {
			script.src = scripts[i].src;
			if (typeof(global_script_src_pool[script.src]) == "undefined") {
				global_script_src_pool[script.src] = true;
				s += 2000;
			} else {
				s += 10;
			}
		} else {
			script.text = scripts[i].text;
			s += 10;
		}
		script.defer = true;
		script.type =  "text/javascript";
		script.id = get_script_id();
		global_script_pool[script.id] = script;
		add_script = add_html;
		add_script += "document.getElementsByTagName('head').item(0)";
		add_script += ".appendChild(global_script_pool['" + script.id + "']);\n";
		window.setTimeout(add_script, s);
		remove_script = "document.getElementsByTagName('head').item(0)";
		remove_script += ".removeChild(document.getElementById('" + script.id + "'));\n";
		remove_script += "delete global_script_pool['" + script.id + "'];\n";
		window.setTimeout(remove_script, s + 10000);
	}
	var end_script = "if (document_buffer.match(/<\\/script>/i)) {\n";
	end_script += "set_innerHTML('" + obj_id + "', document_buffer, " + s + ");\n";
	end_script += "}\n";
	end_script += "else {\n";
	end_script += "document.getElementById('" + obj_id + "').innerHTML = document_buffer;\n";
	end_script += "innerhtml_lock = null;\n";
	end_script += "}";
	window.setTimeout(end_script, s);
}
function getHtml(eo) {
	if (chkObject(eo)) {
		return $(eo).innerHTML;
	}
	return;
}
function getIcon(URI, type) {
	if (!chkEmpty(URI)) {
		switch(type) {
			case 'loading':
				return '<img src="'+URI+'/img/icon_loading.gif" alt="Data Loading...">';
				break;
			case 'success':
				return '<img src="'+URI+'/img/icon_success.gif" alt="Success!">';
				break;
			case 'failed':
				return '<img src="'+URI+'/img/icon_failed.gif" alt="Failed!">';
				break;
			case 'btn_tag':
				return '<img src="'+URI+'/img/icon_button_tag.gif" alt="">&nbsp;';
				break;
		}
	}
	return;
}
function getPos(e, df) {
	switch(df) {
		case 'x':
			if (BrowserType == 1) {
				return e.clientX+document.body.scrollLeft;
			} else {
				return e.clientX+document.documentElement.scrollLeft;
			}
			break;
		case 'y':
			if (BrowserType == 1) {
				return e.clientY+document.body.scrollTop;
			} else {
				return e.clientY+document.documentElement.scrollTop;
			}
			break;
	}
	return "0";
}
function focusIn(eo) {
	if (chkObject(eo)) {
		$(eo).focus();
	}
}
function innerValue(eo, vf) {
	if (chkObject(eo)) {
		if (chkEmpty(vf)) {
			var vf = '';
		}
		$(eo).value = vf;
	}
}
function getValue(eo) {
	if (chkObject(eo)) {
		return $(eo).value;
	}
	return false;
}
//去除右邊之空白字元
function rTrim(str) {
	while(str.length >0) {
		if (str.charAt(str.length-1) != ' ') {
			break;
		}
		str = str.substring(0, str.length-1);
	}
	return str;
}
//去除左邊之空白字元
function lTrim(str) {
	while(str.length>0) {
		if (str.charAt(0) != ' ') {
			break;
		}
		str = str.substring(1, str.length);
	}
	return str;
}
//去除左右兩邊之空白字元
function trim(str) {
	return rTrim(lTrim(str));
}
function trimAllElements() {
	var formLength = document.forms.length;
	for (var i=0; i<formLength; i++) {
		var eleLength = document.forms[i].elements.length;
		for(var ii=0; ii<eleLength; ii++) {
			document.forms[i].elements[ii].value = document.forms[i].elements[ii].value.trim();
		}
	}
}
function getNamesValue(eo, i) {
	i = chkEmpty(i) ? 0 : i;
	if (document.getElementsByName(eo)[i]) {
		return document.getElementsByName(eo)[i].value;
	}
	return false;
}
function hiddenBlock(eo) {
	if (chkObject(eo)) {
		setCSSprop(eo, 'visibilty', 'hidden');
		setCSSprop(eo, 'display', 'none');
	}
}
function visibleBlock(eo) {
	if (chkObject(eo)) {
		setCSSprop(eo, 'visibilty', 'visible');
		setCSSprop(eo, 'display', '');
	}
}
function toggleBlock(teo, heo) {
	if (chkObject(teo)) {
		visibleBlock(teo);
	}
	if (chkObject(heo)) {
		hiddenBlock(heo);
	}
}
function setObjState(eo, df) {
	if (chkEmpty(df)) {
		var df = true;
		var color = "#D8D8D8";
	} else {
		df = false;
		var color = "#FFFFFF";
	}
	$(eo).disabled = df;
	$(eo).style.backgroundColor = color;
}
function clearSelect(eo) {
	var eo = $(eo);
	if (!chkEmpty(typeof(eo.options))) {
    	for (var i = eo.options.length - 1; i > -1; i--) {
	       	if (eo.options.remove) {
            	eo.options.remove(i);
       		} else {
	            eo.removeChild(eo.options[i]);
       		}
   		}
   	}
}
function setSelect(eo, d, vf, tf, selvf) {
	var eo = $(eo);
    for (var i = 0, n = d.length; i < n; i++) {
       	var opt = document.createElement('option');
       	opt.text = d[i][tf];
       	opt.value = d[i][vf];
       	if (!chkEmpty(selvf)) {
       		if (selvf == d[i][vf]) {
       			opt.selected = true;
       		}
       	}
       	if (eo.options.add) {
            eo.options.add(opt);
       	} else {
            eo.appendChild(opt);
       	}
   	}
}
function checkall(form, prefix, checkall) {
	var checkall = checkall ? checkall : 'chkall';
	for(var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];
		if(e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) {
			e.checked = form.elements[checkall].checked;
		}
	}
}
function chkIntervalDate(sdo, edo, msg) {
	if (chkObject(sdo) && chkObject(edo)) {
		var sdate = getValue(sdo);
		var edate = getValue(edo);
		if (!chkEmpty(sdate) && !chkEmpty(edate)) {
			var d1 = new Date(sdate.replace(/-/g,"/"));
			var d2 = new Date(edate.replace(/-/g,"/"));
			if (Date.parse(d1) - Date.parse(d2)>0) {
				alert(msg);
				return false;
			}
		} else if (chkEmpty(sdate)) {
			alert('輸入時間不合法');
			return false;
		}
	}
	return true;
}
function chkInputData(eo, msg) {
	if (chkObject(eo)) {
		if (chkEmpty(getValue(eo))) {
			alert(msg);
			return false;
		}
		return true;
	}
}
function chkPasswdData(sio, tio, msg) {
	if (chkObject(sio) && chkObject(tio)) {
		var s = getValue(sio);
		var t = getValue(tio);
		if (chkEmpty(s) && chkEmpty(t)) {
			return true;
		} else if (chkEmpty(s) || chkEmpty(t)) {
			alert('密碼資料填寫不完全');
			return false;
		} else if (s != t) {
			alert(msg);
			return false;
		}
		return true;
	}
}
function toggleEditor(id) {
	if (!tinyMCE.get(id)) {
		tinyMCE.execCommand('mceAddControl', false, id);
	} else {
		tinyMCE.execCommand('mceRemoveControl', false, id);
	}
}
function ajaxFormfilemanager(SiteURL, elementId) {
	var win = window.open(SiteURL + ajaxfilemanagerURI + '/ajaxfilemanager/ajaxfilemanager.php?editor=form&elementId='+elementId, 'ajaxFileImageManager', 'width=782,height=500');		
	return false;
}
function explainSwitch(eo, df) {
	if (chkObject(eo)) {
		if (chkEmpty(df)) {
			if (getElementStyle(eo, 'display') == "none") {
				visibleBlock(eo);
			} else {
				hiddenBlock(eo);
			}
		} else {
			if (df == 'v') {
				visibleBlock(eo);
			} else if (df == 'h') {
				hiddenBlock(eo);
			}
		}
	}
}
function showOpen(eo) {
	if (!document.getElementById) return false;
	if (!$(eo)) return false;
	var show = $(eo);
	show.style.width = "0px";
	show.style.height = "0px";
	show.style.display = "block";
	movement = setTimeout("animationOpen(eo)",0)
}
function animationOpen(eo) {
	if (!document.getElementById) return false;
	if (!$(eo)) return false;
	var show = $(eo);
	var xpos = parseInt(getElementStyle(eo, 'width'));
	var ypos = parseInt(getElementStyle(eo, 'height'));
	if (xpos == 760 && ypos == 420) {
		return true;
	}
	if (xpos < 760) {
		xpos+=10;
	}
	if (xpos > 760) {
		xpos-=10;
	}
	if (ypos < 420) {
		ypos+=10;
	}
	if (ypos > 420) {
		ypos-=10;
	}
	show.style.width = xpos + "px";
	show.style.height = ypos + "px";
	movement = setTimeout("animationOpen(eo)",0);
}
function showClose(eo) {
	if (!document.getElementById) return false;
	if (!$(eo)) return false;
	var show = $(eo);
	show.style.width = "1000px";
	show.style.height = "420px";
	show.style.display = "block";
	movement = setTimeout("animationClose('"+eo+"')",0)
}
function animationClose(eo) {
	if (!document.getElementById) return false;
	if (!$(eo)) return false;
	var show = $(eo);
	var xpos = parseInt(getElementStyle(eo, 'width'));
	var ypos = parseInt(getElementStyle(eo, 'height'));
	if (xpos == 0 && ypos == 0) {
		return true;
	}
	if (xpos < 0) {
		xpos+=10;
	}
	if (xpos > 0) {
		xpos-=10;
	}
	if (ypos < 0) {
		ypos+=10;
	}
	if (ypos > 0) {
		ypos-=10;
	}
	show.style.width = xpos + "px";
	show.style.height = ypos + "px";
	movement = setTimeout("animationClose('"+eo+"')",0);
}
//--Start Get Url to Div
function ahah(url, target) {
	$(target).innerHTML = ' Fetching data...';
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (req != undefined) {
		req.onreadystatechange = function() {ahahDone(url, target);};
		req.open("GET", url, true);
		req.send("");
	}
}
function ahahDone(url, target) {
	if (req.readyState == 4) { // only if req is "loaded"
		if (req.status == 200) { // only if "OK"
			$(target).innerHTML = req.responseText;
		} else {
			$(target).innerHTML=" AHAH Error:\\n"+ req.status + "\\n" +req.statusText;
		}
	}
}
function load(name, div) {
	ahah(name,div);
	return false;
}
//--Start Show Calendar
var weekend = [0,6];
var gNow = new Date();
var ggWinCal;
var headcolor = "#0C5FCB";
var headtext = "#FFFFFF";
var bordercolor = "#000000";
Calendar.Months = ["一", "二", "三", "四", "五", "六","七", "八", "九", "十", "十一", "十二"];
Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
Calendar.get_month = Calendar_get_month;
Calendar.get_daysofmonth = Calendar_get_daysofmonth;
Calendar.calc_month_year = Calendar_calc_month_year;
new Calendar();
function Calendar(p_item, p_WinCal, p_month, p_year) {
	if ((p_month == null) && (p_year == null)) return;
	if (p_WinCal == null) this.gWinCal = ggWinCal;
	else this.gWinCal = p_WinCal;
	if (p_month == null) {
		this.gMonthName = null;
		this.gMonth = null;
		this.gYearly = true;
	} else {
		this.gMonthName = Calendar.get_month(p_month);
		this.gMonth = new Number(p_month);
		this.gYearly = false;
	}
	this.gYear = p_year;
	this.gReturnItem = p_item;
}
function Calendar_print() {	ggWinCal.print(); }
function Calendar_get_month(monthNo) { return Calendar.Months[monthNo]; }
function Calendar_get_daysofmonth(monthNo, p_year) {
	if ((p_year % 4) == 0) {
		if ((p_year % 100) == 0 && (p_year % 400) != 0) return Calendar.DOMonth[monthNo];
		else return Calendar.lDOMonth[monthNo];
	} else { return Calendar.DOMonth[monthNo]; }
}
function Calendar_calc_month_year(p_Month, p_Year, incr) {
	var ret_arr = new Array();
	if (incr == -1) {
		if (p_Month == 0) {
			ret_arr[0] = 11;
			ret_arr[1] = parseInt(p_Year) - 1;
		}  else {
			ret_arr[0] = parseInt(p_Month) - 1;
			ret_arr[1] = parseInt(p_Year);
		}
	} else if (incr == 1) {
		if (p_Month == 11) {
			ret_arr[0] = 0;
			ret_arr[1] = parseInt(p_Year) + 1;
		} else {
			ret_arr[0] = parseInt(p_Month) + 1;
			ret_arr[1] = parseInt(p_Year);
		}
	}
	return ret_arr;
}
Calendar.prototype.getMonthlyCalendarCode = function() {
	var vCode = "";
	var vHeader_Code = "";
	var vData_Code = "";
	vHeader_Code = this.cal_header();
	vData_Code = this.cal_data();
	vCode = vCode + vHeader_Code + vData_Code;
	vCode = vCode + "</TABLE>";
	return vCode;
}
Calendar.prototype.show = function() {
	var vCode = "";
	this.gWinCal.document.open();
	this.wwrite("<HTML><HEAD>");
	this.wwrite("<style type='text/css'>");
	this.wwrite("<!--");
	this.wwrite("BODY { font-size: 11px; color: #004B97; font-family: Arial, Tahoma; }");
	this.wwrite(".THEAD { color: " + headtext + "; height: 20px; background-color: " + headcolor + "; }");
	this.wwrite(".TANN { height: 20px; background-color: #D5D5D5; }");
	this.wwrite(".TINPUT { height: 20px; background-color: #F5F5F5; }");
	this.wwrite(".BUTTON { padding: 0 5px; color: #154BA0; background-repeat: repeat-x; background-position: 0 50%; outline: 1px solid #86B9D6; border: 1px solid #FFFFFF !important; height: 19px !important; border: 1px solid #86B9D6; height: 21px; line-height: 17px; }");
	this.wwrite("A:visited {color: #005EBB; TEXT-DECORATION: none}");
	this.wwrite("A:link {color: #005EBB;text-decoration: none}");
	this.wwrite("A:hover {LEFT: 1px; COLOR: #FF0033; POSITION: relative; TOP: 1px; TEXT-DECORATION: none}");
	this.wwrite("-->");
	this.wwrite("</style>");
	this.wwrite("<TITLE>日曆選取 - Design By Lover@Yiima</TITLE></HEAD>");
	this.wwrite("<BODY TOPMARGIN=\"3\" LEFTMARGIN=\"3\" MARGINHEIGHT=\"3\" MARGINWIDTH=\"3\">");
	this.wwrite("<TABLE CELLSPACING=1 CELLPADDING=1 BORDER=1 BORDERCOLOR=" + bordercolor + " BORDER-STYLE:inset WIDTH='100%'>");
	this.wwrite("<TR><TD COLSPAN=\"7\" WIDTH=\"100%\" ALIGN=\"CENTER\">");
	this.wwrite("<SELECT ONCHANGE='location.href=this.options[this.selectedIndex].value;'>");
	var sYY = this.gYear - 10;
	var eYY = parseInt(this.gYear) + 10;
	for (i = sYY; i < eYY; i++) {
		if (i == parseInt(this.gYear)) {
			this.wwrite("<OPTION VALUE=\"javascript:window.opener.Build('" + this.gReturnItem + "', '" + this.gMonth + "', '" + i + "', '" + this.gFormat + "', '" + this.gReturnElement + "');\" SELECTED>");
			this.wwrite("西元 " + i + " 年");
			this.wwrite("</OPTION>");
		} else {
			this.wwrite("<OPTION VALUE=\"javascript:window.opener.Build('" + this.gReturnItem + "', '" + this.gMonth + "', '" + i + "', '" + this.gFormat + "', '" + this.gReturnElement + "');\">");
			this.wwrite("西元 " + i + " 年");
			this.wwrite("</OPTION>");
		}
	}
	this.wwrite("</SELECT>");
	this.wwrite("&nbsp;");
	this.wwrite("<SELECT ONCHANGE='location.href=this.options[this.selectedIndex].value;'>");
	for (var i = 0; i < 12; i++) {
		var j = i + 1;
		if (i == this.gMonth) {
			this.wwrite("<OPTION VALUE=\"javascript:window.opener.Build('" + this.gReturnItem + "', '" + i + "', '" + this.gYear + "', '" + this.gFormat + "', '" + this.gReturnElement + "');\" SELECTED>");
			this.wwrite( j + " 月");
			this.wwrite("</OPTION>");
		} else {
			this.wwrite("<OPTION VALUE=\"javascript:window.opener.Build('" + this.gReturnItem + "', '" + i + "', '" + this.gYear + "', '" + this.gFormat + "', '" + this.gReturnElement + "');\">");
			this.wwrite( j + " 月");
			this.wwrite("</OPTION>");
		}
	}
	this.wwrite("</SELECT>");
	this.wwrite("</TD></TR>");
	vCode = this.getMonthlyCalendarCode();
	this.wwrite(vCode);
	this.gWinCal.document.close();
}
Calendar.prototype.wwrite = function(wtext) { this.gWinCal.document.writeln(wtext); }
Calendar.prototype.wwriteA = function(wtext) { this.gWinCal.document.write(wtext); }
Calendar.prototype.cal_header = function() {
	var vCode = "";
	vCode = vCode + "<TR CLASS=\"THEAD\">";
	vCode = vCode + "<TH WIDTH='15%'>日</TH>";
	vCode = vCode + "<TH WIDTH='14%'>一</TH>";
	vCode = vCode + "<TH WIDTH='14%'>二</TH>";
	vCode = vCode + "<TH WIDTH='14%'>三</TH>";
	vCode = vCode + "<TH WIDTH='14%'>四</TH>";
	vCode = vCode + "<TH WIDTH='14%'>五</TH>";
	vCode = vCode + "<TH WIDTH='15%'>六</TH>";
	vCode = vCode + "</TR>";
	return vCode;
}
Calendar.prototype.cal_data = function() {
	var vDate = new Date();
	vDate.setDate(1);
	vDate.setMonth(this.gMonth);
	vDate.setFullYear(this.gYear);
	var vFirstDay=vDate.getDay();
	var vDay=1;
	var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
	var vOnLastDay=0;
	var vCode = "";
	vCode = vCode + "<TR ALIGN=\"CENTER\">\n";
	for (i=0; i<vFirstDay; i++) {
		vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(i) + ">&nbsp;</TD>\n";
	}
	for (j=vFirstDay; j<7; j++) {
		vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + ">" + 
			"<A HREF='#' onClick=\"self.opener.document.getElementById('" + this.gReturnItem + "').value='" + 
			this.format_data(vDay) + "'; window.close();\">" + this.format_day(vDay) + "</A></TD>\n";
		vDay=vDay + 1;
	}
	vCode = vCode + "</TR>\n";
	for (k=2; k<7; k++) {
		vCode = vCode + "<TR ALIGN=\"CENTER\">";
		for (j=0; j<7; j++) {
			vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + ">" + 
				"<A HREF='#' onClick=\"self.opener.document.getElementById('" + this.gReturnItem + "').value='" + 
				this.format_data(vDay) + "'; window.close();\">" + this.format_day(vDay) + "</A></TD>\n";
			vDay=vDay + 1;
			if (vDay > vLastDay) {
				vOnLastDay = 1;
				break;
			}
		}
		if (j == 6)	vCode = vCode + "</TR>";
		if (vOnLastDay == 1) break;
	}
	for (m=1; m<(7-j); m++) {
		if (this.gYearly) vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) + ">&nbsp;</TD>\n";
		else vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) + "><FONT COLOR='gray'>" + m + "</FONT></TD>\n";
	}
	return vCode;
}
Calendar.prototype.format_day = function(vday) {
	var vNowDay = gNow.getDate();
	var vNowMonth = gNow.getMonth();
	var vNowYear = gNow.getFullYear();
	if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear) {
		return ("<FONT COLOR=\"RED\"><B>" + vday + "</B></FONT>");
	} else { return (vday); }
}
Calendar.prototype.write_weekend_string = function(vday) {
	var i;
	for (i=0; i<weekend.length; i++) {
		if (vday == weekend[i]) return (" BGCOLOR=\"#FFB997\"");
	}
	return "";
}
Calendar.prototype.format_data = function(p_day) {
	var vData;
	var vMonth = 1 + this.gMonth;
	vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
	var vY4 = new String(this.gYear);
	var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;
	vData = vY4 + "-" + vMonth + "-" + vDD;
	return vData;
}
function Build(p_item, p_month, p_year) {
	var p_WinCal = ggWinCal;
	gCal = new Calendar(p_item, p_WinCal, p_month, p_year);
	gCal.show();
}
function showCalendar() {
	p_item = arguments[0];
	if (chkEmpty(arguments[1])) {
		p_year = new String(gNow.getFullYear().toString());
		p_month = new String(gNow.getMonth());
	} else {
		argDate = arguments[1];
		argDate_s1 = argDate.indexOf('-');
		argDate_s2 = argDate.indexOf('-', argDate_s1+1);
		p_year = argDate.substring(0, argDate_s1);
		p_month = argDate.substring(argDate_s1+1, argDate_s2)-1;
		if (chkEmpty(p_month)) {
			p_month = 12;
		}
	}
	vWinCal = window.open("", "Calendar", "width=200,height=200,status=no,resizable=no,top=200,left=200");
	vWinCal.opener = self;
	ggWinCal = vWinCal;
	Build(p_item, p_month, p_year);
}
function showDynaClock(eo, df) {
	if (chkObject(eo)) {
		var date = new Date();
		var hour = date.getHours();
		var min = date.getMinutes();
		var sec = date.getSeconds();
		var col = ":";
		var spc = " ";
		var apm = "";
		if (!chkEmpty(df)) {
			if ( hour >12 ) {
				apm="pm";
				hour=hour-12;
			} else {
				apm="am";
			}
			if (hour == 0) hour=12;
		}
		if (hour<=9) hour="0"+hour;
		if (min<=9) min="0"+min;
		if (sec<=9) sec="0"+sec;
		innerHtml(eo, hour+col+min+col+sec+spc+apm);
	}
}
function showLoading(eo, temp, df) {
	if (chkObject(eo)) {
		switch(df) {
			default:
				var showhtml = '<img src="'+temp+'/images/icon_loading_line.gif"> loading...';
				innerHtml(eo, showhtml);
				break;
		}
	}
}
function getElementStyle(elemID, CSSStyleProp) {
    var elem = $(elemID);
    if (elem.currentStyle) {
        return elem.currentStyle[CSSStyleProp];
    } else if (window.getComputedStyle) {
        var compStyle = window.getComputedStyle(elem, "");
        return compStyle.getPropertyValue(CSSStyleProp);
    }
    return false;
}
function preCSSprop(co, eo, property, purpose, value, unit) {
	if (chkObject(eo)) {
		var thisCSS = new Array;
		thisCSS[eo] = new Array;
		thisCSS[eo][property] = {
			'purpose'	:	purpose,
			'value'		:	value,
			'unit'		:	unit
		}
		if (chkObject(co)) {
			if (chkChecked(co)) {
				runCSSprop(thisCSS);
			}
		}
	}
}
function convCSSprop(property) {
	if (!chkEmpty(property)) {
		switch(property) {
			case 'border-top':
					return 'borderTop';
				break;
			case 'border-top-width':
					return 'borderTopWidth';
				break;
			case 'border-top-color':
					return 'borderTopColor';
				break;
			case 'border-top-style':
					return 'borderTopStyle';
				break;
			case 'border-right':
					return 'borderRight';
				break;
				case 'border-right-width':
					return 'borderRightWidth';
				break;
			case 'border-right-color':
					return 'borderRightColor';
				break;
			case 'border-right-style':
					return 'borderRightStyle';
				break;
			case 'border-bottom':
					return 'borderBottom';
				break;
			case 'border-bottom-width':
					return 'borderBottomWidth';
				break;
			case 'border-bottom-color':
					return 'borderBottomColor';
				break;
			case 'border-bottom-style':
					return 'borderBottomStyle';
				break;
			case 'border-left':
					return 'borderLeft';
				break;
			case 'border-left-width':
					return 'borderLeftWidth';
				break;
			case 'border-left-color':
					return 'borderLeftColor';
				break;
			case 'border-left-style':
					return 'borderLeftStyle';
				break;
			case 'background-color':
					return 'backgroundColor';
				break;
			case 'background-image':
					return 'backgroundImage';
				break;
			case 'background-repeat':
					return 'backgroundRepeat';
				break;
			case 'font-size':
					return 'fontSize';
				break;
			default:
					return property;
				break;
		}
	}
	return false;
}
function setCSSprop(eo, prop, value) {
	if (chkObject(eo)) {
		var comm = "$('"+eo+"').style."+convCSSprop(prop)+" = '"+value+"';";
		eval(comm);
	}
}
function runCSSprop(css) {
	var comm = new String;
	for(var eo in css) {
		comm += "$('"+ eo +"').style.";
		for(var prop in css[eo]) {
			var obj = css[eo][prop];
			switch(obj['purpose']) {
				case 'measure':
						if (obj['unit'] == "auto") {
							comm += convCSSprop(prop) + " = '" + obj['unit'] + "';";
						} else {
							var value = chkEmpty(obj['value']) ? 0 : parseInt(obj['value']);
							value = isNaN(value) ? 0 : value;
							comm += convCSSprop(prop) + " = '" + value + obj['unit'] + "';";
						}
					break;
				case 'tints':
						comm += convCSSprop(prop) + " = '" + obj['value'] + "';";
					break;
				case 'image':
						comm += convCSSprop(prop) + " = 'url(" + obj['value'] + ")';";
					break;
				case 'repeat':
						comm += convCSSprop(prop) + " = '" + obj['value'] + "';";
					break;
				case 'style':
						comm += convCSSprop(prop) + " = '" + obj['value'] + "';";
					break;
			}
		}
	}
	eval(comm);
}
function SHA256(s){
	var chrsz   = 8;
	var hexcase = 0;
	function safe_add (x, y) {
		var lsw = (x & 0xFFFF) + (y & 0xFFFF);
		var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
		return (msw << 16) | (lsw & 0xFFFF);
	}
	function S (X, n) { return ( X >>> n ) | (X << (32 - n)); }
	function R (X, n) { return ( X >>> n ); }
	function Ch(x, y, z) { return ((x & y) ^ ((~x) & z)); }
	function Maj(x, y, z) { return ((x & y) ^ (x & z) ^ (y & z)); }
	function Sigma0256(x) { return (S(x, 2) ^ S(x, 13) ^ S(x, 22)); }
	function Sigma1256(x) { return (S(x, 6) ^ S(x, 11) ^ S(x, 25)); }
	function Gamma0256(x) { return (S(x, 7) ^ S(x, 18) ^ R(x, 3)); }
	function Gamma1256(x) { return (S(x, 17) ^ S(x, 19) ^ R(x, 10)); }
	function core_sha256 (m, l) {
		var K = new Array(0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0xFC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x6CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2);
		var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19);
		var W = new Array(64);
		var a, b, c, d, e, f, g, h, i, j;
		var T1, T2;
		m[l >> 5] |= 0x80 << (24 - l % 32);
		m[((l + 64 >> 9) << 4) + 15] = l;
		for ( var i = 0; i<m.length; i+=16 ) {
			a = HASH[0];
			b = HASH[1];
			c = HASH[2];
			d = HASH[3];
			e = HASH[4];
			f = HASH[5];
			g = HASH[6];
			h = HASH[7];
			for ( var j = 0; j<64; j++) {
				if (j < 16) W[j] = m[j + i];
				else W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]);
				T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]);
				T2 = safe_add(Sigma0256(a), Maj(a, b, c));
				h = g;
				g = f;
				f = e;
				e = safe_add(d, T1);
				d = c;
				c = b;
				b = a;
				a = safe_add(T1, T2);
			}
			HASH[0] = safe_add(a, HASH[0]);
			HASH[1] = safe_add(b, HASH[1]);
			HASH[2] = safe_add(c, HASH[2]);
			HASH[3] = safe_add(d, HASH[3]);
			HASH[4] = safe_add(e, HASH[4]);
			HASH[5] = safe_add(f, HASH[5]);
			HASH[6] = safe_add(g, HASH[6]);
			HASH[7] = safe_add(h, HASH[7]);
		}
		return HASH;
	}
	function str2binb (str) {
		var bin = Array();
		var mask = (1 << chrsz) - 1;
		for(var i = 0; i < str.length * chrsz; i += chrsz) {
			bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32);
		}
		return bin;
	}
	function Utf8Encode(string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
		for (var n = 0; n < string.length; n++) {
			var c = string.charCodeAt(n);
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
		}
		return utftext;
	}
	function binb2hex (binarray) {
		var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
		var str = "";
		for(var i = 0; i < binarray.length * 4; i++) {
			str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
			hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8  )) & 0xF);
		}
		return str;
	}
	s = Utf8Encode(s);
	return binb2hex(core_sha256(str2binb(s), s.length * chrsz));
}
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.documentElement.scrollWidth;
		yScroll = document.documentElement.scrollHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight) {
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth) {
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}
function fixIe6Png(URI) {
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	if ((version >= 5.5 && version < 7.0) && (document.body.filters)) {
    	for(var i=0; i<document.images.length; i++) {
    		var img = document.images[i];
      		var imgName = img.src.toUpperCase();
      		if (imgName.indexOf(".PNG") > 0) {
        		var width = img.width;
        		var height = img.height;
        		var sizingMethod = (img.className.toLowerCase().indexOf("scale") >= 0)? "scale" : "image";
        		img.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src.replace('%23', '%2523').replace("'", "%27") + "', sizingMethod='" + sizingMethod + "')";
        		img.src = URI + "/img/png_blank.gif";
        		img.width = width; 
        		img.height = height;
			}
		}
	}
}
function changeSelected(so, vl) {
	var i = 0;
	var so = $(so);
	for(i=0; i<so.options.length; i++) {
		if (so.options[i].value == vl) {
			so.options[i].selected = true;
			break;
		}
	}
}
function exSelected(id, vtp, df) {
	if (!chkEmpty(id)) {
		if (chkEmpty(vtp) && chkEmpty(dtp)) {
			alert('Configuration Transfer Error!!');
		} else {
			var tp = chkEmpty(vtp) ? dtp : vtp;
		}
		var vl = getValue('exActivable_' + id);
		if (chkEmpty(vl) && chkEmpty(df)) {
			alert('You Must Activable a Reulst!!');
			location.reload();
		} else {
			var data = new Array(tp, id, vl);
			rpc.rpc_exSelected(data, function(result) {
				if (!result) {
					alert('RPC Error!! Please Send Message for Our Service.');
				}
				location.reload();
			});
		}
	}
}
function editField(eo, id, fd, way, vtp, size, so) {
	if (chkObject(eo)) {
		if (chkEmpty(id)) { id = 'new'; }
		if (chkEmpty(vtp) && chkEmpty(dtp)) {
			alert('Configuration Transfer Error!!');
		} else {
			var tp = chkEmpty(vtp) ? dtp : vtp;
		}
		if (!chkEmpty(fd)) {
			var data = new Array(eo, id, fd, tp, way, size, so);
			rpc.rpc_editField(data, function(result) {
				if (result) {
					var rem_html = getHtml(eo);
					if (chkEmpty(thisPageRem['cast'])) {
						thisPageRem['cast'] = true;
						thisPageRem[eo] = rem_html;
					}
					innerHtml(eo, result['html']);
					if (way == 'content') {
						explainSwitch('ctrl_' + id, 'h');
						toggleEditor(result['elmid']);
					}
				} else {
					alert('RPC Error!! Please Send Message for Our Service.');
				}
			});
		}
	}
}
function saveField(eo, io, id, fd, way, vtp) {
	if (chkObject(eo)) {
		if (chkEmpty(id)) { id = 'new'; }
		if (chkEmpty(vtp) && chkEmpty(dtp)) {
			alert('Configuration Transfer Error!!');
		} else {
			var tp = chkEmpty(vtp) ? dtp : vtp;
		}
		if (!chkEmpty(fd)) {
			var vl = (way == 'content') ? tinyMCE.get(io).getContent() : getValue(io);
			var data = new Array(eo, id, fd, tp, way, vl);
			rpc.rpc_saveField(data, function(result) {
				if (result) {
					thisPageRem['cast'] = false;
					if (id == 'new') {
						location.reload();
					} else {
						innerHtml(eo, result);
						if (way == 'content') {
							explainSwitch('ctrl_' + id, 'v');
						}
					}
				} else {
					alert('RPC Error!! Please Send Message for Our Service.');
				}
			});
		}
	}
}
function resotreField(eo) {
	if (chkObject(eo)) {
		if (!chkEmpty(thisPageRem[eo])) {
			innerHtml(eo, thisPageRem[eo]);
			thisPageRem['cast'] = false;
			delete thisPageRem[eo];
		} else {
			innerHtml(eo, '&nbsp;');
		}
	}
}