var flickr = {
	myFlickrFeed: new Ajax("/en/experience/feeds/flickr.xml", {method: 'get'}).request(),
	flickrPhoto : [],
	photoCount: 0,

	read : function() {
		// This is going to read the photos Array
		var flickrXMLDoc = this.myFlickrFeed.response.xml;
		var photos = flickrXMLDoc.getElementsByTagName('photo');

		/*LOOP THRU YOU TUBE FEED AND MAKE ARRAY*/
		for (i = 0; photos.length > i; i++){
			var nodeCount = photos[i].childNodes.length;
			this.flickrPhoto["photo" + i] = new Array();
			
			for (n = 0; nodeCount > n; n++) {
				if (photos[i].childNodes[n].nodeType == 1) {
					this.flickrPhoto["photo" + i][photos[i].childNodes[n].nodeName] = photos[i].childNodes[n].firstChild.nodeValue;
				}
			}
		}
	},
	
	find : function() {
		// This will build out thumbs from XML array
		var thumbLayout = '';

		for (photo in this.flickrPhoto) {
			if (typeof(this.flickrPhoto[photo]) == 'object') {
				if (this.photoCount < 9) {
					thumbLayout += this.build(this.flickrPhoto[photo]);
				}
				this.photoCount++;
			}
		}

		$('flickr_target').setHTML(thumbLayout);
	},

	build : function(argItem) {
		var itemLayout = '';

		itemLayout += '<div id="photo' + this.photoCount + '" class="photo_thumb_link"><a href="bounce.html?item=http%3A%2F%2Fflickr.com%2Fphotos%2F' + argItem['owner'] + '%2F' + argItem['id'] + '" name="&lid=photo' + this.photoCount + '&lpos=just_developed" target="_blank"><img src="http://farm' + argItem['farm'] + '.static.flickr.com/' + argItem['server'] + '/' + argItem['id'] + '_' + argItem['secret'] + '_s.jpg" /></a></div>';

		return itemLayout;
	}
}