Index: mod/scorm/datamodels/scorm_13lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/datamodels/scorm_13lib.php,v
retrieving revision 1.31
diff -u -r1.31 scorm_13lib.php
--- mod/scorm/datamodels/scorm_13lib.php	13 May 2010 23:01:38 -0000	1.31
+++ mod/scorm/datamodels/scorm_13lib.php	7 Jul 2010 04:04:58 -0000
@@ -10,7 +10,9 @@
     }
 
     $result = new stdClass();
-    $result->toc = "<ul id='s0' class='$liststyle'>\n";
+    $result->toc = '<div id="scorm_layout">';
+    $result->toc .= '<div id="scorm_toc">';
+    $result->toc .= '<div id="scorm_tree"><ul>';
     $tocmenus = array();
     $result->prerequisites = true;
     $incomplete = false;
@@ -20,7 +22,12 @@
     //
     if (!empty($currentorg)) {
         if (($organizationtitle = $DB->get_field('scorm_scoes', 'title', array('scorm'=>$scorm->id,'identifier'=>$currentorg))) != '') {
-            $result->toc .= "\t<li>$organizationtitle</li>\n";
+            if ($play) {
+            $result->toctitle = "$organizationtitle";
+            }
+            else {
+                $result->toc .= "\t<li>$organizationtitle</li>\n";
+            }
             $tocmenus[] = $organizationtitle;
         }
     }
@@ -78,7 +85,8 @@
                         if (isset($_COOKIE['hide:SCORMitem'.$sco->id])) {
                             $style = ' style="display: none;"';
                         }
-                        $result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
+                        //$result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
+                        $result->toc .= "\t\t><ul>\n";
                         $level++;
                     } else {
                         $result->toc .= $closelist;
@@ -103,10 +111,10 @@
                 if (isset($_COOKIE['hide:SCORMitem'.$nextsco->id])) {
                     $icon = 'plus';
                 }
-                $result->toc .= "\t\t".'<li><a href="javascript:expandCollide(\'img'.$sublist.'\',\'s'.$sublist.'\','.$nextsco->id.');">'.
-                                '<img id="img'.$sublist.'" src="'.$OUTPUT->pix_url($icon, 'scorm').'" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
+//                $result->toc .= "\t\t".'<li><a href="javascript:expandCollide(\'img'.$sublist.'\',\'s'.$sublist.'\','.$nextsco->id.');">'.
+//                                '<img id="img'.$sublist.'" src="'.$OUTPUT->pix_url($icon, 'scorm').'" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
             } else if ($isvisible) {
-                $result->toc .= "\t\t".'<li><img src="'.$OUTPUT->pix_url('spacer', 'scorm').'" alt="" />';
+//                $result->toc .= "\t\t".'<li><img src="'.$OUTPUT->pix_url('spacer', 'scorm').'" alt="" />';
             }
             if (empty($sco->title)) {
                 $sco->title = $sco->identifier;
@@ -174,13 +182,16 @@
                             $result->prerequisites = true;
                         }
                             $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
-                            $result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
+                            $thisscoidstr = '&scoid='.$sco->id;
+                            $link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr;
+                            //$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
+                            $result->toc .= '<li><a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>'."</li>\n";
                             $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
                     } else {
                         if ($sco->id == $scoid) {
                             $result->prerequisites = false;
                         }
-                        $result->toc .= '&nbsp;'.format_string($sco->title)."</li>\n";
+                        $result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
                     }
                 }
             } else {
@@ -206,7 +217,16 @@
             $result->incomplete = $incomplete;
         }
     }
