--- loncom/interface/lonhtmlcommon.pm	2004/05/05 14:12:54	1.68
+++ loncom/interface/lonhtmlcommon.pm	2004/06/05 14:46:12	1.75
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.68 2004/05/05 14:12:54 matthew Exp $
+# $Id: lonhtmlcommon.pm,v 1.75 2004/06/05 14:46:12 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -868,37 +868,74 @@ sub crumbs {
 # ------------------------------------------------- Output headers for HTMLArea
 
 sub htmlareaheaders {
-    unless (&htmlareablocked()) { return ''; }
+    if (&htmlareablocked()) { return ''; }
     my $lang='en';
+    if (&mt('htmlarea_lang') ne 'htmlarea_lang') {
+	$lang=&mt('htmlarea_lang');
+    }
     return (<<ENDHEADERS);
 <script type="text/javascript">
-    _editor_url="/htmlarea/";
+_editor_url='/htmlarea/';
+_editor_lang='$lang';
 </script>
 <script type="text/javascript" src="/htmlarea/htmlarea.js"></script>
-<script type="text/javascript" src="/htmlarea/lang/$lang.js"></script>
-<script type="text/javascript" src="/htmlarea/dialog.js"></script>
-<style type="text/css">
-\@import url(/htmlarea/htmlarea.css);
-</style>
 ENDHEADERS
 }
 
+# ------------------------------------------------- Activate additional buttons
+
+sub htmlareaaddbuttons {
+    if (&htmlareablocked()) { return ''; }
+    return (<<ENDADDBUTTON);
+    var config=new HTMLArea.Config();
+    config.registerButton('ed_math','LaTeX Inline',
+			  '/htmlarea/images/ed_math.gif',false,
+			    function(editor,id) {
+			      editor.surroundHTML('<m>\$','\$</m>');
+			    }
+			  );
+    config.registerButton('ed_math_eqn','LaTeX Equation',
+			  '/htmlarea/images/ed_math_eqn.gif',false,
+			    function(editor,id) {
+			      editor.surroundHTML(
+				     '<center><m>\\\\[','\\\\]</m></center>');
+			    }
+			  );
+    config.toolbar.push(['ed_math','ed_math_eqn']);
+ENDADDBUTTON
+}
 # ---------------------------------------------------------- Script to activate
 
 sub htmlareaactive {
-    unless (&htmlareablocked()) { return ''; }
+    if (&htmlareablocked()) { return ''; }
+    my $addbuttons=&htmlareaaddbuttons();
     return (<<ENDSCRIPT);
 <script type="text/javascript" defer="1">
-    HTMLArea.replaceAll();
+    $addbuttons
+    HTMLArea.replaceAll(config);
 </script>
 ENDSCRIPT
 }
 
+# ----------------------------------------- Script to activate only some fields
+
+sub htmlareaselectactive {
+    my @fields=@_;
+    if (&htmlareablocked()) { return ''; }
+    my $output='<script type="text/javascript" defer="1">'.
+	&htmlareaaddbuttons();
+    foreach(@fields) {
+	$output.="\nHTMLArea.replace('$_',config);";
+    }
+    $output.="\nwindow.status='Activated Editfields';\n</script>";
+    return $output;
+}
+
 # --------------------------------------------------------------------- Blocked
 
 sub htmlareablocked {
-    unless (&htmlareabrowser()) { return ''; }
-    return 1;
+    unless (&htmlareabrowser()) { return 1; }
+    return 0;
 }
 
 # ---------------------------------------- Browser capable of running HTMLArea?
@@ -975,23 +1012,34 @@ returns: nothing
         # The last breadcrumb does not have a link, so handle it separately.
         my $last = pop(@Crumbs);
         #
-        # The first one should be the course, I guess.
+        # The first one should be the course or a menu link
 	if (!defined($menulink)) { $menulink=1; }
-        if ($menulink && exists($ENV{'request.course.id'}) && $ENV{'request.course.id'} ne '') {
-            my $cid = $ENV{'request.course.id'};
+        if ($menulink) {
+            my $description = 'Menu';
+            if (exists($ENV{'request.course.id'}) && 
+                $ENV{'request.course.id'} ne '') {
+                $description = 
+                    $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+            }
             unshift(@Crumbs,{
-                             href=>'/adm/menu',
-                             title=>'Go to main menu',
-                             text=>$ENV{'course.'.$cid.'.description'},
-                            });
+                    href   =>'/adm/menu',
+                    title  =>'Go to main menu',
+                    target =>'_top',
+                    text   =>$description,
+                });
         }
         my $links .= 
             join('-&gt;',
                  map {
                      $faq = $_->{'faq'} if (exists($_->{'faq'}));
                      $bug = $_->{'bug'} if (exists($_->{'bug'}));
-                     '<a href="'.$_->{'href'}.'" title="'.&mt($_->{'title'}).'">'.
-                         &mt($_->{'text'}).'</a>' 
+                     my $result = '<a href="'.$_->{'href'}.'" ';
+                     if (defined($_->{'target'}) && $_->{'target'} ne '') {
+                         $result .= 'target="'.$_->{'target'}.'" ';
+                     }
+                     $result .='title="'.&mt($_->{'title'}).'">'.
+                         &mt($_->{'text'}).'</a>';
+                     $result;
                      } @Crumbs
                  );
         $links .= '-&gt;' if ($links ne '');