--- loncom/interface/londocs.pm	2009/01/28 18:10:04	1.329
+++ loncom/interface/londocs.pm	2009/02/10 14:23:18	1.339
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.329 2009/01/28 18:10:04 droeschl Exp $
+# $Id: londocs.pm,v 1.339 2009/02/10 14:23:18 ehlerst Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2764,7 +2764,7 @@ sub handler {
                 'sipr' => 'Simple Problem',
                 'drbx' => 'Drop Box',
                 'scuf' => 'Score Upload Form',
-                'bull' => 'Bulletin Board',
+                'bull' => 'Discussion Board',
                 'mypi' => 'My Personal Info',
                 'grpo' => 'Group Files',
                 'rost' => 'Course Roster',
@@ -2872,17 +2872,49 @@ ERFORM
            $containertag = '<input type="hidden" name="folderpath" value="" />';
            $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
        }
-       $r->print(&generate_admin_options($containertag,$uploadtag,\%lt,\%help,\%env));
-       $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
-		     &mt('Editing the Table of Contents for your '.$type)));
+	$r->print(<<HIDDENFORM);
+	<form name="renameform" method="post" action="/adm/coursedocs">
+   <input type="hidden" name="title" />
+   <input type="hidden" name="cmd" />
+   <input type="hidden" name="markcopy" />
+   <input type="hidden" name="copyfolder" />
+   $containertag
+ </form>
+ <form name="simpleedit" method="post" action="/adm/coursedocs">
+   <input type="hidden" name="importdetail" value="" />
+   $uploadtag
+ </form>
+HIDDENFORM
     }
+# --------------------------------------------------------- Main tab structure
+    my $activeClass = 1;
+    $r->print('<ul class="LC_TabContentBigger" id="mainnav">');
+    if (($standard) && ($allowed) && (!$forcesupplement)) {
+	my $active = '';
+        if($activeClass == 1){
+           $active = 'class="active"';
+	   $activeClass = 0;
+	}
+	$r->print('<li '.$active.'onclick="javascript:showPage(this,\'Main Course Documents\',\'mainnav\',\'maincoursedoc\');">'.&mt('Main Course Documents').'</li>');
+    }
+    if (!$forcestandard) {
+	my $active = '';
+        if($activeClass == 1){
+           $active = 'class="active"';
+        }
+	$r->print('<li '.$active.'onclick="javascript:showPage(this,\'Supplemental Course Documents\',\'mainnav\',\'maincoursedoc\');">'.&mt('Supplemental Course Documents').'</li>');
+    }
+    $r->print('<li onclick="javascript:showPage(this,\'Special Admin Options\',\'mainnav\',\'maincoursedoc\');">'.&mt('Special Admin Options').'</li>');
+    $r->print('</ul><div class="LC_ContentBoxSpecial" style="margin:0 0;padding:0 0;"><div id="maincoursedoc" style="margin:0 0;padding:0 0;">');
 # --------------------------------------------------------- Standard documents
-    $r->print('<table class="LC_docs_documents">');
-
     if (($standard) && ($allowed) && (!$forcesupplement)) {
-	$r->print('<tr><td class="LC_docs_document">');
-#  '<h2>'.&mt('Main Course Documents').
-#  ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
+       my $active = 'style="display: none;"';
+       if($activeClass == 0){
+          $active = 'style="display: block;"';
+       }
+       $r->print('<div class="LC_ContentBox" id="Main Course Documents" '.$active.'>');
+        $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
+                     &mt('Editing the Table of Contents for your '.$type)));
        my $folder=$env{'form.folder'};
        if ($folder eq '' || $folder eq 'supplemental') {
            $folder='default';
@@ -2897,11 +2929,6 @@ ERFORM
            #$postexec='self.close();';
        }
        $hadchanges=0;
-       my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
-			   $upload_output,$type);
-       if ($error) {
-	   $r->print('<p><span class="LC_error">'.$error.'</span></p>');
-       }
        if ($hadchanges) {
 	   &mark_hash_old();
        }
@@ -3036,46 +3063,9 @@ NASOFORM
 	</form>
 NROSTFORM
 
