').css( $.extend( css, { position: 'fixed' } ) ).append( html ).appendTo( DOM().body );
+ }
+ };
+
+ // if debug is on, display errors and throw exception if fatal
+ if ( DEBUG ) {
+ echo( msg );
+ if ( fatal ) {
+ throw new Error(type + ': ' + msg);
+ }
+
+ // else just echo a silent generic error if fatal
+ } else if ( fatal ) {
+ if ( _hasError ) {
+ return;
+ }
+ _hasError = true;
+ fatal = false;
+ echo( 'Gallery could not load.' );
+ }
+};
+
+// Add the version
+Galleria.version = VERSION;
+
+Galleria.getLoadedThemes = function() {
+ return $.map(_loadedThemes, function(theme) {
+ return theme.name;
+ });
+};
+
+/**
+ A method for checking what version of Galleria the user has installed and throws a readable error if the user needs to upgrade.
+ Useful when building plugins that requires a certain version to function.
+
+ @param {number} version The minimum version required
+
+ @param {string} [msg] Optional message to display. If not specified, Galleria will throw a generic error.
+
+ @returns Galleria
+*/
+
+Galleria.requires = function( version, msg ) {
+ msg = msg || 'You need to upgrade Galleria to version ' + version + ' to use one or more components.';
+ if ( Galleria.version < version ) {
+ Galleria.raise(msg, true);
+ }
+ return Galleria;
+};
+
+/**
+ Adds preload, cache, scale and crop functionality
+
+ @constructor
+
+ @requires jQuery
+
+ @param {number} [id] Optional id to keep track of instances
+*/
+
+Galleria.Picture = function( id ) {
+
+ // save the id
+ this.id = id || null;
+
+ // the image should be null until loaded
+ this.image = null;
+
+ // Create a new container
+ this.container = Utils.create('galleria-image');
+
+ // add container styles
+ $( this.container ).css({
+ overflow: 'hidden',
+ position: 'relative' // for IE Standards mode
+ });
+
+ // saves the original measurements
+ this.original = {
+ width: 0,
+ height: 0
+ };
+
+ // flag when the image is ready
+ this.ready = false;
+
+ // flag for iframe Picture
+ this.isIframe = false;
+
+};
+
+Galleria.Picture.prototype = {
+
+ // the inherited cache object
+ cache: {},
+
+ // show the image on stage
+ show: function() {
+ Utils.show( this.image );
+ },
+
+ // hide the image
+ hide: function() {
+ Utils.moveOut( this.image );
+ },
+
+ clear: function() {
+ this.image = null;
+ },
+
+ /**
+ Checks if an image is in cache
+
+ @param {string} src The image source path, ex '/path/to/img.jpg'
+
+ @returns {boolean}
+ */
+
+ isCached: function( src ) {
+ return !!this.cache[src];
+ },
+
+ /**
+ Preloads an image into the cache
+
+ @param {string} src The image source path, ex '/path/to/img.jpg'
+
+ @returns Galleria.Picture
+ */
+
+ preload: function( src ) {
+ $( new Image() ).on( 'load', (function(src, cache) {
+ return function() {
+ cache[ src ] = src;
+ };
+ }( src, this.cache ))).attr( 'src', src );
+ },
+
+ /**
+ Loads an image and call the callback when ready.
+ Will also add the image to cache.
+
+ @param {string} src The image source path, ex '/path/to/img.jpg'
+ @param {Object} [size] The forced size of the image, defined as an object { width: xx, height:xx }
+ @param {Function} callback The function to be executed when the image is loaded & scaled
+
+ @returns The image container (jQuery object)
+ */
+
+ load: function(src, size, callback) {
+
+ if ( typeof size == 'function' ) {
+ callback = size;
+ size = null;
+ }
+
+ if( this.isIframe ) {
+ var id = 'if'+new Date().getTime();
+
+ var iframe = this.image = $('