function profile(element, options) {
	this.element = element;
	this.options = jQuery.extend(profile, profile.DEFAULTS, options);
	this.options.error_output='.error';
	this.options.request_suffix='/json';
}
profile.prototype={
	album_add_submit:function(form){
		var self=this;
		//TODO: this is not thread safty
		this.options.form=form;
		form.submit(function(){
			values={};
			$.each(['privacy','title'],function(i,name){
				input=form.find('input[name='+this+']');
				values[name]=input.val();
				//console.log(input.attr('type'));
				if(input.attr('type')=='checkbox'){
					values[name]=input.attr('checked');
				}
			});
			//console.log(self);
			$.postJSON(this.action+profile.options.request_suffix,values,self.album_add_handler,self);
			return false;
		});

	},
	album_add_handler:function(data){
		
		if(!data.status){
			this.options.form.find(this.options.error_output).html(data.error);
			this.options.form.find(this.options.error_output).show();
		}else{
			$.fancybox(data.html);
		}
		//TODO: delete
		$.fancybox.resize();
	},
	fav_add_submit:function(form){
		var self=this;
		//TODO: this is not thread safty
		this.options.form=form;
		form.submit(function(){
			values={};
			$.each(['title'],function(i,name){
				input=form.find('input[name='+this+']');
				values[name]=input.val();
				if(input.attr('type')=='checkbox'){
					values[name]=input.attr('checked');
				}
			});
			//console.log(self);
			$.postJSON(this.action+profile.options.request_suffix,values,self.fav_add_handler,self);
			return false;
		});

	},
	fav_add_handler:function(data){
		
		if(!data.status){
			this.options.form.find(this.options.error_output).html(data.error);
			this.options.form.find(this.options.error_output).show();
		}else{
			$.fancybox(data.html);
		}
		//TODO: delete
		$.fancybox.resize();
	}
}

