--- loncom/interface/loncommon.pm	2009/06/09 18:42:42	1.841
+++ loncom/interface/loncommon.pm	2009/10/16 00:17:25	1.898
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.841 2009/06/09 18:42:42 tempelho Exp $
+# $Id: loncommon.pm,v 1.898 2009/10/16 00:17:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -483,27 +483,18 @@ ENDAUTHORBRW
 
 sub coursebrowser_javascript {
     my ($domainfilter,$sec_element,$formname)=@_;
-    my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Group - for which you wish to add/modify a user role');
-   my $output = '
+    my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Community - for which you wish to add/modify a user role.');
+    my $id_functions = &javascript_index_functions();
+    my $output = '
 <script type="text/javascript" language="JavaScript">
 // <![CDATA[
     var stdeditbrowser;'."\n";
-   $output .= <<"ENDSTDBRW";
+
+    $output .= <<"ENDSTDBRW";
     function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag,crstype) {
         var url = '/adm/pickcourse?';
-        var domainfilter = '';
         var formid = getFormIdByName(formname);
-        if (formid > -1) {
-            var domid = getIndexByName(formid,udom);
-            if (domid > -1) {
-                if (document.forms[formid].elements[domid].type == 'select-one') {
-                    domainfilter=document.forms[formid].elements[domid].options[document.forms[formid].elements[domid].selectedIndex].value;
-                }
-                if (document.forms[formid].elements[domid].type == 'hidden') {
-                    domainfilter=document.forms[formid].elements[domid].value;
-                }
-            }
-        }
+        var domainfilter = getDomainFromSelectbox(formname,udom);
         if (domainfilter != null) {
            if (domainfilter != '') {
                url += 'domainfilter='+domainfilter+'&';
@@ -529,10 +520,15 @@ sub coursebrowser_javascript {
                 }
             }     
         }
+        if (formname == 'ccrs') {
+            var ownername = document.forms[formid].ccuname.value;
+            var ownerdom =  document.forms[formid].ccdomain.options[document.forms[formid].ccdomain.selectedIndex].value;
+            url += '&cloner='+ownername+':'+ownerdom;
+        }
         if (multflag !=null && multflag != '') {
             url += '&multiple='+multflag;
         }
-        if (crstype == 'Course/Group') {
+        if (crstype == 'Course/Community') {
             if (formname == 'cu') {
                 crstype = document.cu.crstype.options[document.cu.crstype.selectedIndex].value; 
                 if (crstype == "") {
@@ -550,24 +546,7 @@ sub coursebrowser_javascript {
         stdeditbrowser = open(url,title,options,'1');
         stdeditbrowser.focus();
     }
-
-    function getFormIdByName(formname) {
-        for (var i=0;i<document.forms.length;i++) {
-            if (document.forms[i].name == formname) {
-                return i;
-            }
-        }
-        return -1; 
-    }
-
-    function getIndexByName(formid,item) {
-        for (var i=0;i<document.forms[formid].elements.length;i++) {
-            if (document.forms[formid].elements[i].name == item) {
-                return i;
-            }
-        }
-        return -1;
-    }
+$id_functions
 ENDSTDBRW
     if ($sec_element ne '') {
         $output .= &setsec_javascript($sec_element,$formname);
@@ -578,6 +557,109 @@ ENDSTDBRW
     return $output;
 }
 
+sub javascript_index_functions {
+    return <<"ENDJS";
+
+function getFormIdByName(formname) {
+    for (var i=0;i<document.forms.length;i++) {
+        if (document.forms[i].name == formname) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+function getIndexByName(formid,item) {
+    for (var i=0;i<document.forms[formid].elements.length;i++) {
+        if (document.forms[formid].elements[i].name == item) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+function getDomainFromSelectbox(formname,udom) {
+    var userdom;
+    var formid = getFormIdByName(formname);
+    if (formid > -1) {
+        var domid = getIndexByName(formid,udom);
+        if (domid > -1) {
+            if (document.forms[formid].elements[domid].type == 'select-one') {
+                userdom=document.forms[formid].elements[domid].options[document.forms[formid].elements[domid].selectedIndex].value;
+            }
+            if (document.forms[formid].elements[domid].type == 'hidden') {
+                userdom=document.forms[formid].elements[domid].value;
+            }
+        }
+    }
+    return userdom;
+}
+
+ENDJS
+
+}
+
+sub userbrowser_javascript {
+    my $id_functions = &javascript_index_functions();
+    return <<"ENDUSERBRW";
+
+function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom,crsdom,caller) {
+    var url = '/adm/pickuser?';
+    var userdom = getDomainFromSelectbox(formname,udom);
+    if (userdom != null) {
+       if (userdom != '') {
+           url += 'srchdom='+userdom+'&';
+       }
+    }
+    url += 'form=' + formname + '&unameelement='+uname+
+                                '&udomelement='+udom+
+                                '&ulastelement='+ulast+
+                                '&ufirstelement='+ufirst+
+                                '&uemailelement='+uemail+
+                                '&hideudomelement='+hideudom+
+                                '&coursedom='+crsdom;
+    if ((caller != null) && (caller != undefined)) {
+        url += '&caller='+caller;
+    }
+    var title = 'User_Browser';
+    var options = 'scrollbars=1,resizable=1,menubar=0';
+    options += ',width=700,height=600';
+    var stdeditbrowser = open(url,title,options,'1');
+    stdeditbrowser.focus();
+}
+
+function fix_domain (formname,udom,origdom,uname) {
+    var formid = getFormIdByName(formname);
+    if (formid > -1) {
+        var unameid = getIndexByName(formid,uname);
+        var domid = getIndexByName(formid,udom);
+        var hidedomid = getIndexByName(formid,origdom);
+        if (hidedomid > -1) {
+            var fixeddom = document.forms[formid].elements[hidedomid].value;
+            var unameval = document.forms[formid].elements[unameid].value;
+            if ((fixeddom != '') && (fixeddom != undefined) && (fixeddom != null) && (unameval != '') && (unameval != undefined) && (unameval != null)) {
+                if (domid > -1) {
+                    var slct = document.forms[formid].elements[domid];
+                    if (slct.type == 'select-one') {
+                        var i;
+                        for (i=0;i<slct.length;i++) {
+                            if (slct.options[i].value==fixeddom) { slct.selectedIndex=i; }
+                        }
+                    }
+                    if (slct.type == 'hidden') {
+                        slct.value = fixeddom;
+                    }
+                }
+            }
+        }
+    }
+    return;
+}
+
+$id_functions
+ENDUSERBRW
+}
+
 sub setsec_javascript {
     my ($sec_element,$formname) = @_;
     my $setsections = qq|
@@ -620,12 +702,16 @@ function setSect(sectionlist) {
 
 sub selectcourse_link {
    my ($form,$unameele,$udomele,$desc,$extra_element,$multflag,$selecttype)=@_;
+   my $linktext = &mt('Select Course');
+   if ($selecttype eq 'Community') {
+       $linktext = &mt('Select Community'); 
+   }
    return '<span class="LC_nobreak">'
          ."<a href='"
          .'javascript:opencrsbrowser("'.$form.'","'.$unameele
          .'","'.$udomele.'","'.$desc.'","'.$extra_element
          .'","'.$multflag.'","'.$selecttype.'");'
-         ."'>".&mt('Select Course').'</a>'
+         ."'>".$linktext.'</a>'
          .'</span>';
 }
 
@@ -635,6 +721,14 @@ sub selectauthor_link {
           &mt('Select Author').'</a>';
 }
 
+sub selectuser_link {
+    my ($form,$unameelem,$domelem,$lastelem,$firstelem,$emailelem,$hdomelem,
+        $coursedom,$linktext,$caller) = @_;
+    return '<a href="javascript:openuserbrowser('."'$form','$unameelem','$domelem',".
+           "'$lastelem','$firstelem','$emailelem','$hdomelem','$coursedom','$caller'".
+           ');">'.$linktext.'</a>';
+}
+
 sub check_uncheck_jscript {
     my $jscript = <<"ENDSCRT";
 function checkAll(field) {
@@ -1111,8 +1205,8 @@ sub help_menu_js {
 
     my $template .= <<"ENDTEMPLATE";
 <script type="text/javascript">
-// <!-- BEGIN LON-CAPA Internal
 // <![CDATA[
+// <!-- BEGIN LON-CAPA Internal
 var banner_link = '';
 function helpMenu(target) {
     var caller = this;
@@ -1137,8 +1231,8 @@ function writeHelp(caller) {
     caller.document.close()
     caller.focus()
 }
-// ]]>
 // END LON-CAPA Internal -->
+// ]]>
 </script>
 ENDTEMPLATE
     return $template;
@@ -1787,7 +1881,7 @@ sub select_level_form {
 
 =pod
 
-=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$autosubmit)
+=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange)
 
 Returns a string containing a <select name='$name' size='1'> form to 
 allow a user to select the domain to preform an operation in.  
@@ -1798,16 +1892,15 @@ selected");
 
 If the $showdomdesc flag is set, the domain name is followed by the domain description.
 
-If the $autosubmit flag is set, the form containing the domain selector will be auto-submitted by an onchange action.  
+The optional $onchange argumnet specifies what should occur if the domain selector is changed, e.g., 'this.form.submit()' if the form is to be automatically submitted.  
 
 =cut
 
 #-------------------------------------------
 sub select_dom_form {
-    my ($defdom,$name,$includeempty,$showdomdesc,$autosubmit) = @_;
-    my $onchange;
-    if ($autosubmit) {
-        $onchange = ' onchange="this.form.submit()"';
+    my ($defdom,$name,$includeempty,$showdomdesc,$onchange) = @_;
+    if ($onchange) {
+        $onchange = ' onchange="'.$onchange.'"';
     }
     my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
     if ($includeempty) { @domains=('',@domains); }
@@ -2862,7 +2955,7 @@ sub messagewrapper {
 sub noteswrapper {
     my ($link,$un,$do)=@_;
     return 
-"<a href='/adm/email?recordftf=retrieve&recname=$un&recdom=$do'>$link</a>";
+"<a href='/adm/email?recordftf=retrieve&amp;recname=$un&amp;recdom=$do'>$link</a>";
 }
 
 # ------------------------------------------------------------- Aboutme Wrapper
@@ -2872,7 +2965,7 @@ sub aboutmewrapper {
     if (!defined($username)  && !defined($domain)) {
         return;
     }
-    return '<a href="/adm/'.$domain.'/'.$username.'/aboutme"'.
+    return '<a href="/adm/'.$domain.'/'.$username.'/aboutme?forcestudent=1"'.
 	($target?' target="$target"':'').' title="'.&mt("View this user's personal information page").'">'.$link.'</a>';
 }
 
@@ -2886,7 +2979,7 @@ sub syllabuswrapper {
 # -----------------------------------------------------------------------------
 
 sub track_student_link {
-    my ($linktext,$sname,$sdom,$target,$start) = @_;
+    my ($linktext,$sname,$sdom,$target,$start,$only_body) = @_;
     my $link ="/adm/trackstudent?";
     my $title = 'View recent activity';
     if (defined($sname) && $sname !~ /^\s*$/ &&
@@ -2900,6 +2993,7 @@ sub track_student_link {
         $target = '';
     }
     if ($start) { $link.='&amp;start='.$start; }
+    if ($only_body) { $link .= '&amp;only_body=1'; }
     $title = &mt($title);
     $linktext = &mt($linktext);
     return qq{<a href="$link" title="$title" $target>$linktext</a>}.
@@ -3766,7 +3860,7 @@ sub blockcheck {
                  ($env{'request.role'} !~ m{^st\./\Q$cdom\E/\Q$cnum\E}));
         next if ($no_userblock);
 
-        # Retrieve blocking times and identity of blocker for course
+        # Retrieve blocking times and identity of locker for course
         # of specified user, unless user has 'evb' privilege.
         
         my ($start,$end)=&get_blocks($setters,$activity,$cdom,$cnum);
@@ -3831,103 +3925,51 @@ sub parse_block_record {
     return ($setuname,$setudom,$title,$blocks);
 }
 
-sub build_block_table {
-    my ($startblock,$endblock,$setters) = @_;
-    my %lt = &Apache::lonlocal::texthash(
-        'cacb' => 'Currently active communication blocks',
-        'cour' => 'Course',
-        'dura' => 'Duration',
-        'blse' => 'Block set by'
-    );
-    my $output;
-    $output = '<br />'.$lt{'cacb'}.':<br />';
-    $output .= &start_data_table();
-    $output .= '
-<tr>
- <th>'.$lt{'cour'}.'</th>
- <th>'.$lt{'dura'}.'</th>
- <th>'.$lt{'blse'}.'</th>
-</tr>
-';
-    foreach my $course (keys(%{$setters})) {
-        my %courseinfo=&Apache::lonnet::coursedescription($course);
-        for (my $i=0; $i<@{$$setters{$course}{staff}}; $i++) {
-            my ($uname,$udom) = @{$$setters{$course}{staff}[$i]};
-            my $fullname = &plainname($uname,$udom);
-            if (defined($env{'user.name'}) && defined($env{'user.domain'})
-                && $env{'user.name'} ne 'public' 
-                && $env{'user.domain'} ne 'public') {
-                $fullname = &aboutmewrapper($fullname,$uname,$udom);
-            }
-            my ($openblock,$closeblock) = @{$$setters{$course}{times}[$i]};
-            $openblock = &Apache::lonlocal::locallocaltime($openblock);
-            $closeblock= &Apache::lonlocal::locallocaltime($closeblock);
-            $output .= &Apache::loncommon::start_data_table_row().
-                       '<td>'.$courseinfo{'description'}.'</td>'.
-                       '<td>'.$openblock.' to '.$closeblock.'</td>'.
-                       '<td>'.$fullname.'</td>'.
-                        &Apache::loncommon::end_data_table_row();
-        }
-    }
-    $output .= &end_data_table();
-}
-
 sub blocking_status {
-    my ($activity,$uname,$udom) = @_;
-    my %setters;
-    my ($blocked,$output,$ownitem,$is_course);
-    my ($startblock,$endblock)=&blockcheck(\%setters,$activity,$uname,$udom);
-    if ($startblock && $endblock) {
-        $blocked = 1;
-        if (wantarray) {
-            my $category;
-            if ($activity eq 'boards') {
-                $category = 'Discussion posts in this course';
-            } elsif ($activity eq 'blogs') {
-                $category = 'Blogs';
-            } elsif ($activity eq 'port') {
-                if (defined($uname) && defined($udom)) {
-                    if ($uname eq $env{'user.name'} &&
-                        $udom eq $env{'user.domain'}) {
-                        $ownitem = 1;
-                    }
-                }
-                $is_course = &Apache::lonnet::is_course($udom,$uname);
-                if ($ownitem) { 
-                    $category = 'Your portfolio files';  
-                } elsif ($is_course) {
-                    my $coursedesc;
-                    foreach my $course (keys(%setters)) {
-                        my %courseinfo =
-                             &Apache::lonnet::coursedescription($course);
-                        $coursedesc = $courseinfo{'description'};
-                    }
-                    $category = "Group portfolio in the course '$coursedesc'";
-                } else {
-                    $category = 'Portfolio files belonging to ';
-                    if ($env{'user.name'} eq 'public' && 
-                        $env{'user.domain'} eq 'public') {
-                        $category .= &plainname($uname,$udom);
-                    } else {
-                        $category .= &aboutmewrapper(&plainname($uname,$udom),$uname,$udom);  
-                    }
-                }
-            } elsif ($activity eq 'groups') {
-                $category = 'Groups in this course';
-            }
-            my $showstart = &Apache::lonlocal::locallocaltime($startblock);
-            my $showend = &Apache::lonlocal::locallocaltime($endblock);
-            $output = '<br />'.&mt('[_1] will be inaccessible between [_2] and [_3] because communication is being blocked.',$category,$showstart,$showend).'<br />';
-            if (!($activity eq 'port' && !($ownitem) && !($is_course))) { 
-                $output .= &build_block_table($startblock,$endblock,\%setters);
-            }
-        }
-    }
-    if (wantarray) {
-        return ($blocked,$output);
-    } else {
-        return $blocked;
-    }
+  my ($activity,$uname,$udom) = @_;
+  my %setters;
+
+  # check for active blocking
+  my ($startblock,$endblock)=&blockcheck(\%setters,$activity,$uname,$udom);
+
+  my $blocked = $startblock && $endblock ? 1 : 0;
+
+  # caller just wants to know whether a block is active
+  if (!wantarray) { return $blocked; }
+
+  # build a link to a popup window containing the details
+  my $querystring  = "?activity=$activity";
+  # $uname and $udom decide whose portfolio the user is trying to look at
+     $querystring .= "&amp;udom=$udom"      if $udom;
+     $querystring .= "&amp;uname=$uname"    if $uname;
+
+  my $output .= <<'END_MYBLOCK';
+    function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
+        var options = "width=" + w + ",height=" + h + ",";
+        options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
+        options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
+        var newWin = window.open(url, wdwName, options);
+        newWin.focus();
+    }
+END_MYBLOCK
+
+  $output = Apache::lonhtmlcommon::scripttag($output);
+  
+  my $popupUrl = "/adm/blockingstatus/$querystring";
+  my $text = mt('Communication Blocked');
+
+  $output .= <<"END_BLOCK";
+<div class='LC_comblock'>
+  <a onclick='openWindow("$popupUrl","Blocking Table",600,300,"no","no");return false;' href='/adm/blockingstatus/$querystring'
+  title='$text'>
+  <img class='LC_noBorder LC_middle' title='$text' src='/res/adm/pages/comblock.png' alt='$text'/></a>
+  <a onclick='openWindow("$popupUrl","Blocking Table",600,300,"no","no");return false;' href='/adm/blockingstatus/$querystring' 
+  title='$text'>$text</a>
+</div>
+
+END_BLOCK
+
+  return ($blocked, $output);
 }
 
 ###############################################
@@ -4005,7 +4047,7 @@ sub determinedomain {
     my $domain=shift;
     if (! $domain) {
         # Determine domain if we have not been given one
-        $domain = $Apache::lonnet::perlvar{'lonDefDomain'};
+        $domain = &Apache::lonnet::default_login_domain();
         if ($env{'user.domain'}) { $domain=$env{'user.domain'}; }
         if ($env{'request.role.domain'}) { 
             $domain=$env{'request.role.domain'}; 
@@ -4223,7 +4265,7 @@ Returns: HTML div with $content
 sub head_subbox {
     my ($content)=@_;
     my $output =
-        '<div id="LC_head_subbox2">' #FIXME: solve conflicts with lonhtmlcommon:breadcrumbs LC_head_subbox
+        '<div id="LC_head_subbox">'
        .$content
        .'</div>'
 }
@@ -4355,6 +4397,9 @@ sub bodytag {
         if ($env{'request.role'} !~ /^cr/) {
             $role = &Apache::lonnet::plaintext($role,&course_type());
         }
+        if ($env{'request.course.sec'}) {
+            $role .= ('&nbsp;'x2).'-&nbsp;'.&mt('section:').'&nbsp;'.$env{'request.course.sec'};
+        }   
 	$realm = $env{'course.'.$env{'request.course.id'}.'.description'};
     } else {
         $role = &Apache::lonnet::plaintext($role);
@@ -4394,32 +4439,52 @@ sub bodytag {
         $dc_info = '('.$dc_info.')';
     }
 
+    $role = '<span class="LC_nobreak">('.$role.')</span>' if $role;
+    &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']);
+
     if ($env{'environment.remote'} eq 'off') {
         # No Remote
-	if ($env{'request.state'} eq 'construct') {
-	    $forcereg=1;
-	}
+        if ($env{'request.state'} eq 'construct') {
+            $forcereg=1;
+        }
 
-#    if ($env{'request.state'} eq 'construct') {
-#        $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
-#    }
+    #    if ($env{'request.state'} eq 'construct') {
+    #        $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
+    #    }
 
         my $titletable = '<table id="LC_title_bar">'
-                        ."<tr><td> $titleinfo $dc_info</td>"
-                        .'</tr></table>';
+                            ."<tr><td> $titleinfo $dc_info</td>"
+                            .'</tr></table>';
 
-	if ($no_nav_bar) {
-	    $bodytag .= $titletable;
-	} else {
-        $bodytag .= qq|<div id="LC_nav_bar">$name ($role)<br />
-            <em>$realm</em> $dc_info</div>|;
-	    if ($env{'request.state'} eq 'construct') {
-                $bodytag .= &Apache::lonmenu::menubuttons($forcereg,$forcereg,
-							  $titletable);
-            } else {
-                $bodytag .= &Apache::lonmenu::menubuttons($forcereg,$forcereg).
-		    $titletable;
-            }
+        if ($no_nav_bar) {
+            $bodytag .= $titletable;
+        } else {
+            $bodytag .= qq|<div id="LC_nav_bar">$name $role<br />
+                <em>$realm</em> $dc_info</div>| unless $env{'form.inhibitmenu'};
+
+#SD $titletable is obsolete
+#SD            if ($env{'request.state'} eq 'construct') {
+#SD                $bodytag .= &Apache::lonmenu::menubuttons($forcereg,$titletable);
+#SD            } else {
+#SD                $bodytag .= &Apache::lonmenu::menubuttons($forcereg).$titletable;
+#SD            }
+               if (   $env{'form.inhibitmenu'} eq 'yes' 
+                   || $ENV{'REQUEST_URI'} eq '/adm/logout'
+                   || $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {
+                   
+                   return $bodytag;
+               }
+
+               $bodytag .= Apache::lonhtmlcommon::scripttag(
+                                Apache::lonmenu::utilityfunctions(),
+                                'start');
+               $bodytag .= Apache::lonmenu::primary_menu();
+               $bodytag .= Apache::lonmenu::secondary_menu();
+               #SD remove next line
+               #$bodytag .= Apache::lonmenu::menubuttons($forcereg);
+               $bodytag .= Apache::lonmenu::serverform();
+               $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); 
+               $bodytag .= Apache::lonmenu::innerregister($forcereg) if $forcereg;
         }
         return $bodytag;
     }
@@ -4436,7 +4501,12 @@ sub bodytag {
 
     # Explicit link to get inline menu
     my $menu= ($no_inline_link?''
-	       :'<br /><a href="/adm/remote?action=collapse">'.&mt('Switch to Inline Menu Mode').'</a>');
+	       :'<a href="/adm/remote?action=collapse" target="_top">'.&mt('Switch to Inline Menu Mode').'</a>');
+    $bodytag .= qq|<div id="LC_nav_bar">$name $role
+            <em>$realm</em> $dc_info </div>
+            <ol class="LC_primary_menu LC_right">
+                <li>$menu</li>
+            </ol>| unless $env{'form.inhibitmenu'};
     #
     return(<<ENDBODY);
 $bodytag
@@ -4566,9 +4636,9 @@ sub standard_css {
 
     my $sans                 = 'Verdana,Arial,Helvetica,sans-serif';
     my $mono                 = 'monospace';
-    my $data_table_head      = $tabbg;
-    my $data_table_light     = '#EEEEEE';
-    my $data_table_dark      = '#DDDDDD';
+    my $data_table_head      = $sidebg;
+    my $data_table_light     = '#FAFAFA';
+    my $data_table_dark      = '#F0F0F0';
     my $data_table_darker    = '#CCCCCC';
     my $data_table_highlight = '#FFFF00';
     my $mail_new             = '#FFBB77';
@@ -4747,14 +4817,6 @@ table#LC_title_bar.LC_with_remote {
   margin: 0;
 }
 
-table.LC_docs_path {
-  width: 100%;
-  border: 0;
-  background: $pgbg;
-  border-collapse: collapse;
-  padding: 0;
-}
-
 table#LC_title_bar td {
   background: $tabbg;
 }
@@ -4798,19 +4860,12 @@ table#LC_top_nav td.LC_top_nav_login {
   text-align: center;
 }
 
-table.LC_breadcrumbs td,
-table.LC_docs_path td  {
-  background: $tabbg;
-  color: $fontmenu;
-  font-size: smaller;
+.LC_breadcrumbs_component {
+    float: right;
+    margin: 0 1em;
 }
-
-table.LC_breadcrumbs td.LC_breadcrumbs_component,
-table.LC_docs_path td.LC_docs_path_component {
-  background: $tabbg;
-  color: $fontmenu;
-  font-size: larger;
-  text-align: right;
+.LC_breadcrumbs_component img {
+    vertical-align: middle;
 }
 
 td.LC_table_cell_checkbox {
@@ -4825,21 +4880,21 @@ table#LC_mainmenu td.LC_mainmenu_column
  font-size: 70%;
 }
 
-#LC_head_subbox {
+#LC_breadcrumbs {
  clear:both;
  background: $sidebg;
  border-bottom: 1px solid $lg_border_color;
- height: 32px;
  line-height: 32px; 
  margin: 0;
  padding: 0;
 }
+
 /* Preliminary fix to hide breadcrumbs inside remote control window */
-#LC_remote #LC_head_subbox {
+#LC_remote #LC_breadcrumbs {
     display:none;
 }
 
-#LC_head_subbox2 { /* FIXME: replace by LC_head_subbox once lonhtmlcommon::breadcrumbs has been fixed */
+#LC_head_subbox {
  clear:both;
  background: #F8F8F8; /* $sidebg; */
  border-bottom: 1px solid $lg_border_color;
@@ -4885,14 +4940,6 @@ td.LC_menubuttons_text {
   font-weight: bold;
 }
 
-.LC_roleslog_note {
-  font-size: small;
-}
-
-.LC_mail_functions {
-    font-weight: bold;
-}
-
 table.LC_data_table,
 table.LC_mail_list {
   border: 1px solid #000000;
@@ -4912,6 +4959,7 @@ table.LC_nested_outer {
   width: 100%;
 }
 
+table.LC_innerpickbox,
 table.LC_nested {
   border: none;
   border-collapse: collapse;
@@ -4922,13 +4970,19 @@ table.LC_nested {
 table.LC_data_table tr th, 
 table.LC_calendar tr th, 
 table.LC_mail_list tr th,
-table.LC_prior_tries tr th {
+table.LC_prior_tries tr th,
+table.LC_innerpickbox tr th {
   font-weight: bold;
   background-color: $data_table_head;
   color:$fontmenu;
   font-size:90%;
 }
 
+table.LC_innerpickbox tr th,
+table.LC_innerpickbox tr td {
+  vertical-align: top;
+}
+
 table.LC_data_table tr.LC_info_row > td {
   background-color: #CCCCCC;
   font-weight: bold;
@@ -4965,6 +5019,9 @@ table.LC_nested tr.LC_empty_row td {
   padding: 8px;
 }
 
+table.LC_caption {
+}
+
 table.LC_nested tr.LC_empty_row td {
   padding: 4ex
 }
@@ -5246,7 +5303,7 @@ table.LC_pick_box {
 }
 
 table.LC_pick_box td.LC_pick_box_title {
-  background: $tabbg;
+  background: $sidebg;
   font-weight: bold;
   text-align: right;
   vertical-align: top;
@@ -5254,14 +5311,6 @@ table.LC_pick_box td.LC_pick_box_title {
   padding: 8px;
 }
 
-table.LC_pick_box td.LC_selfenroll_pick_box_title {
-  background: $tabbg;
-  font-weight: bold;
-  text-align: right;
-  width: 350px;
-  padding: 8px;
-}
-
 table.LC_pick_box td.LC_pick_box_value {
   text-align: left;
   padding: 8px;
@@ -5420,19 +5469,34 @@ div.LC_feedback_link {
 
 div.LC_feedback_link img {
   height: 22px;
+  vertical-align:middle;
 }
 
 div.LC_feedback_link a{
   text-decoration: none;
 }
 
+div.LC_comblock {
+  display:inline; 
+  color:$font;
+  font-size:90%;
+}
+
+div.LC_feedback_link div.LC_comblock {
+  padding-left:5px;
+}
+
+div.LC_feedback_link div.LC_comblock a {
+  color:$font;
+}
+
 span.LC_feedback_link {
-  //background: $feedback_link_bg;
+  /* background: $feedback_link_bg; */
   font-size: larger;
 }
 
 span.LC_message_link {
-  //background: $feedback_link_bg;
+  /* background: $feedback_link_bg; */
   font-size: larger;
   position: absolute;
   right: 1em;
@@ -5516,8 +5580,7 @@ table.LC_prior_match tr td {
   border: 1px solid #000000;
 }
 
-td.LC_nobreak,
-span.LC_nobreak {
+.LC_nobreak {
   white-space: nowrap;
 }
 
@@ -5541,21 +5604,24 @@ table.LC_docs_documents td.LC_docs_docum
   padding: 4px;
 }
 
-.LC_docs_entry_move {
-  border: none;
-  border-collapse: collapse;
-}
-
-.LC_docs_entry_move td {
-  border: 2px solid #BBBBBB;
+div.LC_docs_entry_move {
+  border: 1px solid #BBBBBB;
   background: #DDDDDD;
+  width: 22px;
+  padding: 1px;
+  margin: 0;
 }
 
-.LC_docs_editor td.LC_docs_entry_commands {
+table.LC_data_table tr > td.LC_docs_entry_commands,
+table.LC_data_table tr > td.LC_docs_entry_parameter {
   background: #DDDDDD;
   font-size: x-small;
 }
 
+.LC_docs_entry_parameter {
+  white-space: nowrap;
+}
+
 .LC_docs_copy {
   color: #000099;
 }
@@ -5577,17 +5643,6 @@ table.LC_docs_documents td.LC_docs_docum
   font-size: x-small;
 }
 
-.LC_docs_editor td.LC_docs_entry_title,
-.LC_docs_editor td.LC_docs_entry_icon {
-  background: #FFFFBB;
-}
-
-.LC_docs_editor td.LC_docs_entry_parameter {
-  background: #BBBBFF;
-  font-size: x-small;
-  white-space: nowrap;
-}
-
 table.LC_docs_adddocs td,
 table.LC_docs_adddocs th {
   border: 1px solid #BBBBBB;
@@ -5624,10 +5679,6 @@ table.LC_double_column tr td.LC_right_co
   vertical-align: top;
 }
 
-span.LC_role_level {
-  font-weight: bold;
-}
-
 div.LC_left_float {
   float: left;
   padding-right: 5%;
@@ -5748,14 +5799,6 @@ div.LC_edit_problem_saves {
   padding-bottom: 5px;
 }
 
-hr.LC_edit_problem_divide {
-  clear: both;
-  color: $tabbg;
-  background-color: $tabbg;
-  height: 3px;
-  border: none;
-}
-
 img.stift{
   border-width: 0;
   vertical-align: middle;
@@ -5790,10 +5833,10 @@ div.LC_createcourse {
 # --------------------------*/
 
 a:hover,
-ol.LC_smallMenu a:hover,
+ol.LC_primary_menu a:hover,
 ol#LC_MenuBreadcrumbs a:hover,
 ol#LC_PathBreadcrumbs a:hover,
-ul#LC_TabMainMenuContent a:hover,
+ul#LC_secondary_menu a:hover,
 .LC_FormSectionClearButton input:hover
 ul.LC_TabContent   li:hover a {
 	color:#BF2317;
@@ -5820,16 +5863,13 @@ h2,h3,h4,h5,h6 {
 }
 
 .LC_Box > .LC_hcell {
-    margin: 0 -10px;
+    margin: 0 -10px 10px -10px;
 }
 
 .LC_noBorder {
         border: 0;
 }
 
-
-/* Main Header with discription of Person, Course, etc. */
-
 .LC_Right {
         float: right;
         margin: 0;
@@ -5865,7 +5905,7 @@ fieldset > legend {
 
 #LC_nav_bar {
     float: left;
-    margin: 0;
+    margin: 0.2em 0 0 0;
 }
 
 #LC_nav_bar em{
@@ -5873,43 +5913,42 @@ fieldset > legend {
     font-style: normal;
 }
 
-ol.LC_smallMenu {
+ol.LC_primary_menu {
     float: right;
+    margin: 0.2em 0 0 0;
 }
 
-ol.LC_smallMenu, ol#LC_PathBreadcrumbs {
+ol#LC_PathBreadcrumbs {
 	margin: 0;
 }
 
-ol.LC_smallMenu li {
+ol.LC_primary_menu li {
 	display: inline;
 	padding: 5px 5px 0 10px;
 	vertical-align: top;
 }
 
-ol.LC_smallMenu li img {
+ol.LC_primary_menu li img {
 	vertical-align: bottom;
 }
 
-ol.LC_smallMenu a {
+ol.LC_primary_menu a {
 	font-size: 90%;
 	color: RGB(80, 80, 80);
 	text-decoration: none;
 }
 
-ul#LC_TabMainMenuContent {
+ul#LC_secondary_menu {
     clear: both;
     color: $fontmenu;
     background: $tabbg;
     list-style: none;
     padding: 0;
     margin: 0;
-    float:left;
     width: 100%;
 }
 
-ul#LC_TabMainMenuContent li {
-    float: left;
+ul#LC_secondary_menu li {
     font-weight: bold;
     line-height: 1.8em;
     padding: 0 0.8em; 
@@ -5918,30 +5957,27 @@ ul#LC_TabMainMenuContent li {
     vertical-align: middle;
 }
 
-ul.LC_TabContent ,
-ul.LC_TabContentBigger {
+ul.LC_TabContent {
 	display:block;
+	background: $sidebg;
+	border-bottom: solid 1px $lg_border_color;
 	list-style:none;
-	margin: 0;
+	margin: 0 -10px;
 	padding: 0;
 }
 
 ul.LC_TabContent li,
 ul.LC_TabContentBigger li {
-	display: inline;
-	border-right: solid 1px $lg_border_color;
 	float:left;
-	line-height:140%;
-	white-space:nowrap;
 }
 
-ul#LC_TabMainMenuContent li a {
+ul#LC_secondary_menu li a {
     color: $fontmenu;
 	text-decoration: none;
 }
 
 ul.LC_TabContent {
-	min-height:1.6em;
+	min-height:1.5em;
 }
 
 ul.LC_TabContent li {
@@ -5951,6 +5987,10 @@ ul.LC_TabContent li {
 	border-bottom:solid 1px $lg_border_color;
 }
 
+ul.LC_TabContent .right {
+	float:right;
+}
+
 ul.LC_TabContent li a, ul.LC_TabContent li {
 	color:rgb(47,47,47);
 	text-decoration:none;
@@ -5965,33 +6005,68 @@ ul.LC_TabContent li:hover, ul.LC_TabCont
 	padding-right: 16px;
 }
 
-ul.LC_TabContentBigger li {
-	vertical-align:bottom;
-	border-top:solid 1px $lg_border_color;
-	border-left:solid 1px $lg_border_color;
-	padding:5px 10px 5px 10px;
-	margin-left:2px;
-	background: #d9d9d9;
-}
-
 #maincoursedoc {
 	clear:both;
 }
 
-ul.LC_TabContentBigger li:hover, 
-ul.LC_TabContentBigger li.active {
-	background:url(/adm/lonIcons/lightGreyBG.png) repeat-x right bottom;
+ul.LC_TabContentBigger {
+        display:block;
+        list-style:none;
+        padding: 0;
+}
+
+ul.LC_TabContentBigger li {
+        vertical-align:bottom;
+        height: 30px;
+        font-size:110%;
+        font-weight:bold;
+        color: #737373;
 }
 
-ul.LC_TabContentBigger li, 
+
 ul.LC_TabContentBigger li a {
-	font-size:110%;
-	font-weight:bold;
+        background:url('/adm/lonIcons/tabbgleft.gif') left bottom no-repeat;
+	height: 30px;
+	line-height: 30px;
+	text-align: center;
+	display: block;
+	text-decoration: none;
+}
+
+ul.LC_TabContentBigger li:hover a, 
+ul.LC_TabContentBigger li.active a {
+	background:url('/adm/lonIcons/tabbgleft.gif') left top no-repeat;
+	color:$font;
+	text-decoration: underline;
+}
+
+
+ul.LC_TabContentBigger li b {
+	background: url('/adm/lonIcons/tabbgright.gif') no-repeat right bottom;
+	display: block;
+	float: left;
+	padding: 0 30px;
+}
+
+ul.LC_TabContentBigger li:hover b,
+ul.LC_TabContentBigger li.active b {
+        background:url('/adm/lonIcons/tabbgright.gif') right top no-repeat;
+        color:$font;
+	border-bottom: 1px solid #FFFFFF;
+}
+
+
+ul.LC_CourseBreadcrumbs {
+  background: $sidebg;
+  line-height: 32px;
+  padding-left: 10px;
+  margin: 0 0 10px 0;
+  list-style-position: inside;
+
 }
 
 ol#LC_MenuBreadcrumbs, 
-ol#LC_PathBreadcrumbs, 
-ul#LC_CourseBreadcrumbs {
+ol#LC_PathBreadcrumbs {
 	padding-left: 10px;
 	margin: 0;
 	list-style-position: inside;
@@ -5999,14 +6074,13 @@ ul#LC_CourseBreadcrumbs {
 
 ol#LC_MenuBreadcrumbs li, 
 ol#LC_PathBreadcrumbs li, 
-ul#LC_CourseBreadcrumbs li {
-	display: inline;
-	padding: 0 0 0 10px;
-	overflow:hidden;
+ul.LC_CourseBreadcrumbs li {
+    display: inline;
+    white-space: nowrap;
 }
 
 ol#LC_MenuBreadcrumbs li a,
-ul#LC_CourseBreadcrumbs li a {
+ul.LC_CourseBreadcrumbs li a {
 	text-decoration: none;
 	font-size:90%;
 }
@@ -6108,13 +6182,6 @@ div.LC_columnSection>* {
 	overflow:hidden;
 }
 
-.clear {
-	clear: both;
-	line-height: 0;
-	font-size: 0;
-	height: 0;
-}
-
 .LC_loginpage_container {
 	text-align:left;
 	margin : 0 auto;
@@ -6169,7 +6236,7 @@ table em {
 table.LC_tableBrowseRes,
 table.LC_tableOfContent {
         border:none;
-	border-spacing: 1;
+	border-spacing: 1px;
 	padding: 3px;
 	background-color: #FFFFFF;
 	font-size: 90%;
@@ -6263,7 +6330,7 @@ a.LC_toolbarItem {
 	background-color:transparent;
 }
 
-ul.LC_functionslist li {
+ul.LC_funclist li {
   float: left;
   white-space: nowrap;
   height: 35px; /* at least as high as heighest list item */
@@ -6398,7 +6465,8 @@ sub xml_begin {
             .'<html xmlns:math="http://www.w3.org/1998/Math/MathML" ' 
 	    .'xmlns="http://www.w3.org/1999/xhtml">';
     } else {
-	$output='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>';
+	$output='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
+           .'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
     }
     return $output;
 }
@@ -6485,6 +6553,8 @@ $args - additional optional args support
              inherit_jsmath -> when creating popup window in a page,
                                     should it have jsmath forced on by the
                                     current page
+             bread_crumbs ->             Array containing breadcrumbs
+             bread_crumbs_components ->  if exists show it as headline else show only the breadcrumbs
 
 =back
 
@@ -6721,6 +6791,11 @@ sub simple_error_page {
     sub end_data_table_header_row {
 	return '</tr>'."\n";;
     }
+
+    sub data_table_caption {
+        my $caption = shift;
+        return "<caption class=\"LC_caption\">$caption</caption>";
+    }
 }
 
 =pod
@@ -7493,6 +7568,7 @@ sub user_picker {
         #       loncreateuser::print_user_query_page()
         #       has been completed.
         next if ($option eq 'alc');
+        next if (($option eq 'crs') && ($env{'form.form'} eq 'requestcrs'));  
         next if ($option eq 'crs' && !$env{'request.course.id'});
         if ($curr_selected{'srchin'} eq $option) {
             $srchinsel .= ' 
@@ -7657,24 +7733,20 @@ $newuserscript
 
 $new_user_create
 
-<table>
- <tr>
-  <td>$lt{'doma'}:</td>
-  <td>$domform</td>
-  </td>
- </tr>
- <tr>
-  <td>$lt{'usr'}:</td>
-  <td>$srchbysel
-      $srchtypesel 
-      <input type="text" size="15" name="srchterm" value="$srchterm" />
-      $srchinsel 
-  </td>
- </tr>
-</table>
-<br />
 END_BLOCK
 
+    $output .= &Apache::lonhtmlcommon::start_pick_box().
+               &Apache::lonhtmlcommon::row_title($lt{'doma'}).
+               $domform.
+               &Apache::lonhtmlcommon::row_closure().
+               &Apache::lonhtmlcommon::row_title($lt{'usr'}).
+               $srchbysel.
+               $srchtypesel. 
+               '<input type="text" size="15" name="srchterm" value="'.$srchterm.'" />'.
+               $srchinsel.
+               &Apache::lonhtmlcommon::row_closure(1). 
+               &Apache::lonhtmlcommon::end_pick_box().
+               '<br />';
     return $output;
 }
 
@@ -8547,7 +8619,7 @@ sub csv_print_samples {
     $r->print(&mt('Samples').'<br />'.&start_data_table().
               &start_data_table_header_row());
     foreach my $sample (sort({$a <=> $b} keys(%{ $samples->[0] }))) { 
-        $r->print('<th>'.&mt('Column&nbsp;[_1]',($sample+1)).'</th>'); }
+        $r->print('<th>'.&mt('Column [_1]',($sample+1)).'</th>'); }
     $r->print(&end_data_table_header_row());
     foreach my $hash (@$samples) {
 	$r->print(&start_data_table_row());
@@ -8591,7 +8663,7 @@ sub csv_print_select_table {
 	my ($value,$display,$defaultcol)=@{ $array_ref };
 	$r->print(&start_data_table_row().'<td>'.$display.'</td>');
 
-	$r->print('<td><select name=f'.$i.
+	$r->print('<td><select name="f'.$i.'"'.
 		  ' onchange="javascript:flip(this.form,'.$i.');">');
 	$r->print('<option value="none"></option>');
 	foreach my $sample (sort({$a <=> $b} keys(%{ $samples->[0] }))) {
@@ -9245,10 +9317,11 @@ sub restore_settings {
 
 =item * &build_recipient_list()
 
-Build recipient lists for four types of e-mail:
+Build recipient lists for five types of e-mail:
 (a) Error Reports, (b) Package Updates, (c) lonstatus warnings/errors
-(d) Help requests, generated by
-lonerrorhandler.pm, CHECKRPMS, loncron, and lonsupportreq.pm respectively.
+(d) Help requests, (e) Course requests needing approval,  generated by
+lonerrorhandler.pm, CHECKRPMS, loncron, lonsupportreq.pm and
+loncoursequeueadmin.pm respectively.
 
 Inputs:
 defmail (scalar - email address of default recipient), 
@@ -9821,7 +9894,8 @@ sub check_clone {
         $clonemsg = &mt('No new course created.').$linefeed.&mt('A new course could not be cloned from the specified original - [_1] - because it is a non-existent course.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});     
     } else {
 	my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});
-	if ($env{'request.role.domain'} eq $args->{'clonedomain'}) {
+	if (($env{'request.role.domain'} eq $args->{'clonedomain'}) && 
+            (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
 	    $can_clone = 1;
 	} else {
 	    my %clonehash = &Apache::lonnet::get('environment',['cloners'],
@@ -9849,7 +9923,7 @@ sub check_clone {
 }
 
 sub construct_course {
-    my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context) = @_;
+    my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context,$cnum,$category) = @_;
     my $outcome;
     my $linefeed =  '<br />'."\n";
     if ($context eq 'auto') {
@@ -9887,7 +9961,8 @@ sub construct_course {
                                              $args->{'crscode'},
                                              $args->{'ccuname'}.':'.
                                              $args->{'ccdomain'},
-                                             $args->{'crstype'});
+                                             $args->{'crstype'},
+                                             $cnum,$context,$category);
 
     # Note: The testing routines depend on this being output; see 
     # Utils::Course. This needs to at least be output as a comment
@@ -10196,7 +10271,7 @@ sub group_term {
     my $crstype = &course_type();
     my %names = (
                   'Course' => 'group',
-                  'Group' => 'team',
+                  'Community' => 'group',
                 );
     return $names{$crstype};
 }
@@ -10389,7 +10464,7 @@ sub init_user_environment {
                 &Apache::lonnet::usertools_access($username,$domain,$tool,'reload');
         }
 
-        foreach my $crstype ('official','unofficial') {
+        foreach my $crstype ('official','unofficial','community') {
             $userenv{'canrequest.'.$crstype} =
                 &Apache::lonnet::usertools_access($username,$domain,$crstype,
                                                   'reload','requestcourses');