function PicasaApi() {
	this.initialize.apply(this, arguments);
}
PicasaApi.prototype = {
	initialize: function(response) { 
		this.feed = new Array();

		this.feed.entry = new Array();
		for (var i = 0; i < response.feed.entry.length; i ++) {
			this.feed.entry[i] = {
				id: response.feed.entry[i].gphoto$id.$t,
				albumid: response.feed.entry[i].gphoto$albumid.$t,
				title: response.feed.entry[i].title.$t,
				link: response.feed.entry[i].link[1].href,
				published: response.feed.entry[i].published.$t,
				updated: response.feed.entry[i].updated.$t,
				size: response.feed.entry[i].gphoto$size.$t,
				media: {
					content: response.feed.entry[i].media$group.media$content,
					thumbnail: response.feed.entry[i].media$group.media$thumbnail 
				}
			};
		};
	},

	debug: function() {
		$("#debug").text(this.feed.entry[0].media.content[0].url);
	},
	
	generateHtml: function(id, checkedboxes) {
		var output = "";
		var smalloutput = "";

		var maxwidth = 500;
		var width = 0;
		var checkedId = "";
		
		for (var i = 0; i < checkedboxes.length; i ++) {
			checkedId = checkedboxes[i].id;
				if (this.myimages[checkedId].width < maxwidth) {
					
					smalloutput += this.getOutput(checkedId);
					width += this.myimages[checkedId].width;
					
					if ( maxwidth < width ) {
						smalloutput += "<br />\n";
						width = 0;
					}
					
				} else {
					output += this.getOutput(checkedId);
					output += "<br />\n";    
				}
		}
		
		output += "\n" + smalloutput;
		$("#target").text(output);
	},

	getList: function() {
		var output = "";
		for (var i = 0; i < this.feed.entry.length; i ++) {
			output += this.getOutput(i, "1");
		}
		return output;
	},
	
	getOutput: function(id, size) {

		var output = "<a href=\"" + this.feed.entry[id].link
		+ "\" rel=\"tb-photos\" class=\"thickbox\" >"
		+ "<img src=\"" + this.feed.entry[id].media.thumbnail[size].url + "\" "
		+ "width=\""  + this.feed.entry[id].media.thumbnail[size].width + "\" "
		+ "height=\""  + this.feed.entry[id].media.thumbnail[size].height + "\" "
		+ "title=\""  + this.feed.entry[id].title + "\" /></a>";  
		return output;
	}
};