-    $result->toc .= "\t</ul>\n";
+//    $result->toc .= "\t</ul>\n";
+
+
+    // NEW IMS TOC
+    $result->toc .= '</ul></div></div>';
+    $result->toc .= '</div>';
+    $result->toc .= '<div id="scorm_navpanel"></div>';
+
+
+
     if ($scorm->hidetoc == 0) {
         $PAGE->requires->data_for_js('scormdata', array(
                 'plusicon' => $OUTPUT->pix_url('plus', 'scorm'),
Index: mod/scorm/datamodels/aicclib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/datamodels/aicclib.php,v
retrieving revision 1.35
diff -u -r1.35 aicclib.php
--- mod/scorm/datamodels/aicclib.php	3 Jul 2010 13:37:24 -0000	1.35
+++ mod/scorm/datamodels/aicclib.php	7 Jul 2010 04:04:58 -0000
@@ -340,7 +340,10 @@
     }
 
     $result = new stdClass();
-    $result->toc = "<ul id='s0' class='$liststyle'>\n";
+    //$result->toc = "<ul id='s0' class='$liststyle'>\n";
+    $result->toc = '<div id="scorm_layout">';
+    $result->toc .= '<div id="scorm_toc">';
+    $result->toc .= '<div id="scorm_tree"><ul>';
     $tocmenus = array();
     $result->prerequisites = true;
     $incomplete = false;
@@ -350,7 +353,12 @@
     //
     if (!empty($currentorg)) {
         if (($organizationtitle = $DB->get_field('scorm_scoes','title', array('scorm'=>$scorm->id,'identifier'=>$currentorg))) != '') {
-            $result->toc .= "\t<li>$organizationtitle</li>\n";
+            if ($play) {
+                $result->toctitle = "$organizationtitle";
+            }
+            else {
+                $result->toc .= "\t<li>$organizationtitle</li>\n";
+            }
             $tocmenus[] = $organizationtitle;
         }
     }
@@ -411,7 +419,8 @@
                         if (isset($_COOKIE['hide:SCORMitem'.$sco->id])) {
                             $style = ' style="display: none;"';
                         }
-                        $result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
+                        //$result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
+                        $result->toc .= "\t\t<ul>\n";
                         $level++;
                     } else {
                         $result->toc .= $closelist;
@@ -438,9 +447,9 @@
                 if (isset($_COOKIE['hide:SCORMitem'.$nextsco->id])) {
                     $icon = 'plus';
                 }
-                $result->toc .= '<a href="javascript:expandCollide(\'img'.$sublist.'\',\'s'.$sublist.'\','.$nextsco->id.');"><img id="img'.$sublist.'" src="'.$OUTPUT->pix_url($icon, 'scorm').'" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
+                //$result->toc .= '<a href="javascript:expandCollide(\'img'.$sublist.'\',\'s'.$sublist.'\','.$nextsco->id.');"><img id="img'.$sublist.'" src="'.$OUTPUT->pix_url($icon, 'scorm').'" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
             } else if ($isvisible) {
-                $result->toc .= '<img src="'.$OUTPUT->pix_url('spacer', 'scorm').'" alt="" />';
+                //$result->toc .= '<img src="'.$OUTPUT->pix_url('spacer', 'scorm').'" alt="" />';
             }
             if (empty($sco->title)) {
                 $sco->title = $sco->identifier;
@@ -504,7 +513,10 @@
                             $result->prerequisites = true;
                         }
                         $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
-                        $result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
+                        $thisscoidstr = '&scoid='.$sco->id;
+                        $link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr;
+                        //$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
+                        $result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
                         $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
                     } else {
                         if ($sco->id == $scoid) {
@@ -536,7 +548,14 @@
             $result->incomplete = $incomplete;
         }
     }
-    $result->toc .= "\t</ul>\n";
+    //$result->toc .= "\t</ul>\n";
+
+    // NEW IMS TOC
+    $result->toc .= '</ul></div></div>';
+    $result->toc .= '</div>';
+    $result->toc .= '<div id="scorm_navpanel"></div>';
+
+
     if ($scorm->hidetoc == 0) {
         $result->toc .= html_writer::script(js_writer::set_variable('scormdata', array(
                 'plusicon' => $OUTPUT->pix_url('plus', 'scorm'),
Index: mod/scorm/datamodels/scorm_12lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/datamodels/scorm_12lib.php,v
retrieving revision 1.33
diff -u -r1.33 scorm_12lib.php
--- mod/scorm/datamodels/scorm_12lib.php	13 May 2010 23:01:38 -0000	1.33
+++ mod/scorm/datamodels/scorm_12lib.php	7 Jul 2010 04:04:58 -0000
@@ -116,7 +116,10 @@
     }
 
     $result = new stdClass();
-    $result->toc = "<ul id='s0' class='$liststyle'>\n";
+    //$result->toc = "<ul id='s0' class='$liststyle'>\n";
+    $result->toc = '<div id="scorm_layout">';
+    $result->toc .= '<div id="scorm_toc">';
+    $result->toc .= '<div id="scorm_tree"><ul>';
     $tocmenus = array();
     $result->prerequisites = true;
     $incomplete = false;
@@ -126,10 +129,16 @@
     //
     if (!empty($currentorg)) {
         if (($organizationtitle = $DB->get_field('scorm_scoes','title', array('scorm'=>$scorm->id,'identifier'=>$currentorg))) != '') {
-            $result->toc .= "\t<li>$organizationtitle</li>\n";
+            if ($play) {
+                $result->toctitle = "$organizationtitle";
+            }
+            else {
+                $result->toc .= "\t<li>$organizationtitle</li>\n";
+            }
             $tocmenus[] = $organizationtitle;
         }
     }
+
     //
     // If not specified retrieve the last attempt number
     //
@@ -185,7 +194,11 @@
                         if (isset($_COOKIE['hide:SCORMitem'.$sco->id])) {
                             $style = ' style="display: none;"';
                         }
-                        $result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
+                        //$result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
+                        $result->toc .= "\t\t<ul>\n";
+
+
+
                         $level++;
                     } else {
                         $result->toc .= $closelist;
@@ -212,9 +225,9 @@
                 if (isset($_COOKIE['hide:SCORMitem'.$nextsco->id])) {
                     $icon = 'plus';
                 }
-                $result->toc .= '<a href="javascript:expandCollide(\'img'.$sublist.'\',\'s'.$sublist.'\','.$nextsco->id.');"><img id="img'.$sublist.'" src="'.$OUTPUT->pix_url($icon, 'scorm').'" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
+                //$result->toc .= '<a href="javascript:expandCollide(\'img'.$sublist.'\',\'s'.$sublist.'\','.$nextsco->id.');"><img id="img'.$sublist.'" src="'.$OUTPUT->pix_url($icon, 'scorm').'" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
             } else if ($isvisible) {
-                $result->toc .= '<img src="'.$OUTPUT->pix_url('spacer', 'scorm').'" alt="" />';
+                //$result->toc .= '<img src="'.$OUTPUT->pix_url('spacer', 'scorm').'" alt="" />';
             }
             if (empty($sco->title)) {
                 $sco->title = $sco->identifier;
@@ -280,13 +293,18 @@
                             $result->prerequisites = true;
                         }
                         $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
-                        $result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
+                        $thisscoidstr = '&scoid='.$sco->id;
+                        $link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr;
+
+                        //$result->toc .= $statusicon.'&nbsp;'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."\n";
+                        //$result->toc .= $startbold.'<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>'.$endbold."\n";
+                        $result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
                         $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
                     } else {
                         if ($sco->id == $scoid) {
                             $result->prerequisites = false;
                         }
-                        $result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."</li>\n";
+                        $result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
                     }
                 }
             } else {
@@ -315,7 +333,17 @@
             $result->incomplete = $incomplete;
         }
     }
