
$(function() { pageload() });

function pageload() {
	$('#the_schedule').html('Loading...');
	$.get('schedule.txt', function(data, textStatus) {
		processSchedule(data);
	});
}

function processSchedule(data) {
	var html = '';
	var delimiter = data.substring(5, data.indexOf('#'));
	var lines = data.split(delimiter);
	lines.shift();	// Remove the initial START line
	for(i=0; i<lines.length; i++) {
		var line = $.trim(lines[i]);
		if ( line == '' || line.substr(0,1) == '#') continue;	// Skip comments and empty lines
		if ( line.substr(0,1) == '~' ) {
			if (html != '') {
				html += "</p>";
			}
            line = '<p align="left" class="style9"><span class="style12">' + line.substr(1) + '</span>';
		}
		if ((spos = line.indexOf('[[')) != -1) {
			epos = line.indexOf(']]');
			var match = line.match(/\[\[([^\]]+?)]]/);
			line = line.substring(0,spos) + '<a href="' + match[1] + '">' + match[1] + '</a>' + line.substring(epos+2);
		}
		html += line + '<br/>';
	}
	$('#the_schedule').html(html);
}

/*
<p align="left" class="style9">
<span class="style12">Monday, April 21</span><br />
  Retta Hosts her bi-weekly radio show <br />
  The Noontime Jamboree<br />
  KBOO 90.7 fm, Portland, Oregon<br />
  Noon - 1:30 pm
</p>
*/