
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});


// place any jQuery/helper plugins in here, instead of separate, slower script files.

(function() {
    $.fn.bgscroll = $.fn.bgScroll = function( options ) {
         
        if( !this.length ) return this;
        if( !options ) options = {};
        if( !window.scrollElements ) window.scrollElements = {};
         
        for( var i = 0; i < this.length; i++ ) {
             
            var allowedChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            var randomId = '';
            for( var l = 0; l < 5; l++ ) randomId += allowedChars.charAt( Math.floor( Math.random() * allowedChars.length ) );
             
                this[ i ].current = 0;
                this[ i ].scrollSpeed = options.scrollSpeed ? options.scrollSpeed : 70;
                this[ i ].direction = options.direction ? options.direction : 'h';
                window.scrollElements[ randomId ] = this[ i ];
                 
                eval( 'window[randomId]=function(){var axis=0;var e=window.scrollElements.' + randomId + ';e.current -= 1;if (e.direction == "h") axis = e.current + "px 0";else if (e.direction == "v") axis = "0 " + e.current + "px";else if (e.direction == "d") axis = e.current + "px " + e.current + "px";$( e ).css("background-position", axis);}' );
                                                          
                setInterval( 'window.' + randomId + '()', options.scrollSpeed ? options.scrollSpeed : 70 );
            }
             
            return this;
        }
})(jQuery);
