common.js 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675
  1. var BROWSER = {};
  2. var USERAGENT = navigator.userAgent.toLowerCase();
  3. browserVersion({
  4. 'ie': 'msie',
  5. 'firefox': '',
  6. 'chrome': '',
  7. 'opera': '',
  8. 'safari': '',
  9. 'mozilla': '',
  10. 'webkit': '',
  11. 'maxthon': '',
  12. 'qq': 'qqbrowser',
  13. 'rv': 'rv'
  14. });
  15. if (BROWSER.safari || BROWSER.rv) {
  16. BROWSER.firefox = true;
  17. }
  18. BROWSER.opera = BROWSER.opera ? opera.version() : 0;
  19. HTMLNODE = document.getElementsByTagName('head')[0].parentNode;
  20. if (BROWSER.ie) {
  21. BROWSER.iemode = parseInt(typeof document.documentMode != 'undefined' ? document.documentMode : BROWSER.ie);
  22. HTMLNODE.className = 'ie_all ie' + BROWSER.iemode;
  23. }
  24. var CSSLOADED = [];
  25. var JSLOADED = [];
  26. var JSMENU = [];
  27. JSMENU['active'] = [];
  28. JSMENU['timer'] = [];
  29. JSMENU['drag'] = [];
  30. JSMENU['layer'] = 0;
  31. JSMENU['zIndex'] = {'win': 200, 'menu': 300, 'dialog': 400, 'prompt': 500};
  32. JSMENU['float'] = '';
  33. var CURRENTSTYPE = null;
  34. var discuz_uid = isUndefined(discuz_uid) ? 0 : discuz_uid;
  35. var creditnotice = isUndefined(creditnotice) ? '' : creditnotice;
  36. var cookiedomain = isUndefined(cookiedomain) ? '' : cookiedomain;
  37. var cookiepath = isUndefined(cookiepath) ? '' : cookiepath;
  38. var EXTRAFUNC = [], EXTRASTR = '';
  39. EXTRAFUNC['showmenu'] = [];
  40. var DISCUZCODE = [];
  41. DISCUZCODE['num'] = '-1';
  42. DISCUZCODE['html'] = [];
  43. var USERABOUT_BOX = true;
  44. var USERCARDST = null;
  45. var CLIPBOARDSWFDATA = '';
  46. var NOTICETITLE = [];
  47. var NOTICECURTITLE = document.title;
  48. if (BROWSER.firefox && window.HTMLElement) {
  49. HTMLElement.prototype.__defineGetter__("innerText", function () {
  50. var anyString = "";
  51. var childS = this.childNodes;
  52. for (var i = 0; i < childS.length; i++) {
  53. if (childS[i].nodeType == 1) {
  54. anyString += childS[i].tagName == "BR" ? '\n' : childS[i].innerText;
  55. } else if (childS[i].nodeType == 3) {
  56. anyString += childS[i].nodeValue;
  57. }
  58. }
  59. return anyString;
  60. });
  61. HTMLElement.prototype.__defineSetter__("innerText", function (sText) {
  62. this.textContent = sText;
  63. });
  64. HTMLElement.prototype.__defineSetter__('outerHTML', function (sHTML) {
  65. var r = this.ownerDocument.createRange();
  66. r.setStartBefore(this);
  67. var df = r.createContextualFragment(sHTML);
  68. this.parentNode.replaceChild(df, this);
  69. return sHTML;
  70. });
  71. HTMLElement.prototype.__defineGetter__('outerHTML', function () {
  72. var attr;
  73. var attrs = this.attributes;
  74. var str = '<' + this.tagName.toLowerCase();
  75. for (var i = 0; i < attrs.length; i++) {
  76. attr = attrs[i];
  77. if (attr.specified)
  78. str += ' ' + attr.name + '="' + attr.value + '"';
  79. }
  80. if (!this.canHaveChildren) {
  81. return str + '>';
  82. }
  83. return str + '>' + this.innerHTML + '</' + this.tagName.toLowerCase() + '>';
  84. });
  85. HTMLElement.prototype.__defineGetter__('canHaveChildren', function () {
  86. switch (this.tagName.toLowerCase()) {
  87. case'area':
  88. case'base':
  89. case'basefont':
  90. case'col':
  91. case'frame':
  92. case'hr':
  93. case'img':
  94. case'br':
  95. case'input':
  96. case'isindex':
  97. case'link':
  98. case'meta':
  99. case'param':
  100. return false;
  101. }
  102. return true;
  103. });
  104. }
  105. function $(id) {
  106. return !id ? null : document.getElementById(id);
  107. }
  108. function $C(classname, ele, tag) {
  109. var returns = [];
  110. ele = ele || document;
  111. tag = tag || '*';
  112. if (ele.getElementsByClassName) {
  113. var eles = ele.getElementsByClassName(classname);
  114. if (tag != '*') {
  115. for (var i = 0, L = eles.length; i < L; i++) {
  116. if (eles[i].tagName.toLowerCase() == tag.toLowerCase()) {
  117. returns.push(eles[i]);
  118. }
  119. }
  120. } else {
  121. returns = eles;
  122. }
  123. } else {
  124. eles = ele.getElementsByTagName(tag);
  125. var pattern = new RegExp("(^|\\s)" + classname + "(\\s|$)");
  126. for (i = 0, L = eles.length; i < L; i++) {
  127. if (pattern.test(eles[i].className)) {
  128. returns.push(eles[i]);
  129. }
  130. }
  131. }
  132. return returns;
  133. }
  134. function _attachEvent(obj, evt, func, eventobj) {
  135. eventobj = !eventobj ? obj : eventobj;
  136. if (obj.addEventListener) {
  137. obj.addEventListener(evt, func, false);
  138. } else if (eventobj.attachEvent) {
  139. obj.attachEvent('on' + evt, func);
  140. }
  141. }
  142. function _detachEvent(obj, evt, func, eventobj) {
  143. eventobj = !eventobj ? obj : eventobj;
  144. if (obj.removeEventListener) {
  145. obj.removeEventListener(evt, func, false);
  146. } else if (eventobj.detachEvent) {
  147. obj.detachEvent('on' + evt, func);
  148. }
  149. }
  150. function browserVersion(types) {
  151. var other = 1;
  152. for (i in types) {
  153. var v = types[i] ? types[i] : i;
  154. if (USERAGENT.indexOf(v) != -1) {
  155. var re = new RegExp(v + '(\\/|\\s|:)([\\d\\.]+)', 'ig');
  156. var matches = re.exec(USERAGENT);
  157. var ver = matches != null ? matches[2] : 0;
  158. other = ver !== 0 && v != 'mozilla' ? 0 : other;
  159. } else {
  160. var ver = 0;
  161. }
  162. eval('BROWSER.' + i + '= ver');
  163. }
  164. BROWSER.other = other;
  165. }
  166. function getEvent() {
  167. if (document.all) return window.event;
  168. func = getEvent.caller;
  169. while (func != null) {
  170. var arg0 = func.arguments[0];
  171. if (arg0) {
  172. if ((arg0.constructor == Event || arg0.constructor == MouseEvent) || (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
  173. return arg0;
  174. }
  175. }
  176. func = func.caller;
  177. }
  178. return null;
  179. }
  180. function isUndefined(variable) {
  181. return typeof variable == 'undefined' ? true : false;
  182. }
  183. function in_array(needle, haystack) {
  184. if (typeof needle == 'string' || typeof needle == 'number') {
  185. for (var i in haystack) {
  186. if (haystack[i] == needle) {
  187. return true;
  188. }
  189. }
  190. }
  191. return false;
  192. }
  193. function trim(str) {
  194. return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
  195. }
  196. function strlen(str) {
  197. return (BROWSER.ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
  198. }
  199. function mb_strlen(str) {
  200. var len = 0;
  201. for (var i = 0; i < str.length; i++) {
  202. len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1;
  203. }
  204. return len;
  205. }
  206. function mb_cutstr(str, maxlen, dot) {
  207. var len = 0;
  208. var ret = '';
  209. var dot = !dot ? '...' : dot;
  210. maxlen = maxlen - dot.length;
  211. for (var i = 0; i < str.length; i++) {
  212. len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1;
  213. if (len > maxlen) {
  214. ret += dot;
  215. break;
  216. }
  217. ret += str.substr(i, 1);
  218. }
  219. return ret;
  220. }
  221. function preg_replace(search, replace, str, regswitch) {
  222. var regswitch = !regswitch ? 'ig' : regswitch;
  223. var len = search.length;
  224. for (var i = 0; i < len; i++) {
  225. re = new RegExp(search[i], regswitch);
  226. str = str.replace(re, typeof replace == 'string' ? replace : (replace[i] ? replace[i] : replace[0]));
  227. }
  228. return str;
  229. }
  230. function htmlspecialchars(str) {
  231. return preg_replace(['&', '<', '>', '"'], ['&amp;', '&lt;', '&gt;', '&quot;'], str);
  232. }
  233. function display(id) {
  234. var obj = $(id);
  235. if (obj.style.visibility) {
  236. obj.style.visibility = obj.style.visibility == 'visible' ? 'hidden' : 'visible';
  237. } else {
  238. obj.style.display = obj.style.display == '' ? 'none' : '';
  239. }
  240. }
  241. function checkall(form, prefix, checkall) {
  242. var checkall = checkall ? checkall : 'chkall';
  243. count = 0;
  244. for (var i = 0; i < form.elements.length; i++) {
  245. var e = form.elements[i];
  246. if (e.name && e.name != checkall && !e.disabled && (!prefix || (prefix && e.name.match(prefix)))) {
  247. e.checked = form.elements[checkall].checked;
  248. if (e.checked) {
  249. count++;
  250. }
  251. }
  252. }
  253. return count;
  254. }
  255. function setcookie(cookieName, cookieValue, seconds, path, domain, secure) {
  256. if (cookieValue == '' || seconds < 0) {
  257. cookieValue = '';
  258. seconds = -2592000;
  259. }
  260. if (seconds) {
  261. var expires = new Date();
  262. expires.setTime(expires.getTime() + seconds * 1000);
  263. }
  264. domain = !domain ? cookiedomain : domain;
  265. path = !path ? cookiepath : path;
  266. document.cookie = escape(cookiepre + cookieName) + '=' + escape(cookieValue)
  267. + (expires ? '; expires=' + expires.toGMTString() : '')
  268. + (path ? '; path=' + path : '/')
  269. + (domain ? '; domain=' + domain : '')
  270. + (secure ? '; secure' : '');
  271. }
  272. function getcookie(name, nounescape) {
  273. name = cookiepre + name;
  274. var cookie_start = document.cookie.indexOf(name);
  275. var cookie_end = document.cookie.indexOf(";", cookie_start);
  276. if (cookie_start == -1) {
  277. return '';
  278. } else {
  279. var v = document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length));
  280. return !nounescape ? unescape(v) : v;
  281. }
  282. }
  283. function getHost(url) {
  284. var host = "null";
  285. if (typeof url == "undefined" || null == url) {
  286. url = location.href;
  287. }
  288. var regex = /^\w+\:\/\/([^\/]*).*/;
  289. var match = url.match(regex);
  290. if (typeof match != "undefined" && null != match) {
  291. host = match[1];
  292. }
  293. return host;
  294. }
  295. function newfunction(func) {
  296. var args = [];
  297. for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
  298. return function (event) {
  299. doane(event);
  300. window[func].apply(window, args);
  301. return false;
  302. }
  303. }
  304. function evalscript(s) {
  305. if (s.indexOf('<script') == -1) return s;
  306. var p = /<script[^\>]*?>([^\x00]*?)<\/script>/ig;
  307. var arr = [];
  308. while (arr = p.exec(s)) {
  309. var p1 = /<script[^\>]*?src=\"([^\>]*?)\"[^\>]*?(reload=\"1\")?(?:charset=\"([\w\-]+?)\")?><\/script>/i;
  310. var arr1 = [];
  311. arr1 = p1.exec(arr[0]);
  312. if (arr1) {
  313. appendscript(arr1[1], '', arr1[2], arr1[3]);
  314. } else {
  315. p1 = /<script(.*?)>([^\x00]+?)<\/script>/i;
  316. arr1 = p1.exec(arr[0]);
  317. appendscript('', arr1[2], arr1[1].indexOf('reload=') != -1);
  318. }
  319. }
  320. return s;
  321. }
  322. var safescripts = {}, evalscripts = [];
  323. function safescript(id, call, seconds, times, timeoutcall, endcall, index) {
  324. seconds = seconds || 1000;
  325. times = times || 0;
  326. var checked = true;
  327. try {
  328. if (typeof call == 'function') {
  329. call();
  330. } else {
  331. eval(call);
  332. }
  333. } catch (e) {
  334. checked = false;
  335. }
  336. if (!checked) {
  337. if (!safescripts[id] || !index) {
  338. safescripts[id] = safescripts[id] || [];
  339. safescripts[id].push({
  340. 'times': 0, 'si': setInterval(function () {
  341. safescript(id, call, seconds, times, timeoutcall, endcall, safescripts[id].length);
  342. }, seconds)
  343. });
  344. } else {
  345. index = (index || 1) - 1;
  346. safescripts[id][index]['times']++;
  347. if (safescripts[id][index]['times'] >= times) {
  348. clearInterval(safescripts[id][index]['si']);
  349. if (typeof timeoutcall == 'function') {
  350. timeoutcall();
  351. } else {
  352. eval(timeoutcall);
  353. }
  354. }
  355. }
  356. } else {
  357. try {
  358. index = (index || 1) - 1;
  359. if (safescripts[id][index]['si']) {
  360. clearInterval(safescripts[id][index]['si']);
  361. }
  362. if (typeof endcall == 'function') {
  363. endcall();
  364. } else {
  365. eval(endcall);
  366. }
  367. } catch (e) {
  368. }
  369. }
  370. }
  371. function appendscript(src, text, reload, charset) {
  372. var id = hash(src + text);
  373. if (!reload && in_array(id, evalscripts)) return;
  374. if (reload && $(id)) {
  375. $(id).parentNode.removeChild($(id));
  376. }
  377. evalscripts.push(id);
  378. var scriptNode = document.createElement("script");
  379. scriptNode.type = "text/javascript";
  380. scriptNode.id = id;
  381. scriptNode.charset = charset ? charset : (BROWSER.firefox ? document.characterSet : document.charset);
  382. try {
  383. if (src) {
  384. scriptNode.src = src;
  385. scriptNode.onloadDone = false;
  386. scriptNode.onload = function () {
  387. scriptNode.onloadDone = true;
  388. JSLOADED[src] = 1;
  389. };
  390. scriptNode.onreadystatechange = function () {
  391. if ((scriptNode.readyState == 'loaded' || scriptNode.readyState == 'complete') && !scriptNode.onloadDone) {
  392. scriptNode.onloadDone = true;
  393. JSLOADED[src] = 1;
  394. }
  395. };
  396. } else if (text) {
  397. scriptNode.text = text;
  398. }
  399. document.getElementsByTagName('head')[0].appendChild(scriptNode);
  400. } catch (e) {
  401. }
  402. }
  403. function stripscript(s) {
  404. return s.replace(/<script.*?>.*?<\/script>/ig, '');
  405. }
  406. function ajaxmenu(ctrlObj, timeout, cache, duration, pos, recall, idclass, contentclass) {
  407. if (!ctrlObj.getAttribute('mid')) {
  408. var ctrlid = ctrlObj.id;
  409. if (!ctrlid) {
  410. ctrlObj.id = 'ajaxid_' + Math.random();
  411. }
  412. } else {
  413. var ctrlid = ctrlObj.getAttribute('mid');
  414. if (!ctrlObj.id) {
  415. ctrlObj.id = 'ajaxid_' + Math.random();
  416. }
  417. }
  418. var menuid = ctrlid + '_menu';
  419. var menu = $(menuid);
  420. if (isUndefined(timeout)) timeout = 3000;
  421. if (isUndefined(cache)) cache = 1;
  422. if (isUndefined(pos)) pos = '43';
  423. if (isUndefined(duration)) duration = timeout > 0 ? 0 : 3;
  424. if (isUndefined(idclass)) idclass = 'p_pop';
  425. if (isUndefined(contentclass)) contentclass = 'p_opt';
  426. var func = function () {
  427. showMenu({
  428. 'ctrlid': ctrlObj.id,
  429. 'menuid': menuid,
  430. 'duration': duration,
  431. 'timeout': timeout,
  432. 'pos': pos,
  433. 'cache': cache,
  434. 'layer': 2
  435. });
  436. if (typeof recall == 'function') {
  437. recall();
  438. } else {
  439. eval(recall);
  440. }
  441. };
  442. if (menu) {
  443. if (menu.style.display == '') {
  444. hideMenu(menuid);
  445. } else {
  446. func();
  447. }
  448. } else {
  449. menu = document.createElement('div');
  450. menu.id = menuid;
  451. menu.style.display = 'none';
  452. menu.className = idclass;
  453. menu.innerHTML = '<div class="' + contentclass + '" id="' + menuid + '_content"></div>';
  454. $('append_parent').appendChild(menu);
  455. var url = (!isUndefined(ctrlObj.attributes['shref']) ? ctrlObj.attributes['shref'].value : (!isUndefined(ctrlObj.href) ? ctrlObj.href : ctrlObj.attributes['href'].value));
  456. url += (url.indexOf('?') != -1 ? '&' : '?') + 'ajaxmenu=1';
  457. ajaxget(url, menuid + '_content', 'ajaxwaitid', '', '', func);
  458. }
  459. doane();
  460. }
  461. function hash(string, length) {
  462. var length = length ? length : 32;
  463. var start = 0;
  464. var i = 0;
  465. var result = '';
  466. filllen = length - string.length % length;
  467. for (i = 0; i < filllen; i++) {
  468. string += "0";
  469. }
  470. while (start < string.length) {
  471. result = stringxor(result, string.substr(start, length));
  472. start += length;
  473. }
  474. return result;
  475. }
  476. function stringxor(s1, s2) {
  477. var s = '';
  478. var hash = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  479. var max = Math.max(s1.length, s2.length);
  480. for (var i = 0; i < max; i++) {
  481. var k = s1.charCodeAt(i) ^ s2.charCodeAt(i);
  482. s += hash.charAt(k % 52);
  483. }
  484. return s;
  485. }
  486. function showPreview(val, id) {
  487. var showObj = $(id);
  488. if (showObj) {
  489. showObj.innerHTML = val.replace(/\n/ig, "<bupdateseccoder />");
  490. }
  491. }
  492. function doane(event, preventDefault, stopPropagation) {
  493. var preventDefault = isUndefined(preventDefault) ? 1 : preventDefault;
  494. var stopPropagation = isUndefined(stopPropagation) ? 1 : stopPropagation;
  495. e = event ? event : window.event;
  496. if (!e) {
  497. e = getEvent();
  498. }
  499. if (!e) {
  500. return null;
  501. }
  502. if (preventDefault) {
  503. if (e.preventDefault) {
  504. e.preventDefault();
  505. } else {
  506. e.returnValue = false;
  507. }
  508. }
  509. if (stopPropagation) {
  510. if (e.stopPropagation) {
  511. e.stopPropagation();
  512. } else {
  513. e.cancelBubble = true;
  514. }
  515. }
  516. return e;
  517. }
  518. function showMenu(v) {
  519. var ctrlid = isUndefined(v['ctrlid']) ? v : v['ctrlid'];
  520. var showid = isUndefined(v['showid']) ? ctrlid : v['showid'];
  521. var menuid = isUndefined(v['menuid']) ? showid + '_menu' : v['menuid'];
  522. var ctrlObj = $(ctrlid);
  523. var menuObj = $(menuid);
  524. if (!menuObj) return;
  525. var mtype = isUndefined(v['mtype']) ? 'menu' : v['mtype'];
  526. var evt = isUndefined(v['evt']) ? 'mouseover' : v['evt'];
  527. var pos = isUndefined(v['pos']) ? '43' : v['pos'];
  528. var layer = isUndefined(v['layer']) ? 1 : v['layer'];
  529. var duration = isUndefined(v['duration']) ? 2 : v['duration'];
  530. var timeout = isUndefined(v['timeout']) ? 250 : v['timeout'];
  531. var maxh = isUndefined(v['maxh']) ? 600 : v['maxh'];
  532. var cache = isUndefined(v['cache']) ? 1 : v['cache'];
  533. var drag = isUndefined(v['drag']) ? '' : v['drag'];
  534. var dragobj = drag && $(drag) ? $(drag) : menuObj;
  535. var fade = isUndefined(v['fade']) ? 0 : v['fade'];
  536. var cover = isUndefined(v['cover']) ? 0 : v['cover'];
  537. var zindex = isUndefined(v['zindex']) ? JSMENU['zIndex']['menu'] : v['zindex'];
  538. var ctrlclass = isUndefined(v['ctrlclass']) ? '' : v['ctrlclass'];
  539. var winhandlekey = isUndefined(v['win']) ? '' : v['win'];
  540. if (winhandlekey && ctrlObj && !ctrlObj.getAttribute('fwin')) {
  541. ctrlObj.setAttribute('fwin', winhandlekey);
  542. }
  543. zindex = cover ? zindex + 500 : zindex;
  544. if (typeof JSMENU['active'][layer] == 'undefined') {
  545. JSMENU['active'][layer] = [];
  546. }
  547. for (i in EXTRAFUNC['showmenu']) {
  548. try {
  549. eval(EXTRAFUNC['showmenu'][i] + '()');
  550. } catch (e) {
  551. }
  552. }
  553. if (evt == 'click' && in_array(menuid, JSMENU['active'][layer]) && mtype != 'win') {
  554. hideMenu(menuid, mtype);
  555. return;
  556. }
  557. if (mtype == 'menu') {
  558. hideMenu(layer, mtype);
  559. }
  560. if (ctrlObj) {
  561. if (!ctrlObj.getAttribute('initialized')) {
  562. ctrlObj.setAttribute('initialized', true);
  563. ctrlObj.unselectable = true;
  564. ctrlObj.outfunc = typeof ctrlObj.onmouseout == 'function' ? ctrlObj.onmouseout : null;
  565. ctrlObj.onmouseout = function () {
  566. if (this.outfunc) this.outfunc();
  567. if (duration < 3 && !JSMENU['timer'][menuid]) {
  568. JSMENU['timer'][menuid] = setTimeout(function () {
  569. hideMenu(menuid, mtype);
  570. }, timeout);
  571. }
  572. };
  573. ctrlObj.overfunc = typeof ctrlObj.onmouseover == 'function' ? ctrlObj.onmouseover : null;
  574. ctrlObj.onmouseover = function (e) {
  575. doane(e);
  576. if (this.overfunc) this.overfunc();
  577. if (evt == 'click') {
  578. clearTimeout(JSMENU['timer'][menuid]);
  579. JSMENU['timer'][menuid] = null;
  580. } else {
  581. for (var i in JSMENU['timer']) {
  582. if (JSMENU['timer'][i]) {
  583. clearTimeout(JSMENU['timer'][i]);
  584. JSMENU['timer'][i] = null;
  585. }
  586. }
  587. }
  588. };
  589. }
  590. }
  591. if (!menuObj.getAttribute('initialized')) {
  592. menuObj.setAttribute('initialized', true);
  593. menuObj.ctrlkey = ctrlid;
  594. menuObj.mtype = mtype;
  595. menuObj.layer = layer;
  596. menuObj.cover = cover;
  597. if (ctrlObj && ctrlObj.getAttribute('fwin')) {
  598. menuObj.scrolly = true;
  599. }
  600. menuObj.style.position = 'absolute';
  601. menuObj.style.zIndex = zindex + layer;
  602. menuObj.onclick = function (e) {
  603. return doane(e, 0, 1);
  604. };
  605. if (duration < 3) {
  606. if (duration > 1) {
  607. menuObj.onmouseover = function () {
  608. clearTimeout(JSMENU['timer'][menuid]);
  609. JSMENU['timer'][menuid] = null;
  610. };
  611. }
  612. if (duration != 1) {
  613. menuObj.onmouseout = function () {
  614. JSMENU['timer'][menuid] = setTimeout(function () {
  615. hideMenu(menuid, mtype);
  616. }, timeout);
  617. };
  618. }
  619. }
  620. if (cover) {
  621. var coverObj = document.createElement('div');
  622. coverObj.id = menuid + '_cover';
  623. coverObj.style.position = 'absolute';
  624. coverObj.style.zIndex = menuObj.style.zIndex - 1;
  625. coverObj.style.left = coverObj.style.top = '0px';
  626. coverObj.style.width = '100%';
  627. coverObj.style.height = Math.max(document.documentElement.clientHeight, document.body.offsetHeight) + 'px';
  628. coverObj.style.backgroundColor = '#000';
  629. coverObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=50)';
  630. coverObj.style.opacity = 0.5;
  631. coverObj.onclick = function () {
  632. hideMenu();
  633. };
  634. $('append_parent').appendChild(coverObj);
  635. _attachEvent(window, 'load', function () {
  636. coverObj.style.height = Math.max(document.documentElement.clientHeight, document.body.offsetHeight) + 'px';
  637. }, document);
  638. }
  639. }
  640. if (drag) {
  641. dragobj.style.cursor = 'move';
  642. dragobj.onmousedown = function (event) {
  643. try {
  644. dragMenu(menuObj, event, 1);
  645. } catch (e) {
  646. }
  647. };
  648. }
  649. if (cover) $(menuid + '_cover').style.display = '';
  650. if (fade) {
  651. var O = 0;
  652. var fadeIn = function (O) {
  653. if (O > 100) {
  654. clearTimeout(fadeInTimer);
  655. return;
  656. }
  657. menuObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + O + ')';
  658. menuObj.style.opacity = O / 100;
  659. O += 20;
  660. var fadeInTimer = setTimeout(function () {
  661. fadeIn(O);
  662. }, 40);
  663. };
  664. fadeIn(O);
  665. menuObj.fade = true;
  666. } else {
  667. menuObj.fade = false;
  668. }
  669. menuObj.style.display = '';
  670. if (ctrlObj && ctrlclass) {
  671. ctrlObj.className += ' ' + ctrlclass;
  672. menuObj.setAttribute('ctrlid', ctrlid);
  673. menuObj.setAttribute('ctrlclass', ctrlclass);
  674. }
  675. if (pos != '*') {
  676. setMenuPosition(showid, menuid, pos);
  677. }
  678. if (BROWSER.ie && BROWSER.ie < 7 && winhandlekey && $('fwin_' + winhandlekey)) {
  679. $(menuid).style.left = (parseInt($(menuid).style.left) - parseInt($('fwin_' + winhandlekey).style.left)) + 'px';
  680. $(menuid).style.top = (parseInt($(menuid).style.top) - parseInt($('fwin_' + winhandlekey).style.top)) + 'px';
  681. }
  682. if (maxh && menuObj.scrollHeight > maxh) {
  683. menuObj.style.height = maxh + 'px';
  684. if (BROWSER.opera) {
  685. menuObj.style.overflow = 'auto';
  686. } else {
  687. menuObj.style.overflowY = 'auto';
  688. }
  689. }
  690. if (!duration) {
  691. setTimeout('hideMenu(\'' + menuid + '\', \'' + mtype + '\')', timeout);
  692. }
  693. if (!in_array(menuid, JSMENU['active'][layer])) JSMENU['active'][layer].push(menuid);
  694. menuObj.cache = cache;
  695. if (layer > JSMENU['layer']) {
  696. JSMENU['layer'] = layer;
  697. }
  698. var hasshow = function (ele) {
  699. while (ele.parentNode && ((typeof (ele['currentStyle']) === 'undefined') ? window.getComputedStyle(ele, null) : ele['currentStyle'])['display'] !== 'none') {
  700. ele = ele.parentNode;
  701. }
  702. if (ele === document) {
  703. return true;
  704. } else {
  705. return false;
  706. }
  707. };
  708. if (!menuObj.getAttribute('disautofocus')) {
  709. try {
  710. var focused = false;
  711. var tags = ['input', 'select', 'textarea', 'button', 'a'];
  712. for (var i = 0; i < tags.length; i++) {
  713. var _all = menuObj.getElementsByTagName(tags[i]);
  714. if (_all.length) {
  715. for (j = 0; j < _all.length; j++) {
  716. if ((!_all[j]['type'] || _all[j]['type'] != 'hidden') && hasshow(_all[j])) {
  717. _all[j].className += ' hidefocus';
  718. _all[j].focus();
  719. focused = true;
  720. var cobj = _all[j];
  721. _attachEvent(_all[j], 'blur', function () {
  722. cobj.className = trim(cobj.className.replace(' hidefocus', ''));
  723. });
  724. break;
  725. }
  726. }
  727. }
  728. if (focused) {
  729. break;
  730. }
  731. }
  732. } catch (e) {
  733. }
  734. }
  735. }
  736. var delayShowST = null;
  737. function delayShow(ctrlObj, call, time) {
  738. if (typeof ctrlObj == 'object') {
  739. var ctrlid = ctrlObj.id;
  740. call = call || function () {
  741. showMenu(ctrlid);
  742. };
  743. }
  744. var time = isUndefined(time) ? 500 : time;
  745. delayShowST = setTimeout(function () {
  746. if (typeof call == 'function') {
  747. call();
  748. } else {
  749. eval(call);
  750. }
  751. }, time);
  752. if (!ctrlObj.delayinit) {
  753. _attachEvent(ctrlObj, 'mouseout', function () {
  754. clearTimeout(delayShowST);
  755. });
  756. ctrlObj.delayinit = 1;
  757. }
  758. }
  759. var dragMenuDisabled = false;
  760. function dragMenu(menuObj, e, op) {
  761. e = e ? e : window.event;
  762. if (op == 1) {
  763. if (dragMenuDisabled || in_array(e.target ? e.target.tagName : e.srcElement.tagName, ['TEXTAREA', 'INPUT', 'BUTTON', 'SELECT'])) {
  764. return;
  765. }
  766. JSMENU['drag'] = [e.clientX, e.clientY];
  767. JSMENU['drag'][2] = parseInt(menuObj.style.left);
  768. JSMENU['drag'][3] = parseInt(menuObj.style.top);
  769. document.onmousemove = function (e) {
  770. try {
  771. dragMenu(menuObj, e, 2);
  772. } catch (err) {
  773. }
  774. };
  775. document.onmouseup = function (e) {
  776. try {
  777. dragMenu(menuObj, e, 3);
  778. } catch (err) {
  779. }
  780. };
  781. doane(e);
  782. } else if (op == 2 && JSMENU['drag'][0]) {
  783. var menudragnow = [e.clientX, e.clientY];
  784. menuObj.style.left = (JSMENU['drag'][2] + menudragnow[0] - JSMENU['drag'][0]) + 'px';
  785. menuObj.style.top = (JSMENU['drag'][3] + menudragnow[1] - JSMENU['drag'][1]) + 'px';
  786. menuObj.removeAttribute('top_');
  787. menuObj.removeAttribute('left_');
  788. doane(e);
  789. } else if (op == 3) {
  790. JSMENU['drag'] = [];
  791. document.onmousemove = null;
  792. document.onmouseup = null;
  793. }
  794. }
  795. function setMenuPosition(showid, menuid, pos) {
  796. var showObj = $(showid);
  797. var menuObj = menuid ? $(menuid) : $(showid + '_menu');
  798. if (isUndefined(pos) || !pos) pos = '43';
  799. var basePoint = parseInt(pos.substr(0, 1));
  800. var direction = parseInt(pos.substr(1, 1));
  801. var important = pos.indexOf('!') != -1 ? 1 : 0;
  802. 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;
  803. if (!menuObj || (basePoint > 0 && !showObj)) return;
  804. if (showObj) {
  805. sxy = fetchOffset(showObj);
  806. sx = sxy['left'];
  807. sy = sxy['top'];
  808. sw = showObj.offsetWidth;
  809. sh = showObj.offsetHeight;
  810. }
  811. mw = menuObj.offsetWidth;
  812. mcw = menuObj.clientWidth;
  813. mh = menuObj.offsetHeight;
  814. mch = menuObj.clientHeight;
  815. switch (basePoint) {
  816. case 1:
  817. bpl = sx;
  818. bpt = sy;
  819. break;
  820. case 2:
  821. bpl = sx + sw;
  822. bpt = sy;
  823. break;
  824. case 3:
  825. bpl = sx + sw;
  826. bpt = sy + sh;
  827. break;
  828. case 4:
  829. bpl = sx;
  830. bpt = sy + sh;
  831. break;
  832. }
  833. switch (direction) {
  834. case 0:
  835. menuObj.style.left = (document.body.clientWidth - menuObj.clientWidth) / 2 + 'px';
  836. mt = (document.documentElement.clientHeight - menuObj.clientHeight) / 2;
  837. break;
  838. case 1:
  839. ml = bpl - mw;
  840. mt = bpt - mh;
  841. break;
  842. case 2:
  843. ml = bpl;
  844. mt = bpt - mh;
  845. break;
  846. case 3:
  847. ml = bpl;
  848. mt = bpt;
  849. break;
  850. case 4:
  851. ml = bpl - mw;
  852. mt = bpt;
  853. break;
  854. }
  855. var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
  856. var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
  857. if (!important) {
  858. if (in_array(direction, [1, 4]) && ml < 0) {
  859. ml = bpl;
  860. if (in_array(basePoint, [1, 4])) ml += sw;
  861. } else if (ml + mw > scrollLeft + document.body.clientWidth && sx >= mw) {
  862. ml = bpl - mw;
  863. if (in_array(basePoint, [2, 3])) {
  864. ml -= sw;
  865. } else if (basePoint == 4) {
  866. ml += sw;
  867. }
  868. }
  869. if (in_array(direction, [1, 2]) && mt < 0) {
  870. mt = bpt;
  871. if (in_array(basePoint, [1, 2])) mt += sh;
  872. } else if (mt + mh > scrollTop + document.documentElement.clientHeight && sy >= mh) {
  873. mt = bpt - mh;
  874. if (in_array(basePoint, [3, 4])) mt -= sh;
  875. }
  876. }
  877. if (pos.substr(0, 3) == '210') {
  878. ml += 69 - sw / 2;
  879. mt -= 5;
  880. if (showObj.tagName == 'TEXTAREA') {
  881. ml -= sw / 2;
  882. mt += sh / 2;
  883. }
  884. }
  885. if (direction == 0 || menuObj.scrolly) {
  886. if (BROWSER.ie && BROWSER.ie < 7) {
  887. if (direction == 0) mt += scrollTop;
  888. } else {
  889. if (menuObj.scrolly) mt -= scrollTop;
  890. menuObj.style.position = 'fixed';
  891. }
  892. }
  893. if (ml) menuObj.style.left = ml + 'px';
  894. if (mt) menuObj.style.top = mt + 'px';
  895. if (direction == 0 && BROWSER.ie && !document.documentElement.clientHeight) {
  896. menuObj.style.position = 'absolute';
  897. menuObj.style.top = (document.body.clientHeight - menuObj.clientHeight) / 2 + 'px';
  898. }
  899. if (menuObj.style.clip && !BROWSER.opera) {
  900. menuObj.style.clip = 'rect(auto, auto, auto, auto)';
  901. }
  902. }
  903. function hideMenu(attr, mtype) {
  904. attr = isUndefined(attr) ? '' : attr;
  905. mtype = isUndefined(mtype) ? 'menu' : mtype;
  906. if (attr == '') {
  907. for (var i = 1; i <= JSMENU['layer']; i++) {
  908. hideMenu(i, mtype);
  909. }
  910. return;
  911. } else if (typeof attr == 'number') {
  912. for (var j in JSMENU['active'][attr]) {
  913. hideMenu(JSMENU['active'][attr][j], mtype);
  914. }
  915. return;
  916. } else if (typeof attr == 'string') {
  917. var menuObj = $(attr);
  918. if (!menuObj || (mtype && menuObj.mtype != mtype)) return;
  919. var ctrlObj = '', ctrlclass = '';
  920. if ((ctrlObj = $(menuObj.getAttribute('ctrlid'))) && (ctrlclass = menuObj.getAttribute('ctrlclass'))) {
  921. var reg = new RegExp(' ' + ctrlclass);
  922. ctrlObj.className = ctrlObj.className.replace(reg, '');
  923. }
  924. clearTimeout(JSMENU['timer'][attr]);
  925. var hide = function () {
  926. if (menuObj.cache) {
  927. if (menuObj.style.visibility != 'hidden') {
  928. menuObj.style.display = 'none';
  929. if (menuObj.cover) $(attr + '_cover').style.display = 'none';
  930. }
  931. } else {
  932. menuObj.parentNode.removeChild(menuObj);
  933. if (menuObj.cover) $(attr + '_cover').parentNode.removeChild($(attr + '_cover'));
  934. }
  935. var tmp = [];
  936. for (var k in JSMENU['active'][menuObj.layer]) {
  937. if (attr != JSMENU['active'][menuObj.layer][k]) tmp.push(JSMENU['active'][menuObj.layer][k]);
  938. }
  939. JSMENU['active'][menuObj.layer] = tmp;
  940. };
  941. if (menuObj.fade) {
  942. var O = 100;
  943. var fadeOut = function (O) {
  944. if (O == 0) {
  945. clearTimeout(fadeOutTimer);
  946. hide();
  947. return;
  948. }
  949. menuObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + O + ')';
  950. menuObj.style.opacity = O / 100;
  951. O -= 20;
  952. var fadeOutTimer = setTimeout(function () {
  953. fadeOut(O);
  954. }, 40);
  955. };
  956. fadeOut(O);
  957. } else {
  958. hide();
  959. }
  960. }
  961. }
  962. function getCurrentStyle(obj, cssproperty, csspropertyNS) {
  963. if (obj.style[cssproperty]) {
  964. return obj.style[cssproperty];
  965. }
  966. if (obj.currentStyle) {
  967. return obj.currentStyle[cssproperty];
  968. } else if (document.defaultView.getComputedStyle(obj, null)) {
  969. var currentStyle = document.defaultView.getComputedStyle(obj, null);
  970. var value = currentStyle.getPropertyValue(csspropertyNS);
  971. if (!value) {
  972. value = currentStyle[cssproperty];
  973. }
  974. return value;
  975. } else if (window.getComputedStyle) {
  976. var currentStyle = window.getComputedStyle(obj, "");
  977. return currentStyle.getPropertyValue(csspropertyNS);
  978. }
  979. }
  980. function fetchOffset(obj, mode) {
  981. var left_offset = 0, top_offset = 0, mode = !mode ? 0 : mode;
  982. if (obj.getBoundingClientRect && !mode) {
  983. var rect = obj.getBoundingClientRect();
  984. var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
  985. var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
  986. if (document.documentElement.dir == 'rtl') {
  987. scrollLeft = scrollLeft + document.documentElement.clientWidth - document.documentElement.scrollWidth;
  988. }
  989. left_offset = rect.left + scrollLeft - document.documentElement.clientLeft;
  990. top_offset = rect.top + scrollTop - document.documentElement.clientTop;
  991. }
  992. if (left_offset <= 0 || top_offset <= 0) {
  993. left_offset = obj.offsetLeft;
  994. top_offset = obj.offsetTop;
  995. while ((obj = obj.offsetParent) != null) {
  996. position = getCurrentStyle(obj, 'position', 'position');
  997. if (position == 'relative') {
  998. continue;
  999. }
  1000. left_offset += obj.offsetLeft;
  1001. top_offset += obj.offsetTop;
  1002. }
  1003. }
  1004. return {'left': left_offset, 'top': top_offset};
  1005. }
  1006. function showTip(ctrlobj) {
  1007. $F('_showTip', arguments);
  1008. }
  1009. function showPrompt(ctrlid, evt, msg, timeout, classname) {
  1010. $F('_showPrompt', arguments);
  1011. }
  1012. function showCreditPrompt() {
  1013. $F('_showCreditPrompt', []);
  1014. }
  1015. function hideWindow(k, all, clear) {
  1016. all = isUndefined(all) ? 1 : all;
  1017. clear = isUndefined(clear) ? 1 : clear;
  1018. hideMenu('fwin_' + k, 'win');
  1019. if (clear && $('fwin_' + k)) {
  1020. $('append_parent').removeChild($('fwin_' + k));
  1021. }
  1022. if (all) {
  1023. hideMenu();
  1024. }
  1025. }
  1026. function AC_FL_RunContent() {
  1027. var str = '';
  1028. var ret = AC_GetArgs(arguments, "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash");
  1029. if (BROWSER.ie && !BROWSER.opera) {
  1030. str += '<object ';
  1031. for (var i in ret.objAttrs) {
  1032. str += i + '="' + ret.objAttrs[i] + '" ';
  1033. }
  1034. str += '>';
  1035. for (var i in ret.params) {
  1036. str += '<param name="' + i + '" value="' + ret.params[i] + '" /> ';
  1037. }
  1038. str += '</object>';
  1039. } else {
  1040. str += '<embed ';
  1041. for (var i in ret.embedAttrs) {
  1042. str += i + '="' + ret.embedAttrs[i] + '" ';
  1043. }
  1044. str += '></embed>';
  1045. }
  1046. return str;
  1047. }
  1048. function AC_GetArgs(args, classid, mimeType) {
  1049. var ret = new Object();
  1050. ret.embedAttrs = new Object();
  1051. ret.params = new Object();
  1052. ret.objAttrs = new Object();
  1053. for (var i = 0; i < args.length; i = i + 2) {
  1054. var currArg = args[i].toLowerCase();
  1055. switch (currArg) {
  1056. case"classid":
  1057. break;
  1058. case"pluginspage":
  1059. ret.embedAttrs[args[i]] = 'http://www.macromedia.com/go/getflashplayer';
  1060. break;
  1061. case"src":
  1062. ret.embedAttrs[args[i]] = args[i + 1];
  1063. ret.params["movie"] = args[i + 1];
  1064. break;
  1065. case"codebase":
  1066. ret.objAttrs[args[i]] = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0';
  1067. break;
  1068. case"onafterupdate":
  1069. case"onbeforeupdate":
  1070. case"onblur":
  1071. case"oncellchange":
  1072. case"onclick":
  1073. case"ondblclick":
  1074. case"ondrag":
  1075. case"ondragend":
  1076. case"ondragenter":
  1077. case"ondragleave":
  1078. case"ondragover":
  1079. case"ondrop":
  1080. case"onfinish":
  1081. case"onfocus":
  1082. case"onhelp":
  1083. case"onmousedown":
  1084. case"onmouseup":
  1085. case"onmouseover":
  1086. case"onmousemove":
  1087. case"onmouseout":
  1088. case"onkeypress":
  1089. case"onkeydown":
  1090. case"onkeyup":
  1091. case"onload":
  1092. case"onlosecapture":
  1093. case"onpropertychange":
  1094. case"onreadystatechange":
  1095. case"onrowsdelete":
  1096. case"onrowenter":
  1097. case"onrowexit":
  1098. case"onrowsinserted":
  1099. case"onstart":
  1100. case"onscroll":
  1101. case"onbeforeeditfocus":
  1102. case"onactivate":
  1103. case"onbeforedeactivate":
  1104. case"ondeactivate":
  1105. case"type":
  1106. case"id":
  1107. ret.objAttrs[args[i]] = args[i + 1];
  1108. break;
  1109. case"width":
  1110. case"height":
  1111. case"align":
  1112. case"vspace":
  1113. case"hspace":
  1114. case"class":
  1115. case"title":
  1116. case"accesskey":
  1117. case"name":
  1118. case"tabindex":
  1119. ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i + 1];
  1120. break;
  1121. default:
  1122. ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i + 1];
  1123. }
  1124. }
  1125. ret.objAttrs["classid"] = classid;
  1126. if (mimeType) {
  1127. ret.embedAttrs["type"] = mimeType;
  1128. }
  1129. return ret;
  1130. }
  1131. function simulateSelect(selectId, widthvalue) {
  1132. var selectObj = $(selectId);
  1133. if (!selectObj) return;
  1134. if (BROWSER.other) {
  1135. if (selectObj.getAttribute('change')) {
  1136. selectObj.onchange = function () {
  1137. eval(selectObj.getAttribute('change'));
  1138. }
  1139. }
  1140. return;
  1141. }
  1142. var widthvalue = widthvalue ? widthvalue : 70;
  1143. var defaultopt = selectObj.options[0] ? selectObj.options[0].innerHTML : '';
  1144. var defaultv = '';
  1145. var menuObj = document.createElement('div');
  1146. var ul = document.createElement('ul');
  1147. var handleKeyDown = function (e) {
  1148. e = BROWSER.ie ? event : e;
  1149. if (e.keyCode == 40 || e.keyCode == 38) doane(e);
  1150. };
  1151. var selectwidth = (selectObj.getAttribute('width', i) ? selectObj.getAttribute('width', i) : widthvalue) + 'px';
  1152. var tabindex = selectObj.getAttribute('tabindex', i) ? selectObj.getAttribute('tabindex', i) : 1;
  1153. for (var i = 0; i < selectObj.options.length; i++) {
  1154. var li = document.createElement('li');
  1155. li.innerHTML = selectObj.options[i].innerHTML;
  1156. li.k_id = i;
  1157. li.k_value = selectObj.options[i].value;
  1158. if (selectObj.options[i].selected) {
  1159. defaultopt = selectObj.options[i].innerHTML;
  1160. defaultv = selectObj.options[i].value;
  1161. li.className = 'current';
  1162. selectObj.setAttribute('selecti', i);
  1163. }
  1164. li.onclick = function () {
  1165. if ($(selectId + '_ctrl').innerHTML != this.innerHTML) {
  1166. var lis = menuObj.getElementsByTagName('li');
  1167. lis[$(selectId).getAttribute('selecti')].className = '';
  1168. this.className = 'current';
  1169. $(selectId + '_ctrl').innerHTML = this.innerHTML;
  1170. $(selectId).setAttribute('selecti', this.k_id);
  1171. $(selectId).options.length = 0;
  1172. $(selectId).options[0] = new Option('', this.k_value);
  1173. eval(selectObj.getAttribute('change'));
  1174. }
  1175. hideMenu(menuObj.id);
  1176. return false;
  1177. };
  1178. ul.appendChild(li);
  1179. }
  1180. selectObj.options.length = 0;
  1181. selectObj.options[0] = new Option('', defaultv);
  1182. selectObj.style.display = 'none';
  1183. selectObj.outerHTML += '<a href="javascript:;" id="' + selectId + '_ctrl" style="width:' + selectwidth + '" tabindex="' + tabindex + '">' + defaultopt + '</a>';
  1184. menuObj.id = selectId + '_ctrl_menu';
  1185. menuObj.className = 'sltm';
  1186. menuObj.style.display = 'none';
  1187. menuObj.style.width = selectwidth;
  1188. menuObj.appendChild(ul);
  1189. $('append_parent').appendChild(menuObj);
  1190. $(selectId + '_ctrl').onclick = function (e) {
  1191. $(selectId + '_ctrl_menu').style.width = selectwidth;
  1192. showMenu({
  1193. 'ctrlid': (selectId == 'loginfield' ? 'account' : selectId + '_ctrl'),
  1194. 'menuid': selectId + '_ctrl_menu',
  1195. 'evt': 'click',
  1196. 'pos': '43'
  1197. });
  1198. doane(e);
  1199. };
  1200. $(selectId + '_ctrl').onfocus = menuObj.onfocus = function () {
  1201. _attachEvent(document.body, 'keydown', handleKeyDown);
  1202. };
  1203. $(selectId + '_ctrl').onblur = menuObj.onblur = function () {
  1204. _detachEvent(document.body, 'keydown', handleKeyDown);
  1205. };
  1206. $(selectId + '_ctrl').onkeyup = function (e) {
  1207. e = e ? e : window.event;
  1208. value = e.keyCode;
  1209. if (value == 40 || value == 38) {
  1210. if (menuObj.style.display == 'none') {
  1211. $(selectId + '_ctrl').onclick();
  1212. } else {
  1213. lis = menuObj.getElementsByTagName('li');
  1214. selecti = selectObj.getAttribute('selecti');
  1215. lis[selecti].className = '';
  1216. if (value == 40) {
  1217. selecti = parseInt(selecti) + 1;
  1218. } else if (value == 38) {
  1219. selecti = parseInt(selecti) - 1;
  1220. }
  1221. if (selecti < 0) {
  1222. selecti = lis.length - 1
  1223. } else if (selecti > lis.length - 1) {
  1224. selecti = 0;
  1225. }
  1226. lis[selecti].className = 'current';
  1227. selectObj.setAttribute('selecti', selecti);
  1228. lis[selecti].parentNode.scrollTop = lis[selecti].offsetTop;
  1229. }
  1230. } else if (value == 13) {
  1231. var lis = menuObj.getElementsByTagName('li');
  1232. lis[selectObj.getAttribute('selecti')].onclick();
  1233. } else if (value == 27) {
  1234. hideMenu(menuObj.id);
  1235. }
  1236. };
  1237. }
  1238. function switchTab(prefix, current, total, activeclass) {
  1239. $F('_switchTab', arguments);
  1240. }
  1241. function imageRotate(imgid, direct) {
  1242. $F('_imageRotate', arguments);
  1243. }
  1244. function thumbImg(obj, method) {
  1245. if (!obj) {
  1246. return;
  1247. }
  1248. obj.onload = null;
  1249. file = obj.src;
  1250. zw = obj.offsetWidth;
  1251. zh = obj.offsetHeight;
  1252. if (zw < 2) {
  1253. if (!obj.id) {
  1254. obj.id = 'img_' + Math.random();
  1255. }
  1256. setTimeout("thumbImg($('" + obj.id + "'), " + method + ")", 100);
  1257. return;
  1258. }
  1259. zr = zw / zh;
  1260. method = !method ? 0 : 1;
  1261. if (method) {
  1262. fixw = obj.getAttribute('_width');
  1263. fixh = obj.getAttribute('_height');
  1264. if (zw > fixw) {
  1265. zw = fixw;
  1266. zh = zw / zr;
  1267. }
  1268. if (zh > fixh) {
  1269. zh = fixh;
  1270. zw = zh * zr;
  1271. }
  1272. } else {
  1273. fixw = typeof imagemaxwidth == 'undefined' ? '600' : imagemaxwidth;
  1274. if (zw > fixw) {
  1275. zw = fixw;
  1276. zh = zw / zr;
  1277. obj.style.cursor = 'pointer';
  1278. if (!obj.onclick) {
  1279. obj.onclick = function () {
  1280. zoom(obj, obj.src);
  1281. };
  1282. }
  1283. }
  1284. }
  1285. obj.width = zw;
  1286. obj.height = zh;
  1287. }
  1288. var zoomstatus = 1;
  1289. function zoom(obj, zimg, nocover, pn, showexif) {
  1290. $F('_zoom', arguments);
  1291. }
  1292. function showselect(obj, inpid, t, rettype) {
  1293. $F('_showselect', arguments);
  1294. }
  1295. function showColorBox(ctrlid, layer, k, bgcolor) {
  1296. $F('_showColorBox', arguments);
  1297. }
  1298. function ctrlEnter(event, btnId, onlyEnter) {
  1299. if (isUndefined(onlyEnter)) onlyEnter = 0;
  1300. if ((event.ctrlKey || onlyEnter) && event.keyCode == 13) {
  1301. $(btnId).click();
  1302. return false;
  1303. }
  1304. return true;
  1305. }
  1306. function parseurl(str, mode, parsecode) {
  1307. if (isUndefined(parsecode)) parsecode = true;
  1308. if (parsecode) str = str.replace(/\[code\]([\s\S]+?)\[\/code\]/ig, function ($1, $2) {
  1309. return codetag($2, -1);
  1310. });
  1311. 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]');
  1312. 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]');
  1313. 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]');
  1314. 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]');
  1315. str = str.replace(/([^\w->=\]:"'\.\/]|^)(([\-\.\w]+@[\.\-\w]+(\.\w+)+))/ig, mode == 'html' ? '$1<a href="mailto:$2">$2</a>' : '$1[email]$2[/email]');
  1316. if (parsecode) {
  1317. for (var i = 0; i <= DISCUZCODE['num']; i++) {
  1318. str = str.replace("[\tDISCUZ_CODE_" + i + "\t]", DISCUZCODE['html'][i]);
  1319. }
  1320. }
  1321. return str;
  1322. }
  1323. function codetag(text, br) {
  1324. var br = !br ? 1 : br;
  1325. DISCUZCODE['num']++;
  1326. if (br > 0 && typeof wysiwyg != 'undefined' && wysiwyg) text = text.replace(/<br[^\>]*>/ig, '\n');
  1327. text = text.replace(/\$/ig, '$$');
  1328. DISCUZCODE['html'][DISCUZCODE['num']] = '[code]' + text + '[/code]';
  1329. return '[\tDISCUZ_CODE_' + DISCUZCODE['num'] + '\t]';
  1330. }
  1331. function saveUserdata(name, data) {
  1332. try {
  1333. if (window.localStorage) {
  1334. localStorage.setItem('Discuz_' + name, data);
  1335. } else if (window.sessionStorage) {
  1336. sessionStorage.setItem('Discuz_' + name, data);
  1337. }
  1338. } catch (e) {
  1339. if (BROWSER.ie) {
  1340. if (data.length < 54889) {
  1341. with (document.documentElement) {
  1342. setAttribute("value", data);
  1343. save('Discuz_' + name);
  1344. }
  1345. }
  1346. }
  1347. }
  1348. setcookie('clearUserdata', '', -1);
  1349. }
  1350. function loadUserdata(name) {
  1351. if (window.localStorage) {
  1352. return localStorage.getItem('Discuz_' + name);
  1353. } else if (window.sessionStorage) {
  1354. return sessionStorage.getItem('Discuz_' + name);
  1355. } else if (BROWSER.ie) {
  1356. with (document.documentElement) {
  1357. load('Discuz_' + name);
  1358. return getAttribute("value");
  1359. }
  1360. }
  1361. }
  1362. function initTab(frameId, type) {
  1363. $F('_initTab', arguments);
  1364. }
  1365. function hasClass(elem, className) {
  1366. return elem.className && (" " + elem.className + " ").indexOf(" " + className + " ") != -1;
  1367. }
  1368. function runslideshow() {
  1369. $F('_runslideshow', []);
  1370. }
  1371. function toggle_collapse(objname, noimg, complex, lang) {
  1372. $F('_toggle_collapse', arguments);
  1373. }
  1374. function updatestring(str1, str2, clear) {
  1375. str2 = '_' + str2 + '_';
  1376. return clear ? str1.replace(str2, '') : (str1.indexOf(str2) == -1 ? str1 + str2 : str1);
  1377. }
  1378. function getClipboardData() {
  1379. window.document.clipboardswf.SetVariable('str', CLIPBOARDSWFDATA);
  1380. }
  1381. function setCopy(text, msg) {
  1382. $F('_setCopy', arguments);
  1383. }
  1384. function copycode(obj) {
  1385. $F('_copycode', arguments);
  1386. }
  1387. function showdistrict(container, elems, totallevel, changelevel, containertype) {
  1388. $F('_showdistrict', arguments);
  1389. }
  1390. function setDoodle(fid, oid, url, tid, from) {
  1391. $F('_setDoodle', arguments);
  1392. }
  1393. function extstyle(css) {
  1394. $F('_extstyle', arguments);
  1395. }
  1396. function widthauto(obj) {
  1397. $F('_widthauto', arguments);
  1398. }
  1399. var secST = new Array();
  1400. function updatesecqaa(idhash) {
  1401. $F('_updatesecqaa', arguments);
  1402. }
  1403. function updateseccode(idhash) {
  1404. $F('_updateseccode', arguments);
  1405. }
  1406. function checksec(type, idhash, showmsg, recall) {
  1407. $F('_checksec', arguments);
  1408. }
  1409. function createPalette(colorid, id, func) {
  1410. $F('_createPalette', arguments);
  1411. }
  1412. function showForummenu(fid) {
  1413. $F('_showForummenu', arguments);
  1414. }
  1415. function showUserApp() {
  1416. $F('_showUserApp', arguments);
  1417. }
  1418. function cardInit() {
  1419. var cardShow = function (obj) {
  1420. if (BROWSER.ie && BROWSER.ie < 7 && obj.href.indexOf('username') != -1) {
  1421. return;
  1422. }
  1423. pos = obj.getAttribute('c') == '1' ? '43' : obj.getAttribute('c');
  1424. USERCARDST = setTimeout(function () {
  1425. ajaxmenu(obj, 500, 1, 2, pos, null, 'p_pop card');
  1426. }, 250);
  1427. };
  1428. var cardids = {};
  1429. var a = document.body.getElementsByTagName('a');
  1430. for (var i = 0; i < a.length; i++) {
  1431. if (a[i].getAttribute('c')) {
  1432. var href = a[i].getAttribute('href', 1);
  1433. if (typeof cardids[href] == 'undefined') {
  1434. cardids[href] = Math.round(Math.random() * 10000);
  1435. }
  1436. a[i].setAttribute('mid', 'card_' + cardids[href]);
  1437. a[i].onmouseover = function () {
  1438. cardShow(this)
  1439. };
  1440. a[i].onmouseout = function () {
  1441. clearTimeout(USERCARDST);
  1442. };
  1443. }
  1444. }
  1445. }
  1446. function navShow(id) {
  1447. var mnobj = $('snav_mn_' + id);
  1448. if (!mnobj) {
  1449. return;
  1450. }
  1451. var uls = $('mu').getElementsByTagName('ul');
  1452. for (i = 0; i < uls.length; i++) {
  1453. if (uls[i].className != 'cl current') {
  1454. uls[i].style.display = 'none';
  1455. }
  1456. }
  1457. if (mnobj.className != 'cl current') {
  1458. showMenu({'ctrlid': 'mn_' + id, 'menuid': 'snav_mn_' + id, 'pos': '*'});
  1459. mnobj.className = 'cl floatmu';
  1460. mnobj.style.width = ($('nv').clientWidth) + 'px';
  1461. mnobj.style.display = '';
  1462. }
  1463. }
  1464. function strLenCalc(obj, checklen, maxlen) {
  1465. var v = obj.value, charlen = 0, maxlen = !maxlen ? 200 : maxlen, curlen = maxlen, len = strlen(v);
  1466. for (var i = 0; i < v.length; i++) {
  1467. if (v.charCodeAt(i) < 0 || v.charCodeAt(i) > 255) {
  1468. curlen -= charset == 'utf-8' ? 2 : 1;
  1469. }
  1470. }
  1471. if (curlen >= len) {
  1472. $(checklen).innerHTML = curlen - len;
  1473. } else {
  1474. obj.value = mb_cutstr(v, maxlen, 0);
  1475. }
  1476. }
  1477. function relatedlinks(rlinkmsgid) {
  1478. $F('_relatedlinks', arguments);
  1479. }
  1480. function con_handle_response(response) {
  1481. return response;
  1482. }
  1483. function showTopLink() {
  1484. var ft = $('ft');
  1485. if (ft) {
  1486. var scrolltop = $('scrolltop');
  1487. var viewPortHeight = parseInt(document.documentElement.clientHeight);
  1488. var scrollHeight = parseInt(document.body.getBoundingClientRect().top);
  1489. var basew = parseInt(ft.clientWidth);
  1490. var sw = scrolltop.clientWidth;
  1491. if (basew < 1000) {
  1492. var left = parseInt(fetchOffset(ft)['left']);
  1493. left = left < sw ? left * 2 - sw : left;
  1494. scrolltop.style.left = (basew + left) + 'px';
  1495. } else {
  1496. scrolltop.style.left = 'auto';
  1497. scrolltop.style.right = 0;
  1498. }
  1499. if (BROWSER.ie && BROWSER.ie < 7) {
  1500. scrolltop.style.top = viewPortHeight - scrollHeight - 150 + 'px';
  1501. }
  1502. if (scrollHeight < -100) {
  1503. scrolltop.style.visibility = 'visible';
  1504. } else {
  1505. scrolltop.style.visibility = 'hidden';
  1506. }
  1507. }
  1508. }
  1509. function showCreditmenu() {
  1510. $F('_showCreditmenu', []);
  1511. }
  1512. function showUpgradeinfo() {
  1513. $F('_showUpgradeinfo', []);
  1514. }
  1515. function setShortcut() {
  1516. var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
  1517. if (!loadUserdata('setshortcut') && !scrollTop) {
  1518. $F('_setShortcut', []);
  1519. }
  1520. }
  1521. function smilies_show(id, smcols, seditorkey) {
  1522. $F('_smilies_show', arguments, 'smilies');
  1523. }
  1524. function showfocus(ftype, autoshow) {
  1525. var id = parseInt($('focuscur').innerHTML);
  1526. if (ftype == 'prev') {
  1527. id = (id - 1) < 1 ? focusnum : (id - 1);
  1528. if (!autoshow) {
  1529. window.clearInterval(focusautoshow);
  1530. }
  1531. } else if (ftype == 'next') {
  1532. id = (id + 1) > focusnum ? 1 : (id + 1);
  1533. if (!autoshow) {
  1534. window.clearInterval(focusautoshow);
  1535. }
  1536. }
  1537. $('focuscur').innerHTML = id;
  1538. $('focus_con').innerHTML = $('focus_' + (id - 1)).innerHTML;
  1539. }
  1540. function rateStarHover(target, level) {
  1541. if (level == 0) {
  1542. $(target).style.width = '';
  1543. } else {
  1544. $(target).style.width = level * 16 + 'px';
  1545. }
  1546. }
  1547. function rateStarSet(target, level, input) {
  1548. $(input).value = level;
  1549. $(target).className = 'star star' + level;
  1550. }
  1551. function img_onmouseoverfunc(obj) {
  1552. if (typeof showsetcover == 'function') {
  1553. showsetcover(obj);
  1554. }
  1555. return;
  1556. }
  1557. function getElementOffset(element) {
  1558. var left = element.offsetLeft, top = element.offsetTop;
  1559. while (element = element.offsetParent) {
  1560. left += element.offsetLeft;
  1561. top += element.offsetTop;
  1562. }
  1563. if ($('nv').style.position == 'fixed') {
  1564. top -= parseInt($('nv').style.height);
  1565. }
  1566. return {'left': left, 'top': top};
  1567. }
  1568. function mobileplayer() {
  1569. var platform = navigator.platform;
  1570. var ua = navigator.userAgent;
  1571. var ios = /iPhone|iPad|iPod/.test(platform) && ua.indexOf("AppleWebKit") > -1;
  1572. var andriod = ua.indexOf("Android") > -1;
  1573. if (ios || andriod) {
  1574. return true;
  1575. } else {
  1576. return false;
  1577. }
  1578. }
  1579. if (BROWSER.ie) {
  1580. document.documentElement.addBehavior("#default#userdata");
  1581. }