-       $r->print(<<ENDFORM);
-
-<ul class="LC_TabContent">
-<li>$lt{'nd'}</li>
-<li>$lt{'pm'}</li>
-<li>$lt{'pubd'}</li>
-<li>$lt{'sd'}</li>
-<li>$lt{'mo'}</li>
-<li>$lt{'hao'}</li>
-</ul>
-
-<table class="LC_docs_adddocs">
-<!-- <tr>
-<th>$lt{'uplm'}</th>
-<th>$lt{'impp'}</th>
-<th>$lt{'spec'}</th>
-</tr> -->
-<tr>
-<td>
-$fileuploadform
-</td>
-<td>
-$simpleeditdefaultform
-<hr />
-$recoverform
-ENDFORM
-       unless ($env{'form.pagepath'}) {
-	   $r->print(<<ENDFORM);
-<hr />
-$extresourcesform
-	<br />
-$imspform
-ENDFORM
-       }
-       $r->print('</td><td>');
        unless ($env{'form.pagepath'}) {
 	   my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
 
-
-
 	my $newpageform=(<<NPFORM);
 	<form action="/adm/coursedocs" method="post" name="newpage">
 	<input type="hidden" name="folderpath" value="$path" />
@@ -3125,51 +3115,58 @@ NSYLFORM
 NGFFORM
 
 
-           $r->print(<<ENDFORM);
-<br />
-$newfolderform
-<br />
-$newpageform
-<br />
-$newsylform
-<br />
-$newnavform
-<br />
-$newsmppageform
-<br />
-$newsmpproblemform
-<br />
-$newdropboxform
-<br />
-$newexuploadform
-<br />
-$newbulform
-<br />
-$newaboutmeform
-<br />
-$newaboutsomeoneform
-<br />
-$newgroupfileform
-<br />
-$newrosterform
-ENDFORM
+        my $specialdocumentsform=(<<SPDOFORM);
+	<br />$newfolderform
+	<br />$newpageform
+	<br />$newsylform
+	<br />$newnavform
+	<br />$newsmppageform
+	<br />$newsmpproblemform
+	<br />$newdropboxform
+	<br />$newexuploadform
+	<br />$newbulform
+	<br />$newaboutmeform
+	<br />$newaboutsomeoneform
+	<br />$newgroupfileform
+	<br />$newrosterform
+SPDOFORM
+
+
+my %orderhash = (
+                'aa' => 'New Document',
+                'bb' => 'Published Documents',
+                'cc' => 'Special Documents',
+		'dd' => 'More Options',
+                'zz' => 'Hide all Options',
+                );
+my %namehash = (
+                'New Document' => $fileuploadform,
+                'Published Documents' => $simpleeditdefaultform,
+                'Special Documents' => $specialdocumentsform,
+		'More Options' => $extresourcesform.'<br />'.$imspform.'<br />'.$recoverform,
+                );
+my $tid='1';
+my $content='content';
+my $navigation='navigation';
+my $varcd = 'Main Course Documents';
+$r->print(&generate_edit_table($tid,$content,$navigation,$varcd,\%namehash,\%orderhash)); 
+my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
+       if ($error) {
+           $r->print('<p><span class="LC_error">'.$error.'</span></p>');
        }
+$r->print('</div>');
+      }
        if ($env{'form.pagepath'}) {
-           $r->print(<<ENDBLOCK);
-$newsmpproblemform
-<br />
-$newexuploadform
-ENDBLOCK
        }
