
(function($){

	/* IMGSCALER */
	
	$.fn.imgscaler = function(options) {
		
		// Default settings, extended by user-specified options
		var settings = jQuery.extend({
			placement: 'center',
			show: true,
			fade: true,
			time: 400,
			toppad: 0,
			bottompad: 0
		}, options);
		
		return this.each( function(){
			
			var $this = $(this);
			
			var img = $this.find('img:first');
			
			// resize and show image if we have one
			if (img.length) {
				
				// Attach image ratio, resize image, and show image on load
				img.one("load", function(){
						img.data('ratio', img.width() / img.height());
						scaleImg(img);
						if (settings.show) showImg(img);
					})
					.each(function(){
						if(this.complete) {
							$(this).trigger("load");
						}
					});
				
				// Adjust the background size when the window is resized
				$(window).resize(function(){
					scaleImg(img);
				});
				
			}
		});
		
		function scaleImg(img) {
			
			var wrapper = img.parent(),
				wrapperW = wrapper.width(),
				wrapperH = wrapper.height(),
				imgRatio = img.data('ratio'),
				imgW = wrapperW,
				imgH = Math.ceil(imgW / imgRatio);
		
			if (imgH < wrapperH) {
				imgH = wrapperH;
				imgW = Math.ceil( imgH * imgRatio );
			}
			
			var imgLft = (imgW > wrapperW) ? Math.ceil( (imgW - wrapperW) / -2 ) : 0;
			var imgTop = (imgH > wrapperH) ? Math.ceil( (imgH - wrapperH) / -2 ) : 0;
			
			img.css({
				'width': imgW,
				'height': imgH,
				'margin-left': imgLft,
				'margin-top': imgTop
			});
			
		}
		
		function showImg(img) {
			
			// fade in or show immediately
			if (settings.fade) {
				img.fadeIn(settings.time);
			} else {
				img.show();
			}
			
		}
	};
	
})(this.jQuery);




window.log = function(){
  log.history = log.history || [];  
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
(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||{});


