var FlickrScript = new Class({
    initialize: function(type, format){
		// You must supply your own API key to use Flickr Services
		this.fApiKey	= '3e4f31ce228adca7b71ed524d3df641d';
		
		// You'll probably want to leave these alone
		this.fBaseUrl	= 'http://www.flickr.com/services/';
		this.host		= 'http://localhost/educacion/flickr/';
		this.fType		= (!type)?'rest':type;
		this.fFormat	= (!format)?'json':format;
		this.js			= 'photoset';
		this.fArgs		= {};
    },
	callFlickrUrl: function(args,cname,width,js){
    	var showTumbs = {};
    	this.fArgs.api_key = this.fApiKey;
		this.fArgs.format = this.fFormat;
		this.fArgs.nojsoncallback = '1';
		var i = 1;
		$extend(this.fArgs, args);
		$$('.'+cname).each(function(e){
			this.js	= (!js)? this.js:js;
			//var myScript = new Asset.javascript(this.host + 'flickr.' + this.js + '.min.js');
			var info = e.get('class').trim();
			info = info.replace(cname,'').trim();
			var data = info.split(' ');
			var j = 0;
			var multib = {overlay: new overlay()};
			var widthb = width;
			var config = null;
			if (data.length > 0) {
				e.set('html','');
				this.fArgs.photoset_id = data[0];
				for (j=0;j<data.length;j++) {
					if(j != 0){
						config = data[j].split('_');
						if (config[0] == 'w') {
							widthb = config[1].toInt();
						}
						if (config[0] == 'fixedTop') {
							multib.fixedTop = config[1];
						}
					}
				}
				var setRequest = new Request.JSONP({
					callbackKey: 'jsoncallback',
				    url:         this.fBaseUrl+this.fType+'/',
				    data:        this.fArgs,
				    onComplete:  function( rsp ) {
						if (rsp.stat == 'ok' && eval('rsp.' + this.js)){
							showTumbs[i] = new ShowTumb(rsp,e,widthb,'mb_'+i).chain(new multiBox('mb_'+i, multib));
							i++;
						}
				    }.bind(this),
				    onFailure: function(){
						alert('Fallo de conexión');
					}
				}).send();
			}
		},this);
	}
});