<!-- ShowTableConverter.js -->
<!--

function ShowTableConverter(shows) {
//alert("stc ctor");
   //variables
   //alert("setting showlist to: " + showList.getShow(1).date);
   this.shows = shows;
   
   // methods
   this.printTable = printTable;
   this.printHeader = printHeader;
   this.printRow = printRow;

   // constants
   this.tba = "TBA";
   this.cellPad = 15;
   this.headerBGColor = "#dd0000";
   this.oddRowBGColor = null;
   //this.oddRowBGColor = null;
   this.evenRowBGColor ="22222";
   //this.evenRowBGColor = null;
   this.dateBGColor = null;
   //this.mapText = "<i><font size=x-small>map</font></i>";
   this.mapText = "<font size=-2 color='gray'>(directions)</font>";

   this.dateTextColor = "#aaaaaa";     //Color of text in date field
   this.commentTextColor = "gray";
}

function printRow(show, oddRow) {
   var isOddRow = (oddRow == 1);
   var wroteColor = null;
   if (isOddRow) {
     document.write("<tr");
     if (this.oddRowBGColor != null) {
       document.write(" bgcolor=" + this.oddRowBGColor + ">");
       wroteColor = this.oddRowBGColor;
     } else {
       document.write(">");
     } 
   } else {
     document.write("<tr");
     if (this.evenRowBGColor != null) {
       document.write(" bgcolor=" + this.evenRowBGColor + ">");
       wroteColor = this.evenRowBGColor;
     } else {
       document.write(">");
     }
   }

   // date
   document.write  ("<td");
   if (this.dateBGColor != null) {
     document.write(" bgcolor = '" + this.dateBGColor + "'>");
   } else {
     document.write(">");
   }
   
   if (this.dateTextColor != null) {
     document.write("<font color='" + this.dateTextColor + "'>" + show.date + "</font>");
   } else {
     document.write(show.date);
   }
   document.write("</td><td>&nbsp;</td>");

   // city
   document.write ("<td>");
   var city = show.venue.city;
   var state = show.venue.state;
   if ((city != null) && (state != null)) {
     document.write(show.venue.city + ", " + show.venue.state);
   } else {
     document.write(this.tba);
   }
   document.write("</td><td>&nbsp</td>");

   // venue
   document.write ("<td>");
   var venue = show.venue.name;
   var venueLink = show.venue.link;
   if (venue != null) {
     if (venueLink != null) {
       document.write("<a href='" + venueLink + "'>"+venue+"</a>");
     } else {
       document.write(venue);
     }
   } else {
     document.write(this.tba);
   }

   var venueAddress = show.venue.address;
   if ((venueAddress != null) && (city != null) && (state != null)) {
      // map link

      /*Parameter Description Valid Values Req'd 
      width Map width in pixels. 1 to 800. Yes 
      height Map height in pixels. 1 to 600. Yes 
      level Map zoom level, where 1=national and 10=street level. 1 through 10. Default is ?? No 
      style Map appearance: 0=grayscale, 1=medium, 2=full color/detail. 0,1,2. Defaults to 2. No 
      icontitles Indicates whether or not to turn POI names on at zoon levels 9 and 10. POI names are off at all other zoom levels. yes, no
      Default is No. No 
      streetaddress The address for the center point of the map.   No 
      city The city for the center point of the map.   Yes 
      state The state for the center point of the map.   Yes 
      zip The zip code for the center point of the map.   No 
      country The country for the center point of the map. Default is US. No
      */

      var mqRef = "http://www.mapquest.com/cgi-bin/ia_free?";
      var widthP = "width=800";
      var heightP = "&height=500";
      var addressP = "&streetAddress=" + escape(venueAddress);
      var cityP = "&city=" + escape(city);
      var stateP = "&state=" + state;
      document.write(" <a href='" + mqRef + widthP + heightP + addressP + cityP + stateP+"'>" +
                     this.mapText + "</a>");
      //alert("map link");
   }
   document.write("</td><td>&nbsp</td>");

   // bands
   document.write("<td>");
   var bands = show.bands;
   if (bands != null) {
   	 for (var i = 0; i < bands.length; i++) {
       var bandName = bands[i].name;
       var bandLink = bands[i].link;
       if (bandLink != null) {
         document.write("<a href='" + bandLink + "'>" + bandName + "</a>");
       } else {
         document.write(bandName);
       }
       if (i < (bands.length - 1)) document.write(", ");
     }
   } else {
     document.write(this.tba);
   }
   document.write("</td></tr>");

   // comment
   if (show.comment != null) {
     //alert(wroteColor);
     if (wroteColor != null) {
       document.write("<tr bgcolor='" + wroteColor +"'>");
     } else {
       document.write("<tr>");
     }
     document.write("<td>&nbsp;</td><td>&nbsp;</td><td colspan=5><i><font color='" + this.commentTextColor + "'>" + show.comment + "</i></td></tr>"); 
   }
}

function printHeader() {
	document.writeln("<table border=0 cellpadding=2 cellspacing=0>");
    document.writeln("<tr bgcolor='"+ this.headerBGColor +"'><td><b>date</td><td width="+this.cellPad+">&nbsp;</td>");
    document.writeln("    <td><b>city</td><td width="+this.cellPad+">&nbsp;</td>");
    document.writeln("    <td><b>venue</td><td width="+this.cellPad+">&nbsp;</td>");
    document.writeln("    <td><b>other bands</td></tr>");
}

function printTable() {
	this.printHeader();
    //alert("printing table");
   //document.writeln(this.showList.getShow(1).date);
   //document.writeln("<table>");
   var oddRow = 1;
   var rowCounter = 0;
   for (var i = 0; i < this.shows.length; i++) {
      if (!this.shows[i].isOld()) {
        this.printRow(this.shows[i], oddRow);
        oddRow = oddRow * -1;
        rowCounter++;
     }
   }

   if (rowCounter == 0) {
      // no rows were printed, print out the no schedule shows line
      document.writeln("<tr><td colspan=7><center>No Shows Scheduled...</center></td></tr>");
   }
   document.writeln("</table>");
   //alert("date: " + this.shows[1].date);
}
//-->


