(function(){
	var outer = document.createElement("div"),
		$outer = $(outer),
		images = []
	;
	
	
	var getScaledWidth = function(rawWidth, rawHeight, newHeight) {
		var ratio = Number(newHeight) / Number(rawHeight); // scale
		return Math.ceil(Number(rawWidth) * ratio);
	};
	var getScaledHeight = function(rawWidth, rawHeight, newWidth) {
		var ratio = Number(newWidth) / Number(rawWidth); // scale
		return Math.ceil(Number(rawHeight) * ratio);
	};
	
	var picshow = function(params){
		var
			//Dimension
			outerWidth = outer.style.width = params.width || "100%",
			outerHeight = outer.style.height = params.height || "240px"
		;
		
		
		
	};
	
	picshow.prototype.load = function(arr){
		var i, img;
		if(typeof arr !== "object" && arr[0] === undefined && arr.length === undefined) {
			throw "[picshow.load] ERROR: expected array and saw " + typeof arr;
		}
		
		//Clear existing images.
		images = [];
		$outer.empty();
		
		for(i = 0; i < arr.length; i++) {
			//Create and setup each image.
			img = document.createElement("img");
			img.src = arr[i];
			this.setupImage(img);
			images.push(img);
		}
	};
	picshow.prototype.setupImage = function(img) {
		$(img).load(function(){
			img.scaledWidth = this.getScaledWidth(img.width);
			img.scaledHeight = this.getScaledHeight(img.height);
			//TODO: add image to picshow
			outer.appendChild(img);
		})
	}
	
})();

