--- loncom/interface/coursecatalog.pm	2010/04/04 15:38:34	1.60
+++ loncom/interface/coursecatalog.pm	2010/07/08 23:19:19	1.63
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler for displaying the course catalog interface
 #
-# $Id: coursecatalog.pm,v 1.60 2010/04/04 15:38:34 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.63 2010/07/08 23:19:19 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -87,8 +87,13 @@ sub handler {
     }
     &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,
                                            \%idx,\@jsarray,$subcats);
+    my ($numtitles,@codetitles);
     if ($env{'form.coursenum'} ne '' && &user_is_known()) {
-        &course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems);
+        if ($env{'form.currcat_0'} eq 'instcode::0') {
+            $numtitles = &instcode_course_selector($r,$codedom,$formname,$domdesc,
+                                                   undef,undef,\@codetitles);
+        }
+        &course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems,\@codetitles);
     } else {
         my ($catlinks,$has_subcats,$selitem) = &category_breadcrumbs($codedom,@cats);
         my $catjs = <<"ENDSCRIPT";
@@ -114,12 +119,12 @@ function setCourseId(caller) {
 
 ENDSCRIPT
         $catjs .= &courselink_javascript(); 
-        my $numtitles;
         if ($env{'form.currcat_0'} eq 'instcode::0') {
             $numtitles = &instcode_course_selector($r,$codedom,$formname,$domdesc,
-                                                   $catlinks,$catjs);
+                                                   $catlinks,$catjs,\@codetitles);
             if ($env{'form.state'} eq 'listing') {
-                $r->print(&print_course_listing($codedom,$numtitles));
+                $r->print(&print_course_listing($codedom,$numtitles,undef,undef,undef,
+                                                \@codetitles));
             }
         } else {
             my (%add_entries);
@@ -164,7 +169,7 @@ ENDJS
                           $display_button.'" /></form><br /><br />');
             }
             if ($env{'form.state'} eq 'listing') {
-                $r->print(&print_course_listing($codedom,undef,\@trails,\%allitems,$subcats));
+                $r->print(&print_course_listing($codedom,undef,\@trails,\%allitems,$subcats,\@codetitles));
             }
         }
     }
@@ -173,7 +178,7 @@ ENDJS
 }
 
 sub course_details {
-    my ($r,$codedom,$formname,$domdesc,$trails,$allitems) = @_;
+    my ($r,$codedom,$formname,$domdesc,$trails,$allitems,$codetitles) = @_;
     my $output;
     my %add_entries = (topmargin    => "0",
                        marginheight => "0",);
@@ -192,7 +197,7 @@ sub course_details {
     my $brtexttwo = 'Course details';
     if ($env{'form.currcat_0'} eq 'communities::0') {
         $brtextone = 'Community listing';
-        $brtextone = 'Community details';
+        $brtexttwo = 'Community details';
     }
     &Apache::lonhtmlcommon::add_breadcrumb
              ({href=>"javascript:document.$formname.submit()",
@@ -206,7 +211,7 @@ sub course_details {
         $r->print(&mt('Detailed course information:'));
     }
     $r->print('<br /><br />'.
-              &print_course_listing($codedom,undef,$trails,$allitems).
+              &print_course_listing($codedom,undef,$trails,$allitems,undef,$codetitles).
               '<br /><br />');
     $r->print('<form name="'.$formname.'" method="post" action="/adm/coursecatalog">'.
               '<a href = "javascript:document.coursecatalog.submit()">');
@@ -248,10 +253,9 @@ END
 }
 
 sub instcode_course_selector {
-    my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs) = @_;
+    my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs,$codetitles) = @_;
     my %coursecodes = ();
     my %codes = ();
-    my @codetitles = ();
     my %cat_titles = ();
     my %cat_order = ();
     my %cat_items;
@@ -261,7 +265,7 @@ sub instcode_course_selector {
                        marginheight => "0",);
     my ($jscript,$totcodes,$numtitles,$lasttitle) = 
         &Apache::courseclassifier::instcode_selectors_data($codedom,$formname,
-                           \%cat_items,\@codetitles,\%cat_titles,\%cat_order);
+                           \%cat_items,$codetitles,\%cat_titles,\%cat_order);
     my $js = '<script type"text/javascript">'."\n$jscript\n$catjs\n".
               '</script>';
     if ($totcodes) {
@@ -278,7 +282,7 @@ sub instcode_course_selector {
         if ($numtitles > 0) {
             $r->print('<b>'.&mt('Choose which course(s) to list.').'</b><br />'.
                       &Apache::courseclassifier::build_instcode_selectors($numtitles,
-                       $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order));
+                       $lasttitle,\%cat_items,$codetitles,\%cat_titles,\%cat_order));
         }
         $r->print('<input type="hidden" name="coursenum" value="" />'."\n".
                   '<input type="hidden" name="sortby" value="" />'."\n".
@@ -327,10 +331,7 @@ sub cat_header {
           text=>"Course/Community Catalog"});
     }
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'));
-    my $onchange;
-    unless ($env{'form.interface'} eq 'textual') {
-        $onchange = 'this.form.submit()';
-    }
+    my $onchange = 'this.form.submit()';
     $r->print('<form name="coursecatdom" method="post" action="/adm/coursecatalog">'.
               '<table border="0"><tr><td><b>'.&mt('Domain:').'</b></td><td>'.
               &Apache::loncommon::select_dom_form($codedom,'showdom','',1,$onchange));
@@ -578,8 +579,8 @@ sub user_is_dc {
 }
 
 sub search_official_courselist {
-    my ($domain,$numtitles) = @_;
-    my $instcode = &Apache::courseclassifier::instcode_search_str($domain,$numtitles);
+    my ($domain,$numtitles,$codetitles) = @_;
+    my $instcode = &Apache::courseclassifier::instcode_search_str($domain,$numtitles,$codetitles);
     my $showhidden;
     if (&user_is_dc($domain)) {
         $showhidden = $env{'form.showhidden'};
@@ -636,7 +637,7 @@ sub search_courselist {
 }
 
 sub print_course_listing {
-    my ($domain,$numtitles,$trails,$allitems,$subcats) = @_;
+    my ($domain,$numtitles,$trails,$allitems,$subcats,$codetitles) = @_;
     my $output;
     my %courses;
     my $knownuser = &user_is_known();
@@ -660,7 +661,7 @@ sub print_course_listing {
         }
     } else {
         if ($env{'form.currcat_0'} eq 'instcode::0') {
-            %courses = &search_official_courselist($domain,$numtitles);
+            %courses = &search_official_courselist($domain,$numtitles,$codetitles);
         } else {
             %courses = &search_courselist($domain,$subcats);
         }