-       $r->print('</td></tr>'."\n".
-'</table>');
-       $r->print('</td></tr>');
     }
 # ----------------------------------------------------- Supplemental documents
     if (!$forcestandard) {
-       $r->print('<tr><td class="LC_docs_document">');
-# '<h2>'.&mt('Supplemental Course Documents').
-#  ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
+       my $active = 'style="display: none;"';
+       if($activeClass == 1){
+          $active = 'style="display: block;"';
+       }
+       $r->print('<div class="LC_ContentBox" id="Supplemental Course Documents" '.$active.'>');
+	&changewarning($r);
        my $folder=$env{'form.folder'};
        unless ($folder=~/^supplemental/) {
 	   $folder='supplemental';
@@ -3179,10 +3176,6 @@ ENDBLOCK
           $env{'form.folderpath'} = 'supplemental&'.
                                     &escape(&mt('Supplemental '.$type.' Documents'));
        }
-       my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
-       if ($error) {
-	   $r->print('<p><span class="LC_error">'.$error.'</span></p>');
-       }
        if ($allowed) {
 	   my $folderseq=
 	       '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
@@ -3261,30 +3254,36 @@ SNSFORM
 	</form>
 SNAMFORM
 
-	   $r->print(<<ENDSUPFORM);
-<ul class="LC_TabContent">
-<li>$lt{'nd'}</li>
-<li>$lt{'sd'}</li>
-<li>$lt{'hao'}</li>
-</ul>
-<table class="LC_docs_adddocs">
-<tr><td>
-$supupdocform
-</td>
-<td>
-$supnewfolderform
-<br />
-$supnewextform
-<br />
-$supnewsylform
-<br />
-$supnewaboutmeform
-</td></tr>
-</table></td></tr>
-ENDSUPFORM
+
+
+my %suporderhash = (
+                'ee' => 'New Document',
+                'ff' => 'Special Documents',
+                'zz' => 'Hide all Options',
+                );
+
+my %supnamehash = (
+                'New Document' => $supupdocform,
+                'Special Documents' => $supnewfolderform.'<br />'.$supnewextform.'<br />'.$supnewsylform.'<br />'.$supnewaboutmeform,
+                );
+
+my $tid='2';
+my $content='content';
+my $navigation='navigation';
+my $varscd = 'Supplemental Course Documents';
+
+$r->print(&generate_edit_table($tid,$content,$navigation,$varscd,\%supnamehash,\%suporderhash));
+my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
+       if ($error) {
+           $r->print('<p><span class="LC_error">'.$error.'</span></p>');
        }
-    }
-    $r->print('</table>');
+$r->print('</div>');
+	} 
+   }
+$r->print('<div class="LC_ContentBox" id="Special Admin Options" style="display: none;">');
+$r->print(&generate_admin_options($containertag,$uploadtag,\%help,\%env));
+$r->print('</div>');
+$r->print('</div>');
     if ($allowed) {
 	$r->print('
 <form method="post" name="extimport" action="/adm/coursedocs">
@@ -3309,24 +3308,18 @@ ENDSUPFORM
 } 
 
 sub generate_admin_options {
-  my ($containertag,$uploadtag,$lt_ref,$help_ref,$env_ref) = @_;
-  my %lt = %{$lt_ref};
+  my ($containertag,$uploadtag,$help_ref,$env_ref) = @_;
+ my %lt=&Apache::lonlocal::texthash(
+                                         'vc' => 'Verify Content',
+                                         'cv' => 'Check/Set Resource Versions',
+                                         'ls' => 'List Symbs',
+                                         'sl' => 'Show Log'
+                                          );
   my %help = %{$help_ref};
   my %env = %{$env_ref};
   my $dumpbut=&dumpbutton();
   my $exportbut=&exportbutton();
   return (<<ENDOPTIONFORM);
- <form name="renameform" method="post" action="/adm/coursedocs">
-   <input type="hidden" name="title" />
-   <input type="hidden" name="cmd" />
-   <input type="hidden" name="markcopy" />
-   <input type="hidden" name="copyfolder" />
-   $containertag
- </form>
- <form name="simpleedit" method="post" action="/adm/coursedocs">
-   <input type="hidden" name="importdetail" value="" />
-   $uploadtag
- </form>
  <form action="/adm/coursedocs" method="post" name="courseverify">
    <ul style="list-style-type:none">
        <li>
@@ -3350,29 +3343,36 @@ sub generate_admin_options {
         </li>
    </ul>
  </form>
- <div style="clear: both; height: 0px;">&nbsp;</div>
+<!-- <div style="clear: both; height: 0px;">&nbsp;</div>-->
 ENDOPTIONFORM
+
 }
 
+
 sub generate_edit_table {
-    my ($optionhash_ref,$namehash_ref,$orderhash_ref) = @_;
-    my %optionhash = %{$optionhash_ref};         #id verlinkt mit inhalt
+    my ($tid,$content,$navigation,$varcd,$namehash_ref,$orderhash_ref) = @_;
     my %namehash = %{$namehash_ref};             #name verlinkt mit id
     my %orderhash = %{$orderhash_ref};           #name mit kürzel verlinkt mit name
     my $form;
-    $form = '<div class="LC_ContentBoxSpecial"><h4 class="LC_hcell">'.&mt('Upload Course Documents').'<h4>';
-    $form .= '<ul class="LC_TabContent">';
+
+    
+
+    $form = '<div class="LC_ContentBoxSpecial"><h4 class="LC_hcell">'.&mt($varcd).'</h4>';
+    $form .= '<ul id="'.$navigation.$tid.'" class="LC_TabContent">';
     foreach my $name (sort(keys(%orderhash))){
-        if($name eq 'zz_hide'){
-            $form .= '<li><a onclick="hideAllSection();" href="#">'.&mt($orderhash{$name}).'</a></li>';
+        if($name eq 'zz'){
+            $form .= '<li onclick="javascript:hideAll(this, \''.$navigation.$tid.'\' ,\''.$content.$tid.'\');" class="active">'.&mt($orderhash{$name}).'</li>';
         }else{
-            $form .= '<li><a onclick="popUpSection(\''.$namehash{$orderhash{$name}}.'\');" href="#">'.&mt($orderhash{$name}).'</a></li>';
+            $form .= '<li onclick="javascript:showPage(this, \''.$tid.$orderhash{$name}.'\', \''.$navigation.$tid.'\',\''.$content.$tid.'\');">'.&mt($orderhash{$name}).'</li>';
         }
     }
-    foreach my $field (keys(%optionhash)){
-        $form .= '<div id="'.$field.'" class="LC_ContentBox LC_hideThis">'.$optionhash{$field}.'</div>';
-    }
-    $form .= '</div>';
+    $form .= '</ul>';
+    $form .= '<div id="'.$content.$tid.'" style="padding: 0 0; margin: 0 0;">';
+    foreach my $field (keys(%namehash)){
+        $form .= '<div id="'.$tid.$field.'" class="LC_ContentBox" style="display: none;">'.$namehash{$field}.'</div>';
+      }
+    $form .= '</div></div>';
+    
     return $form;
 }
 
@@ -3388,7 +3388,7 @@ sub editing_js {
                                           p_msp => 'Title for the Page',
                                           p_msb => 'Title for the Problem',
                                           p_mdb => 'Title for the Drop Box',
-                                          p_mbb => 'Title for the Bulletin Board',
+                                          p_mbb => 'Title for the Discussion Board',
                                           p_mab => "Enter user:domain for User's 'About Me' Page",
                                           p_mab2 => "About [_99]",
                                           p_mab_alrt1 => 'Not a valid user:domain',
@@ -3490,93 +3490,121 @@ function makeabout() {
 	   if ((comp[0]) && (comp[1])) {
 	       this.document.forms.newaboutsomeone.importdetail.value=
 		   '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
-	       this.document.forms.newaboutsomeone.submit();
-	   } else {
-               alert("$lt{'p_mab_alrt1'}");
-           }
-       } else {
-           alert("$lt{'p_mab_alrt2'}");
-       }
+       this.document.forms.newaboutsomeone.submit();
+   } else {
+       alert("$lt{'p_mab_alrt1'}");
    }
+} else {
+   alert("$lt{'p_mab_alrt2'}");
+}
+}
 }
 
 function makeims() {
-    var caller = document.forms.ims.folder.value;
-    var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
-    newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
-    newWindow.location.href = newlocation;
+var caller = document.forms.ims.folder.value;
+var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
+newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
+newWindow.location.href = newlocation;
 }
 
 
 function finishpick() {
-    var title=this.document.forms.extimport.title.value;
-    var url=this.document.forms.extimport.url.value;
-    var form=this.document.forms.extimport.useform.value;
-    var residx=this.document.forms.extimport.residx.value;
-    eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
+var title=this.document.forms.extimport.title.value;
+var url=this.document.forms.extimport.url.value;
+var form=this.document.forms.extimport.useform.value;
+var residx=this.document.forms.extimport.residx.value;
+eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
 }
 
 function changename(folderpath,index,oldtitle,container,pagesymb) {
-    var title=prompt('$lt{"p_chn"}',oldtitle);
-    if (title) {
-	this.document.forms.renameform.markcopy.value=-1;
-	this.document.forms.renameform.title.value=title;
-	this.document.forms.renameform.cmd.value='rename_'+index;
-        if (container == 'sequence') {
-	    this.document.forms.renameform.folderpath.value=folderpath;
-        }
-        if (container == 'page') {
-            this.document.forms.renameform.pagepath.value=folderpath;
-            this.document.forms.renameform.pagesymb.value=pagesymb;
-        }
-        this.document.forms.renameform.submit();
-    }
+var title=prompt('$lt{"p_chn"}',oldtitle);
+if (title) {
+this.document.forms.renameform.markcopy.value=-1;
+this.document.forms.renameform.title.value=title;
+this.document.forms.renameform.cmd.value='rename_'+index;
+if (container == 'sequence') {
+    this.document.forms.renameform.folderpath.value=folderpath;
+}
+if (container == 'page') {
+    this.document.forms.renameform.pagepath.value=folderpath;
+    this.document.forms.renameform.pagesymb.value=pagesymb;
+}
+this.document.forms.renameform.submit();
+}
 }
 
 function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
