PageSourceSearch

https://bhmtsff.com/static/js/common.js?e89

js bhmtsff.com collected 2026-09-24 11:48:16 UTC 71,988 bytes, 2,261 lines download raw bytes

1/*
2	[Discuz!] (C)2001-2099 Comsenz Inc.
3	This is NOT a freeware, use is subject to license terms
4
5	$Id: common.js 36359 2017-01-20 05:06:45Z nemohou $
6*/
7
8function $(id) {
9	return !id ? null : document.getElementById(id);
10}
11
12function $C(classname, ele, tag) {
13	var returns = [];
14	ele = ele || document;
15	tag = tag || '*';
16	if(ele.getElementsByClassName) {
17		var eles = ele.getElementsByClassName(classname);
18		if(tag != '*') {
19			for (var i = 0, L = eles.length; i < L; i++) {
20				if (eles[i].tagName.toLowerCase() == tag.toLowerCase()) {
21						returns.push(eles[i]);
22				}
23			}
24		} else {
25			returns = eles;
26		}
27	}else {
28		eles = ele.getElementsByTagName(tag);
29		var pattern = new RegExp("(^|\\s)"+classname+"(\\s|$)");
30		for (i = 0, L = eles.length; i < L; i++) {
31				if (pattern.test(eles[i].className)) {
32						returns.push(eles[i]);
33				}
34		}
35	}
36	return returns;
37}
38
39function _attachEvent(obj, evt, func, eventobj) {
40	eventobj = !eventobj ? obj : eventobj;
41	if(obj.addEventListener) {
42		obj.addEventListener(evt, func, false);
43	} else if(eventobj.attachEvent) {
44		obj.attachEvent('on' + evt, func);
45	}
46}
47
48function _detachEvent(obj, evt, func, eventobj) {
49	eventobj = !eventobj ? obj : eventobj;
50	if(obj.removeEventListener) {
51		obj.removeEventListener(evt, func, false);
52	} else if(eventobj.detachEvent) {
53		obj.detachEvent('on' + evt, func);
54	}
55}
56
57function browserVersion(types) {
58	var other = 1;
59	for(i in types) {
60		var v = types[i] ? types[i] : i;
61		if(USERAGENT.indexOf(v) != -1) {
62			var re = new RegExp(v + '(\\/|\\s|:)([\\d\\.]+)', 'ig');
63			var matches = re.exec(USERAGENT);
64			var ver = matches != null ? matches[2] : 0;
65			other = ver !== 0 && v != 'mozilla' ? 0 : other;
66		}else {
67			var ver = 0;
68		}
69		eval('BROWSER.' + i + '= ver');
70	}
71	BROWSER.other = other;
72}
73
74function getEvent() {
75	if(document.all) return window.event;
76	func = getEvent.caller;
77	while(func != null) {
78		var arg0 = func.arguments[0];
79		if (arg0) {
80			if((arg0.constructor  == Event || arg0.constructor == MouseEvent) || (typeof(arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
81				return arg0;
82			}
83		}
84		func=func.caller;
85	}
86	return null;
87}
88
89function isUndefined(variable) {
90	return typeof variable == 'undefined' ? true : false;
91}
92
93function in_array(needle, haystack) {
94	if(typeof needle == 'string' || typeof needle == 'number') {
95		for(var i in haystack) {
96			if(haystack[i] == needle) {
97					return true;
98			}
99		}
100	}
101	return false;
102}
103
104function trim(str) {
105	return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
106}
107
108function strlen(str) {
109	return (BROWSER.ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
110}
111
112function mb_strlen(str) {
113	var len = 0;
114	for(var i = 0; i < str.length; i++) {
115		len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1;
116	}
117	return len;
118}
119
120function mb_cutstr(str, maxlen, dot) {
121	var len = 0;
122	var ret = '';
123	var dot = !dot ? '...' : dot;
124	maxlen = maxlen - dot.length;
125	for(var i = 0; i < str.length; i++) {
126		len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1;
127		if(len > maxlen) {
128			ret += dot;
129			break;
130		}
131		ret += str.substr(i, 1);
132	}
133	return ret;
134}
135
136function preg_replace(search, replace, str, regswitch) {
137	var regswitch = !regswitch ? 'ig' : regswitch;
138	var len = search.length;
139	for(var i = 0; i < len; i++) {
140		re = new RegExp(search[i], regswitch);
141		str = str.replace(re, typeof replace == 'string' ? replace : (replace[i] ? replace[i] : replace[0]));
142	}
143	return str;
144}
145
146function htmlspecialchars(str) {
147	return preg_replace(['&', '<', '>', '"'], ['&amp;', '&lt;', '&gt;', '&quot;'], str);
148}
149
150function display(id) {
151	var obj = $(id);
152	if(obj.style.visibility) {
153		obj.style.visibility = obj.style.visibility == 'visible' ? 'hidden' : 'visible';
154	} else {
155		obj.style.display = obj.style.display == '' ? 'none' : '';
156	}
157}
158
159function checkall(form, prefix, checkall) {
160	var checkall = checkall ? checkall : 'chkall';
161	count = 0;
162	for(var i = 0; i < form.elements.length; i++) {
163		var e = form.elements[i];
164		if(e.name && e.name != checkall && !e.disabled && (!prefix || (prefix && e.name.match(prefix)))) {
165			e.checked = form.elements[checkall].checked;
166			if(e.checked) {
167				count++;
168			}
169		}
170	}
171	return count;
172}
173
174function setcookie(cookieName, cookieValue, seconds, path, domain, secure) {
175	if(cookieValue == '' || seconds < 0) {
176		cookieValue = '';
177		seconds = -2592000;
178	}
179	if(seconds) {
180		var expires = new Date();
181		expires.setTime(expires.getTime() + seconds * 1000);
182	}
183	domain = !domain ? cookiedomain : domain;
184	path = !path ? cookiepath : path;
185	document.cookie = escape(cookiepre + cookieName) + '=' + escape(cookieValue)
186		+ (expires ? '; expires=' + expires.toGMTString() : '')
187		+ '; path=' + (path ? path : '/')
188		+ (domain ? '; domain=' + domain : '')
189		+ (secure ? '; secure' : '');
190}
191
192function getcookie(name, nounescape) {
193	name = cookiepre + name;
194	var cookie_start = document.cookie.indexOf(name);
195	var cookie_end = document.cookie.indexOf(";", cookie_start);
196	if(cookie_start == -1) {
197		return '';
198	} else {
199		var v = document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length));
200		return !nounescape ? unescape(v) : v;
201	}
202}
203
204function Ajax(recvType, waitId) {
205	var aj = new Object();
206	aj.loading = '請稍候...';
207	aj.recvType = recvType ? recvType : 'XML';
208	aj.waitId = waitId ? $(waitId) : null;
209	aj.resultHandle = null;
210	aj.sendString = '';
211	aj.targetUrl = '';
212	aj.setLoading = function(loading) {
213		if(typeof loading !== 'undefined' && loading !== null) aj.loading = loading;
214	};
215	aj.setRecvType = function(recvtype) {
216		aj.recvType = recvtype;
217	};
218	aj.setWaitId = function(waitid) {
219		aj.waitId = typeof waitid == 'object' ? waitid : $(waitid);
220	};
221	aj.createXMLHttpRequest = function() {
222		var request = false;
223		if(window.XMLHttpRequest) {
224			request = new XMLHttpRequest();
225			if(request.overrideMimeType) {
226				request.overrideMimeType('text/xml');
227			}
228		} else if(window.ActiveXObject) {
229			var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
230			for(var i=0; i<versions.length; i++) {
231				try {
232					request = new ActiveXObject(versions[i]);
233					if(request) {
234						return request;
235					}
236				} catch(e) {}
237			}
238		}
239		return request;
240	};
241	aj.XMLHttpRequest = aj.createXMLHttpRequest();
242	aj.showLoading = function() {
243		if(aj.waitId && (aj.XMLHttpRequest.readyState != 4 || aj.XMLHttpRequest.status != 200)) {
244			aj.waitId.style.display = '';
245			aj.waitId.innerHTML = '<span><img src="' + IMGDIR + '/loading.gif" class="vm"> ' + aj.loading + '</span>';
246		}
247	};
248	aj.processHandle = function() {
249		if(aj.XMLHttpRequest.readyState == 4 && aj.XMLHttpRequest.status == 200) {
250			if(aj.waitId) {
251				aj.waitId.style.display = 'none';
252			}
253			if(aj.recvType == 'HTML') {
254				aj.resultHandle(aj.XMLHttpRequest.responseText, aj);
255			} else if(aj.recvType == 'XML') {
256				if(!aj.XMLHttpRequest.responseXML || !aj.XMLHttpRequest.responseXML.lastChild || aj.XMLHttpRequest.responseXML.lastChild.localName == 'parsererror') {
257					aj.resultHandle('' , aj);
258				} else {
259					aj.resultHandle(aj.XMLHttpRequest.responseXML.lastChild.firstChild.nodeValue, aj);
260				}
261			} else if(aj.recvType == 'JSON') {
262				var s = null;
263				try {
264					s = (new Function("return ("+aj.XMLHttpRequest.responseText+")"))();
265				} catch (e) {
266					s = null;
267				}
268				aj.resultHandle(s, aj);
269			}
270		}
271	};
272	aj.get = function(targetUrl, resultHandle) {
273		targetUrl = hostconvert(targetUrl);
274		setTimeout(function(){aj.showLoading()}, 250);
275		aj.targetUrl = targetUrl;
276		aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
277		aj.resultHandle = resultHandle;
278		var attackevasive = isUndefined(attackevasive) ? 0 : attackevasive;
279		if(window.XMLHttpRequest) {
280			aj.XMLHttpRequest.open('GET', aj.targetUrl);
281			aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
282			aj.XMLHttpRequest.send(null);
283		} else {
284			aj.XMLHttpRequest.open("GET", targetUrl, true);
285			aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
286			aj.XMLHttpRequest.send();
287		}
288	};
289	aj.post = function(targetUrl, sendString, resultHandle) {
290		targetUrl = hostconvert(targetUrl);
291		setTimeout(function(){aj.showLoading()}, 250);
292		aj.targetUrl = targetUrl;
293		aj.sendString = sendString;
294		aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
295		aj.resultHandle = resultHandle;
296		aj.XMLHttpRequest.open('POST', targetUrl);
297		aj.XMLHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
298		aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
299		aj.XMLHttpRequest.send(aj.sendString);
300	};
301	aj.getJSON = function(targetUrl, resultHandle) {
302		aj.setRecvType('JSON');
303		aj.get(targetUrl+'&ajaxdata=json', resultHandle);
304	};
305	aj.getHTML = function(targetUrl, resultHandle) {
306		aj.setRecvType('HTML');
307		aj.get(targetUrl+'&ajaxdata=html', resultHandle);
308	};
309	return aj;
310}
311
312function getHost(url) {
313	var host = "null";
314	if(typeof url == "undefined"|| null == url) {
315		url = window.location.href;
316	}
317	var regex = /^\w+\:\/\/([^\/]*).*/;
318	var match = url.match(regex);
319	if(typeof match != "undefined" && null != match) {
320		host = match[1];
321	}
322	return host;
323}
324
325function hostconvert(url) {
326	if(!url.match(/^https?:\/\//)) url = SITEURL + url;
327	var url_host = getHost(url);
328	var cur_host = getHost().toLowerCase();
329	if(url_host && cur_host != url_host) {
330		url = url.replace(url_host, cur_host);
331	}
332	return url;
333}
334
335function newfunction(func) {
336	var args = [];
337	for(var i=1; i<arguments.length; i++) args.push(arguments[i]);
338	return function(event) {
339		doane(event);
340		window[func].apply(window, args);
341		return false;
342	}
343}
344
345function evalscript(s) {
346	if(s.indexOf('<script') == -1) return s;
347	var p = /<script[^\>]*?>([^\x00]*?)<\/script>/ig;
348	var arr = [];
349	while(arr = p.exec(s)) {
350		var p1 = /<script[^\>]*?src=\"([^\>]*?)\"[^\>]*?(reload=\"1\")?(?:charset=\"([\w\-]+?)\")?><\/script>/i;
351		var arr1 = [];
352		arr1 = p1.exec(arr[0]);
353		if(arr1) {
354			appendscript(arr1[1], '', arr1[2], arr1[3]);
355		} else {
356			p1 = /<script(.*?)>([^\x00]+?)<\/script>/i;
357			arr1 = p1.exec(arr[0]);
358			appendscript('', arr1[2], arr1[1].indexOf('reload=') != -1);
359		}
360	}
361	return s;
362}
363
364
365function safescript(id, call, seconds, times, timeoutcall, endcall, index) {
366	seconds = seconds || 1000;
367	times = times || 0;
368	var checked = true;
369	try {
370		if(typeof call == 'function') {
371			call();
372		} else {
373			eval(call);
374		}
375	} catch(e) {
376		checked = false;
377	}
378	if(!checked) {
379		if(!safescripts[id] || !index) {
380			safescripts[id] = safescripts[id] || [];
381			safescripts[id].push({
382				'times':0,
383				'si':setInterval(function () {
384					safescript(id, call, seconds, times, timeoutcall, endcall, safescripts[id].length);
385				}, seconds)
386			});
387		} else {
388			index = (index || 1) - 1;
389			safescripts[id][index]['times']++;
390			if(safescripts[id][index]['times'] >= times) {
391				clearInterval(safescripts[id][index]['si']);
392				if(typeof timeoutcall == 'function') {
393					timeoutcall();
394				} else {
395					eval(timeoutcall);
396				}
397			}
398		}
399	} else {
400		try {
401			index = (index || 1) - 1;
402			if(safescripts[id][index]['si']) {
403				clearInterval(safescripts[id][index]['si']);
404			}
405			if(typeof endcall == 'function') {
406				endcall();
407			} else {
408				eval(endcall);
409			}
410		} catch(e) {}
411	}
412}
413
414function $F(func, args, script) {
415	var run = function () {
416		var argc = args.length, s = '';
417		for(i = 0;i < argc;i++) {
418			s += ',args[' + i + ']';
419		}
420		eval('var check = typeof ' + func + ' == \'function\'');
421		if(check) {
422			eval(func + '(' + s.substr(1) + ')');
423		} else {
424			setTimeout(function () {checkrun();}, 50);
425		}
426	};
427	var checkrun = function () {
428		if(JSLOADED[src]) {
429			run();
430		} else {
431			setTimeout(function () {checkrun();}, 50);
432		}
433	};
434	script = script || 'common_extra';
435	src = JSPATH + script + '.js?' + VERHASH;
436	if(!JSLOADED[src]) {
437		appendscript(src);
438	}
439	return checkrun();
440}
441
442function appendscript(src, text, reload, charset) {
443	var id = hash(src + text);
444	if(!reload && in_array(id, evalscripts)) return;
445	if(reload && $(id)) {
446		$(id).parentNode.removeChild($(id));
447	}
448
449	evalscripts.push(id);
450	var scriptNode = document.createElement("script");
451	scriptNode.type = "text/javascript";
452	scriptNode.id = id;
453	scriptNode.charset = charset ? charset : (BROWSER.firefox ? document.characterSet : document.charset);
454	try {
455		if(src) {
456			scriptNode.src = src;
457			scriptNode.onloadDone = false;
458			scriptNode.onload = function () {
459				scriptNode.onloadDone = true;
460				JSLOADED[src] = 1;
461			};
462			scriptNode.onreadystatechange = function () {
463				if((scriptNode.readyState == 'loaded' || scriptNode.readyState == 'complete') && !scriptNode.onloadDone) {
464					scriptNode.onloadDone = true;
465					JSLOADED[src] = 1;
466				}
467			};
468		} else if(text){
469			scriptNode.text = text;
470		}
471		document.getElementsByTagName('head')[0].appendChild(scriptNode);
472	} catch(e) {}
473}
474
475function hash(string, length) {
476	var length = length ? length : 32;
477	var start = 0;
478	var i = 0;
479	var result = '';
480	filllen = length - string.length % length;
481	for(i = 0; i < filllen; i++){
482		string += "0";
483	}
484	while(start < string.length) {
485		result = stringxor(result, string.substr(start, length));
486		start += length;
487	}
488	return result;
489}
490
491function stringxor(s1, s2) {
492	var s = '';
493	var hash = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
494	var max = Math.max(s1.length, s2.length);
495	for(var i=0; i<max; i++) {
496		var k = s1.charCodeAt(i) ^ s2.charCodeAt(i);
497		s += hash.charAt(k % 52);
498	}
499	return s;
500}
501
502function ajaxupdateevents(obj, tagName) {
503	$F('_ajaxupdateevents', arguments, 'ajax');
504}
505
506function ajaxupdateevent(o) {
507	$F('_ajaxupdateevent', arguments, 'ajax');
508}
509
510function ajaxget(url, showid, waitid, loading, display, recall) {
511	$F('_ajaxget', arguments, 'ajax');
512}
513
514function ajaxpost(formid, showid, waitid, showidclass, submitbtn, recall) {
515	$F('_ajaxpost', arguments, 'ajax');
516}
517
518function ajaxmenu(ctrlObj, timeout, cache, duration, pos, recall, idclass, contentclass) {
519	$F('_ajaxmenu', arguments, 'ajax');
520}
521
522function ajaxinnerhtml(showid, s) {
523	$F('_ajaxinnerhtml', arguments, 'ajax');
524}
525
526function showPreview(val, id) {
527	var showObj = $(id);
528	if(showObj) {
529		showObj.innerHTML = val.replace(/\n/ig, "<bupdateseccoder />");
530	}
531}
532
533function showloading(display, waiting) {
534	var display = display ? display : 'block';
535	var waiting = waiting ? waiting : '請稍候...';
536	$('ajaxwaitid').innerHTML = waiting;
537	$('ajaxwaitid').style.display = display;
538}
539
540function doane(event, preventDefault, stopPropagation) {
541	var preventDefault = isUndefined(preventDefault) ? 1 : preventDefault;
542	var stopPropagation = isUndefined(stopPropagation) ? 1 : stopPropagation;
543	e = event ? event : window.event;
544	if(!e) {
545		e = getEvent();
546	}
547	if(!e) {
548		return null;
549	}
550	if(preventDefault) {
551		if(e.preventDefault) {
552			e.preventDefault();
553		} else {
554			e.returnValue = false;
555		}
556	}
557	if(stopPropagation) {
558		if(e.stopPropagation) {
559			e.stopPropagation();
560		} else {
561			e.cancelBubble = true;
562		}
563	}
564	return e;
565}
566
567function loadcss(cssname) {
568	if(!CSSLOADED[cssname]) {
569		var csspath = (typeof CSSPATH == 'undefined' ? 'data/cache/style_' : CSSPATH);
570		if(!$('css_' + cssname)) {
571			css = document.createElement('link');
572			css.id = 'css_' + cssname,
573			css.type = 'text/css';
574			css.rel = 'stylesheet';
575			css.href = csspath + STYLEID + '_' + cssname + '.css?' + VERHASH;
576			var headNode = document.getElementsByTagName("head")[0];
577			headNode.appendChild(css);
578		} else {
579			$('css_' + cssname).href = csspath + STYLEID + '_' + cssname + '.css?' + VERHASH;
580		}
581		CSSLOADED[cssname] = 1;
582	}
583}
584
585function showMenu(v) {
586	var ctrl
586id = isUndefined(v['ctrlid']) ? v : v['ctrlid'];
587	var showid = isUndefined(v['showid']) ? ctrlid : v['showid'];
588	var menuid = isUndefined(v['menuid']) ? showid + '_menu' : v['menuid'];
589	var ctrlObj = $(ctrlid);
590	var menuObj = $(menuid);
591	if(!menuObj) return;
592	var mtype = isUndefined(v['mtype']) ? 'menu' : v['mtype'];
593	var evt = isUndefined(v['evt']) ? 'mouseover' : v['evt'];
594	var pos = isUndefined(v['pos']) ? '43' : v['pos'];
595	var layer = isUndefined(v['layer']) ? 1 : v['layer'];
596	var duration = isUndefined(v['duration']) ? 2 : v['duration'];
597	var timeout = isUndefined(v['timeout']) ? 250 : v['timeout'];
598	var maxh = isUndefined(v['maxh']) ? 600 : v['maxh'];
599	var cache = isUndefined(v['cache']) ? 1 : v['cache'];
600	var drag = isUndefined(v['drag']) ? '' : v['drag'];
601	var dragobj = drag && $(drag) ? $(drag) : menuObj;
602	var fade = isUndefined(v['fade']) ? 0 : v['fade'];
603	var cover = isUndefined(v['cover']) ? 0 : v['cover'];
604	var zindex = isUndefined(v['zindex']) ? JSMENU['zIndex']['menu'] : v['zindex'];
605	var ctrlclass = isUndefined(v['ctrlclass']) ? '' : v['ctrlclass'];
606	var winhandlekey = isUndefined(v['win']) ? '' : v['win'];
607	if(winhandlekey && ctrlObj && !ctrlObj.getAttribute('fwin')) {
608		ctrlObj.setAttribute('fwin', winhandlekey);
609	}
610	zindex = cover ? zindex + 500 : zindex;
611	if(typeof JSMENU['active'][layer] == 'undefined') {
612		JSMENU['active'][layer] = [];
613	}
614
615	for(i in EXTRAFUNC['showmenu']) {
616		try {
617			eval(EXTRAFUNC['showmenu'][i] + '()');
618		} catch(e) {}
619	}
620
621	if(evt == 'click' && in_array(menuid, JSMENU['active'][layer]) && mtype != 'win') {
622		hideMenu(menuid, mtype);
623		return;
624	}
625	if(mtype == 'menu') {
626		hideMenu(layer, mtype);
627	}
628
629	if(ctrlObj) {
630		if(!ctrlObj.getAttribute('initialized')) {
631			ctrlObj.setAttribute('initialized', true);
632			ctrlObj.unselectable = true;
633
634			ctrlObj.outfunc = typeof ctrlObj.onmouseout == 'function' ? ctrlObj.onmouseout : null;
635			ctrlObj.onmouseout = function() {
636				if(this.outfunc) this.outfunc();
637				if(duration < 3 && !JSMENU['timer'][menuid]) {
638					JSMENU['timer'][menuid] = setTimeout(function () {
639						hideMenu(menuid, mtype);
640					}, timeout);
641				}
642			};
643
644			ctrlObj.overfunc = typeof ctrlObj.onmouseover == 'function' ? ctrlObj.onmouseover : null;
645			ctrlObj.onmouseover = function(e) {
646				doane(e);
647				if(this.overfunc) this.overfunc();
648				if(evt == 'click') {
649					clearTimeout(JSMENU['timer'][menuid]);
650					JSMENU['timer'][menuid] = null;
651				} else {
652					for(var i in JSMENU['timer']) {
653						if(JSMENU['timer'][i]) {
654							clearTimeout(JSMENU['timer'][i]);
655							JSMENU['timer'][i] = null;
656						}
657					}
658				}
659			};
660		}
661	}
662
663	if(!menuObj.getAttribute('initialized')) {
664		menuObj.setAttribute('initialized', true);
665		menuObj.ctrlkey = ctrlid;
666		menuObj.mtype = mtype;
667		menuObj.layer = layer;
668		menuObj.cover = cover;
669		if(ctrlObj && ctrlObj.getAttribute('fwin')) {menuObj.scrolly = true;}
670		menuObj.style.position = 'absolute';
671		menuObj.style.zIndex = zindex + layer;
672		menuObj.onclick = function(e) {
673			return doane(e, 0, 1);
674		};
675		if(duration < 3) {
676			if(duration > 1) {
677				menuObj.onmouseover = function() {
678					clearTimeout(JSMENU['timer'][menuid]);
679					JSMENU['timer'][menuid] = null;
680				};
681			}
682			if(duration != 1) {
683				menuObj.onmouseout = function() {
684					JSMENU['timer'][menuid] = setTimeout(function () {
685						hideMenu(menuid, mtype);
686					}, timeout);
687				};
688			}
689		}
690		if(cover) {
691			var coverObj = document.createElement('div');
692			coverObj.id = menuid + '_cover';
693			coverObj.style.position = 'absolute';
694			coverObj.style.zIndex = menuObj.style.zIndex - 1;
695			coverObj.style.left = coverObj.style.top = '0px';
696			coverObj.style.width = '100%';
697			coverObj.style.height = Math.max(document.documentElement.clientHeight, document.body.offsetHeight) + 'px';
698			coverObj.style.backgroundColor = '#000';
699			coverObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=50)';
700			coverObj.style.opacity = 0.5;
701			coverObj.onclick = function () {hideMenu();};
702			$('append_parent').appendChild(coverObj);
703			_attachEvent(window, 'load', function () {
704				coverObj.style.height = Math.max(document.documentElement.clientHeight, document.body.offsetHeight) + 'px';
705			}, document);
706		}
707	}
708	if(drag) {
709		dragobj.style.cursor = 'move';
710		dragobj.onmousedown = function(event) {try{dragMenu(menuObj, event, 1);}catch(e){}};
711	}
712
713	if(cover) $(menuid + '_cover').style.display = '';
714	if(fade) {
715		var O = 0;
716		var fadeIn = function(O) {
717			if(O > 100) {
718				clearTimeout(fadeInTimer);
719				return;
720			}
721			menuObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + O + ')';
722			menuObj.style.opacity = O / 100;
723			O += 20;
724			var fadeInTimer = setTimeout(function () {
725				fadeIn(O);
726			}, 40);
727		};
728		fadeIn(O);
729		menuObj.fade = true;
730	} else {
731		menuObj.fade = false;
732	}
733	menuObj.style.display = '';
734	if(ctrlObj && ctrlclass) {
735		ctrlObj.className += ' ' + ctrlclass;
736		menuObj.setAttribute('ctrlid', ctrlid);
737		menuObj.setAttribute('ctrlclass', ctrlclass);
738	}
739	if(pos != '*') {
740		setMenuPosition(showid, menuid, pos);
741	}
742	if(BROWSER.ie && BROWSER.ie < 7 && winhandlekey && $('fwin_' + winhandlekey)) {
743		$(menuid).style.left = (parseInt($(menuid).style.left) - parseInt($('fwin_' + winhandlekey).style.left)) + 'px';
744		$(menuid).style.top = (parseInt($(menuid).style.top) - parseInt($('fwin_' + winhandlekey).style.top)) + 'px';
745	}
746	if(maxh && menuObj.scrollHeight > maxh) {
747		menuObj.style.height = maxh + 'px';
748		if(BROWSER.opera) {
749			menuObj.style.overflow = 'auto';
750		} else {
751			menuObj.style.overflowY = 'auto';
752		}
753	}
754
755	if(!duration) {
756		setTimeout('hideMenu(\'' + menuid + '\', \'' + mtype + '\')', timeout);
757	}
758
759	if(!in_array(menuid, JSMENU['active'][layer])) JSMENU['active'][layer].push(menuid);
760	menuObj.cache = cache;
761	if(layer > JSMENU['layer']) {
762		JSMENU['layer'] = layer;
763	}
764	var hasshow = function(ele) {
765		while(ele.parentNode && ((typeof(ele['currentStyle']) === 'undefined') ? window.getComputedStyle(ele,null) : ele['currentStyle'])['display'] !== 'none') {
766			ele = ele.parentNode;
767		}
768		if(ele === document) {
769			return true;
770		} else {
771			return false;
772		}
773	};
774	if(!menuObj.getAttribute('disautofocus')) {
775		try{
776			var focused = false;
777			var tags = ['input', 'select', 'textarea', 'button', 'a'];
778			for(var i = 0; i < tags.length; i++) {
779				var _all = menuObj.getElementsByTagName(tags[i]);
780				if(_all.length) {
781					for(j = 0; j < _all.length; j++) {
782						if((!_all[j]['type'] || _all[j]['type'] != 'hidden') && hasshow(_all[j])) {
783							if(_all[j].className.indexOf('hidefocus') == -1) {
784								_all[j].className += ' hidefocus';
785							}
786							_all[j].focus();
787							focused = true;
788							var cobj = _all[j];
789							_attachEvent(_all[j], 'blur', function (){cobj.className = trim(cobj.className.replace(' hidefocus', ''));});
790							break;
791						}
792					}
793				}
794				if(focused) {
795					break;
796				}
797			}
798		} catch (e) {
799		}
800	}
801}
802var delayShowST = null;
803function delayShow(ctrlObj, call, time) {
804	if(typeof ctrlObj == 'object') {
805		var ctrlid = ctrlObj.id;
806		call = call || function () {showMenu(ctrlid);};
807	}
808	var time = isUndefined(time) ? 500 : time;
809	delayShowST = setTimeout(function () {
810		if(typeof call == 'function') {
811			call();
812		} else {
813			eval(call);
814		}
815	}, time);
816	if(!ctrlObj.delayinit) {
817		_attachEvent(ctrlObj, 'mouseout', function() {clearTimeout(delayShowST);});
818		ctrlObj.delayinit = 1;
819	}
820}
821
822var dragMenuDisabled = false;
823function dragMenu(menuObj, e, op) {
824	e = e ? e : window.event;
825	if(op == 1) {
826		if(dragMenuDisabled || in_array(e.target ? e.target.tagName : e.srcElement.tagName, ['TEXTAREA', 'INPUT', 'BUTTON', 'SELECT'])) {
827			return;
828		}
829		JSMENU['drag'] = [e.clientX, e.clientY];
830		JSMENU['drag'][2] = parseInt(menuObj.style.left);
831		JSMENU['drag'][3] = parseInt(menuObj.style.top);
832		document.onmousemove = function(e) {try{dragMenu(menuObj, e, 2);}catch(err){}};
833		document.onmouseup = function(e) {try{dragMenu(menuObj, e, 3);}catch(err){}};
834		doane(e);
835	}else if(op == 2 && JSMENU['drag'][0]) {
836		var menudragnow = [e.clientX, e.clientY];
837		menuObj.style.left = (JSMENU['drag'][2] + menudragnow[0] - JSMENU['drag'][0]) + 'px';
838		menuObj.style.top = (JSMENU['drag'][3] + menudragnow[1] - JSMENU['drag'][1]) + 'px';
839		menuObj.removeAttribute('top_');menuObj.removeAttribute('left_');
840		doane(e);
841	}else if(op == 3) {
842		JSMENU['drag'] = [];
843		document.onmousemove = null;
844		document.onmouseup = null;
845	}
846}
847function setMenuPosition(showid, menuid, pos) {
848	var showObj = $(showid);
849	var menuObj = menuid ? $(menuid) : $(showid + '_menu');
850	if(isUndefined(pos) || !pos) pos = '43';
851	var basePoint = parseInt(pos.substr(0, 1));
852	var direction = parseInt(pos.substr(1, 1));
853	var important = pos.indexOf('!') != -1 ? 1 : 0;
854	var sxy = 0, sx = 0, sy = 0, sw = 0, sh = 0, ml = 0, mt = 0, mw = 0, mcw = 0, mh = 0, mch = 0, bpl = 0, bpt = 0;
855
856	if(!menuObj || (basePoint > 0 && !showObj)) return;
857	if(showObj) {
858		sxy = fetchOffset(showObj);
859		sx = sxy['left'];
860		sy = sxy['top'];
861		sw = showObj.offsetWidth;
862		sh = showObj.offsetHeight;
863	}
864	mw = menuObj.offsetWidth;
865	mcw = menuObj.clientWidth;
866	mh = menuObj.offsetHeight;
867	mch = menuObj.clientHeight;
868
869	switch(basePoint) {
870		case 1:
871			bpl = sx;
872			bpt = sy;
873			break;
874		case 2:
875			bpl = sx + sw;
876			bpt = sy;
877			break;
878		case 3:
879			bpl = sx + sw;
880			bpt = sy + sh;
881			break;
882		case 4:
883			bpl = sx;
884			bpt = sy + sh;
885			break;
886	}
887	switch(direction) {
888		case 0:
889			menuObj.style.left = (document.body.clientWidth - menuObj.clientWidth) / 2 + 'px';
890			mt = (document.documentElement.clientHeight - menuObj.clientHeight) / 2;
891			break;
892		case 1:
893			ml = bpl - mw;
894			mt = bpt - mh;
895			break;
896		case 2:
897			ml = bpl;
898			mt = bpt - mh;
899			break;
900		case 3:
901			ml = bpl;
902			mt = bpt;
903			break;
904		case 4:
905			ml = bpl - mw;
906			mt = bpt;
907			break;
908	}
909	var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
910	var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
911	if(!important) {
912		if(in_array(direction, [1, 4]) && ml < 0) {
913			ml = bpl;
914			if(in_array(basePoint, [1, 4])) ml += sw;
915		} else if(ml + mw > scrollLeft + document.body.clientWidth && sx >= mw) {
916			ml = bpl - mw;
917			if(in_array(basePoint, [2, 3])) {
918				ml -= sw;
919			} else if(basePoint == 4) {
920				ml += sw;
921			}
922		}
923		if(in_array(direction, [1, 2]) && mt < 0) {
924			mt = bpt;
925			if(in_array(basePoint, [1, 2])) mt += sh;
926		} else if(mt + mh > scrollTop + document.documentElement.clientHeight && sy >= mh) {
927			mt = bpt - mh;
928			if(in_array(basePoint, [3, 4])) mt -= sh;
929		}
930	}
931	if(pos.substr(0, 3) == '210') {
932		ml += 69 - sw / 2;
933		mt -= 5;
934		if(showObj.tagName == 'TEXTAREA') {
935			ml -= sw / 2;
936			mt += sh / 2;
937		}
938	}
939	if(direction == 0 || menuObj.scrolly) {
940		if(BROWSER.ie && BROWSER.ie < 7) {
941			if(direction == 0) mt += scrollTop;
942		} else {
943			if(menuObj.scrolly) mt -= scrollTop;
944			menuObj.style.position = 'fixed';
945		}
946	}
947	if(ml) menuObj.style.left = ml + 'px';
948	if(mt) menuObj.style.top = mt + 'px';
949	if(direction == 0 && BROWSER.ie && !document.documentElement.clientHeight) {
950		menuObj.style.position = 'absolute';
951		menuObj.style.top = (document.body.clientHeight - menuObj.clientHeight) / 2 + 'px';
952	}
953	if(menuObj.style.clip && !BROWSER.opera) {
954		menuObj.style.clip = 'rect(auto, auto, auto, auto)';
955	}
956}
957
958function hideMenu(attr, mtype) {
959	attr = isUndefined(attr) ? '' : attr;
960	mtype = isUndefined(mtype) ? 'menu' : mtype;
961	if(attr == '') {
962		for(var i = 1; i <= JSMENU['layer']; i++) {
963			hideMenu(i, mtype);
964		}
965		return;
966	} else if(typeof attr == 'number') {
967		for(var j in JSMENU['active'][attr]) {
968			hideMenu(JSMENU['active'][attr][j], mtype);
969		}
970		return;
971	}else if(typeof attr == 'string') {
972		var menuObj = $(attr);
973		if(!menuObj || (mtype && menuObj.mtype != mtype)) return;
974		var ctrlObj = '', ctrlclass = '';
975		if((ctrlObj = $(menuObj.getAttribute('ctrlid'))) && (ctrlclass = menuObj.getAttribute('ctrlclass'))) {
976			var reg = new RegExp(' ' + ctrlclass);
977			ctrlObj.className = ctrlObj.className.replace(reg, '');
978		}
979		clearTimeout(JSMENU['timer'][attr]);
980		var hide = function() {
981			if(menuObj.cache) {
982				if(menuObj.style.visibility != 'hidden') {
983					menuObj.style.display = 'none';
984					if(menuObj.cover) $(attr + '_cover').style.display = 'none';
985				}
986			}else {
987				menuObj.parentNode.removeChild(menuObj);
988				if(menuObj.cover) $(attr + '_cover').parentNode.removeChild($(attr + '_cover'));
989			}
990			var tmp = [];
991			for(var k in JSMENU['active'][menuObj.layer]) {
992				if(attr != JSMENU['active'][menuObj.layer][k]) tmp.push(JSMENU['active'][menuObj.layer][k]);
993			}
994			JSMENU['active'][menuObj.layer] = tmp;
995		};
996		if(menuObj.fade) {
997			var O = 100;
998			var fadeOut = function(O) {
999				if(O == 0) {
1000					clearTimeout(fadeOutTimer);
1001					hide();
1002					return;
1003				}
1004				menuObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + O + ')';
1005				menuObj.style.opacity = O / 100;
1006				O -= 20;
1007				var fadeOutTimer = setTimeout(function () {
1008					fadeOut(O);
1009				}, 40);
1010			};
1011			fadeOut(O);
1012		} else {
1013			hide();
1014		}
1015	}
1016}
1017
1018function getCurrentStyle(obj, cssproperty, csspropertyNS) {
1019	if(obj.style[cssproperty]){
1020		return obj.style[cssproperty];
1021	}
1022	if (obj.currentStyle) {
1023		return obj.currentStyle[cssproperty];
1024	} else if (document.defaultView.getComputedStyle(obj, null)) {
1025		var currentStyle = document.defaultView.getComputedStyle(obj, null);
1026		var value = currentStyle.getPropertyValue(csspropertyNS);
1027		if(!value){
1028			value = currentStyle[cssproperty];
1029		}
1030		return value;
1031	} else if (window.getComputedStyle) {
1032		var currentStyle = window.getComputedStyle(obj, "");
1033		return currentStyle.getPropertyValue(csspropertyNS);
1034	}
1035}
1036
1037function fetchOffset(obj, mode) {
1038	var left_offset = 0, top_offset = 0, mode = !mode ? 0 : mode;
1039
1040	if(obj.getBoundingClientRect && !mode) {
1041		var rect = obj.getBoundingClientRect();
1042		var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
1043		var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
1044		if(document.documentElement.dir == 'rtl') {
1045			scrollLeft = scrollLeft + document.documentElement.clientWidth - document.documentElement.scrollWidth;
1046		}
1047		left_offset = rect.left + scrollLeft - document.documentElement.clientLeft;
1048		top_offset = rect.top + scrollTop - document.documentElement.clientTop;
1049	}
1050	if(left_offset <= 0 || top_offset <= 0) {
1051		left_offset = obj.offsetLeft;
1052		top_offset = obj.offsetTop;
1053		while((obj = obj.offsetParent) != null) {
1054			position = getCurrentStyle(obj, 'position', 'position');
1055			if(position == 'relative') {
1056				continue;
1057			}
1058			left_offset += obj.offsetLeft;
1059			top_offset += obj.offsetTop;
1060		}
1061	}
1062	return {'left' : left_offset, 'top' : top_offset};
1063}
1064
1065function showTip(ctrlobj) {
1066	$F('_showTip', arguments);
1067}
1068
1069function showPrompt(ctrlid, evt, msg, timeout, classname) {
1070	$F('_showPrompt', arguments);
1071}
1072
1073function showCreditPrompt() {
1074	$F('_showCreditPrompt', []);
1075}
1076
1077var showDialogST = null;
1078function showDialog(msg, mode, t, func, cover, funccancel, leftmsg, confirmtxt, canceltxt, closetime, locationtime) {
1079	clearTimeout(showDialogST);
1080	cover = isUndefined(cover) ? (mode == 'info' ? 0 : 1) : cover;
1081	leftmsg = isUndefined(leftmsg) ? '' : leftmsg;
1082	mode = in_array(mode, ['confirm', 'notice', 'info', 'right']) ? mode : 'alert';
1083	var menuid = 'fwin_dialog';
1084	var menuObj = $(menuid);
1085	var showconfirm = 1;
1086	confirmtxtdefault = '確定';
1087	closetime = isUndefined(closetime) ? '' : closetime;
1088	closefunc = function () {
1089		if(typeof func == 'function') func();
1090		else eval(func);
1091		hideMenu(menuid, 'dialog');
1092	};
1093	if(closetime) {
1094		showPrompt(null, null, '<i>' + msg + '</i>', closetime * 1000, 'popuptext');
1095		return;
1096	}
1097	locationtime = isUndefined(locationtime) ? '' : locationtime;
1098	if(locationtime) {
1099		leftmsg = locationtime + ' 秒後頁面跳轉';
1100		showDialogST = setTimeout(closefunc, locationtime * 1000);
1101		showconfirm = 0;
1102	}
1103	confirmtxt = confirmtxt ? confirmtxt : confirmtxtdefault;
1104	canceltxt = canceltxt ? canceltxt : '取消';
1105
1106	if(menuObj) hideMenu('fwin_dialog', 'dialog');
1107	menuObj = document.createElement('div');
1108	menuObj.style.display = 'none';
1109	menuObj.className = 'fwinmask';
1110	menuObj.id = menuid;
1111	$('append_parent').appendChild(menuObj);
1112	var hidedom = '';
1113	if(!BROWSER.ie) {
1114		hidedom = '<style type="text/css">object{visibility:hidden;}</style>';
1115	}
1116	var s = hidedom + '<table cellpadding="0" cellspacing="0" class="fwin"><tr><td class="t_l"></td><td class="t_c"></td><td class="t_r"></td></tr><tr><td class="m_l">&nbsp;&nbsp;</td><td class="m_c"><h3 class="flb"><em>';
1117	s += t ? t : '提示信息';
1118	s += '</em><span><a href="javascript:;" id="fwin_dialog_close" class="flbc" onclick="hideMenu(\'' + menuid + '\', \'dialog\')" title="關閉">關閉</a></span></h3>';
1119	if(mode == 'info') {
1120		s += msg ? msg : '';
1121	} else {
1122		s += '<div class="c altw"><div class="' + (mode == 'alert' ? 'alert_error' : (mode == 'right' ? 'alert_right' : 'alert_info')) + '"><p>' + msg + '</p></div></div>';
1123		s += '<p class="o pns">' + (leftmsg ? '<span class="z xg1">' + leftmsg + '</span>' : '') + (showconfirm ? '<button id="fwin_dialog_submit" value="true" class="pn pnc"><strong>'+confirmtxt+'</strong></button>' : '');
1124		s += mode == 'confirm' ? '<button id="fwin_dialog_cancel" value="true" class="pn" onclick="hideMenu(\'' + menuid + '\', \'dialog\')"><strong>'+canceltxt+'</strong></button>' : '';
1125		s += '</p>';
1126	}
1127	s += '</td><td class="m_r"></td></tr><tr><td class="b_l"></td><td class="b_c"></td><td class="b_r"></td></tr></table>';
1128	menuObj.innerHTML = s;
1129	if($('fwin_dialog_submit')) $('fwin_dialog_submit').onclick = function() {
1130		if(typeof func == 'function') func();
1131		else eval(func);
1132		hideMenu(menuid, 'dialog');
1133	};
1134	if($('fwin_dialog_cancel')) {
1135		$('fwin_dialog_cancel').onclick = function() {
1136			if(typeof funccancel == 'function') funccancel();
1137			else eval(funccancel);
1138			hideMenu(menuid, 'dialog');
1139		};
1140		$('fwin_dialog_close').onclick = $('fwin_dialog_cancel').onclick;
1141	}
1142	showMenu({'mtype':'dialog','menuid':menuid,'duration':3,'pos':'00','zindex':JSMENU['zIndex']['dialog'],'cache':0,'cover':cover});
1143	try {
1144		if($('fwin_dialog_submit')) $('fwin_dialog_submit').focus();
1145	} catch(e) {}
1146}
1147
1148function showWindow(k, url, mode, cache, menuv) {
1149	mode = isUndefined(mode) ? 'get' : mode;
1150	cache = isUndefined(cache) ? 1 : cache;
1151	var menuid = 'fwin_' + k;
1152	var menuObj = $(menuid);
1153	var drag = null;
1154	var loadingst = null;
1155	var hidedom = '';
1156
1157	if(disallowfloat && disallowfloat.indexOf(k) != -1) {
1158		if(BROWSER.ie) url += (url.indexOf('?') != -1 ?  '&' : '?') + 'referer=' + escape(location.href);
1159		location.href = url;
1160		doane();
1161		return;
1162	}
1163
1164	var fetchContent = function() {
1165		if(mode == 'get') {
1166			menuObj.url = url;
1167			url += (url.search(/\?/) > 0 ? '&' : '?') + 'infloat=yes&handlekey=' + k;
1168			url += cache == -1 ? '&t='+(+ new Date()) : '';
1169			if(BROWSER.ie &&  url.indexOf('referer=') < 0) {
1170				url = url + '&referer=' + encodeURIComponent(location);
1171			}
1172			ajaxget(url, 'fwin_content_' + k, null, '', '', function() {initMenu();show();});
1173		} else if(mode == 'post') {
1174			menuObj.act = $(url).action;
1175			ajaxpost(url, 'fwin_content_' + k, '', '', '', function() {initMenu();show();});
1176		}
1177		if(parseInt(BROWSER.ie) != 6) {
1178			loadingst = setTimeout(function() {showDialog('', 'info', '<img src="' + IMGDIR + '/loading.gif"> 請稍候...')}, 500);
1179		}
1180	};
1181	var initMenu = function() {
1182		clearTimeout(loadingst);
1183		var objs = menuObj.getElementsByTagName('*');
1184		var fctrlidinit = false;
1185		for(var i = 0; i < objs.length; i++) {
1186			if(objs[i].id) {
1187				objs[i].setAttribute('fwin', k);
1188			}
1189			if(objs[i].className == 'flb' && !fctrlidinit) {
1190				if(!objs[i].id) objs[i].id = 'fctrl_' + k;
1191				drag = objs[i].id;
1192				fctrlidinit = true;
1193			}
1194		}
1195	};
1196	var show = function() {
1197		hideMenu('fwin_dialog', 'dialog');
1198		v = {'mtype':'win','menuid':menuid,'duration':3,'pos':'00','zindex':JSMENU['zIndex']['win'],'drag':typeof drag == null ? '' : drag,'cache':cache};
1199		for(k in menuv) {
1200			v[k] = menuv[k];
1201		}
1202		showMenu(v);
1203	};
1204
1205	if(!menuObj) {
1206		menuObj = document.createElement('div');
1207		menuObj.id = menuid;
1208		menuObj.className = 'fwinmask';
1209		menuObj.style.display = 'none';
1210		$('append_parent').appendChild(menuObj);
1211		evt = ' style="cursor:move" onmousedown="dragMenu($(\'' + menuid + '\'), event, 1)" ondblclick="hideWindow(\'' + k + '\')"';
1212		if(!BROWSER.ie) {
1213			hidedom = '<style type="text/css">object{visibility:hidden;}</style>';
1214		}
1215		menuObj.innerHTML = hidedom + '<table cellpadding="0" cellspacing="0" class="fwin"><tr><td class="t_l"></td><td class="t_c"' + evt + '></td><td class="t_r"></td></tr><tr><td class="m_l"' + evt + ')">&nbsp;&nbsp;</td><td class="m_c" id="fwin_content_' + k + '">'
1216			+ '</td><td class="m_r"' + evt + '"></td></tr><tr><td class="b_l"></td><td class="b_c"' + evt + '></td><td class="b_r"></td></tr></table>';
1217		if(mode == 'html') {
1218			$('fwin_content_' + k).innerHTML = url;
1219			initMenu();
1220			show();
1221		} else {
1222			fetchContent();
1223		}
1224	} else if((mode == 'get' && (url != menuObj.url || cache != 1)) || (mode == 'post' && $(url).action != menuObj.act)) {
1225		fetchContent();
1226	} else {
1227		show();
1228	}
1229	doane();
1230}
1231
1232function showError(msg) {
1233	var p = /<script[^\>]*?>([^\x00]*?)<\/script>/ig;
1234	msg = msg.replace(p, '');
1235	if(msg !== '') {
1236		showDialog(msg, 'alert', '錯誤信息', null, true, null, '', '', '', 3);
1237	}
1238}
1239
1240function hideWindow(k, all, clear) {
1241	all = isUndefined(all) ? 1 : all;
1242	clear = isUndefined(clear) ? 1 : clear;
1243	hideMenu('fwin_' + k, 'win');
1244	if(clear && $('fwin_' + k)) {
1245		$('append_parent').removeChild($('fwin_' + k));
1246	}
1247	if(all) {
1248		hideMenu();
1249	}
1250}
1251
1252function AC_FL_RunContent() {
1253	var str = '';
1254	var ret = AC_GetArgs(arguments, "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash");
1255	if(BROWSER.ie && !BROWSER.opera) {
1256		str += '<object ';
1257		for (var i in ret.objAttrs) {
1258			str += i + '="' + ret.objAttrs[i] + '" ';
1259		}
1260		str += '>';
1261		for (var i in ret.params) {
1262			str += '<param name="' + i + '" value="' + ret.params[i] + '" /> ';
1263		}
1264		str += '</object>';
1265	} else {
1266		str += '<embed ';
1267		for (var i in ret.embedAttrs) {
1268			str += i + '="' + ret.embedAttrs[i] + '" ';
1269		}
1270		str += '></embed>';
1271	}
1272	return str;
1273}
1274
1275function AC_GetArgs(args, classid, mimeType) {
1276	var ret = new Object();
1277	ret.embedAttrs = new Object();
1278	ret.params = new Object();
1279	ret.objAttrs = new Object();
1280	for (var i = 0; i < args.length; i = i + 2){
1281		var currArg = args[i].toLowerCase();
1282		switch (currArg){
1283			case "classid":break;
1284			case "pluginspage":ret.embedAttrs[args[i]] = 'http://www.macromedia.com/go/getflashplayer';break;
1285			case "src":ret.embedAttrs[args[i]] = args[i+1];ret.params["movie"] = args[i+1];break;
1286			case "codebase":ret.objAttrs[args[i]] = 'http://download.macromedia.com/pub/s
1286hockwave/cabs/flash/swflash.cab#version=9,0,0,0';break;
1287			case "onafterupdate":case "onbeforeupdate":case "onblur":case "oncellchange":case "onclick":case "ondblclick":case "ondrag":case "ondragend":
1288			case "ondragenter":case "ondragleave":case "ondragover":case "ondrop":case "onfinish":case "onfocus":case "onhelp":case "onmousedown":
1289			case "onmouseup":case "onmouseover":case "onmousemove":case "onmouseout":case "onkeypress":case "onkeydown":case "onkeyup":case "onload":
1290			case "onlosecapture":case "onpropertychange":case "onreadystatechange":case "onrowsdelete":case "onrowenter":case "onrowexit":case "onrowsinserted":case "onstart":
1291			case "onscroll":case "onbeforeeditfocus":case "onactivate":case "onbeforedeactivate":case "ondeactivate":case "type":
1292			case "id":ret.objAttrs[args[i]] = args[i+1];break;
1293			case "width":case "height":case "align":case "vspace": case "hspace":case "class":case "title":case "accesskey":case "name":
1294			case "tabindex":ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];break;
1295			default:ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
1296		}
1297	}
1298	ret.objAttrs["classid"] = classid;
1299	if(mimeType) {
1300		ret.embedAttrs["type"] = mimeType;
1301	}
1302	return ret;
1303}
1304
1305function simulateSelect(selectId, widthvalue) {
1306	var selectObj = $(selectId);
1307	if(!selectObj) return;
1308	if(BROWSER.other) {
1309		if(selectObj.getAttribute('change')) {
1310			selectObj.onchange = function () {eval(selectObj.getAttribute('change'));}
1311		}
1312		return;
1313	}
1314	var widthvalue = widthvalue ? widthvalue : 70;
1315	var defaultopt = selectObj.options[0] ? selectObj.options[0].innerHTML : '';
1316	var defaultv = '';
1317	var menuObj = document.createElement('div');
1318	var ul = document.createElement('ul');
1319	var handleKeyDown = function(e) {
1320		e = BROWSER.ie ? event : e;
1321		if(e.keyCode == 40 || e.keyCode == 38) doane(e);
1322	};
1323	var selectwidth = (selectObj.getAttribute('width', i) ? selectObj.getAttribute('width', i) : widthvalue) + 'px';
1324	var tabindex = selectObj.getAttribute('tabindex', i) ? selectObj.getAttribute('tabindex', i) : 1;
1325
1326	for(var i = 0; i < selectObj.options.length; i++) {
1327		var li = document.createElement('li');
1328		li.innerHTML = selectObj.options[i].innerHTML;
1329		li.k_id = i;
1330		li.k_value = selectObj.options[i].value;
1331		if(selectObj.options[i].selected) {
1332			defaultopt = selectObj.options[i].innerHTML;
1333			defaultv = selectObj.options[i].value;
1334			li.className = 'current';
1335			selectObj.setAttribute('selecti', i);
1336		}
1337		li.onclick = function() {
1338			if($(selectId + '_ctrl').innerHTML != this.innerHTML) {
1339				var lis = menuObj.getElementsByTagName('li');
1340				lis[$(selectId).getAttribute('selecti')].className = '';
1341				this.className = 'current';
1342				$(selectId + '_ctrl').innerHTML = this.innerHTML;
1343				$(selectId).setAttribute('selecti', this.k_id);
1344				$(selectId).options.length = 0;
1345				$(selectId).options[0] = new Option('', this.k_value);
1346				eval(selectObj.getAttribute('change'));
1347			}
1348			hideMenu(menuObj.id);
1349			return false;
1350		};
1351		ul.appendChild(li);
1352	}
1353
1354	selectObj.options.length = 0;
1355	selectObj.options[0]= new Option('', defaultv);
1356	selectObj.style.display = 'none';
1357	selectObj.outerHTML += '<a href="javascript:;" id="' + selectId + '_ctrl" style="width:' + selectwidth + '" tabindex="' + tabindex + '">' + defaultopt + '</a>';
1358
1359	menuObj.id = selectId + '_ctrl_menu';
1360	menuObj.className = 'sltm';
1361	menuObj.style.display = 'none';
1362	menuObj.style.width = selectwidth;
1363	menuObj.appendChild(ul);
1364	$('append_parent').appendChild(menuObj);
1365
1366	$(selectId + '_ctrl').onclick = function(e) {
1367		$(selectId + '_ctrl_menu').style.width = selectwidth;
1368		showMenu({'ctrlid':(selectId == 'loginfield' ? 'account' : selectId + '_ctrl'),'menuid':selectId + '_ctrl_menu','evt':'click','pos':'43'});
1369		doane(e);
1370	};
1371	$(selectId + '_ctrl').onfocus = menuObj.onfocus = function() {
1372		_attachEvent(document.body, 'keydown', handleKeyDown);
1373	};
1374	$(selectId + '_ctrl').onblur = menuObj.onblur = function() {
1375		_detachEvent(document.body, 'keydown', handleKeyDown);
1376	};
1377	$(selectId + '_ctrl').onkeyup = function(e) {
1378		e = e ? e : window.event;
1379		value = e.keyCode;
1380		if(value == 40 || value == 38) {
1381			if(menuObj.style.display == 'none') {
1382				$(selectId + '_ctrl').onclick();
1383			} else {
1384				lis = menuObj.getElementsByTagName('li');
1385				selecti = selectObj.getAttribute('selecti');
1386				lis[selecti].className = '';
1387				if(value == 40) {
1388					selecti = parseInt(selecti) + 1;
1389				} else if(value == 38) {
1390					selecti = parseInt(selecti) - 1;
1391				}
1392				if(selecti < 0) {
1393					selecti = lis.length - 1
1394				} else if(selecti > lis.length - 1) {
1395					selecti = 0;
1396				}
1397				lis[selecti].className = 'current';
1398				selectObj.setAttribute('selecti', selecti);
1399				lis[selecti].parentNode.scrollTop = lis[selecti].offsetTop;
1400			}
1401		} else if(value == 13) {
1402			var lis = menuObj.getElementsByTagName('li');
1403			lis[selectObj.getAttribute('selecti')].onclick();
1404		} else if(value == 27) {
1405			hideMenu(menuObj.id);
1406		}
1407	};
1408}
1409
1410function switchTab(prefix, current, total, activeclass) {
1411	$F('_switchTab', arguments);
1412}
1413
1414function imageRotate(imgid, direct) {
1415	$F('_imageRotate', arguments);
1416}
1417
1418function thumbImg(obj, method) {
1419	if(!obj) {
1420		return;
1421	}
1422	obj.onload = null;
1423	file = obj.src;
1424	zw = obj.offsetWidth;
1425	zh = obj.offsetHeight;
1426	if(zw < 2) {
1427		if(!obj.id) {
1428			obj.id = 'img_' + Math.random();
1429		}
1430		setTimeout("thumbImg($('" + obj.id + "'), " + method + ")", 100);
1431		return;
1432	}
1433	zr = zw / zh;
1434	method = !method ? 0 : 1;
1435	if(method) {
1436		fixw = obj.getAttribute('_width');
1437		fixh = obj.getAttribute('_height');
1438		if(zw > fixw) {
1439			zw = fixw;
1440			zh = zw / zr;
1441		}
1442		if(zh > fixh) {
1443			zh = fixh;
1444			zw = zh * zr;
1445		}
1446	} else {
1447		fixw = typeof imagemaxwidth == 'undefined' ? '600' : imagemaxwidth;
1448		if(zw > fixw) {
1449			zw = fixw;
1450			zh = zw / zr;
1451			obj.style.cursor = 'pointer';
1452			if(!obj.onclick) {
1453				obj.onclick = function() {
1454					zoom(obj, obj.src);
1455				};
1456			}
1457		}
1458	}
1459	obj.width = zw;
1460	obj.height = zh;
1461}
1462
1463var zoomstatus = 1;
1464function zoom(obj, zimg, nocover, pn, showexif) {
1465	$F('_zoom', arguments);
1466}
1467
1468function showselect(obj, inpid, t, rettype) {
1469	$F('_showselect', arguments);
1470}
1471
1472function showColorBox(ctrlid, layer, k, bgcolor) {
1473	$F('_showColorBox', arguments);
1474}
1475
1476function ctrlEnter(event, btnId, onlyEnter) {
1477	if(isUndefined(onlyEnter)) onlyEnter = 0;
1478	if((event.ctrlKey || onlyEnter) && event.keyCode == 13) {
1479		$(btnId).click();
1480		return false;
1481	}
1482	return true;
1483}
1484
1485function parseurl(str, mode, parsecode) {
1486	if(isUndefined(parsecode)) parsecode = true;
1487	if(parsecode) str= str.replace(/\[code\]([\s\S]+?)\[\/code\]/ig, function($1, $2) {return codetag($2, -1);});
1488	str = str.replace(/([^>=\]"'\/]|^)((((https?|ftp):\/\/)|www\.)([\w\-]+\.)*[\w\-\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!]*)+\.(swf|flv))/ig, '$1[flash]$2[/flash]');
1489	str = str.replace(/([^>=\]"'\/]|^)((((https?|ftp):\/\/)|www\.)([\w\-]+\.)*[\w\-\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!]*)+\.(mp3|wma))/ig, '$1[audio]$2[/audio]');
1490	str = str.replace(/([^>=\]"'\/@]|^)((((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|qqdl|synacast):\/\/))([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&;~`@':+!#]*)*)/ig, mode == 'html' ? '$1<a href="$2" target="_blank">$2</a>' : '$1[url]$2[/url]');
1491	str = str.replace(/([^\w>=\]"'\/@]|^)((www\.)([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&;~`@':+!#]*)*)/ig, mode == 'html' ? '$1<a href="$2" target="_blank">$2</a>' : '$1[url]$2[/url]');
1492	str = str.replace(/([^\w->
1492=\]:"'\.\/]|^)(([\-\.\w]+@[\.\-\w]+(\.\w+)+))/ig, mode == 'html' ? '$1<a href="mailto:$2">$2</a>' : '$1[email]$2[/email]');
1493	if(parsecode) {
1494		for(var i = 0; i <= DISCUZCODE['num']; i++) {
1495			str = str.replace("[\tDISCUZ_CODE_" + i + "\t]", DISCUZCODE['html'][i]);
1496		}
1497	}
1498	return str;
1499}
1500
1501function codetag(text, br) {
1502	var br = !br ? 1 : br;
1503	DISCUZCODE['num']++;
1504	if(br > 0 && typeof wysiwyg != 'undefined' && wysiwyg) text = text.replace(/<br[^\>]*>/ig, '\n');
1505	text = text.replace(/\$/ig, '$$$$');
1506	DISCUZCODE['html'][DISCUZCODE['num']] = '[code]' + text + '[/code]';
1507	return '[\tDISCUZ_CODE_' + DISCUZCODE['num'] + '\t]';
1508}
1509
1510function saveUserdata(name, data) {
1511	try {
1512		if(window.localStorage){
1513			localStorage.setItem('Discuz_' + name, data);
1514		} else if(window.sessionStorage){
1515			sessionStorage.setItem('Discuz_' + name, data);
1516		}
1517	} catch(e) {
1518		if(BROWSER.ie){
1519			if(data.length < 54889) {
1520				with(document.documentElement) {
1521					setAttribute("value", data);
1522					save('Discuz_' + name);
1523				}
1524			}
1525		}
1526	}
1527	setcookie('clearUserdata', '', -1);
1528}
1529
1530function loadUserdata(name) {
1531	if(window.localStorage){
1532		return localStorage.getItem('Discuz_' + name);
1533	} else if(window.sessionStorage){
1534		return sessionStorage.getItem('Discuz_' + name);
1535	} else if(BROWSER.ie){
1536		with(document.documentElement) {
1537			load('Discuz_' + name);
1538			return getAttribute("value");
1539		}
1540	}
1541}
1542
1543function initTab(frameId, type) {
1544	$F('_initTab', arguments);
1545}
1546
1547function openDiy(){
1548	if(DYNAMICURL) {
1549		window.location.href = SITEURL+DYNAMICURL + (DYNAMICURL.indexOf('?') < 0 ? '?' : '&') + ('diy=yes');
1550	} else {
1551		window.location.href = ((window.location.href + '').replace(/[\?\&]diy=yes/g, '').split('#')[0] + ( window.location.search && window.location.search.indexOf('?diy=yes') < 0 ? '&diy=yes' : '?diy=yes'));
1552	}
1553}
1554
1555function hasClass(elem, className) {
1556	return elem.className && (" " + elem.className + " ").indexOf(" " + className + " ") != -1;
1557}
1558
1559function addClass(elem, className) {
1560	if(!hasClass(elem, className)) elem.className = trim(elem.className += " " + className);
1561}
1562
1563function removeClass(elem, className) {
1564	elem.className = trim((" " + elem.className + " ").replace(" " + trim(className) + " ", " "));
1565}
1566
1567function toggleClass(elem, className) {
1568	elem.className = hasClass(elem, className) ? removeClass(elem, className) : trim(elem.className += " " + className);
1569}
1570
1571function runslideshow() {
1572	$F('_runslideshow', []);
1573}
1574
1575function toggle_collapse(objname, noimg, complex, lang) {
1576	$F('_toggle_collapse', arguments);
1577}
1578
1579function updatestring(str1, str2, clear) {
1580	str2 = '_' + str2 + '_';
1581	return clear ? str1.replace(str2, '') : (str1.indexOf(str2) == -1 ? str1 + str2 : str1);
1582}
1583
1584function getClipboardData() {
1585	window.document.clipboardswf.SetVariable('str', CLIPBOARDSWFDATA);
1586}
1587
1588function setCopy(text, msg) {
1589	var cp = document.createElement('textarea');
1590	cp.style.fontSize = '12pt';
1591	cp.style.border = '0';
1592	cp.style.padding = '0';
1593	cp.style.margin = '0';
1594	cp.style.position = 'absolute';
1595	cp.style.left = '-9999px';
1596	var yPosition = window.pageYOffset || document.documentElement.scrollTop;
1597	cp.style.top = yPosition + 'px';
1598	cp.setAttribute('readonly', '');
1599	text = text.replace(/[\xA0]/g, ' ');
1600	cp.value = text;
1601	$('append_parent').appendChild(cp);
1602	cp.select();
1603	cp.setSelectionRange(0, cp.value.length);
1604	try {
1605		var success = document.execCommand('copy', false, null);
1606	} catch (e) {
1607		var success = false;
1608	}
1609	$('append_parent').removeChild(cp);
1610
1611	if(success) {
1612		if(msg) {
1613			showPrompt(null, null, '<span>' + msg + '</span>', 1500);
1614		}
1615	} else if(BROWSER.ie) {
1616		var r = clipboardData.setData('Text', text);
1617		if(r) {
1618			if(msg) {
1619				showPrompt(null, null, '<span>' + msg + '</span>', 1500);
1620			}
1621		} else {
1622			showDialog('<div class="c"><div style="width: 200px; text-align: center;">複製失敗,請選擇「允許訪問」</div></div>', 'alert');
1623		}
1624	} else {
1625		var msg = '<div class="c"><div style="width: 200px; text-align: center; text-decoration:underline;">點此複製到剪貼板</div>' +
1626		AC_FL_RunContent('id', 'clipboardswf', 'name', 'clipboardswf', 'devicefont', 'false', 'width', '200', 'height', '40', 'src', STATICURL + 'image/common/clipboard.swf', 'menu', 'false',  'allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true', 'wmode', 'transparent', 'style' , 'margin-top:-20px') + '</div>';
1627		showDialog(msg, 'info');
1628		CLIPBOARDSWFDATA = text;
1629	}
1630}
1631
1632function copycode(obj) {
1633	$F('_copycode', arguments);
1634}
1635
1636function showdistrict(container, elems, totallevel, changelevel, containertype) {
1637	$F('_showdistrict', arguments);
1638}
1639
1640function setDoodle(fid, oid, url, tid, from) {
1641	$F('_setDoodle', arguments);
1642}
1643
1644
1645function initSearchmenu(searchform, cloudSearchUrl) {
1646	var defaultUrl = 'search.php?searchsubmit=yes';
1647	if(typeof cloudSearchUrl == "undefined" || cloudSearchUrl == null || cloudSearchUrl == '') {
1648		cloudSearchUrl = defaultUrl;
1649	}
1650
1651	var searchtxt = $(searchform + '_txt');
1652	if(!searchtxt) {
1653		searchtxt = $(searchform);
1654	}
1655	var tclass = searchtxt.className;
1656	searchtxt.className = tclass + ' xg1';
1657	if (!!("placeholder" in document.createElement("input"))) {
1658		if(searchtxt.value == '請輸入搜索內容') {
1659			searchtxt.value = '';
1660		}
1661		searchtxt.placeholder = '請輸入搜索內容';
1662	} else {
1663		searchtxt.onfocus = function () {
1664			if(searchtxt.value == '請輸入搜索內容') {
1665				searchtxt.value = '';
1666				searchtxt.className = tclass;
1667			}
1668		};
1669		searchtxt.onblur = function () {
1670			if(searchtxt.value == '' ) {
1671				searchtxt.value = '請輸入搜索內容';
1672				searchtxt.className = tclass + ' xg1';
1673			}
1674		};
1675	}
1676	if(!$(searchform + '_type_menu')) return false;
1677	var o = $(searchform + '_type');
1678	var a = $(searchform + '_type_menu').getElementsByTagName('a');
1679	var formobj = searchtxt.form;
1680	for(var i=0; i<a.length; i++){
1681		if(a[i].className == 'curtype'){
1682			o.innerHTML = a[i].innerHTML;
1683			$(searchform + '_mod').value = a[i].rel;
1684			formobj.method = 'post';
1685			if((a[i].rel == 'forum' || a[i].rel == 'curforum') && defaultUrl != cloudSearchUrl) {
1686				formobj.action = cloudSearchUrl;
1687				formobj.method = 'get';
1688				if($('srchFId')) {
1689					$('srchFId').value = a[i].rel == 'forum' ? 0 : a[i].getAttribute('fid');
1690				}
1691			} else {
1692				formobj.action = defaultUrl;
1693			}
1694		}
1695		a[i].onclick = function(){
1696			o.innerHTML = this.innerHTML;
1697			$(searchform + '_mod').value = this.rel;
1698			formobj.method = 'post';
1699			if((this.rel == 'forum' || this.rel == 'curforum') && defaultUrl != cloudSearchUrl) {
1700				formobj.action = cloudSearchUrl;
1701				formobj.method = 'get';
1702				if($('srchFId')) {
1703					$('srchFId').value = this.rel == 'forum' ? 0 : this.getAttribute('fid');
1704				}
1705			} else {
1706				formobj.action = defaultUrl;
1707			}
1708		};
1709	}
1710}
1711
1712function searchFocus(obj) {
1713	if(obj.value == '請輸入搜索內容') {
1714		obj.value = '';
1715	}
1716	if($('cloudsearchquery') != null) {
1717		$('cloudsearchquery').value = obj.value;
1718	}
1719}
1720
1721function extstyle(css) {
1722	$F('_extstyle', arguments);
1723}
1724
1725function widthauto(obj) {
1726	$F('_widthauto', arguments);
1727}
1728
1729var secST = new Array();
1730function updatesecqaa(idhash) {
1731	$F('_updatesecqaa', arguments);
1732}
1733
1734function updateseccode(idhash) {
1735	$F('_updateseccode', arguments);
1736}
1737
1738function checksec(type, idhash, showmsg, recall) {
1739	$F('_checksec', arguments);
1740}
1741
1742function createPalette(colorid, id, func) {
1743	$F('_createPalette', arguments);
1744}
1745
1746function showForummenu(fid) {
1747	$F('_showForummenu', arguments);
1748}
1749
1750function showUserApp() {
1751	$F('_showUserApp', arguments);
1752}
1753
1754function cardInit() {
1755	var cardShow = function (obj) {
1756		if(BROWSER.ie && BROWSER.ie < 7 && obj.href.indexOf('username') != -1) {
1757			return;
1758		}
1759		pos = obj.getAttribute('c') == '1' ? '43' : obj.getAttribute('c');
1760		USERCARDST = setTimeout(function() {ajaxmenu(obj, 500, 1, 2, pos, null, 'p_pop card');}, 250);
1761	};
1762	var cardids = {};
1763	var a = document.body.getElementsByTagName('a');
1764	for(var i = 0;i < a.length;i++){
1765		if(a[i].getAttribute('c')) {
1766			var href = a[i].getAttribute('href', 1);
1767			if(typeof cardids[href] == 'undefined') {
1768				cardids[href] = Math.round(Math.random()*10000);
1769			}
1770			a[i].setAttribute('mid', 'card_' + cardids[href]);
1771			a[i].onmouseover = function() {cardShow(this)};
1772			a[i].onmouseout = function() {clearTimeout(USERCARDST);};
1773		}
1774	}
1775}
1776
1777function navShow(id) {
1778	var mnobj = $('snav_mn_' + id);
1779	if(!mnobj) {
1780		return;
1781	}
1782	var uls = $('mu').getElementsByTagName('ul');
1783	for(i = 0;i < uls.length;i++) {
1784		if(uls[i].className != 'cl current') {
1785			uls[i].style.display = 'none';
1786		}
1787	}
1788	if(mnobj.className != 'cl current') {
1789		showMenu({'ctrlid':'mn_' + id,'menuid':'snav_mn_' + id,'pos':'*'});
1790		mnobj.className = 'cl floatmu';
1791		mnobj.style.width = ($('nv').clientWidth) + 'px';
1792		mnobj.style.display = '';
1793	}
1794}
1795
1796function strLenCalc(obj, checklen, maxlen) {
1797	var v = obj.value, charlen = 0, maxlen = !maxlen ? 200 : maxlen, curlen = maxlen, len = strlen(v);
1798	for(var i = 0; i < v.length; i++) {
1799		if(v.charCodeAt(i) < 0 || v.charCodeAt(i) > 255) {
1800			curlen -= charset == 'utf-8' ? 2 : 1;
1801		}
1802	}
1803	if(curlen >= len) {
1804		$(checklen).innerHTML = curlen - len;
1805	} else {
1806		obj.value = mb_cutstr(v, maxlen, 0);
1807	}
1808}
1809
1810function pluginNotice() {
1811	if($('plugin_notice')) {
1812		ajaxget('misc.php?mod=patch&action=pluginnotice', 'plugin_notice', '');
1813	}
1814}
1815
1816function ipNotice() {
1817	if($('ip_notice')) {
1818		ajaxget('misc.php?mod=patch&action=ipnotice&_r='+Math.random(), 'ip_notice', '');
1819	}
1820}
1821
1822function noticeTitle() {
1823	NOTICETITLE = {'State':0, 'oldTitle':NOTICECURTITLE, flashNumber:0, sleep:15};
1824	if(!getcookie('noticeTitle')) {
1825		window.setInterval('noticeTitleFlash();', 500);
1826	} else {
1827		window.setTimeout('noticeTitleFlash();', 500);
1828	}
1829	setcookie('noticeTitle', 1, 600);
1830}
1831
1832function noticeTitleFlash() {
1833	if(NOTICETITLE.flashNumber < 5 || NOTICETITLE.flashNumber > 4 && !NOTICETITLE['State']) {
1834		document.title = (NOTICETITLE['State'] ? '【   】' : '【新提醒】') + NOTICETITLE['oldTitle'];
1835		NOTICETITLE['State'] = !NOTICETITLE['State'];
1836	}
1837	NOTICETITLE.flashNumber = NOTICETITLE.flashNumber < NOTICETITLE.sleep ? ++NOTICETITLE.flashNumber : 0;
1838}
1839
1840function relatedlinks(rlinkmsgid) {
1841	$F('_relatedlinks', arguments);
1842}
1843
1844function con_handle_response(response) {
1845	return response;
1846}
1847
1848function showTopLink() {
1849	var ft = $('ft');
1850	if(ft){
1851		var scrolltop = $('scrolltop');
1852		var viewPortHeight = parseInt(document.documentElement.clientHeight);
1853		var scrollHeight = parseInt(document.body.getBoundingClientRect().top);
1854		var basew = parseInt(ft.clientWidth);
1855		var sw = scrolltop.clientWidth;
1856		if (basew < 1000) {
1857			var left = parseInt(fetchOffset(ft)['left']);
1858			left = left < sw ? left * 2 - sw : left;
1859			scrolltop.style.left = ( basew + left ) + 'px';
1860		} else {
1861			scrolltop.style.left = 'auto';
1862			scrolltop.style.right = 0;
1863		}
1864
1865		if (BROWSER.ie && BROWSER.ie < 7) {
1866			scrolltop.style.top = viewPortHeight - scrollHeight - 150 + 'px';
1867		}
1868		if (scrollHeight < -100) {
1869			scrolltop.style.visibility = 'visible';
1870		} else {
1871			scrolltop.style.visibility = 'hidden';
1872		}
1873	}
1874}
1875
1876function showCreditmenu() {
1877	$F('_showCreditmenu', []);
1878}
1879
1880function showUpgradeinfo() {
1881	$F('_showUpgradeinfo', []);
1882}
1883
1884function addFavorite(url, title) {
1885	try {
1886		window.external.addFavorite(url, title);
1887	} catch (e){
1888		try {
1889			window.sidebar.addPanel(title, url, '');
1890        	} catch (e) {
1891			showDialog("請按 Ctrl+D 鍵添加到收藏夾", 'notice');
1892		}
1893	}
1894}
1895
1896function setHomepage(sURL) {
1897	if(BROWSER.ie){
1898		document.body.style.behavior = 'url(#default#homepage)';
1899		document.body.setHomePage(sURL);
1900	} else {
1901		showDialog("非 IE 瀏覽器請手動將本站設為首頁", 'notice');
1902		doane();
1903	}
1904}
1905
1906function setShortcut() {
1907	var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
1908	if(!loadUserdata('setshortcut') && !scrollTop) {
1909		$F('_setShortcut', []);
1910	}
1911}
1912
1913function smilies_show(id, smcols, seditorkey) {
1914	$F('_smilies_show', arguments, 'smilies');
1915}
1916
1917function showfocus(ftype, autoshow) {
1918	var id = parseInt($('focuscur').innerHTML);
1919	if(ftype == 'prev') {
1920		id = (id-1) < 1 ? focusnum : (id-1);
1921		if(!autoshow) {
1922			window.clearInterval(focusautoshow);
1923		}
1924	} else if(ftype == 'next') {
1925		id = (id+1) > focusnum ? 1 : (id+1);
1926		if(!autoshow) {
1927			window.clearInterval(focusautoshow);
1928		}
1929	}
1930	$('focuscur').innerHTML = id;
1931	$('focus_con').innerHTML = $('focus_'+(id-1)).innerHTML;
1932}
1933
1934function rateStarHover(target,level) {
1935	if(level ==  0) {
1936		$(target).style.width = '';
1937	} else {
1938		$(target).style.width = level * 16 + 'px';
1939	}
1940}
1941function rateStarSet(target,level,input) {
1942	$(input).value = level;
1943	$(target).className = 'star star' + level;
1944}
1945
1946function img_onmouseoverfunc(obj) {
1947	if(typeof showsetcover == 'function') {
1948		showsetcover(obj);
1949	}
1950	return;
1951}
1952
1953function toggleBlind(dom) {
1954	if(dom) {
1955		if(loadUserdata('is_blindman')) {
1956			saveUserdata('is_blindman', '');
1957			dom.title = '開啟輔助訪問';
1958		} else {
1959			saveUserdata('is_blindman', '1');
1960			dom.title = '關閉輔助訪問';
1961		}
1962	}
1963}
1964
1965function checkBlind() {
1966	var dom = $('switchblind');
1967	if(dom) {
1968		if(loadUserdata('is_blindman')) {
1969			dom.title = '關閉輔助訪問';
1970		} else {
1971			dom.title = '開啟輔助訪問';
1972		}
1973	}
1974}
1975
1976function getElementOffset(element) {
1977	var left = element.offsetLeft, top = element.offsetTop;
1978	while(element = element.offsetParent) {
1979		left += element.offsetLeft;
1980		top += element.offsetTop;
1981	}
1982	if($('nv').style.position == 'fixed') {
1983		top -= parseInt($('nv').style.height);
1984	}
1985	return {'left' : left, 'top' : top};
1986}
1987
1988function mobileplayer() {
1989	var platform = navigator.platform;
1990	var ua = navigator.userAgent;
1991	var ios = /iPhone|iPad|iPod/.test(platform) && ua.indexOf( "AppleWebKit" ) > -1;
1992	var andriod = ua.indexOf( "Android" ) > -1;
1993	if(ios || andriod) {
1994		return true;
1995	} else {
1996		return false;
1997	}
1998}
1999
2000function appendstyle(url) {
2001	var link = document.createElement('link');
2002	link.type = 'text/css';
2003	link.rel = 'stylesheet';
2004	link.href = url;
2005	var head = document.getElementsByTagName('head')[0];
2006	head.appendChild(link);
2007}
2008
2009function detectHtml5Support() {
2010	return document.createElement("Canvas").getContext;
2011}
2012
2013function detectPlayer(randomid, ext, src, width, height) {
2014	var h5_support = new Array('aac', 'flac', 'mp3', 'm4a', 'wav', 'flv', 'mp4', 'm4v', '3gp', 'ogv', 'ogg', 'weba', 'webm');
2015	var trad_support = new Array('mp3', 'wma', 'mid', 'wav', 'ra', 'ram', 'rm', 'rmvb', 'swf', 'asf', 'asx', 'wmv', 'avi', 'mpg', 'mpeg', 'mov');
2016	width = width.indexOf("%") == -1 ? width + 'px' : width;
2017	height = height.indexOf("%") == -1 ? height + 'px' : height;
2018	if (in_array(ext, h5_support) && detectHtml5Support()) {
2019		html5Player(randomid, ext, src, width, height);
2020	} else if (in_array(ext, trad_support)) {
2021		tradionalPlayer(randomid, ext, src, width, height);
2022	} else {
2023		$(randomid).style.width = width;
2024		$(randomid).style.height = height;
2025	}
2026}
2027
2028function tradionalPlayer(randomid, ext, src, width, height) {
2029	switch(ext) {
2030		case 'mp3':
2031		case 'wma':
2032		case 'mid':
2033		case 'wav':
2034			height = 64;
2035			html = '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="' + width + '" height="' + height + '"><param name="invokeURLs" value="0"><param name="autostart" value="0" /><param name="url" value="' + src + '" /><embed src="' + src + '" autostart="0" type="application/x-mplayer2" width="' + width + '" height="' + height + '"></embed></object>';
2036			break;
2037		case 'ra':
2038		case 'ram':
2039			height = 32;
2040			html = '<object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="' + width + '" height="' + height + '">
2040<param name="autostart" value="0" /><param name="src" value="' + src + '" /><param name="controls" value="controlpanel" /><param name="console" value="' + randomid + '_" /><embed src="' + src + '" autostart="0" type="audio/x-pn-realaudio-plugin" controls="ControlPanel" console="' + randomid + '_" width="' + width + '" height="' + height + '"></embed></object>';
2041			break;
2042		case 'rm':
2043		case 'rmvb':
2044			html = '<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="' + width + '" height="' + height + '"><param name="autostart" value="0" /><param name="src" value="' + src + '" /><param name="controls" value="imagewindow" /><param name="console" value="' + randomid + '_" /><embed src="' + src + '" autostart="0" type="audio/x-pn-realaudio-plugin" controls="imagewindow" console="' + randomid + '_" width="' + width + '" height="' + height + '"></embed></object><br /><object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="' + width + '" height="32"><param name="src" value="' + src +'" /><param name="controls" value="controlpanel" /><param name="console" value="' + randomid + '_" /><embed src="' + src + '" autostart="0" type="audio/x-pn-realaudio-plugin" controls="controlpanel" console="' + randomid + '_" width="' + width + '" height="32"></embed></object>';
2045			break;
2046		case 'swf':
2047			html = AC_FL_RunContent('width', width, 'height', height, 'allowNetworking', 'internal', 'allowScriptAccess', 'never', 'src', encodeURI(src), 'quality', 'high', 'bgcolor', '#ffffff', 'wmode', 'transparent', 'allowfullscreen', 'true');
2048			break;
2049		case 'asf':
2050		case 'asx':
2051		case 'wmv':
2052		case 'avi':
2053		case 'mpg':
2054		case 'mpeg':
2055			html = '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="' + width + '" height="' + height + '"><param name="invokeURLs" value="0"><param name="autostart" value="0" /><param name="url" value="' + src + '" /><embed src="' + src + '" autostart="0" type="application/x-mplayer2" width="' + width + '" height="' + height + '"></embed></object>';
2056			break;
2057		case 'mov':
2058			html = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="' + width + '" height="' + height + '"><param name="autostart" value="false" /><param name="src" value="' + src + '" /><embed src="' + src + '" autostart="false" type="video/quicktime" controller="true" width="' + width + '" height="' + height + '"></embed></object>';
2059			break;
2060		default:
2061			break;
2062	}
2063	$(randomid).style.width = width;
2064	$(randomid).style.height = height;
2065	$(randomid + '_container').innerHTML = html;
2066}
2067
2068function html5Player(randomid, ext, src, width, height) {
2069	switch (ext) {
2070		case 'aac':
2071		case 'flac':
2072		case 'mp3':
2073		case 'm4a':
2074		case 'wav':
2075		case 'ogg':
2076			height = 66;
2077			if(!HTML5PLAYER['apload']) {
2078				appendstyle(STATICURL + 'js/player/aplayer.min.css');
2079				appendscript(STATICURL + 'js/player/aplayer.min.js');
2080				HTML5PLAYER['apload'] = 1;
2081			}
2082			html5APlayer(randomid, ext, src, width, height);
2083			break;
2084		case 'flv':
2085			if(!HTML5PLAYER['flvload']) {
2086				appendscript(STATICURL + 'js/player/flv.min.js');
2087				HTML5PLAYER['flvload'] = 1;
2088			}
2089		case 'mp4':
2090		case 'm4v':
2091		case '3gp':
2092		case 'ogv':
2093		case 'webm':
2094			if(!HTML5PLAYER['dpload']) {
2095				appendstyle(STATICURL + 'js/player/dplayer.min.css');
2096				appendscript(STATICURL + 'js/player/dplayer.min.js');
2097				HTML5PLAYER['dpload'] = 1;
2098			}
2099			html5DPlayer(randomid, ext, src, width, height);
2100			break;
2101		default:
2102			break;
2103	}
2104	$(randomid).style.width = width;
2105	$(randomid).style.height = height;
2106}
2107
2108function html5APlayer(randomid, ext, src, width, height) {
2109	if (JSLOADED[STATICURL + 'js/player/aplayer.min.js']) {
2110		window[randomid] = new APlayer({
2111			container: $(randomid + '_container'),
2112			mini: false,
2113			autoplay: false,
2114			loop: 'all',
2115			preload: 'none',
2116			volume: 1,
2117			mutex: true,
2118			listFolded: true,
2119			audio: [{
2120				name: ' ',
2121				artist: ' ',
2122				url: src
2123			}]
2124		});
2125	} else {
2126		setTimeout(function () {
2127			html5APlayer(randomid, ext, src, width, height);
2128		}, 50);
2129	}
2130}
2131
2132function html5DPlayer(randomid, ext, src, width, height) {
2133	if (JSLOADED[STATICURL + 'js/player/dplayer.min.js'] && (ext != 'flv' || JSLOADED[STATICURL + 'js/player/flv.min.js'])) {
2134		window[randomid] = new DPlayer({
2135			container: $(randomid + '_container'),
2136			autoplay: false,
2137			loop: true,
2138			screenshot: false,
2139			hotkey: true,
2140			preload: 'none',
2141			volume: 1,
2142			mutex: true,
2143			listFolded: true,
2144			video: {
2145				url: src
2146			}
2147		});
2148	} else {
2149		setTimeout(function () {
2150			html5DPlayer(randomid, ext, src, width, height);
2151		}, 50);
2152	}
2153}
2154
2155var BROWSER = {};
2156var USERAGENT = navigator.userAgent.toLowerCase();
2157browserVersion({'ie':'msie','trident':'','firefox':'','chrome':'','opera':'','safari':'','mozilla':'','webkit':'','maxthon':'','qq':'qqbrowser','rv':'rv'});
2158if(BROWSER.safari || BROWSER.rv) {
2159	BROWSER.firefox = true;
2160}
2161BROWSER.opera = BROWSER.opera ? opera.version() : 0;
2162
2163HTMLNODE = document.getElementsByTagName('head')[0].parentNode;
2164if(BROWSER.ie || BROWSER.trident) {
2165	BROWSER.iemode = parseInt(typeof document.documentMode != 'undefined' ? document.documentMode : BROWSER.ie);
2166	HTMLNODE.className = (BROWSER.iemode<9?'ie_all ':'') +'ie' + BROWSER.iemode;
2167}
2168
2169var CSSLOADED = [];
2170var JSLOADED = [];
2171var JSMENU = [];
2172JSMENU['active'] = [];
2173JSMENU['timer'] = [];
2174JSMENU['drag'] = [];
2175JSMENU['layer'] = 0;
2176JSMENU['zIndex'] = {'win':200,'menu':300,'dialog':400,'prompt':500};
2177JSMENU['float'] = '';
2178var CURRENTSTYPE = null;
2179var discuz_uid = isUndefined(discuz_uid) ? 0 : discuz_uid;
2180var creditnotice = isUndefined(creditnotice) ? '' : creditnotice;
2181var cookiedomain = isUndefined(cookiedomain) ? '' : cookiedomain;
2182var cookiepath = isUndefined(cookiepath) ? '' : cookiepath;
2183var EXTRAFUNC = [], EXTRASTR = '';
2184EXTRAFUNC['showmenu'] = [];
2185
2186var DISCUZCODE = [];
2187DISCUZCODE['num'] = '-1';
2188DISCUZCODE['html'] = [];
2189
2190var USERABOUT_BOX = true;
2191var USERCARDST = null;
2192var CLIPBOARDSWFDATA = '';
2193var NOTICETITLE = [];
2194var NOTICECURTITLE = document.title;
2195var safescripts = {}, evalscripts = [];
2196
2197var HTML5PLAYER = [];
2198HTML5PLAYER['apload'] = 0;
2199HTML5PLAYER['dpload'] = 0;
2200HTML5PLAYER['flvload'] = 0;
2201
2202if(BROWSER.firefox && window.HTMLElement) {
2203	HTMLElement.prototype.__defineGetter__( "innerText", function(){
2204		var anyString = "";
2205		var childS = this.childNodes;
2206		for(var i=0; i <childS.length; i++) {
2207			if(childS[i].nodeType==1) {
2208				anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
2209			} else if(childS[i].nodeType==3) {
2210				anyString += childS[i].nodeValue;
2211			}
2212		}
2213		return anyString;
2214	});
2215	HTMLElement.prototype.__defineSetter__( "innerText", function(sText){
2216		this.textContent=sText;
2217	});
2218	HTMLElement.prototype.__defineSetter__('outerHTML', function(sHTML) {
2219			var r = this.ownerDocument.createRange();
2220		r.setStartBefore(this);
2221		var df = r.createContextualFragment(sHTML);
2222		this.parentNode.replaceChild(df,this);
2223		return sHTML;
2224	});
2225
2226	HTMLElement.prototype.__defineGetter__('outerHTML', function() {
2227		var attr;
2228		var attrs = this.attributes;
2229		var str = '<' + this.tagName.toLowerCase();
2230		for(var i = 0;i < attrs.length;i++){
2231			attr = attrs[i];
2232			if(attr.specified)
2233			str += ' ' + attr.name + '="' + attr.value + '"';
2234		}
2235		if(!this.canHaveChildren) {
2236			return str + '>';
2237		}
2238		return str + '>' + this.innerHTML + '</' + this.tagName.toLowerCase() + '>';
2239		});
2240
2241	HTMLElement.prototype.__defineGetter__('canHaveChildren', function() {
2242		switch(this.tagName.toLowerCase()) {
2243			case 'area':case 'base':case 'basefont':case 'col':case 'frame':case 'hr':case 'img':case 'br':case 'input':case 'isindex':case 'link':case 'meta':case 'param':
2244			return false;
2245			}
2246		return true;
2247	});
2248}
2249
2250if(typeof IN_ADMINCP == 'undefined') {
2251	if(creditnotice != '' && getcookie('creditnotice')) {
2252		_attachEvent(window, 'load', showCreditPrompt, document);
2253	}
2254	if(typeof showusercard != 'undefined' && showusercard == 1) {
2255		_attachEvent(window, 'load', cardInit, document);
2256	}
2257}
2258
2259if(BROWSER.ie) {
2260	document.documentElement.addBehavior("#default#userdata");
2261}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.