/* Copyright 2009 Palm, Inc.  All rights reserved. */

Photos.Model.LocalThumbs = Class.create(Photos.Model.Thumbs, {
	initialize: function($super, albumID, albumName) {
		$super(albumID, albumName);
		this.extractfsParams = ":" + this.targetWidth() + ":" +
						this.targetHeight() + ":4";
	},

	newFullscreenModel: function(index) {
		return new Photos.Model.LocalFullscreen(
					this.albumID, this.albumName, index);
	},

	request: function(offset, limit, done) {
		Photos.Service.listImages(
			offset, limit, "", this.albumID, true,
			this.translate.bind(this, done), this.controller);
	},

	translate: function(done, response) {
		if (!response || !response.returnValue) {
			done([], 0);
			return;
		}

		for (var i = 0, len = response.images.length; i < len; i++) {
			var image = response.images[i];
			image.thumb = Photos.Common.extractfsPath +
		    		encodeURIComponent(image.imagePictureUrl) +
				this.extractfsParams;
		}
		done(response.images, parseInt(response.imagesTotal, 10));
	}
});