-    if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
-	this.document.forms.renameform.markcopy.value=-1;
-	this.document.forms.renameform.cmd.value='del_'+index;
-        if (container == 'sequence') {
-            this.document.forms.renameform.folderpath.value=folderpath;
-        }
-        if (container == 'page') {
-            this.document.forms.renameform.pagepath.value=folderpath;
-            this.document.forms.renameform.pagesymb.value=pagesymb;
-        }
-        this.document.forms.renameform.submit();
-    }
+if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
+this.document.forms.renameform.markcopy.value=-1;
+this.document.forms.renameform.cmd.value='del_'+index;
+if (container == 'sequence') {
+    this.document.forms.renameform.folderpath.value=folderpath;
+}
+if (container == 'page') {
+    this.document.forms.renameform.pagepath.value=folderpath;
+    this.document.forms.renameform.pagesymb.value=pagesymb;
+}
+this.document.forms.renameform.submit();
+}
 }
 
 function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
-    if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
-	this.document.forms.renameform.cmd.value='cut_'+index;
-	this.document.forms.renameform.markcopy.value=index;
-	this.document.forms.renameform.copyfolder.value=folder+'.'+container;
-        if (container == 'sequence') {
-            this.document.forms.renameform.folderpath.value=folderpath;
-        }
-        if (container == 'page') {
-            this.document.forms.renameform.pagepath.value=folderpath;
-            this.document.forms.renameform.pagesymb.value=pagesymb;
-        }
-        this.document.forms.renameform.submit();
-    }
+if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
+this.document.forms.renameform.cmd.value='cut_'+index;
+this.document.forms.renameform.markcopy.value=index;
+this.document.forms.renameform.copyfolder.value=folder+'.'+container;
+if (container == 'sequence') {
+    this.document.forms.renameform.folderpath.value=folderpath;
+}
+if (container == 'page') {
+    this.document.forms.renameform.pagepath.value=folderpath;
+    this.document.forms.renameform.pagesymb.value=pagesymb;
+}
+this.document.forms.renameform.submit();
+}
 }
 
 function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
