
if (Object.isUndefined(CodeCompany)) { var CodeCompany = {}; }

CodeCompany.FastTagObserver = Class.create({

	log: function(str) {
		if (!Object.isUndefined(site)) { site.log('FastTag['+this.name+']: '+str); }
	},

	initialize: function(post_id,options) {
		this.options = Object.extend({
			'tagContainerSelector':	'.tags',
			'postContainerID':		'post-%{ID}'
		},options || {});

		this.options.postContainerID = this.options.postContainerID.replace('%{ID}',post_id);

		this.postContainer = $(this.options.postContainerID);
		if (Object.isUndefined(this.postContainer)) {
			this.log('Unable to locate element #'+this.options.postContainerID);
			return false;
		}
		
		var tagContainers = this.postContainer.select(this.options.tagContainerSelector);
		if (tagContainers.length<1) {
			this.log('Tag container selector gave no results: '+this.options.tagContainerSelector);
			return false;
		}

		this.tagContainer = tagContainers.first();

		this.updateHTML();
	},

	updateHTML: function() {
		this.tagContainer.select('A').each(function(element){
			var x = new Element('span');
			x.addClassName('remove-tag');
			x.update('x');
			element.insert({after:x});
			x.observe('click',this.onClickRemoveTag.bindAsEventListener());
		},this);
	},

	onClickRemoveTag: function() {
		alert('Undervejs :)');
	}
	
});