-    $result->toc .= "\t</ul>\n";
+    //$result->toc .= "\t</ul>\n";
+
+    // NEW IMS TOC
+    $result->toc .= '</ul></div></div>';
+    $result->toc .= '</div>';
+    $result->toc .= '<div id="scorm_navpanel"></div>';
+
+
+
+
+
     if ($scorm->hidetoc == 0) {
         $PAGE->requires->data_for_js('scormdata', array(
                 'plusicon' => $OUTPUT->pix_url('plus', 'scorm'),
Index: mod/scorm/styles.css
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/styles.css,v
retrieving revision 1.1
diff -u -r1.1 styles.css
--- mod/scorm/styles.css	25 Mar 2010 06:38:24 -0000	1.1
+++ mod/scorm/styles.css	7 Jul 2010 04:04:58 -0000
@@ -11,7 +11,7 @@
 #page-mod-scorm-player #scormbox {width: 74%;position: absolute;right: 0px;top: 0px;}
 #page-mod-scorm-player #scormpage {position: relative;width: 100%;}
 #page-mod-scorm-player #scormpage #toctree {position:relative;width:100%;overflow-x: auto;overflow-y: auto;}
-#page-mod-scorm-player #tocbox {position: relative;left: 0px;width: 24%;font-size: 0.8em;}
+#page-mod-scorm-player #tocbox {position: relative;left: 0px;width: 80%;font-size: 0.8em;}
 #page-mod-scorm-player #tochead {position: relative;text-align: center;top: 3px;height: 30px;}
 
 #page-mod-scorm-player .toc,
@@ -21,4 +21,7 @@
 #page-mod-scorm-player .structurelist ul {padding-left: 0.5em;margin-left: 0.5em;}
 
 #page-mod-scorm-view .structurelist  {list-style-type: none;white-space: nowrap;}
-#page-mod-scorm-view .structurelist  {list-style-type: none;white-space: nowrap;}
\ No newline at end of file
+#page-mod-scorm-view .structurelist  {list-style-type: none;white-space: nowrap;}
+
+#page-mod-scorm-player #altfinishlink {width: 80%;position: absolute;right: -10px;top: 10px; border: 0px; }
+#page-mod-scorm-player #altpopuplink  {width: 80%;right: 0px;top: 0px; border: 0px; }
Index: mod/scorm/rd.js
===================================================================
RCS file: mod/scorm/rd.js
diff -N mod/scorm/rd.js
--- mod/scorm/rd.js	25 Jun 2010 01:37:24 -0000	1.10
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,118 +0,0 @@
-<!--
-function attach_resize_event() {
-    YAHOO.util.Event.addListener(window, 'resize', scorm_resize);
-}
-
-var prev='';
-var next='';
-function scorm_set_prev(url) {
-    prev = url;
-}
-function scorm_set_next(url) {
-    next = url;
-}
-
-function scorm_get_element_style(obj, prop, cssProp) {
-    var ret = '';
-
-    if (obj.currentStyle) {
-        ret = obj.currentStyle[prop];
-    } else if (document.defaultView && document.defaultView.getComputedStyle) {
-        var compStyle = document.defaultView.getComputedStyle(obj, null);
-        ret = compStyle.getPropertyValue(cssProp);
-    }
-
-    if (ret == 'auto') ret = '0';
-    return ret;
-}
-
-function scorm_resize () {
-    var cwidth = scormplayerdata.cwidth;
-    var cheight = scormplayerdata.cheight;
-    var winwidth = 0, winheight = 0;
-    if( typeof( window.innerWidth ) == 'number' ) {
-        //Non-IE
-        winwidth = window.innerWidth;
-        winheight = window.innerHeight;
-    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
-        //IE 6+ in 'standards compliant mode'
-        winwidth = document.documentElement.clientWidth;
-        winheight = document.documentElement.clientHeight;
-    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
-        //IE 4 compatible
-        winwidth = document.body.clientWidth;
-        winheight = document.body.clientHeight;
-    }
-
-    var header = document.getElementById('header');
-    var content = document.getElementById('region-content');
-    var headerheight = 0;
-    if (content) {
-        headerheight = content.offsetTop;
-    }
-
-    var footer = document.getElementById('footer');
-    var imsnavbar = document.getElementById('tochead');
-    var scormtop = document.getElementById('scormtop');
-    var footerheight = 0;
-    var imsnavheight = 0;
-    var scormtopheight = 0;
-    if (footer) {
-        footerheight = footer.offsetHeight + parseInt(scorm_get_element_style(footer, 'marginTop', 'margin-top')) + parseInt(scorm_get_element_style(footer, 'marginBottom', 'margin-bottom'));
-    }
-    if (imsnavbar) {
-        imsnavheight = imsnavbar.offsetHeight;
-    }
-    if (scormtop) {
-        scormtopheight = scormtop.offsetHeight;
-    }
-
-    var topmargin = parseInt(scorm_get_element_style(document.getElementsByTagName('body')[0], 'marginTop', 'margin-top'));
-    var bottommargin = parseInt(scorm_get_element_style(document.getElementsByTagName('body')[0], 'marginBottom', 'margin-bottom'));
-
-    var totalheight = headerheight +
-                        footerheight +
-                        scormtopheight+
-                        topmargin +
-                        bottommargin+10; // +10 to save a minor vertical scroll always present!
-
-    var totalheighttoc = totalheight+imsnavheight;
-    // override total height with configured height if it is defined
-    if (cheight > 0) {
-      winheight = cheight;
-    }
-    var finalheighttoc = winheight - totalheighttoc;
-    if (finalheighttoc <= 0) {
-        finalheighttoc = winheight;
-    }
-    var finalheight = winheight - totalheight;
-    if (finalheight <= 0) {
-        finalheight = winheight;
-    }
-    var toctree = document.getElementById('toctree');
-    if (toctree != null){
-        var toctreeHeight = toctree.offsetHeight;
-        document.getElementById('toctree').style.height = finalheighttoc + 'px';
-        var scoframe2 = document.getElementById('scoframe1');
-        document.getElementById('scormobject').style.height = finalheight + 'px';
-    }else{
-        document.getElementById('scormobject').style.height = finalheight + 'px';
-        document.getElementById('scormpage').style.height = finalheight + 'px';
-    }
-
-    // resize the content container too to move the footer below the SCORM content
-    var contenti3 = document.getElementById('content-i3');
-    if (contenti3) {
-        contenti3.style.height = (winheight - totalheight + 30) + 'px';
-    } else {
-       document.getElementById('region-main-box').style.height = (finalheight + 30) + 'px';
-    }
-     // resize the content container too to move the footer below the SCORM content
-    var contenti3 = document.getElementById('content-i3');
-    if (contenti3) {
-        contenti3.style.height = (finalheight + 30) + 'px';
-    } else {
-        document.getElementById('region-main-box').style.height = (finalheight + 30) + 'px';
-    }
-}
--->
Index: mod/scorm/player.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/player.php,v
retrieving revision 1.77
diff -u -r1.77 player.php
--- mod/scorm/player.php	5 Jul 2010 00:40:13 -0000	1.77
+++ mod/scorm/player.php	7 Jul 2010 04:04:58 -0000
@@ -156,132 +156,29 @@
     $PAGE->requires->js('/mod/scorm/request.js', true);
     $PAGE->requires->js('/lib/cookies.js', true);
     $PAGE->requires->js('/mod/scorm/loaddatamodel.php?id='.$cm->id.$scoidstr.$modestr.$attemptstr, true);
-    $PAGE->requires->js('/mod/scorm/rd.js', true);
+    $PAGE->requires->css('/mod/scorm/styles.css');
 
     echo $OUTPUT->header();
 
-    $PAGE->requires->js_function_call('attach_resize_event');
-    if (($sco->previd != 0) && ((!isset($sco->previous)) || ($sco->previous == 0))) {
-        $scostr = '&scoid='.$sco->previd;
-        $PAGE->requires->js_function_call('scorm_set_prev', Array($CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr));
-    } else {
-        $PAGE->requires->js_function_call('scorm_set_prev', Array($CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id));
-    }
-    if (($sco->nextid != 0) && ((!isset($sco->next)) || ($sco->next == 0))) {
-        $scostr = '&scoid='.$sco->nextid;
-        $PAGE->requires->js_function_call('scorm_set_next', Array($CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr));
-    } else {
-        $PAGE->requires->js_function_call('scorm_set_next', Array($CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id));
-    }
+    // NEW IMS TOC
+    $PAGE->requires->string_for_js('navigation', 'scorm');
+    $PAGE->requires->string_for_js('toc', 'scorm');
+    $PAGE->requires->string_for_js('hide', 'moodle');
+    $PAGE->requires->string_for_js('show', 'moodle');
+
+    $name = false;
+
 ?>
     <div id="scormpage">
-<?php
-    if ($scorm->hidetoc == 0) {
-?>
         <div id="tocbox">
-<?php
-        if ($scorm->hidenav ==0){
-?>
-            <!-- Bottons nav at left-->
-            <div id="tochead">
-                <form name="tochead" method="post" action="player.php?id=<?php echo $cm->id ?>" target="_top">
-<?php
-            $orgstr = '&amp;currentorg='.$currentorg;
-            if (($scorm->hidenav == 0) && ($sco->previd != 0) && (!isset($sco->previous) || $sco->previous == 0)) {
-                // Print the prev LO button
-                $scostr = '&amp;scoid='.$sco->previd;
-                $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;
-?>
-                    <input name="prev" type="button" value="<?php print_string('prev','scorm') ?>" onClick="document.location.href=' <?php echo $url; ?> '"/>
-<?php
-            }
-            if (($scorm->hidenav == 0) && ($sco->nextid != 0) && (!isset($sco->next) || $sco->next == 0)) {
-                // Print the next LO button
-                $scostr = '&amp;scoid='.$sco->nextid;
-                $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;
-?>
-                    <input name="next" type="button" value="<?php print_string('next','scorm') ?>" onClick="document.location.href=' <?php echo $url; ?> '"/>
-<?php
-            }
-?>
-                </form>
-            </div> <!-- tochead -->
-<?php
-        }
-?>
             <div id="toctree" class="generalbox">
             <?php echo $result->toc; ?>
             </div> <!-- toctree -->
         </div> <!--  tocbox -->
-<?php
-        $class = ' class="toc"';
-    } else {
-        $class = ' class="no-toc"';
-    }
-?>
-        <div id="scormbox"<?php echo $class; if(($scorm->hidetoc == 2) || ($scorm->hidetoc == 1)){echo 'style="width:100%"';}?>>
-<?php
-    // This very big test check if is necessary the "scormtop" div
-    if (
-           ($mode != 'normal') ||  // We are not in normal mode so review or browse text will displayed
-           (
-               ($scorm->hidenav == 0) &&  // Teacher want to display navigation links
-               ($scorm->hidetoc != 0) &&  // The buttons has not been displayed
-               (
-                   (
-                       ($sco->previd != 0) &&  // This is not the first learning object of the package
-                       ((!isset($sco->previous)) || ($sco->previous == 0))   // Moodle must manage the previous link
-                   ) ||
-                   (
-                       ($sco->nextid != 0) &&  // This is not the last learning object of the package
-                       ((!isset($sco->next)) || ($sco->next == 0))       // Moodle must manage the next link
-                   )
-               )
-           ) || ($scorm->hidetoc == 2)      // Teacher want to display toc in a small dropdown menu
-       ) {
-?>
-            <div id="scormtop">
+        <div id="scormtop">
         <?php echo $mode == 'browse' ? '<div id="scormmode" class="scorm-left">'.get_string('browsemode','scorm')."</div>\n" : ''; ?>
         <?php echo $mode == 'review' ? '<div id="scormmode" class="scorm-left">'.get_string('reviewmode','scorm')."</div>\n" : ''; ?>
-<?php
-        if (($scorm->hidenav == 0) || ($scorm->hidetoc == 2) || ($scorm->hidetoc == 1)) {
-?>
-                <div id="scormnav" class="scorm-right">
-        <?php
-            $orgstr = '&amp;currentorg='.$currentorg;
-            if (($scorm->hidenav == 0) && ($sco->previd != 0) && (!isset($sco->previous) || $sco->previous == 0) && (($scorm->hidetoc == 2) || ($scorm->hidetoc == 1)) ) {
-                // Print the prev LO button
-                $scostr = '&amp;scoid='.$sco->previd;
-                $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;
-?>
-                    <form name="scormnavprev" method="post" action="player.php?id=<?php echo $cm->id ?>" target="_top" style= "display:inline">
-                        <input name="prev" type="button" value="<?php print_string('prev','scorm') ?>" onClick="document.location.href=' <?php echo $url; ?> '"/>
-                    </form>
-<?php
-            }
-            if ($scorm->hidetoc == 2) {
-                echo $result->tocmenu;
-            }
-            if (($scorm->hidenav == 0) && ($sco->nextid != 0) && (!isset($sco->next) || $sco->next == 0) && (($scorm->hidetoc == 2) || ($scorm->hidetoc == 1))) {
-                // Print the next LO button
-                $scostr = '&amp;scoid='.$sco->nextid;
-                $url = $CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modestr.$scostr;
-?>
-                    <form name="scormnavnext" method="post" action="player.php?id=<?php echo $cm->id ?>" target="_top" style= "display:inline">
-                        <input name="next" type="button" value="<?php print_string('next','scorm') ?>" onClick="document.location.href=' <?php echo $url; ?> '"/>
-                    </form>
-<?php
-            }
-        ?>
-                </div>
-<?php
-        }
-?>
-            </div> <!-- Scormtop -->
-<?php
-    } // The end of the very big test
-?>
-            <div id="scormobject" class="scorm-right">
+        </div> <!-- Scormtop -->
                 <noscript>
                     <div id="noscript">
                         <?php print_string('noscriptnoscorm','scorm'); // No Martin(i), No Party ;-) ?>
@@ -291,16 +188,6 @@
 <?php
     if ($result->prerequisites) {
         if ($scorm->popup == 0) {
-            $fullurl="loadSCO.php?id=".$cm->id.$scoidstr.$modestr;
-            ?>
-            <!--[if IE]>
-                <iframe id="scoframe1" class="scoframe" name="scoframe1" src="<?php echo $fullurl; ?>"></iframe>
-            <![endif]-->
-            <![if !IE]>
-                <object id="scoframe1" class="scoframe" type="text/html" data="<?php echo $fullurl; ?>"></object>
-            <![endif]>
-
-<?php
             if (scorm_debugging($scorm)) {
 ?>
                 <script>
@@ -319,7 +206,6 @@
                 </script>
 <?php
             }
-            $PAGE->requires->js_function_call('scorm_resize');
         } else {
             // Clean the name for the window as IE is fussy
             $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
@@ -328,7 +214,6 @@
             }
             $name = 'scorm_'.$name;
 
-            echo html_writer::script(js_writer::function_call('scorm_resize'));
             echo html_writer::script('', $CFG->wwwroot.'/mod/scorm/player.js');
             echo html_writer::script(js_writer::function_call('scorm_openpopup', Array("loadSCO.php?id=".$cm->id.$scoidpop, $name, $scorm->options, $scorm->width, $scorm->height)));
             ?>
@@ -351,10 +236,16 @@
         echo $OUTPUT->box(get_string('noprerequisites','scorm'));
     }
 ?>
-            </div> <!-- SCORM object -->
-        </div> <!-- SCORM box  -->
     </div> <!-- SCORM page -->
 <?php 
+// NEW IMS TOC
+if (!isset($result->toctitle)) {
+    $result->toctitle = get_string('toc', 'scorm');
+}
+
+$PAGE->requires->js_init_call('M.mod_scorm.init', array($scorm->hidenav, $scorm->hidetoc, $result->toctitle, $name, $scorm->options, $scorm->width, $scorm->height));
+
+
 $completion=new completion_info($course);
 $completion->set_module_viewed($cm);
 
Index: mod/scorm/lang/en/scorm.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/lang/en/scorm.php,v
retrieving revision 1.20
diff -u -r1.20 scorm.php
--- mod/scorm/lang/en/scorm.php	5 Jul 2010 05:12:41 -0000	1.20
+++ mod/scorm/lang/en/scorm.php	7 Jul 2010 04:04:58 -0000
@@ -22,6 +22,8 @@
  * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
+$string['toc'] = 'TOC';
+$string['navigation'] = 'Navigation';
 
 $string['activation'] = 'Activation';
 $string['activityloading'] = 'You will be automatically redirected to the activity in';
Index: mod/scorm/module.js
===================================================================
RCS file: mod/scorm/module.js
diff -N mod/scorm/module.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ mod/scorm/module.js	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,321 @@
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Javascript helper function for IMS Content Package module.
+ *
+ * @package   mod-scorm
+ * @copyright 2009 Petr Skoda (http://skodak.org)
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+M.mod_scorm = {};
+
+M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, window_options, window_width, window_height) {
+
+    var popup_winHandle = false;
+
+
+    if (hide_nav == 0) {
+        scorm_hide_nav = false;
+    }
+    else {
+        scorm_hide_nav = true;
+    }
+    if (hide_toc == 0) {
+        scorm_hide_toc = false;
+    }
+    else {
+        scorm_hide_toc = true;
+    }
+
+    var scorm_layout_widget;
+    var scorm_current_node;
+    var scorm_buttons = [];
+    var scorm_bloody_labelclick = false;
+    var scorm_panel;
+
+    Y.use('yui2-resize', 'yui2-dragdrop', 'yui2-container', 'yui2-button', 'yui2-layout', 'yui2-treeview', 'yui2-json', 'yui2-event', function(Y) {
+
+        var scorm_activate_item = function(node) {
+            if (!node) {
+                return;
+            }
+            scorm_current_node = node;
+            scorm_current_node.highlight();
+
+            // make the popup work
+            if (window_name) {
+                popup_winHandle = window.open('', window_name, window_options, window_width, window_height);
+                popup_winHandle.location.href =  node.title;
+            }
+            else {
+                var content = new YAHOO.util.Element('scorm_content');
+                try {
+                    // first try IE way - it can not set name attribute later
+                    // and also it has some restrictions on DOM access from object tag
+                    var obj = document.createElement('<iframe id="scorm_object" src="'+node.title+'">');
+                } catch (e) {
+                    var obj = document.createElement('object');
+                    obj.setAttribute('id', 'scorm_object');
+                    obj.setAttribute('type', 'text/html');
+                    obj.setAttribute('data', node.title);
+                }
+                var old = YAHOO.util.Dom.get('scorm_object');
+                if (old) {
+                    content.replaceChild(obj, old);
+                } else {
+                    content.appendChild(obj);
+                }
+            }
+            scorm_resize_frame();
+
+            scorm_current_node.focus();
+            if (scorm_hide_nav == false) {
+                scorm_fixnav();
+            }
+        };
+
+        /**
+         * Enables/disables navigation buttons as needed.
+         * @return void
+         */
+        var scorm_fixnav = function() {
+            scorm_buttons[0].set('disabled', (scorm_skipprev(scorm_current_node) == null));
+            scorm_buttons[1].set('disabled', (scorm_prev(scorm_current_node) == null));
+            scorm_buttons[2].set('disabled', (scorm_up(scorm_current_node) == null));
+            scorm_buttons[3].set('disabled', (scorm_next(scorm_current_node) == null));
+            scorm_buttons[4].set('disabled', (scorm_skipnext(scorm_current_node) == null));
+        };
+
+
+        var scorm_resize_layout = function(alsowidth) {
+            if (window_name) {
+                scorm_layout_widget.setStyle('width', '260px');
+                scorm_layout_widget.render();
+                return;
+            }
+
+            if (alsowidth) {
+                var layout = YAHOO.util.Dom.get('scorm_layout');
+                layout.style.width = '600px';
+                var newwidth = scorm_get_htmlelement_size('content', 'width');
+                if (newwidth > 600) {
+                    layout.style.width = newwidth+'px';
+                }
+            }
+            var pageheight = scorm_get_htmlelement_size('page', 'height');
+            var layoutheight = scorm_get_htmlelement_size(scorm_layout_widget, 'height');
+            var newheight = layoutheight + parseInt(YAHOO.util.Dom.getViewportHeight()) - pageheight - 20;
+            if (newheight > 400) {
+                if (newheight > 768) {
+                    scorm_layout_widget.setStyle('height', '768px');
+                }
+                else {
+                    scorm_layout_widget.setStyle('height', newheight+'px');
+                }
+            }
+            scorm_layout_widget.render();
+            scorm_resize_frame();
+
+            scorm_panel.align('bl', 'bl');
+        };
+
+        var scorm_get_htmlelement_size = function(el, prop) {
+            var val = YAHOO.util.Dom.getStyle(el, prop);
+            if (val == 'auto') {
+                if (el.get) {
+                    el = el.get('element'); // get real HTMLElement from YUI element
+                }
+                val = YAHOO.util.Dom.getComputedStyle(YAHOO.util.Dom.get(el), prop);
+            }
+            return parseInt(val);
+        };
+
+        var scorm_resize_frame = function() {
+            var obj = YAHOO.util.Dom.get('scorm_object');
+            if (obj) {
+                var content = scorm_layout_widget.getUnitByPosition('center').get('wrap');
+                obj.style.width = (content.offsetWidth - 6)+'px';
+                obj.style.height = (content.offsetHeight - 10)+'px';
+            }
+        };
+
+
+        var scorm_up = function(node) {
+            if (node.depth > 0) {
+                return node.parent;
+            }
+            return null;
+        };
+
+        var scorm_lastchild = function(node) {
+            if (node.children.length) {
+                return scorm_lastchild(node.children[node.children.length-1]);
+            } else {
+                return node;
+            }
+        };
+
+        var scorm_prev = function(node) {
+            if (node.previousSibling && node.previousSibling.children.length) {
+                return scorm_lastchild(node.previousSibling);
+            }
+            return scorm_skipprev(node);
+        };
+
+        var scorm_skipprev = function(node) {
+            if (node.previousSibling) {
+                return node.previousSibling;
+            } else if (node.depth > 0) {
+                return node.parent;
+            }
+            return null;
+        };
+
+        var scorm_next = function(node) {
+            if (node.children.length) {
+                return node.children[0];
+            }
+            return scorm_skipnext(node);
+        };
+
+        var scorm_skipnext = function(node) {
+            if (node.nextSibling) {
+                return node.nextSibling;
+            } else if (node.depth > 0) {
+                return scorm_skipnext(node.parent);
+            }
+            return null;
+        };
+
+
+        // layout
+        YAHOO.widget.LayoutUnit.prototype.STR_COLLAPSE = M.str.moodle.hide;
+        YAHOO.widget.LayoutUnit.prototype.STR_EXPAND = M.str.moodle.show;
+
+/*
+        scorm_layout_widget = new YAHOO.widget.Layout('scorm_layout', {
+            minWidth: 600,
+            minHeight: 400,
+            units: [
+                { position: 'left', body: 'scorm_toc', header: M.str.scorm.toc, width: 250, resize: true, gutter: '2px 5px 5px 2px', collapse: true, minWidth:150},
+                { position: 'center', body: '<div id="scorm_content"></div>', gutter: '2px 5px 5px 2px', scroll: true}
+            ]
+        });
+        */
+        scorm_layout_widget = new YAHOO.widget.Layout('scorm_layout', {
+            minWidth: 250,
+            minHeight: 400,
+            units: [
+                { position: 'left', body: 'scorm_toc', header: toc_title, width: 250, resize: true, gutter: '2px 5px 5px 2px', collapse: true, minWidth:150},
+                { position: 'center', body: '<div id="scorm_content"></div>', gutter: '2px 5px 5px 2px', scroll: true}
+            ]
+        });
+        scorm_layout_widget.render();
+        var left = scorm_layout_widget.getUnitByPosition('left');
+        left.on('collapse', function() {
+            scorm_resize_frame();
+        });
+        left.on('expand', function() {
+            scorm_resize_frame();
+        });
+
+        // ugly resizing hack that works around problems with resizing of iframes and objects
+        left._resize.on('startResize', function() {
+            var obj = YAHOO.util.Dom.get('scorm_object');
+            obj.style.display = 'none';
+        });
+        left._resize.on('endResize', function() {
+            var obj = YAHOO.util.Dom.get('scorm_object');
+            obj.style.display = 'block';
+            scorm_resize_frame();
+        });
+
+        // hide the TOC if that is the default
+        if (scorm_hide_toc == true) {
+            left.collapse();
+        }
+
+        // TOC tree
+        var tree = new YAHOO.widget.TreeView('scorm_tree');
+        tree.singleNodeHighlight = true;
+        tree.subscribe('labelClick', function(node) {
+            scorm_activate_item(node);
+            if (node.children.length) {
+                scorm_bloody_labelclick = true;
+            }
+        });
+        tree.subscribe('collapse', function(node) {
+            if (scorm_bloody_labelclick) {
+                scorm_bloody_labelclick = false;
+                return false;
+            }
+        });
+        tree.subscribe('expand', function(node) {
+            if (scorm_bloody_labelclick) {
+                scorm_bloody_labelclick = false;
+                return false;
+            }
+        });
+        tree.expandAll();
+        tree.render();
+
+        // navigation
+        if (scorm_hide_nav == false) {
+            //scorm_panel = new YAHOO.widget.Panel('scorm_navpanel', { visible:true, draggable:true, close:false,
+            //                                                       context: ['page', 'bl', 'bl', ["windowScroll", "textResize", "windowResize"]], constraintoviewport:true} );
+            scorm_panel = new YAHOO.widget.Panel('scorm_navpanel', { visible:true, draggable:true, close:false, xy: [250, 450],
+                                                                    autofillheight: "body"} );
+            scorm_panel.setHeader(M.str.scorm.navigation);
+    
+            //TODO: make some better&accessible buttons
+            scorm_panel.setBody('<span id="scorm_nav"><button id="nav_skipprev">&lt;&lt;</button><button id="nav_prev">&lt;</button><button id="nav_up">^</button><button id="nav_next">&gt;</button><button id="nav_skipnext">&gt;&gt;</button></span>');
+            scorm_panel.render();
+            scorm_buttons[0] = new YAHOO.widget.Button('nav_skipprev');
+            scorm_buttons[1] = new YAHOO.widget.Button('nav_prev');
+            scorm_buttons[2] = new YAHOO.widget.Button('nav_up');
+            scorm_buttons[3] = new YAHOO.widget.Button('nav_next');
+            scorm_buttons[4] = new YAHOO.widget.Button('nav_skipnext');
+            scorm_buttons[0].on('click', function(ev) {
+                scorm_activate_item(scorm_skipprev(scorm_current_node));
+            });
+            scorm_buttons[1].on('click', function(ev) {
+                scorm_activate_item(scorm_prev(scorm_current_node));
+            });
+            scorm_buttons[2].on('click', function(ev) {
+                scorm_activate_item(scorm_up(scorm_current_node));
+            });
+            scorm_buttons[3].on('click', function(ev) {
+                scorm_activate_item(scorm_next(scorm_current_node));
+            });
+            scorm_buttons[4].on('click', function(ev) {
+                scorm_activate_item(scorm_skipnext(scorm_current_node));
+            });
+            scorm_panel.render();
+        }
+
+        // finally activate the first item
+        scorm_activate_item(tree.getRoot().children[0]);
+
+        // resizing
+        scorm_resize_layout(false);
+
+        // fix layout if window resized
+        window.onresize = function() {
+            scorm_resize_layout(true);
+        };
+    });
+};
