﻿function StringBuffer() {
    this.buffer = [];
}

StringBuffer.prototype.append = function append(string) {
    this.buffer[this.buffer.length] = string;
    return this;
};

StringBuffer.prototype.toString = function toString() {
    return this.buffer.join("");
}; 

// function to allow javascript to programmatically load a CSS stylesheet
function loadStylesheet( filename, media ){
	// ensure that the browser has all the DOM methods/properties we need
	if( !(document.getElementById) ||
		!(document.childNodes) ||
		!(document.createElement) ||
		!(document.getElementsByTagName) ){
		return;
	}

	// make a new link node to the stylesheet
	var link = document.createElement( "link" );
	link.href = filename;
	link.rel = "stylesheet";
	link.type = "text/css";
	link.media = media;

	// insert the stylesheet link into the document head
	document.getElementsByTagName('head')[0].appendChild(link);
}