-    this.document.forms.renameform.markcopy.value=index;
-    this.document.forms.renameform.copyfolder.value=folder+'.'+container;
-    if (container == 'sequence') {
-	this.document.forms.renameform.folderpath.value=folderpath;
-    }
-    if (container == 'page') {
-	this.document.forms.renameform.pagepath.value=folderpath;
-	this.document.forms.renameform.pagesymb.value=pagesymb;
-    }
-    this.document.forms.renameform.submit();
+this.document.forms.renameform.markcopy.value=index;
+this.document.forms.renameform.copyfolder.value=folder+'.'+container;
+if (container == 'sequence') {
+this.document.forms.renameform.folderpath.value=folderpath;
+}
+if (container == 'page') {
+this.document.forms.renameform.pagepath.value=folderpath;
+this.document.forms.renameform.pagesymb.value=pagesymb;
+}
+this.document.forms.renameform.submit();
+}
+
+function unselectInactive(nav) {
+currentNav = document.getElementById(nav);
+currentLis = currentNav.getElementsByTagName('LI');
+for (i = 0; i < currentLis.length; i++) {
+	currentLis[i].className = 'i';
+}
 }
 
+function hideAll(current, nav, data) {
+unselectInactive(nav);
+current.className = 'active';
+currentData = document.getElementById(data);
+currentDivs = currentData.getElementsByTagName('DIV');
+for (i = 0; i < currentDivs.length; i++) {
+	if(currentDivs[i].className == 'LC_ContentBox'){
+		currentDivs[i].style.display = 'none';
+	}
+}
+}
+
+function showPage(current, pageId, nav, data) {
+	hideAll(current, nav, data);
+	unselectInactive(nav);
+	current.className = 'active';
+	currentData = document.getElementById(pageId);
+	currentData.style.display = 'block';
+	return false;
+}
 
 ENDNEWSCRIPT
 }