]> git.mxchange.org Git - friendica.git/blob - view/theme/frost-mobile/js/theme.js
Update Frost-mobile to v0.3
[friendica.git] / view / theme / frost-mobile / js / theme.js
1 $j(document).ready(function() {
2
3         /* enable tinymce on focus and click */
4         $j("#profile-jot-text").focus(enableOnUser);
5         $j("#profile-jot-text").click(enableOnUser);
6
7 /*$j('html').click(function() { $j("#nav-notifications-menu" ).hide(); });*/
8
9         /*$j('.group-edit-icon').hover(
10                 function() {
11                         $j(this).addClass('icon'); $j(this).removeClass('iconspacer');},
12                 function() {
13                         $j(this).removeClass('icon'); $j(this).addClass('iconspacer');}
14         );
15
16         $j('.sidebar-group-element').hover(
17                 function() {
18                         id = $j(this).attr('id');
19                         $j('#edit-' + id).addClass('icon'); $j('#edit-' + id).removeClass('iconspacer');},
20
21                 function() {
22                         id = $j(this).attr('id');
23                         $j('#edit-' + id).removeClass('icon');$j('#edit-' + id).addClass('iconspacer');}
24         );
25
26
27         $j('.savedsearchdrop').hover(
28                 function() {
29                         $j(this).addClass('drop'); $j(this).addClass('icon'); $j(this).removeClass('iconspacer');},
30                 function() {
31                         $j(this).removeClass('drop'); $j(this).removeClass('icon'); $j(this).addClass('iconspacer');}
32         );
33
34         $j('.savedsearchterm').hover(
35                 function() {
36                         id = $j(this).attr('id');
37                         $j('#drop-' + id).addClass('icon');     $j('#drop-' + id).addClass('drophide'); $j('#drop-' + id).removeClass('iconspacer');},
38
39                 function() {
40                         id = $j(this).attr('id');
41                         $j('#drop-' + id).removeClass('icon');$j('#drop-' + id).removeClass('drophide'); $j('#drop-' + id).addClass('iconspacer');}
42         );*/
43
44
45         $j('#event-share-checkbox').change(function() {
46
47                 if ($j('#event-share-checkbox').is(':checked')) { 
48                         $j('#acl-wrapper').show();
49                 }
50                 else {
51                         $j('#acl-wrapper').hide();
52                 }
53         }).trigger('change');
54
55
56         $j(".popupbox").click(function () {
57                 var parent = $j( $j(this).attr('href') ).parent();
58                 if (parent.css('display') == 'none') {
59                         parent.show();
60                 } else {
61                         parent.hide();
62                 }
63                 return false;
64         });
65
66
67
68         if(typeof window.AjaxUpload != "undefined") {
69                 var uploader = new window.AjaxUpload(
70                         window.imageUploadButton,
71                         { action: 'wall_upload/'+window.nickname+'?nomce=1',
72                                 name: 'userfile',
73                                 onSubmit: function(file,ext) { $j('#profile-rotator').show(); },
74                                 onComplete: function(file,response) {
75                                         addeditortext(window.jotId, response);
76                                         $j('#profile-rotator').hide();
77                                 }                                
78                         }
79                 );
80
81                 if($j('#wall-file-upload').length) {
82                         var file_uploader = new window.AjaxUpload(
83                                 'wall-file-upload',
84                                 { action: 'wall_attach/'+window.nickname+'?nomce=1',
85                                         name: 'userfile',
86                                         onSubmit: function(file,ext) { $j('#profile-rotator').show(); },
87                                         onComplete: function(file,response) {
88                                                 addeditortext(window.jotId, response);
89                                                 $j('#profile-rotator').hide();
90                                         }                                
91                                 }
92                         );
93                 }
94         }
95
96
97         if(typeof window.aclInit !="undefined" && typeof acl=="undefined"){
98                 acl = new ACL(
99                         baseurl+"/acl",
100                         [ window.allowCID,window.allowGID,window.denyCID,window.denyGID ]
101                 );
102         }
103
104         switch(window.autocompleteType) {
105                 case 'msg-header':
106                         var a = $j("#recip").autocomplete({ 
107                                 serviceUrl: baseurl + '/acl',
108                                 minChars: 2,
109                                 width: 350,
110                                 onSelect: function(value,data) {
111                                         $j("#recip-complete").val(data);
112                                 }                       
113                         });
114                         break;
115                 case 'contacts-head':
116                         var a = $j("#contacts-search").autocomplete({ 
117                                 serviceUrl: baseurl + '/acl',
118                                 minChars: 2,
119                                 width: 350,
120                         });
121                         a.setOptions({ params: { type: 'a' }});
122                         break;
123                 case 'display-head':
124                         $j(".comment-wwedit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
125                         break;
126                 default:
127                         break;
128         }
129
130
131 /*      if(window.autoCompleteType == "display-head") {
132                 //$j(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
133                 // make auto-complete work in more places
134                 //$j(".wall-item-comment-wrapper textarea").contact_autocomplete(baseurl+"/acl");
135                 $j(".comment-wwedit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
136         }*/
137
138
139         if(window.aclType == "settings-head" || window.aclType == "photos_head" || window.aclType == "event_head") {
140                 $j('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
141                         var selstr;
142                         $j('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
143                                 selstr = $j(this).text();
144                                 $j('#jot-perms-icon').removeClass('unlock').addClass('lock');
145                                 $j('#jot-public').hide();
146                         });
147                         if(selstr == null) { 
148                                 $j('#jot-perms-icon').removeClass('lock').addClass('unlock');
149                                 $j('#jot-public').show();
150                         }
151
152                 }).trigger('change');
153         }
154
155         if(window.aclType == "event_head") {
156                 $j('#events-calendar').fullCalendar({
157                         events: baseurl + '/events/json/',
158                         header: {
159                                 left: 'prev,next today',
160                                 center: 'title',
161                                 right: 'month,agendaWeek,agendaDay'
162                         },                      
163                         timeFormat: 'H(:mm)',
164                         eventClick: function(calEvent, jsEvent, view) {
165                                 showEvent(calEvent.id);
166                         },
167                         
168                         eventRender: function(event, element, view) {
169                                 //console.log(view.name);
170                                 if (event.item['author-name']==null) return;
171                                 switch(view.name){
172                                         case "month":
173                                         element.find(".fc-event-title").html(
174                                                 "<img src='{0}' style='height:10px;width:10px'>{1} : {2}".format(
175                                                         event.item['author-avatar'],
176                                                         event.item['author-name'],
177                                                         event.title
178                                         ));
179                                         break;
180                                         case "agendaWeek":
181                                         element.find(".fc-event-title").html(
182                                                 "<img src='{0}' style='height:12px; width:12px'>{1}<p>{2}</p><p>{3}</p>".format(
183                                                         event.item['author-avatar'],
184                                                         event.item['author-name'],
185                                                         event.item.desc,
186                                                         event.item.location
187                                         ));
188                                         break;
189                                         case "agendaDay":
190                                         element.find(".fc-event-title").html(
191                                                 "<img src='{0}' style='height:24px;width:24px'>{1}<p>{2}</p><p>{3}</p>".format(
192                                                         event.item['author-avatar'],
193                                                         event.item['author-name'],
194                                                         event.item.desc,
195                                                         event.item.location
196                                         ));
197                                         break;
198                                 }
199                         }
200                         
201                 });
202                 
203                 // center on date
204                 var args=location.href.replace(baseurl,"").split("/");
205                 if (args.length>=4) {
206                         $j("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
207                 } 
208                 
209                 // show event popup
210                 var hash = location.hash.split("-")
211                 if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
212         }       
213
214 });
215
216 // update pending count //
217 $j(function(){
218
219         $j("nav").bind('nav-update',  function(e,data){
220                 var elm = $j('#pending-update');
221                 var register = $j(data).find('register').text();
222                 if (register=="0") { register=""; elm.hide();} else { elm.show(); }
223                 elm.html(register);
224         });
225 });
226
227
228
229 function homeRedirect() {
230         $j('html').fadeOut('slow', function(){
231                 window.location = baseurl + "/login";
232         });
233 }
234
235
236 function initCrop() {
237         function onEndCrop( coords, dimensions ) {
238                 $( 'x1' ).value = coords.x1;
239                 $( 'y1' ).value = coords.y1;
240                 $( 'x2' ).value = coords.x2;
241                 $( 'y2' ).value = coords.y2;
242                 $( 'width' ).value = dimensions.width;
243                 $( 'height' ).value = dimensions.height;
244         }
245
246         Event.observe( window, 'load', function() {
247                 new Cropper.ImgWithPreview(
248                 'croppa',
249                 {
250                         previewWrap: 'previewWrap',
251                         minWidth: 175,
252                         minHeight: 175,
253                         maxWidth: 640,
254                         maxHeight: 640,
255                         ratioDim: { x: 100, y:100 },
256                         displayOnInit: true,
257                         onEndCrop: onEndCrop
258                 });
259         });
260 }
261
262
263 function showEvent(eventid) {
264 /*      $j.get(
265                 baseurl + '/events/?id='+eventid,
266                 function(data){
267                         $j.colorbox({html:data});
268                 }
269         );*/                    
270 }
271
272
273
274 /*
275  * TinyMCE/Editor
276  */
277
278 var editor=false;
279 var textlen = 0;
280 var plaintext = 'none';//window.editSelect;
281 //var ispublic = window.isPublic;
282
283 function initEditor(cb){
284         if (editor==false){
285 //              $j("#profile-jot-text-loading").show();
286                 if(plaintext == 'none') {
287 //                      $j("#profile-jot-text-loading").hide();
288                         $j("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
289                         $j("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
290                         editor = true;
291 /*                      $j("a#jot-perms-icon").colorbox({
292                                 'inline' : true,
293                                 'transition' : 'elastic'
294                         });*/
295                         $j("a#jot-perms-icon, a#settings-default-perms-menu").click(function () {
296                                 var parent = $j("#profile-jot-acl-wrapper").parent();
297                                 if (parent.css('display') == 'none') {
298                                         parent.show();
299                                 } else {
300                                         parent.hide();
301                                 }
302 //                              $j("#profile-jot-acl-wrapper").parent().toggle();
303                                 return false;
304                         });
305                         $j(".jothidden").show();
306                         if (typeof cb!="undefined") cb();
307                         return;
308                 }       
309 /*              tinyMCE.init({
310                         theme : "advanced",
311                         mode : "specific_textareas",
312                         editor_selector: window.editSelect,
313                         auto_focus: "profile-jot-text",
314                         plugins : "bbcode,paste,autoresize, inlinepopups",
315                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
316                         theme_advanced_buttons2 : "",
317                         theme_advanced_buttons3 : "",
318                         theme_advanced_toolbar_location : "top",
319                         theme_advanced_toolbar_align : "center",
320                         theme_advanced_blockformats : "blockquote,code",
321                         gecko_spellcheck : true,
322                         paste_text_sticky : true,
323                         entity_encoding : "raw",
324                         add_unload_trigger : false,
325                         remove_linebreaks : false,
326                         //force_p_newlines : false,
327                         //force_br_newlines : true,
328                         forced_root_block : 'div',
329                         convert_urls: false,
330                         content_css: "$baseurl/view/custom_tinymce.css",
331                         theme_advanced_path : false,
332                         file_browser_callback : "fcFileBrowser",
333                         setup : function(ed) {
334                                 cPopup = null;
335                                 ed.onKeyDown.add(function(ed,e) {
336                                         if(cPopup !== null)
337                                                 cPopup.onkey(e);
338                                 });
339
340                                 ed.onKeyUp.add(function(ed, e) {
341                                         var txt = tinyMCE.activeEditor.getContent();
342                                         match = txt.match(/@([^ \n]+)$/);
343                                         if(match!==null) {
344                                                 if(cPopup === null) {
345                                                         cPopup = new ACPopup(this,baseurl+"/acl");
346                                                 }
347                                                 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
348                                                 if(! cPopup.ready) cPopup = null;
349                                         }
350                                         else {
351                                                 if(cPopup !== null) { cPopup.close(); cPopup = null; }
352                                         }
353
354                                         textlen = txt.length;
355                                         if(textlen != 0 && $j('#jot-perms-icon').is('.unlock')) {
356                                                 $j('#profile-jot-desc').html(ispublic);
357                                         }
358                                         else {
359                                                 $j('#profile-jot-desc').html('&nbsp;');
360                                         }        
361
362                                  //Character count
363
364                                         if(textlen <= 140) {
365                                                 $j('#character-counter').removeClass('red');
366                                                 $j('#character-counter').removeClass('orange');
367                                                 $j('#character-counter').addClass('grey');
368                                         }
369                                         if((textlen > 140) && (textlen <= 420)) {
370                                                 $j('#character-counter').removeClass('grey');
371                                                 $j('#character-counter').removeClass('red');
372                                                 $j('#character-counter').addClass('orange');
373                                         }
374                                         if(textlen > 420) {
375                                                 $j('#character-counter').removeClass('grey');
376                                                 $j('#character-counter').removeClass('orange');
377                                                 $j('#character-counter').addClass('red');
378                                         }
379                                         $j('#character-counter').text(textlen);
380                                 });
381
382                                 ed.onInit.add(function(ed) {
383                                         ed.pasteAsPlainText = true;
384                                         $j("#profile-jot-text-loading").hide();
385                                         $j(".jothidden").show();
386                                         if (typeof cb!="undefined") cb();
387                                 });
388
389                         }
390                 });
391                 editor = true;
392                 // setup acl popup
393                 $j("a#jot-perms-icon").colorbox({
394                         'inline' : true,
395                         'transition' : 'elastic'
396                 }); */
397         } else {
398                 if (typeof cb!="undefined") cb();
399         }
400 }
401
402 function enableOnUser(){
403         if (editor) return;
404         $j(this).val("");
405         initEditor();
406 }
407
408 /*function wallInitEditor() {
409         var plaintext = window.editSelect;
410
411         if(plaintext != 'none') {
412                 tinyMCE.init({
413                         theme : "advanced",
414                         mode : "specific_textareas",
415                         editor_selector: /(profile-jot-text|prvmail-text)/,
416                         plugins : "bbcode,paste",
417                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor",
418                         theme_advanced_buttons2 : "",
419                         theme_advanced_buttons3 : "",
420                         theme_advanced_toolbar_location : "top",
421                         theme_advanced_toolbar_align : "center",
422                         theme_advanced_blockformats : "blockquote,code",
423                         gecko_spellcheck : true,
424                         paste_text_sticky : true,
425                         entity_encoding : "raw",
426                         add_unload_trigger : false,
427                         remove_linebreaks : false,
428                         //force_p_newlines : false,
429                         //force_br_newlines : true,
430                         forced_root_block : 'div',
431                         convert_urls: false,
432                         content_css: baseurl + "/view/custom_tinymce.css",
433                                  //Character count
434                         theme_advanced_path : false,
435                         setup : function(ed) {
436                                 ed.onInit.add(function(ed) {
437                                         ed.pasteAsPlainText = true;
438                                         var editorId = ed.editorId;
439                                         var textarea = $j('#'+editorId);
440                                         if (typeof(textarea.attr('tabindex')) != "undefined") {
441                                                 $j('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
442                                                 textarea.attr('tabindex', null);
443                                         }
444                                 });
445                         }
446                 });
447         }
448         else
449                 $j("#prvmail-text").contact_autocomplete(baseurl+"/acl");
450 }*/
451
452
453
454 /*
455  * Jot
456  */
457
458 function addeditortext(textElem, data) {
459         if(window.editSelect == 'none') {
460                 var currentText = $j(textElem).val();
461                 $j(textElem).val(currentText + data);
462         }
463 /*      else
464                 tinyMCE.execCommand('mceInsertRawHTML',false,data);*/
465 }
466
467 function jotVideoURL() {
468         reply = prompt(window.vidURL);
469         if(reply && reply.length) {
470                 addeditortext("#profile-jot-text", '[video]' + reply + '[/video]');
471         }
472 }
473
474 function jotAudioURL() {
475         reply = prompt(window.audURL);
476         if(reply && reply.length) {
477                 addeditortext("#profile-jot-text", '[audio]' + reply + '[/audio]');
478         }
479 }
480
481
482 function jotGetLocation() {
483         reply = prompt(window.whereAreU, $j('#jot-location').val());
484         if(reply && reply.length) {
485                 $j('#jot-location').val(reply);
486         }
487 }
488
489 function jotShare(id) {
490         if ($j('#jot-popup').length != 0) $j('#jot-popup').show();
491
492         $j('#like-rotator-' + id).show();
493         $j.get('share/' + id, function(data) {
494                 if (!editor) $j("#profile-jot-text").val("");
495                 initEditor(function(){
496                         addeditortext("#profile-jot-text", data);
497                         $j('#like-rotator-' + id).hide();
498                         $j(window).scrollTop(0);
499                 });
500
501         });
502 }
503
504 function jotGetLink() {
505         reply = prompt(window.linkURL);
506         if(reply && reply.length) {
507                 reply = bin2hex(reply);
508                 $j('#profile-rotator').show();
509                 $j.get('parse_url?binurl=' + reply, function(data) {
510                         addeditortext(window.jotId, data);
511                         $j('#profile-rotator').hide();
512                 });
513         }
514 }
515
516 /*function linkdropper(event) {
517         var linkFound = event.dataTransfer.types.contains("text/uri-list");
518         if(linkFound)
519                 event.preventDefault();
520 }
521
522 function linkdrop(event) {
523         var reply = event.dataTransfer.getData("text/uri-list");
524         event.target.textContent = reply;
525         event.preventDefault();
526         if(reply && reply.length) {
527                 reply = bin2hex(reply);
528                 $j('#profile-rotator').show();
529                 $j.get('parse_url?binurl=' + reply, function(data) {
530                         //if (!editor) $j("#profile-jot-text").val("");
531                         //initEditor(function(){
532                         addeditortext(window.jotId, data);
533                         $j('#profile-rotator').hide();
534                         //});
535                 });
536         }
537 }*/
538
539 function jotClearLocation() {
540         $j('#jot-coord').val('');
541         $j('#profile-nolocation-wrapper').hide();
542 }
543
544 if(typeof window.geoTag === 'function') window.geoTag();
545
546
547
548 /*
549  * Items
550  */
551
552 function confirmDelete() { return confirm(window.delItem); }
553
554 /*function deleteCheckedItems() {
555         var checkedstr = '';
556
557         $j('.item-select').each( function() {
558                 if($j(this).is(':checked')) {
559                         if(checkedstr.length != 0) {
560                                 checkedstr = checkedstr + ',' + $j(this).val();
561                         }
562                         else {
563                                 checkedstr = $j(this).val();
564                         }
565                 }       
566         });
567         $j.post('item', { dropitems: checkedstr }, function(data) {
568                 window.location.reload();
569         });
570 }*/
571
572 function itemTag(id) {
573         reply = prompt(window.term);
574         if(reply && reply.length) {
575                 reply = reply.replace('#','');
576                 if(reply.length) {
577
578                         commentBusy = true;
579                         $j('body').css('cursor', 'wait');
580
581                         $j.get('tagger/' + id + '?term=' + reply, NavUpdate);
582                         /*if(timer) clearTimeout(timer);
583                         timer = setTimeout(NavUpdate,3000);*/
584                         liking = 1;
585                 }
586         }
587 }
588
589 function itemFiler(id) {
590         
591         $j.get('filer/', function(data){
592
593                 var promptText = $j('#id_term_label', data).text();
594
595                 reply = prompt(promptText);
596                 if(reply && reply.length) {
597                         commentBusy = true;
598                         $j('body').css('cursor', 'wait');
599                         $j.get('filer/' + id + '?term=' + reply, NavUpdate);
600 /*                              if(timer) clearTimeout(timer);
601                         timer = setTimeout(NavUpdate,3000);*/
602                         liking = 1;
603 /*                              $j.colorbox.close();*/
604                 }
605         });
606
607 /*              var bordercolor = $j("input").css("border-color");
608         
609         $j.get('filer/', function(data){
610                 $j.colorbox({html:data});
611                 $j("#id_term").keypress(function(){
612                         $j(this).css("border-color",bordercolor);
613                 })
614                 $j("#select_term").change(function(){
615                         $j("#id_term").css("border-color",bordercolor);
616                 })
617                 
618                 $j("#filer_save").click(function(e){
619                         e.preventDefault();
620                         reply = $j("#id_term").val();
621                         if(reply && reply.length) {
622                                 commentBusy = true;
623                                 $j('body').css('cursor', 'wait');
624                                 $j.get('filer/' + id + '?term=' + reply);
625                                 if(timer) clearTimeout(timer);
626                                 timer = setTimeout(NavUpdate,3000);
627                                 liking = 1;
628                                 $j.colorbox.close();
629                         } else {
630                                 $j("#id_term").css("border-color","#FF0000");
631                         }
632                         return false;
633                 });
634         });
635 */              
636 }
637
638
639
640 /*
641  * Comments
642  */
643
644
645 function commentOpen(obj,id) {
646         if(obj.value == window.commentEmptyText) {
647                 obj.value = "";
648                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
649                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
650                 $j("#mod-cmnt-wrap-" + id).show();
651                 openMenu("comment-edit-submit-wrapper-" + id);
652         }
653 }
654 function commentClose(obj,id) {
655         if(obj.value == "") {
656                 obj.value = window.commentEmptyText;
657                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
658                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
659                 $j("#mod-cmnt-wrap-" + id).hide();
660                 closeMenu("comment-edit-submit-wrapper-" + id);
661         }
662 }
663
664
665 function commentInsert(obj,id) {
666         var tmpStr = $j("#comment-edit-text-" + id).val();
667         if(tmpStr == window.commentEmptyText) {
668                 tmpStr = "";
669                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
670                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
671                 openMenu("comment-edit-submit-wrapper-" + id);
672         }
673         var ins = $j(obj).html();
674         ins = ins.replace("&lt;","<");
675         ins = ins.replace("&gt;",">");
676         ins = ins.replace("&amp;","&");
677         ins = ins.replace("&quot;",'"');
678         $j("#comment-edit-text-" + id).val(tmpStr + ins);
679 }
680
681 function qCommentInsert(obj,id) {
682         var tmpStr = $j("#comment-edit-text-" + id).val();
683         if(tmpStr == window.commentEmptyText) {
684                 tmpStr = "";
685                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
686                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
687                 openMenu("comment-edit-submit-wrapper-" + id);
688         }
689         var ins = $j(obj).val();
690         ins = ins.replace("&lt;","<");
691         ins = ins.replace("&gt;",">");
692         ins = ins.replace("&amp;","&");
693         ins = ins.replace("&quot;",'"');
694         $j("#comment-edit-text-" + id).val(tmpStr + ins);
695         $j(obj).val("");
696 }
697
698 /*function showHideCommentBox(id) {
699         if( $j('#comment-edit-form-' + id).is(':visible')) {
700                 $j('#comment-edit-form-' + id).hide();
701         }
702         else {
703                 $j('#comment-edit-form-' + id).show();
704         }
705 }*/
706
707
708 function insertFormatting(comment,BBcode,id) {
709         
710         var tmpStr = $j("#comment-edit-text-" + id).val();
711         if(tmpStr == comment) {
712                 tmpStr = "";
713                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
714                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
715                 openMenu("comment-edit-submit-wrapper-" + id);
716                 $j("#comment-edit-text-" + id).val(tmpStr);
717         }
718
719         textarea = document.getElementById("comment-edit-text-" +id);
720         if (document.selection) {
721                 textarea.focus();
722                 selected = document.selection.createRange();
723                 if (BBcode == "url"){
724                         selected.text = "["+BBcode+"=http://]" +  selected.text + "[/"+BBcode+"]";
725                         } else                  
726                 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
727         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
728                 var start = textarea.selectionStart;
729                 var end = textarea.selectionEnd;
730                 if (BBcode == "url"){
731                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
732                         } else
733                 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
734         }
735         return true;
736 }
737
738 function cmtBbOpen(id) {
739         $j(".comment-edit-bb-" + id).show();
740 }
741 function cmtBbClose(id) {
742         $j(".comment-edit-bb-" + id).hide();
743 }
744
745