(function() {

	var botw = function(affID, propID) {
		this.options = {
			affID: affID,
			propID: propID,
			useNarrow: false,
			numColumns: 0,
			useSingleMonth: false,
			useStaticYear: false,
			theme: 'blue'
		};
		this.init(affID, propID);
	};

	botw.prototype.init = function(affID, propID) {
		this.options.affID = affID;
		this.options.propID = propID;
		return this;
	};

	botw.prototype.affiliate = function(affID) {
		this.options.affID = affID;
		return this;
	};

	botw.prototype.property = function(propID) {
		this.options.propID = propID;
		return this;
	};

	botw.prototype.columns = function(numColumns) {
		this.options.numColumns = numColumns;
		return this;
	};

	botw.prototype.narrow = function(useNarrow) {
		this.options.useNarrow = useNarrow;
		return this;
	};

	botw.prototype.single_month = function() {
		this.options.useSingleMonth = true;
		return this;
	};

	botw.prototype.entire_year = function() {
		this.options.useStaticYear = true;
		return this;
	};

	botw.prototype.template = function(theme) {
		this.options.theme = theme;
		return this;
	};

	botw.prototype.display = function() {
		html = '';
		html += '<scr'+'ipt src="http://bransonontheweb.com/affiliates/schedule/';
		html += ( this.options.useSingleMonth == true ) ? 'single_month/' : 'full_year/';
		html += this.options.affID +'/'+ this.options.propID +'/?output=js&theme='+ this.options.theme;
		if( this.options.numColumns > 0 )
			html += '&columns='+this.options.numColumns;
		if( this.options.useNarrow == true )
			html += '&narrow=1';
		if( this.options.useStaticYear == true )
			html += '&static=1';
		if( this.options.useTable == true && this.options.useSingleMonth == false )
			html += '&table=1';
		if(window.location)
			html += '&loc='+window.location;
		html += '" type="text/javascript"></scr'+'ipt>';
		window.document.write(html);
	};

	botw.prototype.display_table = function() {
		this.options.useTable = true;
		this.display();
	};

	function jQuery_single_table_ready() {
		if( ! window.jQuery ) { return; }
	}

	window.botw = botw;
})();