]> git.mxchange.org Git - friendica.git/blob - view/theme/diabook/theme.php
diabook-theme: fix footer/impressum
[friendica.git] / view / theme / diabook / theme.php
1 <?php
2
3 /*
4  * Name: Diabook
5  * Description: Diabook: report bugs and request here: http://pad.toktan.org/p/diabook or contact me : thomas_bierey@friendica.eu
6  * Version: (Version: 1.024)
7  * Author: 
8  */
9
10
11 //print diabook-version for debugging
12 $diabook_version = "Diabook (Version: 1.024)";
13 $a->page['htmlhead'] .= sprintf('<script "%s" ></script>', $diabook_version);
14
15 //change css on network and profilepages
16 $cssFile = null;
17
18 $resolution=false;
19 $resolution = get_pconfig(local_user(), "diabook", "resolution");
20 if ($resolution===false) $resolution="normal";
21
22 $color = false;
23 $site_color = get_config("diabook", "color" );
24 if (local_user()) {$color = get_pconfig(local_user(), "diabook", "color");}
25 if ($color===false) $color=$site_color;
26 if ($color===false) $color="diabook";
27
28 if ($color=="diabook") $color_path = "/";
29 if ($color=="aerith") $color_path = "/diabook-aerith/";
30 if ($color=="blue") $color_path = "/diabook-blue/";
31 if ($color=="red") $color_path = "/diabook-red/";
32 if ($color=="pink") $color_path = "/diabook-pink/";
33 if ($color=="green") $color_path = "/diabook-green/";
34 if ($color=="dark") $color_path = "/diabook-dark/";
35
36
37 /**
38  * prints last community activity
39  */
40
41
42  
43 function diabook_community_info(){
44         $a = get_app();
45
46
47         // comunity_profiles
48         $aside['$comunity_profilest_title'] = t('Community Profiles');
49         $aside['$comunity_profiles_items'] = array();
50         $r = q("select gcontact.* from gcontact left join glink on glink.gcid = gcontact.id 
51                           where glink.cid = 0 and glink.uid = 0 order by rand() limit 9");
52         $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
53         if(count($r)) {
54                 $photo = 'photo';
55                 foreach($r as $rr) {
56                         $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
57                         $entry = replace_macros($tpl,array(
58                                 '$id' => $rr['id'],
59                                 '$profile-link' => zrl($rr['url']),
60                                 '$photo' => $rr[$photo],
61                                 '$alt-text' => $rr['name'],
62                         ));
63                         $aside['$comunity_profiles_items'][] = $entry;
64                 }
65         }
66
67         // last 12 users
68         $aside['$lastusers_title'] = t('Last users');
69         $aside['$lastusers_items'] = array();
70         $sql_extra = "";
71         $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 " );
72         $order = " ORDER BY `register_date` DESC ";
73
74         $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
75                         FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` 
76                         WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
77                 0,
78                 9
79         );
80         $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
81         if(count($r)) {
82                 $photo = 'thumb';
83                 foreach($r as $rr) {
84                         $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
85                         $entry = replace_macros($tpl,array(
86                                 '$id' => $rr['id'],
87                                 '$profile-link' => $profile_link,
88                                 '$photo' => $rr[$photo],
89                                 '$alt-text' => $rr['name'],
90                         ));
91                         $aside['$lastusers_items'][] = $entry;
92                 }
93         }
94         
95         
96         // last 10 liked items
97         $aside['$like_title'] = t('Last likes');
98         $aside['$like_items'] = array();
99         $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM 
100                         (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link` 
101                                 FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1
102                         INNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri` 
103                         WHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'
104                         GROUP BY `uri`
105                         ORDER BY `T1`.`created` DESC
106                         LIMIT 0,5",
107                         $a->get_baseurl(),$a->get_baseurl()
108                         );
109
110         foreach ($r as $rr) {
111                 $author  = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>';
112                 $objauthor =  '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>';
113                 
114                 //var_dump($rr['verb'],$rr['object-type']); killme();
115                 switch($rr['verb']){
116                         case 'http://activitystrea.ms/schema/1.0/post':
117                                 switch ($rr['object-type']){
118                                         case 'http://activitystrea.ms/schema/1.0/event':
119                                                 $post_type = t('event');
120                                                 break;
121                                         default:
122                                                 $post_type = t('status');
123                                 }
124                                 break;
125                         default:
126                                 if ($rr['resource-id']){
127                                         $post_type = t('photo');
128                                         $m=array();     preg_match("/\[url=([^]]*)\]/", $rr['body'], $m);
129                                         $rr['plink'] = $m[1];
130                                 } else {
131                                         $post_type = t('status');
132                                 }
133                 }
134                 $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>';
135
136                 $aside['$like_items'][] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
137                 
138         }
139         
140         
141         // last 12 photos
142         $aside['$photos_title'] = t('Last photos');
143         $aside['$photos_items'] = array();
144         $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM 
145                                 (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo` 
146                                         WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')
147                                                 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`
148                                 INNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,
149                                 `user` 
150                                 WHERE `user`.`uid` = `photo`.`uid`
151                                 AND `user`.`blockwall`=0
152                                 AND `user`.`hidewall`=0
153                                 ORDER BY `photo`.`edited` DESC
154                                 LIMIT 0, 9",
155                                 dbesc(t('Contact Photos')),
156                                 dbesc(t('Profile Photos'))
157                                 );
158                 if(count($r)) {
159                 $tpl = file_get_contents( dirname(__file__).'/ch_directory_item.tpl');
160                 foreach($r as $rr) {
161                         $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id'];
162                         $photo_url = $a->get_baseurl() . '/photo/' .  $rr['resource-id'] . '-' . $rr['scale'] .'.jpg';
163                 
164                         $entry = replace_macros($tpl,array(
165                                 '$id' => $rr['id'],
166                                 '$profile-link' => $photo_page,
167                                 '$photo' => $photo_url,
168                                 '$alt-text' => $rr['username']." : ".$rr['desc'],
169                         ));
170
171                         $aside['$photos_items'][] = $entry;
172                 }
173         }
174         
175    
176    //right_aside FIND FRIENDS
177         if(local_user()) {
178         $nv = array();
179         $nv['title'] = Array("", t('Find Friends'), "", "");
180         $nv['directory'] = Array('directory', t('Local Directory'), "", "");
181         $nv['global_directory'] = Array('http://dir.friendica.com/', t('Global Directory'), "", "");
182         $nv['match'] = Array('match', t('Similar Interests'), "", "");
183         $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
184         $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
185         
186         $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendika.com/directory">
187                                                 <span class="sbox_l"></span>
188                                                 <span class="sbox">
189                                                 <input type="text" name="search" size="13" maxlength="50">
190                                                 </span>
191                                                 <span class="sbox_r" id="srch_clear"></span>';
192         
193         $aside['$nv'] = $nv;
194         };
195    
196    //Community Page
197    if(local_user()) {
198    $page = '<div id="" >
199                         <h3 style="margin-top:0px;">'.t("Community Pages").'<a id="close_pages_icon"  onClick="close_pages()" class="icon close_box" title="close"></a></h3></div>
200                         <div id=""><ul style="margin-left: 7px;margin-top: 0px;padding-left: 0px;padding-top: 0px;">';
201
202         $pagelist = array();
203
204         $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`
205                         WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
206                         ORDER BY `name` ASC",
207                         intval($a->user['uid'])
208         );
209
210         $pageD = array();
211
212         // Look if the profile is a community page
213         foreach($contacts as $contact) {
214                 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
215         };
216         
217
218         $contacts = $pageD;
219
220         foreach($contacts as $contact) {
221                 $page .= '<li style="list-style-type: none;" class="tool"><img height="20" width="20" style="float: left; margin-right: 3px;" src="' . $contact['micro'] .'" alt="' . $contact['url'] . '" /> <a href="'.$a->get_baseurl().'/redir/'.$contact["id"].'" style="margin-top: 2px; word-wrap: break-word; width: 132px;" title="' . $contact['url'] . '" class="label" target="external-link">'.
222                                 $contact["name"]."</a></li>";
223         }
224         $page .= '</ul></div></div>';
225         //if (sizeof($contacts) > 0)
226                 
227                 $aside['$page'] = $page;        
228         }
229   //END Community Page  
230   //helpers
231    $helpers = array();
232         $helpers['title'] = Array("", t('Help or @NewHere ?'), "", "");
233         
234         $aside['$helpers'] = $helpers;
235    //end helpers
236    //connectable services
237    $con_services = array();
238         $con_services['title'] = Array("", t('Connect Services'), "", "");
239         
240         $aside['$con_services'] = $con_services;
241    //end connectable services
242   
243   
244    //get_baseurl
245    $url = $a->get_baseurl($ssl_state);   
246    $aside['$url'] = $url;
247
248         $tpl = file_get_contents(dirname(__file__).'/communityhome.tpl');
249         $a->page['right_aside'] = replace_macros($tpl, $aside);
250         
251         
252         
253         
254 }
255
256
257 //profile_side at networkpages
258 if ($a->argv[0] === "network" && local_user()){
259
260         // USER MENU
261         if(local_user()) {
262                 
263                 $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
264                                 
265                 $userinfo = array(
266                                         'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"),
267                                         'name' => $a->user['username'],
268                                 );      
269                 $ps = array('usermenu'=>array());
270                 $ps['usermenu']['status'] = Array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
271                 $ps['usermenu']['profile'] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
272                 $ps['usermenu']['contacts'] = Array('contacts' , t('Contacts'), "", t('Your contacts'));                                
273                 $ps['usermenu']['photos'] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
274                 $ps['usermenu']['events'] = Array('events/', t('Events'), "", t('Your events'));
275                 $ps['usermenu']['notes'] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
276                 $ps['usermenu']['community'] = Array('community/', t('Community'), "", "");
277                 $ps['usermenu']['pgroups'] = Array('http://dir.friendica.com/directory/forum', t('Community Pages'), "", "");
278
279                 $tpl = get_markup_template('profile_side.tpl');
280
281                 $a->page['aside'] .= replace_macros($tpl, array(
282                                 '$userinfo' => $userinfo,
283                                 '$ps' => $ps,
284                         ));
285
286         }
287         
288         $ccCookie = $_COOKIE['close_pages'] + $_COOKIE['close_profiles'] + $_COOKIE['close_helpers'] + $_COOKIE['close_services'] + $_COOKIE['close_friends'] + $_COOKIE['close_twitter'] + $_COOKIE['close_lastusers'] + $_COOKIE['close_lastphotos'] + $_COOKIE['close_lastlikes'];
289         
290         if($ccCookie != "9") {
291         // COMMUNITY
292         diabook_community_info();
293
294         // CUSTOM CSS
295         if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-network.css";}
296         if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-network-wide.css";}
297         }
298 }
299
300
301
302 //right_aside at profile pages
303 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname']){
304         if($ccCookie != "9") {
305         // COMMUNITY
306         diabook_community_info();
307         
308         // CUSTOM CSS
309         if($resolution == "normal") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-profile.css";}
310         if($resolution == "wide") {$cssFile = $a->get_baseurl($ssl_state)."/view/theme/diabook".$color_path."style-profile-wide.css";}
311         
312         }
313 }
314
315 // custom css
316 if (!is_null($cssFile)) $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
317
318 //footer
319 $tpl = get_markup_template('footer.tpl');
320 $a->page['footer'] .= replace_macros($tpl, array());
321
322 //load jquery.cookie.js
323 $cookieJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.cookie.js";
324 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s"></script>', $cookieJS);
325
326 //load jquery.ae.image.resize.js
327 $imageresizeJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.ae.image.resize.js";
328 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $imageresizeJS);
329
330 //load jquery.autogrow-textarea.js
331 $autogrowJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.autogrow.textarea.js";
332 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $autogrowJS);
333
334 //load jquery.twitter.search.js
335 $twitterJS = $a->get_baseurl($ssl_state)."/view/theme/diabook/js/jquery.twitter.search.js";
336 $a->page['htmlhead'] .= sprintf('<script language="JavaScript" src="%s" ></script>', $twitterJS);
337
338 //js scripts
339
340 //check if community_home-plugin is activated and change css
341 $nametocheck = "communityhome";
342 $r = q("select id from addon where name = '%s' and installed = 1", dbesc($nametocheck));
343 if(count($r) == "1") {
344         
345 $a->page['htmlhead'] .= '
346 <script>
347 $(document).ready(function() {
348         $("div#login-submit-wrapper").attr("style","padding-top: 120px;");
349         });
350 </script>';     
351 }
352
353 //comment-edit-wrapper on photo_view
354 if ($a->argv[0].$a->argv[2] === "photos"."image"){
355
356 $a->page['htmlhead'] .= '
357 <script>
358         $(function(){
359         
360                 $(".comment-edit-form").css("display","table");
361                         
362                         });
363     </script>';
364 }
365
366 $a->page['htmlhead'] .= '
367
368 <script>
369
370  $(function() {
371         $("a.lightbox").fancybox(); // Select all links with lightbox class
372         $("#twitter").twitterSearch({               
373         term: "friendica",
374         animInSpeed: 250,
375         bird:    false, 
376         avatar:  false, 
377         colorExterior: "#fff",
378         title: "Last Tweets",
379         timeout: 10000          });
380  });
381    
382 $(window).load(function() {
383         var footer_top = $(document).height() - 30;
384         $("div#footerbox").attr("style", "border-top: 1px solid #D2D2D2; width: 70%;right: 15%;position: absolute;top:"+footer_top+"px;");
385  });
386  </script>';
387  
388  
389 $a->page['htmlhead'] .= '
390
391 <script type="text/javascript">
392
393 function tautogrow(id){
394                 $("textarea#comment-edit-text-" +id).autogrow();        
395         };
396  </script>';
397  
398  
399 $a->page['htmlhead'] .= '
400  <script>
401  
402 $(document).ready(function() {
403     $("iframe").each(function(){
404         var ifr_source = $(this).attr("src");
405         var wmode = "wmode=transparent";
406         if(ifr_source.indexOf("?") != -1) {
407             var getQString = ifr_source.split("?");
408             var oldString = getQString[1];
409             var newString = getQString[0];
410             $(this).attr("src",newString+"?"+wmode+"&"+oldString);
411         }
412         else $(this).attr("src",ifr_source+"?"+wmode);
413        
414     });
415       
416 });
417
418 function yt_iframe() {
419
420         $("iframe").load(function() { 
421         var ifr_src = $(this).contents().find("body iframe").attr("src");
422         $("iframe").contents().find("body iframe").attr("src", ifr_src+"&wmode=transparent");
423     });
424
425         };
426
427 function scrolldown(){
428                         $("html, body").animate({scrollTop:$(document).height()}, "slow");
429                         return false;
430                 };
431                 
432 function scrolltop(){
433                         $("html, body").animate({scrollTop:0}, "slow");
434                         return false;
435                 };
436                 
437 $(window).scroll(function () { 
438                 
439                 var footer_top = $(document).height() - 30;
440                 $("div#footerbox").css("top", footer_top);
441         
442                 var scrollInfo = $(window).scrollTop();      
443                 
444                 if (scrollInfo <= "900"){
445       $("a#top").attr("id","down");
446       $("a#down").attr("onclick","scrolldown()");
447                 $("img#scroll_top_bottom").attr("src","view/theme/diabook/icons/scroll_bottom.png");
448                 } 
449                     
450       if (scrollInfo > "900"){
451       $("a#down").attr("id","top");
452       $("a#top").attr("onclick","scrolltop()");
453                 $("img#scroll_top_bottom").attr("src","view/theme/diabook/icons/scroll_top.png");
454                 }
455                 
456     });
457   
458  </script>';
459  
460 if($a->argv[0] === "settings" && local_user()) {
461 $a->page['htmlhead'] .= ' 
462 <script>
463 function restore_boxes(){
464         $.cookie("close_pages","2", { expires: 365, path: "/" });
465         $.cookie("close_helpers","2", { expires: 365, path: "/" });
466         $.cookie("close_profiles","2", { expires: 365, path: "/" });
467         $.cookie("close_services","2", { expires: 365, path: "/" });
468         $.cookie("close_friends","2", { expires: 365, path: "/" });
469         $.cookie("close_twitter","2", { expires: 365, path: "/" });
470         $.cookie("close_lastusers","2", { expires: 365, path: "/" });
471         $.cookie("close_lastphotos","2", { expires: 365, path: "/" });
472         $.cookie("close_lastlikes","2", { expires: 365, path: "/" });
473         alert("Right-hand column was restored. Please refresh your browser");
474   }
475 </script>';}
476
477
478
479 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()){
480 $a->page['htmlhead'] .= '
481 <script>
482
483  $(function() {
484         $(".oembed.photo img").aeImageResize({height: 400, width: 400});
485   });
486 </script>';
487
488
489         if($ccCookie != "9") {
490 $a->page['htmlhead'] .= '
491 <script>
492 $("right_aside").ready(function(){
493         
494         if($.cookie("close_pages") == "1") 
495                 {
496                 document.getElementById( "close_pages" ).style.display = "none";
497                         };
498                         
499         if($.cookie("close_profiles") == "1") 
500                 {
501                 document.getElementById( "close_profiles" ).style.display = "none";
502                         };
503         
504         if($.cookie("close_helpers") == "1") 
505                 {
506                 document.getElementById( "close_helpers" ).style.display = "none";
507                         };
508                         
509         if($.cookie("close_services") == "1") 
510                 {
511                 document.getElementById( "close_services" ).style.display = "none";
512                         };
513                         
514         if($.cookie("close_friends") == "1") 
515                 {
516                 document.getElementById( "close_friends" ).style.display = "none";
517                         };
518         
519         if($.cookie("close_twitter") == "1") 
520                 {
521                 document.getElementById( "twitter" ).style.display = "none";
522                         };      
523                         
524         if($.cookie("close_lastusers") == "1") 
525                 {
526                 document.getElementById( "close_lastusers" ).style.display = "none";
527                         };
528                         
529         if($.cookie("close_lastphotos") == "1") 
530                 {
531                 document.getElementById( "close_lastphotos" ).style.display = "none";
532                         };
533                         
534         if($.cookie("close_lastlikes") == "1") 
535                 {
536                 document.getElementById( "close_lastlikes" ).style.display = "none";
537                         };}
538
539 );
540
541 function close_pages(){
542  document.getElementById( "close_pages" ).style.display = "none";
543  $.cookie("close_pages","1", { expires: 365, path: "/" });
544  };
545  
546 function close_profiles(){
547  document.getElementById( "close_profiles" ).style.display = "none";
548  $.cookie("close_profiles","1", { expires: 365, path: "/" });
549  };
550  
551 function close_helpers(){
552  document.getElementById( "close_helpers" ).style.display = "none";
553   $.cookie("close_helpers","1", { expires: 365, path: "/" });
554  };
555
556 function close_services(){
557  document.getElementById( "close_services" ).style.display = "none";
558  $.cookie("close_services","1", { expires: 365, path: "/" });
559  };
560  
561 function close_friends(){
562  document.getElementById( "close_friends" ).style.display = "none";
563  $.cookie("close_friends","1", { expires: 365, path: "/" });
564  };
565  
566 function close_twitter(){
567  document.getElementById( "twitter" ).style.display = "none";
568  $.cookie("close_twitter","1", { expires: 365, path: "/" });
569  };
570  
571 function close_lastusers(){
572  document.getElementById( "close_lastusers" ).style.display = "none";
573  $.cookie("close_lastusers","1", { expires: 365, path: "/" });
574  };
575
576 function close_lastphotos(){
577  document.getElementById( "close_lastphotos" ).style.display = "none";
578  $.cookie("close_lastphotos","1", { expires: 365, path: "/" });
579  };
580  
581 function close_lastlikes(){
582  document.getElementById( "close_lastlikes" ).style.display = "none";
583  $.cookie("close_lastlikes","1", { expires: 365, path: "/" });
584  };
585 </script>';}}
586
587 $a->page['htmlhead'] .= ' 
588
589 <script>
590 function insertFormatting(comment,BBcode,id) {
591         
592                 var tmpStr = $("#comment-edit-text-" + id).val();
593                 if(tmpStr == comment) {
594                         tmpStr = "";
595                         $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
596                         $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
597                         openMenu("comment-edit-submit-wrapper-" + id);
598                                                                 }
599
600         textarea = document.getElementById("comment-edit-text-" +id);
601         if (document.selection) {
602                 textarea.focus();
603                 selected = document.selection.createRange();
604                 if (BBcode == "url"){
605                         selected.text = "["+BBcode+"]" + "http://" +  selected.text + "[/"+BBcode+"]";
606                         } else                  
607                 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
608         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
609                 var start = textarea.selectionStart;
610                 var end = textarea.selectionEnd;
611                 if (BBcode == "url"){
612                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
613                         } else
614                 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
615         }
616         return true;
617 }
618
619 function cmtBbOpen(id) {
620         $(".comment-edit-bb-" + id).show();
621 }
622 function cmtBbClose(id) {
623         $(".comment-edit-bb-" + id).hide();
624 }
625
626 </script> ';