Date.fromISOString = (function(){
    var tzoffset = (new Date()).getTimezoneOffset();
    function fastDateParse(y, m, d, h, i, s, ms){ // this -> tz
        return new Date(y, m - 1, d, h || 0, +(i || 0) - this, s || 0, ms || 0);
    }

    // result function
    return function(isoDateString){
        var tz = isoDateString.substr(10).match(/([\-\+])(\d{1,2}):?(\d{1,2})?/) || 0;
        if (tz)
            tz = tzoffset + (tz[1] == '-' ? -1 : 1) * (tz[3] !== null ? +tz[2] * 60 + (+tz[3]) : +tz[2]);
        return fastDateParse.apply(tz || 0, isoDateString.split(/\D/));
    };
})();

project = {};

project.site_elements = {};

project.addSiteElement = function(key, object)
{
    project.site_elements[key] = object;
};

project.environment = 'production';

project.initLoggedInUser = function(user_data) {
    project.user = {};
    project.user.id = user_data.id;
    project.user.user_name = user_data.user_name;
};

project.getBaseUrl = function() {
    return document.getElement('base').get('href');
};

project.navigateTo = function(url, options) {
    options = options || {};

    if (!options.is_absolute)
    {
        //url = document.getElement('base').get('href') + 'index.php/' + url;
        url = document.getElement('base').get('href') + url;
    }

    document.location = url;
};

/*
 * If no console is defined, let's replace the console with empty functions! 
 */
if (typeof(console) === "undefined")
{
    console = {}
    console.log = $empty;
    console.error = $empty;
    console.info = $empty;
    console.debug = $empty;
}

var logWithPrefix = function(prefix, log_type, args)
{
    var need_to_log = true;
    var i = 0;
    
    var logging_exclude_length = Logging.exclude.length;
    for (i = 0; i < logging_exclude_length; i++)
    {
        if (prefix.match(Logging.exclude[i])) need_to_log = false;
    } 

    if (need_to_log) {
        console[log_type]("[" + prefix + "]", args);
    } 
};

Logging = new Class(/**@lends Logging.prototype */{
    Implements: [],
    
    log_prefix: 'CONFIGURE this.log_prefix IN YOURCLASS',
    
    log: function() {
        logWithPrefix(this.log_prefix, 'log', arguments);
    },

    error: function() {
        logWithPrefix(this.log_prefix, 'error', arguments);
    },
    
    info: function() {
        logWithPrefix(this.log_prefix, 'info', arguments);
    }
});

Logging.exclude = [
];


