// Javascript from Moodle modules
/////////////////////////////////////////////////////////////////////////////
//                                                                         //
// NOTICE OF COPYRIGHT                                                     //
//                                                                         //
// Moodle - Filter for converting TeX notation to typeset mathematics      //
// using jsMath                                                            //
//                                                                         //
// Copyright (C) 2005 by Davide P. Cervone                                 //
// This program 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 2 of the License, or       //
// (at your option) any later version.                                     //
//                                                                         //
// This program 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:                            //
//                                                                         //
//          http://www.gnu.org/copyleft/gpl.html                           //
//                                                                         //
/////////////////////////////////////////////////////////////////////////////

/****************************************************************/
/*
 *  Configure the jsMath filter here.  See also the filter.php file.
 */

jsMath = {
  Moodle: {
    version: 1.1,               // version of this file
    processSlashParens: 1,      // process \(...\) in text?
    processSlashBrackets: 1,    // process \[...\] in text?
    processDoubleDollars: 1,    // process $$...$$ in text?
    processSingleDollars: 0,    // process $...$ in text?
    fixEscapedDolars: 0,        // convert \$ to $ outside of math mode?
    mimetexCompatible: 1,       // make jsMath handle mimetex better?
    doubleDollarsAreInLine: 0,  // make $$...$$ be in-line math?
    allowDoubleClicks: 1,       // show TeX source for double-clicks?
    allowDisableTag: 1,         // allow ID="tex2math_off" to disable tex2math?
    showFontWarnings: 0,        // show jsMath font warning messages?
    loadFiles: null,            // a single file name or [file,file,...]
    loadFonts: null,            // a single font name or [font,font,...]
    scale: 150,                 // the default scaling factor for jsMath
    filter: 'filter/jsmath'     // where the filter is found
  }
};

//  If you want to use your own custom delimiters for math instead
//  of the usual ones, then uncomment the following four lines and
//  insert your own delimiters within the quotes.  You may want to
//  turn off processing of the dollars and other delimiters above
//  as well, though you can use them in combination with the
//  custom delimiters if you wish.

//     jsMath.Moodle.customDelimiters = [
//        '[math]','[/math]',        // to begin and end in-line math
//        '[display]','[/display]'   // to begin and end display math
//     ];

//  [Note that the code below doesn't do any special quoting of the
//  strings, so you should not use single quotes or backslashes as
//  part of your strings, unless you know what you are doing.  See
//  the jsMath author's documentation for the tex2math plugin for
//  more caveats about using custom delimiters.]

/****************************************************************/
/****************************************************************/
//
//            DO NOT MAKE CHANGES BELOW THIS
//
/****************************************************************/
/****************************************************************/

jsMath.Autoload = {
  findMathElements: 1,
  findTeXstrings: 0,
  findLaTeXstrings: 0,
  findCustomStrings: jsMath.Moodle.customDelimiters,
  loadFiles: jsMath.Moodle.loadFiles,
  loadFonts: jsMath.Moodle.loadFonts
};

if (jsMath.Moodle.processSingleDollars ||
    jsMath.Moodle.processDoubleDollars ||
    jsMath.Moodle.processSlashParens ||
    jsMath.Moodle.processSlashBrackets ||
    jsMath.Moodle.fixEscapedDollars) {

  jsMath.Autoload.findCustomSettings = {
    processSingleDollars: jsMath.Moodle.processSingleDollars,
    processDoubleDollars: jsMath.Moodle.processDoubleDollars,
    processSlashParens:   jsMath.Moodle.processSlashParens,
    processSlashBrackets: jsMath.Moodle.processSlashBrackets,
    fixEscapedDollars:    jsMath.Moodle.fixEscapedDollars,
    custom: 0
  };
}

jsMath.Autoload.scripts = document.getElementsByTagName('script');
jsMath.Autoload.root = jsMath.Autoload.scripts[jsMath.Autoload.scripts.length-1].src;
jsMath.Autoload.root = jsMath.Autoload.root.replace('/lib/javascript-mod.php',
                                                    '/'+jsMath.Moodle.filter+'/jsMath/');
jsMath.Autoload.scripts = null;

jsMath.tex2math = {
  doubleDollarsAreInLine: jsMath.Moodle.doubleDollarsAreInLine,
  allowDisableTag:        jsMath.Moodle.allowDisableTag
}
if (jsMath.Moodle.mimetexCompatible) {
  if (!jsMath.Autoload.loadFiles) {jsMath.Autoload.loadFiles = []}
  jsMath.Autoload.loadFiles[jsMath.Autoload.loadFiles.length] = "plugins/mimeTeX.js";
}

jsMath.Controls = {cookie: {scale: jsMath.Moodle.scale}};
if (!jsMath.Moodle.allowDoubleClicks) {
  jsMath.Click = {CheckDblClick: function () {}};
}
if (!jsMath.Moodle.showFontWarnings) {
  jsMath.Font = {Message: function () {}};
}

window.onload = function () {
  jsMath.Autoload.Check();
  jsMath.Autoload.Run();
  jsMath.Process();
}

document.write('<script src="'+jsMath.Autoload.root+'plugins/autoload.js"></script>');
