// TOM BENNER
function EardrumEmbed(service, divId) {
	this.baseUrl = 'http://www.eardrumnyc.com/api/';
	this.service = service ? service : 'featured_shows.php';
	this.divId = divId ? divId : 'eardrum_embed';
	this.url = this.baseUrl+this.service;
	this.headElement = document.getElementsByTagName('head').item(0);
	this.counter = 1;
	this.embedId = 'EardrumEmbed'+this.counter++;
	
	this.init = function(){
		this.makeScriptElement();
		this.addScriptElement();
	},
	
	this.makeScriptElement = function(){
		this.scriptElement = document.createElement('script');
		this.scriptElement.setAttribute('type', 'text/javascript');
		this.scriptElement.setAttribute('id', this.embedId);
		this.scriptElement.setAttribute('charset', 'utf-8');
		this.scriptElement.setAttribute('src', this.url);
	},
	
	this.removeScriptElement = function(){
		this.headElement.removeChild(this.scriptElement);  
	},
	
	this.addScriptElement = function(){
		this.headElement.appendChild(this.scriptElement);
	},
	
	this.load = function(html){
		document.getElementById(this.divId).innerHTML = html;
		this.removeScriptElement();
	};
	
	this.init();
	
}