/**
* This library is part of egoditor cms 
* 
*
*/
//no jquery here
/**
 * Classes
 *  @author John Reisig
 */
(function(){var i=false,fnTest=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(e){var f=this.prototype;i=true;var g=new this();i=false;for(var h in e){g[h]=typeof e[h]=="function"&&typeof f[h]=="function"&&fnTest.test(e[h])?(function(c,d){return function(){var a=this._super;this._super=f[c];var b=d.apply(this,arguments);this._super=a;return b}})(h,e[h]):e[h]}function Class(){if(!i&&this.init)this.init.apply(this,arguments)}Class.prototype=g;Class.constructor=Class;Class.extend=arguments.callee;return Class}})();
/**
*Allow us to create name spaces
*/
function namespace(ns){var nsParts=ns.split(".");var root=window;for(var i=0;i<nsParts.length;i++){if(typeof root[nsParts[i]]=="undefined")root[nsParts[i]]=new Object();root=root[nsParts[i]]}}
/**
* Check if what is an array
* @return bool
*/
function isArray(what) {   return Object.prototype.toString.call(what) === '[object Array]'; }
/**
 * Check if an array contains a value
 * @company egoditor.com
 * @author Stephan Reich
 * 
 */
Array.prototype.contains=function(element){for(var i=0;i<this.length;i++){if(this[i]==element){return true}}return false};

/**
 * Check if the element is an array
 * @company egoditor.com
 * @author Stephan Reich
 * @return bool
 */
function isArray(what) {return Object.prototype.toString.call(what) === '[object Array]'; }
/**
 * 
 * @company egoditor.com
 * @author Stephan Reich
 * @return index:integer
 */
Array.prototype.findIndex = function(value){
		var ctr = "";
		for (var i=0; i < this.length; i++) {
			//use === to check for Matches. ie., identical (===), ;
			if (this[i] == value) {
				return i;
			}
		}
		return ctr;
	};
/**
* Create the settings namespace
*/
namespace("ego.settings");
ego.settings = function() {
	/**
	 * Hold the path to the current version of the backend 
	 * @access via getBackendPath,setBackendPath
	 */
	var backendPath = "/backend/1.0/";
	/**
	 * Hold variables
	 * @access via setVar,getVar
	 */
	var vars = {};
return {
    defaults:{
        datepicker:{
            getOptions:function()
            {
                return {"dateFormat":"dd-mm-yy"};
            },
            getDate:function()
            {
                var today = new Date();
                var month = today.getMonth()+1;
                var year = today.getYear();
                var day = today.getDate();
                if(day<10) day = "0" + day;
                if(month<10) month= "0" + month;
                if(year<1000) year+=1900;

                return day+"-"+month+"-"+year;
            }
        }

    },
	/**
	 * Set a global Variable
	 * @param varName:String 
	 * @param varValue:String,Array,Json
	 */
	setVar:function(varName,varValue)
	{
			vars[varName] = varValue;
	},
	/**
	 * Get a global Variable
	 * @param varName:String
	 * @return Mixed
	 */
	getVar:function(varName)
	{
		return vars[varName];
	},
	/**
	 * Receive the path to the backend
	 * @return string
	 */
	getBackendPath:function(){
		return backendPath;
	},
	/**
	 * Set the path to the backend
	 * @param path:String
	 */
	setBackendPath:function(path){
		backendPath = path;
	}

};
}();



