
//*************************************************************************
//meefia.js
//Description: converts a schedule in comma delimited text to an html table
//Verson: 1.2
//Log:
//     8/21/2009 - SH added two new columns: 'Program' and 'Notes'
//     8/31/2009 - SH removed the 'Program' column, added separate 'Day' column 
//
//
//*************************************************************************

function popWin(url, name, width, height, optionals) {
	var newWin,left,top;
	if (width > screen.availWidth - 12) width = screen.availWidth - 12;
	if (height > screen.availHeight - 48) height = screen.availHeight - 48;
	left = (screen.availWidth - width - 12) / 2;
	top = (screen.availHeight - height - 48) / 2;
	if (!optionals) optionals = 'menubar=0,toolbar=0,location=0,directories=0,resizable=0,status=0,scrollbars=0';
	newWin = window.open(url, name, optionals + ',width=' + width +',height=' + height +',left=' + left +',top=' + top);
	newWin.focus();
}

function Event(row) {
	this.rowNum = row[0];
	this.bgClass = (this.rowNum % 2 == 0) ? "even" : "odd";
	this.eventDay      = row[1];
	this.eventDate     = row[2]; // Sunday, September 30
	this.eventTime     = row[3]; // 8;30pm
	this.location      = row[4]; // Gettysburg, PA
	this.venue_line1   = row[5]; // Gettysburg College
	this.venue_line2   = row[6]; // Sunderman Conservatory of Music
	this.venue_line3   = row[7]; // 222 Recital Hall
	this.venue_line4   = row[8]; // 300 N. Washington St 
	this.info_phone    = row[9]; // 717-337-6100
	this.info_link     = row[10]; // http://www.gettysburg.edu/sunderman_conservatory
	this.program_line1 = row[11]; //Mahler's 5th
	this.program_line2 = row[12]; //Mahler's 2nd
	this.program_line3 = row[13]; //Tchaikovsky's Violin Concerto
	this.program_line4 = row[14]; //Twinkle Twinkle Little Star
	this.program_line5 = row[15]; //Bruckner's 2nd Symphony
	this.notes         = row[16]; //This concert is free.
}

function writeSked(type) {
	var output="";
	for (var i=0; i<sked.length; i++) {
		var currentEvent = new Event(sked[i]);
		output += "<tr class='" + currentEvent.bgClass + "'>";
		output += "<td>" + currentEvent.eventDay + "<br/>" + currentEvent.eventDate + "<br/>" + currentEvent.eventTime + "</td>";
		output += "<td class='standOut secondary'>" + currentEvent.location + "</td>";
		output += "<td><table><tbody>" 
								 + (currentEvent.venue_line1=="" ? "" : "<tr><td class='wrapIndent'>" + currentEvent.venue_line1) + "</td></tr>"
								 + (currentEvent.venue_line1=="" ? "" : "<tr><td class='wrapIndent'>" + currentEvent.venue_line2) + "</td></tr>"
								 + (currentEvent.venue_line1=="" ? "" : "<tr><td class='wrapIndent'>" + currentEvent.venue_line3) + "</td></tr>"
								 + (currentEvent.venue_line1=="" ? "" : "<tr><td class='wrapIndent'>" + currentEvent.venue_line4) + "</td></tr>"
								 + "</tbody></table></td>";

		output += "<td>" + (currentEvent.info_phone=="" ? "" : currentEvent.info_phone + "<br/>")
								 + (currentEvent.info_link=='' ? "" : "<a href='" + currentEvent.info_link + "' target='_blank'>Info/Tickets</a>")
								 + "</td>";

		//output += "<td><table><tbody>"
	        //							 + (currentEvent.program_line1=="" ? "" : "<tr><td class='wrapIndent'>" + currentEvent.program_line1) + "</td></tr>"
		//							 + (currentEvent.program_line2=="" ? "" : "<tr><td class='wrapIndent'>" + currentEvent.program_line2) + "</td></tr>"
		//							 + (currentEvent.program_line3=="" ? "" : "<tr><td class='wrapIndent'>" + currentEvent.program_line3) + "</td></tr>"
		//							 + (currentEvent.program_line4=="" ? "" : "<tr><td class='wrapIndent'>" + currentEvent.program_line4) + "</td></tr>"
		//							 + (currentEvent.program_line5=="" ? "" : "<tr><td class='wrapIndent'>" + currentEvent.program_line5) + "</td></tr>"
		//							 + "</tbody></table></td>";

		output += "<td>" + currentEvent.notes + "</td>";
		
		output += "</tr>";
	}
	document.write(output);
}

