window.log = function () {
    log.history = log.history || [];  // store logs to an array for reference
    log.history.push(arguments);
    if (typeof console.log == 'function') {
        // Modern browsers
        if ((Array.prototype.slice.call(arguments)).length == 1 && typeof Array.prototype.slice.call(arguments)[0] == 'string') {
            console.log( (Array.prototype.slice.call(arguments)).toString() );
        }
        else {
            console.log( Array.prototype.slice.call(arguments) );
        }
    }
};

/**
 * Date format
 * http://phpjs.org/functions/date:380
 */
function date(i,j){var d,a,g=/\\?([a-z])/gi,f,e=function(b,a){return(b+="").length<a?Array(++a-b.length).join("0")+b:b},h="Sun,Mon,Tues,Wednes,Thurs,Fri,Satur,January,February,March,April,May,June,July,August,September,October,November,December".split(",");f=function(b,c){return a[b]?a[b]():c};a={d:function(){return e(a.j(),2)},D:function(){return a.l().slice(0,3)},j:function(){return d.getDate()},l:function(){return h[a.w()]+"day"},N:function(){return a.w()||7},S:function(){var b=a.j();return 4> b|20<b&&["st","nd","rd"][b%10-1]||"th"},w:function(){return d.getDay()},z:function(){var b=new Date(a.Y(),a.n()-1,a.j()),c=new Date(a.Y(),0,1);return Math.round((b-c)/864E5)+1},W:function(){var b=new Date(a.Y(),a.n()-1,a.j()-a.N()+3),c=new Date(b.getFullYear(),0,4);return e(1+Math.round((b-c)/864E5/7),2)},F:function(){return h[6+a.n()]},m:function(){return e(a.n(),2)},M:function(){return a.F().slice(0,3)},n:function(){return d.getMonth()+1},t:function(){return(new Date(a.Y(),a.n(),0)).getDate()}, L:function(){var b=a.Y();return 0==b%4&0!=b%100|0==b%400},o:function(){var b=a.n(),c=a.W();return a.Y()+(12===b&&9>c?-1:1===b&&9<c)},Y:function(){return d.getFullYear()},y:function(){return(a.Y()+"").slice(-2)},a:function(){return 11<d.getHours()?"pm":"am"},A:function(){return a.a().toUpperCase()},B:function(){var a=3600*d.getUTCHours(),c=60*d.getUTCMinutes(),f=d.getUTCSeconds();return e(Math.floor((a+c+f+3600)/86.4)%1E3,3)},g:function(){return a.G()%12||12},G:function(){return d.getHours()},h:function(){return e(a.g(), 2)},H:function(){return e(a.G(),2)},i:function(){return e(d.getMinutes(),2)},s:function(){return e(d.getSeconds(),2)},u:function(){return e(1E3*d.getMilliseconds(),6)},e:function(){throw"Not supported (see source code of date() for timezone on how to add support)";},I:function(){var b=new Date(a.Y(),0),c=Date.UTC(a.Y(),0),d=new Date(a.Y(),6),e=Date.UTC(a.Y(),6);return 0+(b-c!==d-e)},O:function(){var a=d.getTimezoneOffset(),c=Math.abs(a);return(0<a?"-":"+")+e(100*Math.floor(c/60)+c%60,4)},P:function(){var b= a.O();return b.substr(0,3)+":"+b.substr(3,2)},T:function(){return"UTC"},Z:function(){return 60*-d.getTimezoneOffset()},c:function(){return"Y-m-d\\Th:i:sP".replace(g,f)},r:function(){return"D, d M Y H:i:s O".replace(g,f)},U:function(){return d/1E3|0}};this.date=function(a,c){d=null==c?new Date:c instanceof Date?new Date(c):new Date(1E3*c);return a.replace(g,f)};return this.date(i,j)};

