]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/media/js/osqa.main.js
OSQA-266
[osqa.git] / forum / skins / default / media / js / osqa.main.js
1 var response_commands = {\r
2     refresh_page: function() {\r
3         window.location.reload(true)\r
4     },\r
5     \r
6     update_post_score: function(id, inc) {\r
7         var $score_board = $('#post-' + id + '-score');\r
8         var current = parseInt($score_board.html())\r
9         if (isNaN(current)){\r
10             current = 0;\r
11         }\r
12         $score_board.html(current + inc)\r
13     },\r
14 \r
15     update_user_post_vote: function(id, vote_type) {\r
16         var $upvote_button = $('#post-' + id + '-upvote');\r
17         var $downvote_button = $('#post-' + id + '-downvote');\r
18 \r
19         $upvote_button.removeClass('on');\r
20         $downvote_button.removeClass('on');\r
21 \r
22         if (vote_type == 'up') {\r
23             $upvote_button.addClass('on');\r
24         } else if (vote_type == 'down') {\r
25             $downvote_button.addClass('on');\r
26         }\r
27     },\r
28 \r
29     update_favorite_count: function(inc) {\r
30         var $favorite_count = $('#favorite-count');\r
31         var count = parseInt($favorite_count.html());\r
32 \r
33         if (isNaN(count))\r
34             count = 0;\r
35 \r
36         count += inc;\r
37 \r
38         if (count == 0)\r
39             count = '';\r
40 \r
41         $favorite_count.html(count);\r
42     },\r
43 \r
44     update_favorite_mark: function(type) {\r
45         if (type == 'on') {\r
46             $('#favorite-mark').addClass('on');\r
47         } else {\r
48             $('#favorite-mark').removeClass('on');\r
49         }\r
50     },\r
51 \r
52     mark_accepted: function(id) {        \r
53         var $answer = $('#answer-container-' + id);\r
54         $answer.addClass('accepted-answer');\r
55         $answer.find('.accept-answer').addClass('on');\r
56     },\r
57 \r
58     unmark_accepted: function(id) {\r
59         var $answer = $('#answer-container-' + id);\r
60         $answer.removeClass('accepted-answer');\r
61         $answer.find('.accept-answer').removeClass('on');\r
62     },\r
63 \r
64     remove_comment: function(id) {\r
65         var $comment = $('#comment-' + id);\r
66         $comment.css('background', 'red')\r
67         $comment.fadeOut('slow', function() {\r
68             $comment.remove();    \r
69         });\r
70     },\r
71 \r
72     insert_comment: function(post_id, comment_id, comment, username, profile_url, delete_url, edit_url) {\r
73         var $container = $('#comments-container-' + post_id);\r
74         var skeleton = $('#new-comment-skeleton-' + post_id).html().toString();\r
75 \r
76         skeleton = skeleton.replace(new RegExp('%ID%', 'g'), comment_id)\r
77                 .replace(new RegExp('%COMMENT%', 'g'), comment)\r
78                 .replace(new RegExp('%USERNAME%', 'g'), username)\r
79                 .replace(new RegExp('%PROFILE_URL%', 'g'), profile_url)\r
80                 .replace(new RegExp('%DELETE_URL%', 'g'), delete_url)\r
81                 .replace(new RegExp('%EDIT_URL%', 'g'), edit_url);\r
82 \r
83         $container.append(skeleton);\r
84 \r
85         $('#comment-' + comment_id).slideDown('slow');\r
86     },\r
87 \r
88     update_comment: function(comment_id, comment_text) {\r
89         var $comment = $('#comment-' + comment_id);\r
90         $comment.find('.comment-text').html(comment_text);\r
91 \r
92         $comment.slideDown('slow');\r
93     },\r
94 \r
95     mark_deleted: function(post_type, post_id) {\r
96         if (post_type == 'answer') {\r
97             var $answer = $('#answer-container-' + post_id);\r
98             $answer.addClass('deleted');\r
99         } else {\r
100             var $container = $('#question-table');\r
101             $container.addClass('deleted');\r
102         }\r
103     },\r
104 \r
105     unmark_deleted: function(post_type, post_id) {\r
106         if (post_type == 'answer') {\r
107             var $answer = $('#answer-container-' + post_id);\r
108             $answer.removeClass('deleted');\r
109         } else {\r
110             var $container = $('#question-table');\r
111             $container.removeClass('deleted');\r
112         }\r
113     },\r
114 \r
115     set_subscription_button: function(text) {\r
116         $('.subscription_switch').html(text);\r
117     },\r
118 \r
119     set_subscription_status: function(text) {\r
120         $('.subscription-status').html(text);\r
121     }\r
122 }\r
123 \r
124 function show_dialog (extern) {\r
125     var default_close_function = function($diag) {\r
126         $diag.fadeOut('fast', function() {\r
127             $diag.remove();\r
128         });\r
129     }\r
130 \r
131     var options = {\r
132         extra_class: '',\r
133         pos: {\r
134             x: ($(window).width() / 2) + $(window).scrollLeft(),\r
135             y: ($(window).height() / 2) + $(window).scrollTop()\r
136         },\r
137         dim: false, \r
138         yes_text: messages.ok,\r
139         yes_callback: default_close_function,\r
140         no_text: messages.cancel,\r
141         show_no: false,\r
142         close_on_clickoutside: false\r
143     }\r
144 \r
145     $.extend(options, extern);\r
146 \r
147     if (options.event != undefined) {\r
148         options.pos = {x: options.event.pageX, y: options.event.pageY};\r
149     }\r
150 \r
151     var html = '<div class="dialog ' + options.extra_class + '" style="display: none;">'\r
152              + '<div class="dialog-content">' + options.html + '</div><div class="dialog-buttons">';\r
153 \r
154     if (options.show_no) {\r
155         html += '<button class="dialog-no">' + options.no_text + '</button>';\r
156     }\r
157 \r
158     html += '<button class="dialog-yes">' + options.yes_text + '</button>'\r
159             + '</div></div>';\r
160 \r
161     $dialog = $(html);\r
162     $('body').append($dialog);\r
163     var message = $('.dialog-content')[0];\r
164     message.style.visibility = "hidden";\r
165 \r
166     if (options.dim === false) {\r
167         $dialog.css({\r
168             visibility: 'hidden',\r
169             display: 'block'\r
170         });\r
171 \r
172         options.dim = {w: $dialog.width(), h: $dialog.height()};\r
173 \r
174         $dialog.css({\r
175             width: 1,\r
176             height: 1,\r
177             visibility: 'visible'\r
178         });\r
179     }\r
180 \r
181     $dialog.css({\r
182         top: options.pos.y,\r
183         left: options.pos.x\r
184     });\r
185 \r
186     $dialog.animate({\r
187         top: "-=" + (options.dim.h / 2),\r
188         left: "-=" + (options.dim.w / 2),\r
189         width: options.dim.w,\r
190         height: options.dim.h\r
191     }, 200, function() {\r
192         message.style.visibility = "visible";\r
193     });\r
194 \r
195     $dialog.find('.dialog-no').click(function() {\r
196         default_close_function($dialog);\r
197     });\r
198 \r
199     $dialog.find('.dialog-yes').click(function() {\r
200         options.yes_callback($dialog);\r
201     });\r
202 \r
203     if (options.close_on_clickoutside) {\r
204         $dialog.one('clickoutside', function() {\r
205             default_close_function($dialog);\r
206         });\r
207     }\r
208 \r
209     return $dialog;\r
210 }\r
211 \r
212 function show_message(evt, msg, callback) {\r
213     var $dialog = show_dialog({\r
214         html: msg,\r
215         extra_class: 'warning',\r
216         event: evt,\r
217         yes_callback: function() {\r
218             $dialog.fadeOut('fast', function() {\r
219                 $dialog.remove();\r
220             });\r
221             if (callback) {\r
222                 callback();\r
223             }\r
224         },\r
225         close_on_clickoutside: true\r
226     });\r
227 }\r
228 \r
229 function load_prompt(evt, el, url) {\r
230     $.get(url, function(data) {\r
231         var doptions = {\r
232          html: data,\r
233             extra_class: 'prompt',\r
234             yes_callback: function() {\r
235                 var postvars = {};\r
236                 $dialog.find('input, textarea, select').each(function() {\r
237                     postvars[$(this).attr('name')] = $(this).val();\r
238                 });\r
239                 $.post(url, postvars, function(data) {\r
240                     $dialog.fadeOut('fast', function() {\r
241                         $dialog.remove();\r
242                     });\r
243                     process_ajax_response(data, evt);\r
244                 }, 'json');\r
245             },\r
246             show_no: true\r
247         }\r
248 \r
249         if (!el.is('.centered')) {\r
250             doptions.event = evt;\r
251         }\r
252 \r
253         var $dialog = show_dialog(doptions);\r
254     });\r
255 }\r
256 \r
257 function process_ajax_response(data, evt, callback) {\r
258     if (!data.success && data['error_message'] != undefined) {\r
259         show_message(evt, data.error_message, function() {if (callback) callback(true);});\r
260         end_command(false);\r
261     } else if (typeof data['commands'] != undefined){\r
262         for (var command in data.commands) {\r
263             response_commands[command].apply(null, data.commands[command])\r
264         }\r
265 \r
266         if (data['message'] != undefined) {\r
267             show_message(evt, data.message, function() {if (callback) callback(false);})\r
268         } else {\r
269             if (callback) callback(false);\r
270         }\r
271         end_command(true);\r
272     }\r
273 }\r
274 \r
275 var running = false;\r
276 \r
277 function start_command() {\r
278     $('body').append($('<div id="command-loader"></div>'));\r
279     running = true;\r
280 }\r
281 \r
282 function end_command(success) {\r
283     if (success) {\r
284         $('#command-loader').addClass('success');\r
285         $('#command-loader').fadeOut("slow", function() {\r
286             $('#command-loader').remove();\r
287             running = false;\r
288         });\r
289     } else {\r
290         $('#command-loader').remove();\r
291         running = false;\r
292     }\r
293 }\r
294 \r
295 $(function() {\r
296     $('a.ajax-command').live('click', function(evt) {\r
297         if (running) return false;\r
298 \r
299         $('.context-menu-dropdown').slideUp('fast');\r
300 \r
301         var el = $(this);\r
302 \r
303         if (el.is('.withprompt')) {\r
304             load_prompt(evt, el, el.attr('href'));\r
305         } else if(el.is('.confirm')) {\r
306             var doptions = {\r
307                 html: messages.confirm,\r
308                 extra_class: 'confirm',\r
309                 yes_callback: function() {\r
310                     start_command();\r
311                     $.getJSON(el.attr('href'), function(data) {\r
312                         process_ajax_response(data, evt);\r
313                         $dialog.fadeOut('fast', function() {\r
314                             $dialog.remove();\r
315                         });\r
316                     });\r
317                 },\r
318                 yes_text: messages.yes,\r
319                 show_no: true,\r
320                 no_text: messages.no\r
321             }\r
322 \r
323             if (!el.is('.centered')) {\r
324                 doptions.event = evt;\r
325             }\r
326             var $dialog = show_dialog(doptions);\r
327         } else {\r
328             start_command();\r
329             $.getJSON(el.attr('href'), function(data) {\r
330                 process_ajax_response(data, evt);\r
331             });\r
332         }\r
333 \r
334         return false\r
335     });\r
336 \r
337     $('.context-menu').each(function() {\r
338         var $menu = $(this);\r
339         var $trigger = $menu.find('.context-menu-trigger');\r
340         var $dropdown = $menu.find('.context-menu-dropdown');\r
341 \r
342         $trigger.click(function() {\r
343             $dropdown.slideToggle('fast', function() {\r
344                 if ($dropdown.is(':visible')) {\r
345                    $dropdown.one('clickoutside', function() {\r
346                        if ($dropdown.is(':visible'))\r
347                             $dropdown.slideUp('fast');\r
348                     });\r
349                 }\r
350             });    \r
351         });\r
352     });\r
353 \r
354     $('div.comment-form-container').each(function() {\r
355         var $container = $(this);\r
356         var $comment_tools = $container.parent().find('.comment-tools');\r
357         var $comments_container = $container.parent().find('.comments-container');\r
358         \r
359         var $form = $container.find('form');\r
360 \r
361         if ($form.length) {\r
362             var $textarea = $container.find('textarea');\r
363             var textarea = $textarea.get(0);\r
364             var $button = $container.find('.comment-submit');\r
365             var $cancel = $container.find('.comment-cancel');\r
366             var $chars_left_message = $container.find('.comments-chars-left-msg');\r
367             var $chars_togo_message = $container.find('.comments-chars-togo-msg');\r
368             var $chars_counter = $container.find('.comments-char-left-count');\r
369 \r
370             var $add_comment_link = $comment_tools.find('.add-comment-link');\r
371 \r
372             var chars_limits = $chars_counter.html().split('|');\r
373 \r
374             var min_length = parseInt(chars_limits[0]);\r
375             var max_length = parseInt(chars_limits[1]);\r
376 \r
377             var warn_length = max_length - 30;\r
378             var current_length = 0;\r
379             var comment_in_form = false;\r
380             var interval = null;\r
381 \r
382             var hcheck = !($.browser.msie || $.browser.opera);\r
383 \r
384             $textarea.css("padding-top", 0).css("padding-bottom", 0).css("resize", "none");\r
385             textarea.style.overflow = 'hidden';\r
386 \r
387 \r
388             function cleanup_form() {\r
389                 $textarea.val('');\r
390                 $textarea.css('height', 80);\r
391                 $chars_counter.html(max_length);\r
392                 $chars_left_message.removeClass('warn');\r
393                 comment_in_form = false;\r
394                 current_length = 0;\r
395 \r
396                 $chars_left_message.hide();\r
397                 $chars_togo_message.show();\r
398 \r
399                 $chars_counter.removeClass('warn');\r
400                 $chars_counter.html(min_length);\r
401                 $button.attr("disabled","disabled");\r
402 \r
403                 interval = null;\r
404             }\r
405 \r
406             cleanup_form();\r
407 \r
408             function process_form_changes() {\r
409                 var length = $textarea.val().replace(/[ ]{2,}/g," ").length;\r
410 \r
411                 if (current_length == length)\r
412                     return;\r
413 \r
414                 if (length < warn_length && current_length >= warn_length) {\r
415                     $chars_counter.removeClass('warn');\r
416                 } else if (current_length < warn_length && length >= warn_length){\r
417                     $chars_counter.addClass('warn');\r
418                 }\r
419 \r
420                 if (length < min_length) {\r
421                     $chars_left_message.hide();\r
422                     $chars_togo_message.show();\r
423                     $chars_counter.html(min_length - length);\r
424                 } else {\r
425                     length = $textarea.val().length;\r
426                     $chars_togo_message.hide();\r
427                     $chars_left_message.show();\r
428                     $chars_counter.html(max_length - length);\r
429                 }\r
430 \r
431                 if (length > max_length || length < min_length) {\r
432                     $button.attr("disabled","disabled");\r
433                 } else {\r
434                     $button.removeAttr("disabled");\r
435                 }\r
436 \r
437                 var current_height = textarea.style.height;\r
438                 if (hcheck)\r
439                     textarea.style.height = "0px";\r
440 \r
441                 var h = Math.max(80, textarea.scrollHeight);\r
442                 textarea.style.height = current_height;\r
443                 $textarea.animate({height: h + 'px'}, 50);\r
444 \r
445                 current_length = length;\r
446             }\r
447 \r
448             function show_comment_form() {\r
449                 $container.slideDown('slow');\r
450                 $add_comment_link.fadeOut('slow');\r
451                 $textarea.focus();\r
452                 window.setInterval(function() {\r
453                     process_form_changes();\r
454                 }, 200);\r
455             }\r
456 \r
457             function hide_comment_form() {\r
458                 if (interval != null) {\r
459                     window.clearInterval(interval);\r
460                     interval = null;\r
461                 }\r
462                 $container.slideUp('slow');\r
463                 $add_comment_link.fadeIn('slow');\r
464             }\r
465 \r
466             $add_comment_link.click(function(){\r
467                 cleanup_form();\r
468                 show_comment_form();\r
469                 return false;\r
470             });\r
471 \r
472             $('#' + $comments_container.attr('id') + ' .comment-edit').live('click', function() {\r
473                 var $link = $(this);\r
474                 var comment_id = /comment-(\d+)-edit/.exec($link.attr('id'))[1];\r
475                 var $comment = $('#comment-' + comment_id);\r
476 \r
477                 comment_in_form = comment_id;\r
478 \r
479                 $.get($link.attr('href'), function(data) {\r
480                     $textarea.val(data);\r
481                 });\r
482 \r
483                 $comment.slideUp('slow');\r
484                 show_comment_form();\r
485                 return false;\r
486             });\r
487 \r
488             $button.click(function(evt) {\r
489                 if (running) return false;\r
490 \r
491                 var post_data = {\r
492                     comment: $textarea.val()\r
493                 }\r
494 \r
495                 if (comment_in_form) {\r
496                     post_data['id'] = comment_in_form;\r
497                 }\r
498 \r
499                 start_command();\r
500                 $.post($form.attr('action'), post_data, function(data) {\r
501                     process_ajax_response(data, evt, function(error) {\r
502                         if (!error) {\r
503                             cleanup_form();\r
504                             hide_comment_form();\r
505                         }\r
506                     });\r
507 \r
508                 }, "json");\r
509 \r
510                 return false;\r
511             });\r
512 \r
513             $cancel.click(function() {\r
514                 if (comment_in_form) {\r
515                     $comment = $('#comment-' + comment_in_form).slideDown('slow');\r
516                 }\r
517                 hide_comment_form();\r
518                 return false;\r
519             });\r
520         }\r
521 \r
522         $comment_tools.find('.show-all-comments-link').click(function() {\r
523             $comments_container.find('.not_top_scorer').slideDown('slow');\r
524             $(this).fadeOut('slow');\r
525             $comment_tools.find('.comments-showing').fadeOut('slow');\r
526             return false;\r
527         });\r
528     });\r
529 });\r
530 \r
531 //var scriptUrl, interestingTags, ignoredTags, tags, $;\r
532 function pickedTags(){\r
533 \r
534     var sendAjax = function(tagname, reason, action, callback){\r
535         var url = scriptUrl;\r
536         if (action == 'add'){\r
537             url += $.i18n._('mark-tag/');\r
538             if (reason == 'good'){\r
539                 url += $.i18n._('interesting/');\r
540             }\r
541             else {\r
542                 url += $.i18n._('ignored/');\r
543             }\r
544         }\r
545         else {\r
546             url += $.i18n._('unmark-tag/');\r
547         }\r
548         url = url + tagname + '/';\r
549 \r
550         var call_settings = {\r
551             type:'POST',\r
552             url:url\r
553         };\r
554         if (callback !== false){\r
555             call_settings.success = callback;\r
556         }\r
557         $.ajax(call_settings);\r
558     };\r
559 \r
560 \r
561     var unpickTag = function(from_target ,tagname, reason, send_ajax){\r
562         //send ajax request to delete tag\r
563         var deleteTagLocally = function(){\r
564             from_target[tagname].remove();\r
565             delete from_target[tagname];\r
566         };\r
567         if (send_ajax){\r
568             sendAjax(tagname,reason,'remove',deleteTagLocally);\r
569         }\r
570         else {\r
571             deleteTagLocally();\r
572         }\r
573 \r
574     };\r
575 \r
576     var setupTagDeleteEvents = function(obj,tag_store,tagname,reason,send_ajax){\r
577         obj.unbind('mouseover').bind('mouseover', function(){\r
578             $(this).attr('src', mediaUrl('media/images/close-small-hover.png'));\r
579         });\r
580         obj.unbind('mouseout').bind('mouseout', function(){\r
581             $(this).attr('src', mediaUrl('media/images/close-small-dark.png'));\r
582         });\r
583         obj.click( function(){\r
584             unpickTag(tag_store,tagname,reason,send_ajax);\r
585         });\r
586     };\r
587 \r
588     var handlePickedTag = function(obj,reason){\r
589         var tagname = $.trim($(obj).prev().attr('value'));\r
590         var to_target = interestingTags;\r
591         var from_target = ignoredTags;\r
592         var to_tag_container;\r
593         if (reason == 'bad'){\r
594             to_target = ignoredTags;\r
595             from_target = interestingTags;\r
596             to_tag_container = $('div .tags.ignored');\r
597         }\r
598         else if (reason != 'good'){\r
599             return;\r
600         }\r
601         else {\r
602             to_tag_container = $('div .tags.interesting');\r
603         }\r
604 \r
605         if (tagname in from_target){\r
606             unpickTag(from_target,tagname,reason,false);\r
607         }\r
608 \r
609         if (!(tagname in to_target)){\r
610             //send ajax request to pick this tag\r
611 \r
612             sendAjax(tagname,reason,'add',function(){\r
613                 var new_tag = $('<span></span>');\r
614                 new_tag.addClass('deletable-tag');\r
615                 var tag_link = $('<a></a>');\r
616                 tag_link.attr('rel','tag');\r
617                 tag_link.attr('href', scriptUrl + $.i18n._('tags/') + tagname);\r
618                 tag_link.html(tagname);\r
619                 var del_link = $('<img></img>');\r
620                 del_link.addClass('delete-icon');\r
621                 del_link.attr('src', mediaUrl('/media/images/close-small-dark.png'));\r
622 \r
623                 setupTagDeleteEvents(del_link, to_target, tagname, reason, true);\r
624 \r
625                 new_tag.append(tag_link);\r
626                 new_tag.append(del_link);\r
627                 to_tag_container.append(new_tag);\r
628 \r
629                 to_target[tagname] = new_tag;\r
630             });\r
631         }\r
632     };\r
633 \r
634     var collectPickedTags = function(){\r
635         var good_prefix = 'interesting-tag-';\r
636         var bad_prefix = 'ignored-tag-';\r
637         var good_re = RegExp('^' + good_prefix);\r
638         var bad_re = RegExp('^' + bad_prefix);\r
639         interestingTags = {};\r
640         ignoredTags = {};\r
641         $('.deletable-tag').each(\r
642             function(i,item){\r
643                 var item_id = $(item).attr('id');\r
644                 var tag_name, tag_store;\r
645                 if (good_re.test(item_id)){\r
646                     tag_name = item_id.replace(good_prefix,'');\r
647                     tag_store = interestingTags;\r
648                     reason = 'good';\r
649                 }\r
650                 else if (bad_re.test(item_id)){\r
651                     tag_name = item_id.replace(bad_prefix,'');\r
652                     tag_store = ignoredTags;\r
653                     reason = 'bad';\r
654                 }\r
655                 else {\r
656                     return;\r
657                 }\r
658                 tag_store[tag_name] = $(item);\r
659                 setupTagDeleteEvents($(item).find('img'),tag_store,tag_name,reason,true);\r
660             }\r
661         );\r
662     };\r
663 \r
664     var setupHideIgnoredQuestionsControl = function(){\r
665         $('#hideIgnoredTagsCb').unbind('click').click(function(){\r
666             $.ajax({\r
667                         type: 'POST',\r
668                         dataType: 'json',\r
669                         cache: false,\r
670                         url: scriptUrl + $.i18n._('command/'),\r
671                         data: {command:'toggle-ignored-questions'}\r
672                     });\r
673         });\r
674     };\r
675     return {\r
676         init: function(){\r
677             collectPickedTags();\r
678             setupHideIgnoredQuestionsControl();\r
679             $("#interestingTagInput, #ignoredTagInput").autocomplete(messages.matching_tags_url, {\r
680                 minChars: 1,\r
681                 matchContains: true,\r
682                 max: 20,\r
683                 /*multiple: false, - the favorite tags and ignore tags don't let you do multiple tags\r
684                 multipleSeparator: " "*/\r
685 \r
686                 formatItem: function(row, i, max, value) {\r
687                     return row[1].split(".")[0] + " (" + row[1].split(".")[1] + ")";\r
688                 },\r
689 \r
690                 formatResult: function(row, i, max, value){\r
691                     return row[0];\r
692                 }\r
693 \r
694             });\r
695             $("#interestingTagAdd").click(function(){handlePickedTag(this,'good');});\r
696             $("#ignoredTagAdd").click(function(){handlePickedTag(this,'bad');});\r
697         }\r
698     };\r
699 }\r
700 \r
701 Hilite={elementid:"content",exact:true,max_nodes:1000,onload:true,style_name:"hilite",style_name_suffix:true,debug_referrer:""};Hilite.search_engines=[["local","q"],["cnprog\\.","q"],["google\\.","q"],["search\\.yahoo\\.","p"],["search\\.msn\\.","q"],["search\\.live\\.","query"],["search\\.aol\\.","userQuery"],["ask\\.com","q"],["altavista\\.","q"],["feedster\\.","q"],["search\\.lycos\\.","q"],["alltheweb\\.","q"],["technorati\\.com/search/([^\\?/]+)",1],["dogpile\\.com/info\\.dogpl/search/web/([^\\?/]+)",1,true]];Hilite.decodeReferrer=function(d){var g=null;var e=new RegExp("");for(var c=0;c<Hilite.search_engines.length;c++){var f=Hilite.search_engines[c];e.compile("^http://(www\\.)?"+f[0],"i");var b=d.match(e);if(b){var a;if(isNaN(f[1])){a=Hilite.decodeReferrerQS(d,f[1])}else{a=b[f[1]+1]}if(a){a=decodeURIComponent(a);if(f.length>2&&f[2]){a=decodeURIComponent(a)}a=a.replace(/\'|"/g,"");a=a.split(/[\s,\+\.]+/);return a}break}}return null};Hilite.decodeReferrerQS=function(f,d){var b=f.indexOf("?");var c;if(b>=0){var a=new String(f.substring(b+1));b=0;c=0;while((b>=0)&&((c=a.indexOf("=",b))>=0)){var e,g;e=a.substring(b,c);b=a.indexOf("&",c)+1;if(e==d){if(b<=0){return a.substring(c+1)}else{return a.substring(c+1,b-1)}}else{if(b<=0){return null}}}}return null};Hilite.hiliteElement=function(f,e){if(!e||f.childNodes.length==0){return}var c=new Array();for(var b=0;b<e.length;b++){e[b]=e[b].toLowerCase();if(Hilite.exact){c.push("\\b"+e[b]+"\\b")}else{c.push(e[b])}}c=new RegExp(c.join("|"),"i");var a={};for(var b=0;b<e.length;b++){if(Hilite.style_name_suffix){a[e[b]]=Hilite.style_name+(b+1)}else{a[e[b]]=Hilite.style_name}}var d=function(m){var j=c.exec(m.data);if(j){var n=j[0];var i="";var h=m.splitText(j.index);var g=h.splitText(n.length);var l=m.ownerDocument.createElement("SPAN");m.parentNode.replaceChild(l,h);l.className=a[n.toLowerCase()];l.appendChild(h);return l}else{return m}};Hilite.walkElements(f.childNodes[0],1,d)};Hilite.hilite=function(){var a=Hilite.debug_referrer?Hilite.debug_referrer:document.referrer;var b=null;a=Hilite.decodeReferrer(a);if(a&&((Hilite.elementid&&(b=document.getElementById(Hilite.elementid)))||(b=document.body))){Hilite.hiliteElement(b,a)}};Hilite.walkElements=function(d,f,e){var a=/^(script|style|textarea)/i;var c=0;while(d&&f>0){c++;if(c>=Hilite.max_nodes){var b=function(){Hilite.walkElements(d,f,e)};setTimeout(b,50);return}if(d.nodeType==1){if(!a.test(d.tagName)&&d.childNodes.length>0){d=d.childNodes[0];f++;continue}}else{if(d.nodeType==3){d=e(d)}}if(d.nextSibling){d=d.nextSibling}else{while(f>0){d=d.parentNode;f--;if(d.nextSibling){d=d.nextSibling;break}}}}};if(Hilite.onload){if(window.attachEvent){window.attachEvent("onload",Hilite.hilite)}else{if(window.addEventListener){window.addEventListener("load",Hilite.hilite,false)}else{var __onload=window.onload;window.onload=function(){Hilite.hilite();__onload()}}}};\r
702 \r
703 var mediaUrl = function(resource){\r
704     return scriptUrl + 'm/' + osqaSkin + '/' + resource;\r
705 };\r
706 \r
707 /*\r
708  * jQuery i18n plugin\r
709  * @requires jQuery v1.1 or later\r
710  *\r
711  * Examples at: http://recurser.com/articles/2008/02/21/jquery-i18n-translation-plugin/\r
712  * Dual licensed under the MIT and GPL licenses:\r
713  *   http://www.opensource.org/licenses/mit-license.php\r
714  *   http://www.gnu.org/licenses/gpl.html\r
715  *\r
716  * Based on 'javascript i18n that almost doesn't suck' by markos\r
717  * http://markos.gaivo.net/blog/?p=100\r
718  *\r
719  * Revision: $Id$\r
720  * Version: 1.0.0  Feb-10-2008\r
721  */\r
722  (function($) {\r
723 /**\r
724  * i18n provides a mechanism for translating strings using a jscript dictionary.\r
725  *\r
726  */\r
727 \r
728 \r
729 /*\r
730  * i18n property list\r
731  */\r
732 $.i18n = {\r
733 \r
734 /**\r
735  * setDictionary()\r
736  * Initialise the dictionary and translate nodes\r
737  *\r
738  * @param property_list i18n_dict : The dictionary to use for translation\r
739  */\r
740         setDictionary: function(i18n_dict) {\r
741                 i18n_dict = i18n_dict;\r
742         },\r
743 \r
744 /**\r
745  * _()\r
746  * The actual translation function. Looks the given string up in the\r
747  * dictionary and returns the translation if one exists. If a translation\r
748  * is not found, returns the original word\r
749  *\r
750  * @param string str : The string to translate\r
751  * @param property_list params : params for using printf() on the string\r
752  * @return string : Translated word\r
753  *\r
754  */\r
755         _: function (str, params) {\r
756                 var transl = str;\r
757                 if (i18n_dict&& i18n_dict[str]) {\r
758                         transl = i18n_dict[str];\r
759                 }\r
760                 return this.printf(transl, params);\r
761         },\r
762 \r
763 /**\r
764  * toEntity()\r
765  * Change non-ASCII characters to entity representation\r
766  *\r
767  * @param string str : The string to transform\r
768  * @return string result : Original string with non-ASCII content converted to entities\r
769  *\r
770  */\r
771         toEntity: function (str) {\r
772                 var result = '';\r
773                 for (var i=0;i<str.length; i++) {\r
774                         if (str.charCodeAt(i) > 128)\r
775                                 result += "&#"+str.charCodeAt(i)+";";\r
776                         else\r
777                                 result += str.charAt(i);\r
778                 }\r
779                 return result;\r
780         },\r
781 \r
782 /**\r
783  * stripStr()\r
784  *\r
785  * @param string str : The string to strip\r
786  * @return string result : Stripped string\r
787  *\r
788  */\r
789         stripStr: function(str) {\r
790                 return str.replace(/^\s*/, "").replace(/\s*$/, "");\r
791         },\r
792 \r
793 /**\r
794  * stripStrML()\r
795  *\r
796  * @param string str : The multi-line string to strip\r
797  * @return string result : Stripped string\r
798  *\r
799  */\r
800         stripStrML: function(str) {\r
801                 // Split because m flag doesn't exist before JS1.5 and we need to\r
802                 // strip newlines anyway\r
803                 var parts = str.split('\n');\r
804                 for (var i=0; i<parts.length; i++)\r
805                         parts[i] = stripStr(parts[i]);\r
806 \r
807                 // Don't join with empty strings, because it "concats" words\r
808                 // And strip again\r
809                 return stripStr(parts.join(" "));\r
810         },\r
811 \r
812 /*\r
813  * printf()\r
814  * C-printf like function, which substitutes %s with parameters\r
815  * given in list. %%s is used to escape %s.\r
816  *\r
817  * Doesn't work in IE5.0 (splice)\r
818  *\r
819  * @param string S : string to perform printf on.\r
820  * @param string L : Array of arguments for printf()\r
821  */\r
822         printf: function(S, L) {\r
823                 if (!L) return S;\r
824 \r
825                 var nS = "";\r
826                 var tS = S.split("%s");\r
827 \r
828                 for(var i=0; i<L.length; i++) {\r
829                         if (tS[i].lastIndexOf('%') == tS[i].length-1 && i != L.length-1)\r
830                                 tS[i] += "s"+tS.splice(i+1,1)[0];\r
831                         nS += tS[i] + L[i];\r
832                 }\r
833                 return nS + tS[tS.length-1];\r
834         }\r
835 \r
836 };\r
837 \r
838 \r
839 })(jQuery);\r
840 \r
841 \r
842 //var i18nLang;\r
843 var i18nZh = {\r
844         'insufficient privilege':'??????????',\r
845         'cannot pick own answer as best':'??????????????',\r
846         'anonymous users cannot select favorite questions':'?????????????',\r
847         'please login':'??????',\r
848         'anonymous users cannot vote':'????????',\r
849         '>15 points requried to upvote':'??+15?????????',\r
850         '>100 points required to downvote':'??+100?????????',\r
851         'please see': '??',\r
852         'cannot vote for own posts':'??????????',\r
853         'daily vote cap exhausted':'????????????????',\r
854         'cannot revoke old vote':'??????????????',\r
855         'please confirm offensive':"??????????????????????",\r
856         'anonymous users cannot flag offensive posts':'???????????',\r
857         'cannot flag message as offensive twice':'???????',\r
858         'flag offensive cap exhausted':'?????????????5?\91??\92???',\r
859         'need >15 points to report spam':"??+15??????\91???\92?",\r
860         'confirm delete':"?????/????????",\r
861         'anonymous users cannot delete/undelete':"???????????????",\r
862         'post recovered':"?????????????",\r
863         'post deleted':"????????????",\r
864         'add comment':'????',\r
865         'community karma points':'????',\r
866         'to comment, need':'????',\r
867         'delete this comment':'?????',\r
868         'hide comments':"????",\r
869         'add a comment':"????",\r
870         'comments':"??",\r
871         'confirm delete comment':"?????????",\r
872         'characters':'??',\r
873         'can write':'???',\r
874         'click to close':'???????',\r
875         'loading...':'???...',\r
876         'tags cannot be empty':'???????',\r
877         'tablimits info':"??5????????????20????",\r
878         'content cannot be empty':'???????',\r
879         'content minchars': '????? {0} ???',\r
880         'please enter title':'??????',\r
881         'title minchars':"????? {0} ???",\r
882         'delete':'??',\r
883         'undelete':     '??',\r
884         'bold':'??',\r
885         'italic':'??',\r
886         'link':'???',\r
887         'quote':'??',\r
888         'preformatted text':'??',\r
889         'image':'??',\r
890         'numbered list':'??????',\r
891         'bulleted list':'??????',\r
892         'heading':'??',\r
893         'horizontal bar':'???',\r
894         'undo':'??',\r
895         'redo':'??',\r
896         'enter image url':'<b>??????</b></p><p>???<br />http://www.example.com/image.jpg   \"????\"',\r
897         'enter url':'<b>??Web??</b></p><p>???<br />http://www.cnprog.com/   \"????\"</p>"',\r
898         'upload image':'?????????'\r
899 };\r
900 \r
901 var i18nEn = {\r
902         'need >15 points to report spam':'need >15 points to report spam ',\r
903     '>15 points requried to upvote':'>15 points required to upvote ',\r
904         'tags cannot be empty':'please enter at least one tag',\r
905         'anonymous users cannot vote':'sorry, anonymous users cannot vote ',\r
906         'anonymous users cannot select favorite questions':'sorry, anonymous users cannot select favorite questions ',\r
907         'to comment, need': '(to comment other people\'s posts, karma ',\r
908         'please see':'please see ',\r
909         'community karma points':' or more is necessary) - ',\r
910         'upload image':'Upload image:',\r
911         'enter image url':'enter URL of the image, e.g. http://www.example.com/image.jpg \"image title\"',\r
912         'enter url':'enter Web address, e.g. http://www.example.com \"page title\"',\r
913         'daily vote cap exhausted':'sorry, you\'ve used up todays vote cap',\r
914         'cannot pick own answer as best':'sorry, you cannot accept your own answer',\r
915         'cannot revoke old vote':'sorry, older votes cannot be revoked',\r
916         'please confirm offensive':'are you sure this post is offensive, contains spam, advertising, malicious remarks, etc.?',\r
917         'flag offensive cap exhausted':'sorry, you\'ve used up todays cap of flagging offensive messages ',\r
918         'confirm delete':'are you sure you want to delete this?',\r
919         'anonymous users cannot delete/undelete':'sorry, anonymous users cannot delete or undelete posts',\r
920         'post recovered':'your post is now restored!',\r
921         'post deleted':'your post has been deleted',\r
922         'confirm delete comment':'do you really want to delete this comment?',\r
923         'can write':'have ',\r
924         'tablimits info':'up to 5 tags, no more than 20 characters each',\r
925         'content minchars': 'please enter more than {0} characters',\r
926         'title minchars':"please enter at least {0} characters",\r
927         'characters':'characters left',\r
928     'cannot vote for own posts':'sorry, you cannot vote for your own posts',\r
929     'cannot flag message as offensive twice':'cannot flag message as offensive twice ',\r
930         '>100 points required to downvote':'>100 points required to downvote '\r
931 };\r
932 \r
933 var i18nEs = {\r
934         'insufficient privilege':'privilegio insuficiente',\r
935         'cannot pick own answer as best':'no puede escoger su propia respuesta como la mejor',\r
936         'anonymous users cannot select favorite questions':'usuarios anonimos no pueden seleccionar',\r
937         'please login':'por favor inicie sesión',\r
938         'anonymous users cannot vote':'usuarios anónimos no pueden votar',\r
939         '>15 points requried to upvote': '>15 puntos requeridos para votar positivamente',\r
940         '>100 points required to downvote':'>100 puntos requeridos para votar negativamente',\r
941         'please see': 'por favor vea',\r
942         'cannot vote for own posts':'no se puede votar por sus propias publicaciones',\r
943         'daily vote cap exhausted':'cuota de votos diarios excedida',\r
944         'cannot revoke old vote':'no puede revocar un voto viejo',\r
945         'please confirm offensive':"por favor confirme ofensiva",\r
946         'anonymous users cannot flag offensive posts':'usuarios anónimos no pueden marcar publicaciones como ofensivas',\r
947         'cannot flag message as offensive twice':'no puede marcar mensaje como ofensivo dos veces',\r
948         'flag offensive cap exhausted':'cuota para marcar ofensivas ha sido excedida',\r
949         'need >15 points to report spam':"necesita >15 puntos para reportar spam",\r
950         'confirm delete':"¿Está seguro que desea borrar esto?",\r
951         'anonymous users cannot delete/undelete':"usuarios anónimos no pueden borrar o recuperar publicaciones",\r
952         'post recovered':"publicación recuperada",\r
953         'post deleted':"publicación borrada?",\r
954         'add comment':'agregar comentario',\r
955         'community karma points':'reputación comunitaria',\r
956         'to comment, need':'para comentar, necesita reputación',\r
957         'delete this comment':'borrar este comentario',\r
958         'hide comments':"ocultar comentarios",\r
959         'add a comment':"agregar comentarios",\r
960         'comments':"comentarios",\r
961         'confirm delete comment':"¿Realmente desea borrar este comentario?",\r
962         'characters':'caracteres faltantes',\r
963         'can write':'tiene ',\r
964         'click to close':'haga click para cerrar',\r
965         'loading...':'cargando...',\r
966         'tags cannot be empty':'las etiquetas no pueden estar vacías',\r
967         'tablimits info':"hasta 5 etiquetas de no mas de 20 caracteres cada una",\r
968         'content cannot be empty':'el contenido no puede estar vacío',\r
969         'content minchars': 'por favor introduzca mas de {0} caracteres',\r
970         'please enter title':'por favor ingrese un título',\r
971         'title minchars':"por favor introduzca al menos {0} caracteres",\r
972         'delete':'borrar',\r
973         'undelete':     'recuperar',\r
974         'bold': 'negrita',\r
975         'italic':'cursiva',\r
976         'link':'enlace',\r
977         'quote':'citar',\r
978         'preformatted text':'texto preformateado',\r
979         'image':'imagen',\r
980         'numbered list':'lista numerada',\r
981         'bulleted list':'lista no numerada',\r
982         'heading':'??',\r
983         'horizontal bar':'barra horizontal',\r
984         'undo':'deshacer',\r
985         'redo':'rehacer',\r
986         'enter image url':'introduzca la URL de la imagen, por ejemplo?<br />http://www.example.com/image.jpg   \"titulo de imagen\"',\r
987         'enter url':'introduzca direcciones web, ejemplo?<br />http://www.cnprog.com/   \"titulo del enlace\"</p>"',\r
988         'upload image':'cargar imagen?',\r
989         'questions/' : 'preguntas/',\r
990         'vote/' : 'votar/'\r
991 };\r
992 \r
993 var i18n = {\r
994         'en':i18nEn,\r
995         'zh_CN':i18nZh,\r
996         'es':i18nEs\r
997 };\r
998 \r
999 var i18n_dict = i18n[i18nLang];\r
1000 \r
1001 /*\r
1002         jQuery TextAreaResizer plugin\r
1003         Created on 17th January 2008 by Ryan O'Dell\r
1004         Version 1.0.4\r
1005 */(function($){var textarea,staticOffset;var iLastMousePos=0;var iMin=32;var grip;$.fn.TextAreaResizer=function(){return this.each(function(){textarea=$(this).addClass('processed'),staticOffset=null;$(this).wrap('<div class="resizable-textarea"><span></span></div>').parent().append($('<div class="grippie"></div>').bind("mousedown",{el:this},startDrag));var grippie=$('div.grippie',$(this).parent())[0];grippie.style.marginRight=(grippie.offsetWidth-$(this)[0].offsetWidth)+'px'})};function startDrag(e){textarea=$(e.data.el);textarea.blur();iLastMousePos=mousePosition(e).y;staticOffset=textarea.height()-iLastMousePos;textarea.css('opacity',0.25);$(document).mousemove(performDrag).mouseup(endDrag);return false}function performDrag(e){var iThisMousePos=mousePosition(e).y;var iMousePos=staticOffset+iThisMousePos;if(iLastMousePos>=(iThisMousePos)){iMousePos-=5}iLastMousePos=iThisMousePos;iMousePos=Math.max(iMin,iMousePos);textarea.height(iMousePos+'px');if(iMousePos<iMin){endDrag(e)}return false}function endDrag(e){$(document).unbind('mousemove',performDrag).unbind('mouseup',endDrag);textarea.css('opacity',1);textarea.focus();textarea=null;staticOffset=null;iLastMousePos=0}function mousePosition(e){return{x:e.clientX+document.documentElement.scrollLeft,y:e.clientY+document.documentElement.scrollTop}}})(jQuery);\r
1006 /*\r
1007  * Autocomplete - jQuery plugin 1.0.2\r
1008  * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer\r
1009  * Dual licensed under the MIT and GPL licenses:\r
1010  *   http://www.opensource.org/licenses/mit-license.php\r
1011  *   http://www.gnu.org/licenses/gpl.html\r
1012  */;(function($){$.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=$.extend({},$.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?$.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value;};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new $.Autocompleter(this,options);});},result:function(handler){return this.bind("result",handler);},search:function(handler){return this.trigger("search",[handler]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(options){return this.trigger("setOptions",[options]);},unautocomplete:function(){return this.trigger("unautocomplete");}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);}break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);}break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);}break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;}break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break;}}}if(typeof fn=="function")fn(result);else $input.trigger("result",result&&[result.data,result.value]);}$.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback);});}).bind("flushCache",function(){cache.flush();}).bind("setOptions",function(){$.extend(options,arguments[1]);if("data"in arguments[1])cache.populate();}).bind("unautocomplete",function(){select.unbind();$input.unbind();$(input.form).unbind(".autocomplete");});function selectCurrent(){var selected=select.selected();if(!selected)return false;var v=selected.result;previousValue=v;if(options.multiple){var words=trimWords($input.val());if(words.length>1){v=words.slice(0,words.length-1).join(options.multipleSeparator)+options.multipleSeparator+v;}v+=options.multipleSeparator;}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}var currentValue=$input.val();if(!skipPrevCheck&&currentValue==previousValue)return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value){return[""];}var words=value.split(options.multipleSeparator);var result=[];$.each(words,function(i,value){if($.trim(value))result[i]=$.trim(value);});return result;}function lastWord(value){if(!options.multiple)return value;var words=trimWords(value);return words[words.length-1];}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$.Autocompleter.Selection(input,previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}else\r
1013     $input.val("");}});}if(wasVisible)$.Autocompleter.Selection(input,input.value.length,input.value.length);};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i<rows.length;i++){var row=$.trim(rows[i]);if(row){row=row.split("|");parsed[parsed.length]={data:row,value:row[0],result:options.formatResult&&options.formatResult(row,row[0])||row[0]};}}return parsed;};function stopLoading(){$input.removeClass(options.loadingClass);};};$.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(row){return row[0];},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>");},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)s=s.toLowerCase();var i=s.indexOf(sub);if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}if(!data[q]){length++;}data[q]=value;}function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i<ol;i++){var rawValue=options.data[i];rawValue=(typeof rawValue=="string")?[rawValue]:rawValue;var value=options.formatMatch(rawValue,i+1,options.data.length);if(value===false)continue;var firstChar=value.charAt(0).toLowerCase();if(!stMatchSets[firstChar])stMatchSets[firstChar]=[];var row={value:value,data:rawValue,result:options.formatResult&&options.formatResult(rawValue)||value};stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row);}};$.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value);});}setTimeout(populate,25);function flush(){data={};length=0;}return{flush:flush,add:add,populate:populate,load:function(q){if(!options.cacheLength||!length)return null;if(!options.url&&options.matchContains){var csub=[];for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}return csub;}else\r
1014     if(data[q]){return data[q];}else\r
1015     if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)return;element=$("<div/>").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("<ul/>").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)element.css("width",options.width);needsInit=false;}function target(event){var element=event.target;while(element&&element.tagName!="LI")element=element.parentNode;if(!element)return[];return element;}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset<list.scrollTop()){list.scrollTop(offset);}}};function movePosition(step){active+=step;if(active<0){active=listItems.size()-1;}else if(active>=listItems.size()){active=0;}}function limitNumberOfItems(available){return options.max&&options.max<available?options.max:available;}function fillList(){list.empty();var max=limitNumberOfItems(data.length);for(var i=0;i<max;i++){if(!data[i])continue;var formatted=options.formatItem(data[i].data,i+1,max,data[i].value,term);if(formatted===false)continue;var li=$("<li/>").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i]);}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}if($.fn.bgiframe)list.bgiframe();}return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.Autocompleter.Selection=function(field,start,end){if(field.createTextRange){var selRange=field.createTextRange();selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}else if(field.setSelectionRange){field.setSelectionRange(start,end);}else{if(field.selectionStart){field.selectionStart=start;field.selectionEnd=end;}}field.focus();};})(jQuery);\r
1016 \r
1017 var notify = function() {\r
1018     var visible = false;\r
1019     return {\r
1020         show: function(html) {\r
1021             if (html) {\r
1022                 $("body").css("margin-top", "2.2em");\r
1023                 $(".notify span").html(html);\r
1024             }\r
1025             $(".notify").fadeIn("slow");\r
1026             visible = true;\r
1027         },\r
1028         close: function(doPostback) {\r
1029             $(".notify").fadeOut("fast");\r
1030             $("body").css("margin-top", "0");\r
1031             visible = false;\r
1032         },\r
1033         isVisible: function() { return visible; }\r
1034     };\r
1035 } ();\r
1036 \r
1037 /*\r
1038  * jQuery outside events - v1.1 - 3/16/2010\r
1039  * http://benalman.com/projects/jquery-outside-events-plugin/\r
1040  *\r
1041  * Copyright (c) 2010 "Cowboy" Ben Alman\r
1042  * Dual licensed under the MIT and GPL licenses.\r
1043  * http://benalman.com/about/license/\r
1044  */\r
1045 (function($,c,b){$.map("click dblclick mousemove mousedown mouseup mouseover mouseout change select submit keydown keypress keyup".split(" "),function(d){a(d)});a("focusin","focus"+b);a("focusout","blur"+b);$.addOutsideEvent=a;function a(g,e){e=e||g+b;var d=$(),h=g+"."+e+"-special-event";$.event.special[e]={setup:function(){d=d.add(this);if(d.length===1){$(c).bind(h,f)}},teardown:function(){d=d.not(this);if(d.length===0){$(c).unbind(h)}},add:function(i){var j=i.handler;i.handler=function(l,k){l.target=k;j.apply(this,arguments)}}};function f(i){$(d).each(function(){var j=$(this);if(this!==i.target&&!j.has(i.target).length){j.triggerHandler(e,[i.target])}})}}})(jQuery,document,"outside");\r
1046 \r
1047 $(document).ready( function(){\r
1048     pickedTags().init();\r
1049 \r
1050     $('input#bnewaccount').click(function() {\r
1051         $('#bnewaccount').disabled=true;\r
1052     });\r
1053 });\r
1054 \r