window.connectTemplate = new ConnectTemplate();

function ConnectTemplate()
{
	var self = this;
	
	this.useTemplate = function( targetId, templateId, vars )
	{
		$('#'+targetId).html( self.returnTemplate(templateId, vars) );
	}
	
	this.returnTemplate = function( templateId, vars )
	{
		if( vars == undefined ) vars = {};
		
		var templateContent = $('#'+templateId).html();

		$.each( vars, function(index, value) {
			templateContent = templateContent.replace(new RegExp('{'+index+'}','g'), value);
		});
		
		return templateContent;
	}
}
