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