//<![CDATA[
/**MathWorx Copyright (c) 2008 Shane Steinert-Threlkeld
Dual-licensed under the MIT and GNU GPL Licenses.
For more information, see LICENSE file */

/** @fileoverview  This file must be loaded in your HTML document <strong>before</strong> any other mathematical objects. 
Make sure to change the pathToHere variable, and either put the files you need in the autoLoad array, or include them individually. */

/**The value of zero to use in cases of roundoff error, etc. 
@type Number
@final */
var Zero = 1e-6;
/**The path to the directory containing all the files; can be a URL or a complete path 
@type String
@final */
var pathToHere = 'http://pikappa.ch/svg/';
/**The names of the files to automatically load whenever easyload.js is loaded (['Matrix'], i.e.) 
@type Array
@final */
var autoLoad = [];
/**The path to image icons.  See SceneButton.js to see and/or change file names.
@type String
@final */
var pathToButtons = 'http://pikappa.ch/svg/3D/buttons/';


/*************************************************************************************************

			DO NOT REMOVE OR CHANGE THE CODE BELOW HERE

*************************************************************************************************/

var includes = new Array();

/** Includes a file in an HTML document.  There MUST be a &lt;head&gt; tag in the HTML document as that is where the &lt;script&gt; tag will be added.
Will only include a file once so that it does not get loaded multiple times.
@param {String} file the URL or path of the file to be included */
function include(file) {
	if(includes.contains(file)) {
		return null;
	}
	var script = document.createElement("script");
	script.setAttribute("type","text/javascript");
	script.setAttribute("src",file);
	var head = document.getElementsByTagName("head")[0];
	head.insertBefore(script, head.firstChild);
	includes.push(file);
}

/** Includes all of the files in a supplied array (autoLoad for example).
@param {Array} dependsOn the array of filenames to be included (pathToHere/filename) */
function require(dependsOn) {
	for(i = 0; i < dependsOn.length; i++) {
		include(pathToHere + '' + dependsOn[i] + '.js');
	}
}

/**Adds a method to the Array prototype to test whether or not two Arrays (including nested arrays) are equal.  
Largely taken from open source: http://www.svendtofte.com/code/usefull_prototypes/prototypes.js
@param {Array} arr the array with which to check equality
@return {Boolean} true if two arrays are equal, false if not 
@addon */
Array.prototype.compareArray = function(arr) {
	if(this.length != arr.length) {
		return false;
	}
	for(var i = 0; i < this.length; i++) {
		if(this[i].compareArray) {
			if(!this[i].compareArray(arr[i])) {
				return false;
			} else {
				continue;
			}
		}
		//NOTE: only change to !-- if you are very sure
		if(this[i] != arr[i]) {
			return false;
		}
	}
	return true;
}

/**Adds a method to the Array prototype to check whether or not the array contains a given object.
@param {Object} obj the object to search for in the array
@return {Boolean} true if obj is in this array, false otherwise */
Array.prototype.contains = function(obj) {
	for(var i = 0; i < this.length; i++) {
		if(this[i] == obj) {
			return true;
		}
	}
	return false;
}


require(autoLoad);
// ]]>

