PageSourceSearch

https://www.truthmall.com/static/js/common.js?iz2

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

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.