Flickr = function(){
	return {
		init : function(type, format){
			this.key = 'ad6e3db2fb2e7cebedeb963a48831a25';
			this.base = 'http://www.flickr.com/services/rest/';
	    },
		
		call : function(args){
			args.api_key = this.key;
			args.format = "json";
			this.dst(this.base + this.qs(args));
		},
		
		qs : function(args){
			var s = "";
			for(k in args){
				if(s) s += "&";
				else s = "?";
				s += k + "=" + args[k];
			}
			return s;
		},
		
		dst : function(url){
			var script=document.createElement('script');
		    script.src=url;
		    script.type="text/javascript";
		    document.getElementsByTagName('head')[0].appendChild(script);
		},
		
		url : function(o, type, idfield){
			if(type) var typ = "_" + type;
			else var typ = "";
			
			if(idfield) o.id = o[idfield];
			
			return "http://farm" + o.farm + ".static.flickr.com/"
				+ o.server + "/" + o.id + "_" + o.secret
				+ typ + ".jpg";
		}
	}
}();