/*
  This is the 'root' javascript file for the Havel site, which loads almost all the javascript necessary
  See below for what each does.
  Other javascript files that may need inclusion (after this one):
  * js/editor.js  -- for the Notebook Editor context only
  * js/tiny_mce_init.js -- will only be included inline in the editor.html page
  * js/slides.js -- only for image galleries
  * js/video.js' -- for video window; Havel's implemented use of media.js 

  Some confluent terms in this project:
    notebook == outline
    asset == videoclip (or possibly picture, link, gallery, glossary term, etc)
    timeline == videoclip
  More terms:
    media_panels: a meaningless red herring that's simply the 'magic' directory name that we assume exists in havel_path and that contains /materials, /video_window, /js, etc.
    MediaClip     (see js/media_controller/media.js)
    MediaSequence (see js/media_controller/media.js)
    playlist      (see js/media_controller/media.js)
*/

var my_basepath = document.location.toString().match(/.*\//)[0]; 
var havel_path = my_basepath.match(/.*(?=\/media_panels\/)/);
if (!havel_path) {
    x = my_basepath.match(/.*\/havel(?=\/)/);
    havel_path = (x) ? x.toString() : my_basepath.split('/').slice(0,3).join('/');
}
else {
    havel_path = havel_path.toString();
}

var havel_secure = 'https://www1.columbia.edu/sec/ccnmtl/projects/havel';
var thumbnail_path = 'http://havel.columbia.edu/pics/thumbnails/';

//forces login and redirects to destination= parameter
var login_url = 'https://www1.columbia.edu/sec-cgi-bin/ccnmtl/access/havel/login.php'; 
//sets a cookie for whether we're logged in or not (semi deprecated)
var local_login_url = havel_path+'/media_panels/auth/login.html';
//deletes aforementioned cookie AND forwards to Pamacea logout
var local_logout_url = havel_path+'/media_panels/auth/logout.html';
//used to include json call of loadNotebook([json notebook data]) e.g. ?author=gm2127
var public_notebook_url = 'http://ccnmtl.columbia.edu/cgi-bin/ccnmtl/havel/notebook.php'; //insecure
var edit_notebook_url = 'https://www1.columbia.edu/sec-cgi-bin/ccnmtl/projects/havel/notebook.php';

//temporary (re)definition but also defined in MochiPlus.js
function require_js(arr) { var x;while(x=arr.shift()) { 
    document.write('<script type="text/javascript" src="'+x+'"></script>');
}}
var mp = havel_path + '/media_panels/';
require_js([mp+'js/MochiKit/Base.js' /* Our favorite JS library */
	    ,mp+'js/MochiKit/Iter.js' /* Our favorite JS library */
	    ,mp+'js/MochiKit/Logging.js' /* Our favorite JS library */
	    ,mp+'js/MochiKit/LoggingPane.js' /* Our favorite JS library */
	    ,mp+'js/MochiKit/Async.js' /* Our favorite JS library */
	    ,mp+'js/MochiKit/DOM.js' /* Our favorite JS library */
	    ,mp+'js/MochiKit/Style.js' /* Our favorite JS library */
	    ,mp+'js/MochiKit/Color.js' /* Our favorite JS library */
	    ,mp+'js/MochiKit/Position.js' /* Our favorite JS library */
	    ,mp+'js/MochiKit/Signal.js' /* Our favorite JS library */
	    ,mp+'js/MochiKit/Visual.js' /* Our favorite JS library */
	    ,mp+'js/MochiPlus.js' /* What MochiKit should (and someday might) include */
	    ,mp+'auth/logged_in.js' /* takes care of local authentication management. sets $logged_in and $restricted_domain */
	    /*sets logged_in on whether the person is logged in or not */
	    ,'https://www1.columbia.edu/sec-cgi-bin/ccnmtl/access/logged_in.php' 
	    /*sets restricted_domain whether they're in columbia.edu domain */
	    ,'https://www1.columbia.edu/sec/ccnmtl/access/cudomain/restricted/'
	    ,mp+'js/media_controller/media.js' /* the media controller which handles flash/qt, clips/markers/timecodes, etc */
	    ,mp+'js/notebook.js' /* notebook functions for saving, loading notebooks from personal notebooks to featured notebooks*/
	    ,mp+'js/shared_notebooks.js' /* havel courses supported by keywords */
]);
