function print_table_header(header_font_color, header_bg_color, table_width, tr_header_class, th_class, table_class, font_face, font_size, use_font_tag, use_css) {
  var strfont_start, strfont_end, css_tr, css_th, css_table;
  if (use_font_tag == 'y') {
    strfont_start = '<font color=' + header_font_color + ' face=' + font_face + ' size=' + font_size + '><b>';
    strfont_end = '</font>';
  }
  else {
    strfont_start = '';
    strfont_end = '';
  }

  if (use_css == 'y') {
    css_tr = ' class="' + tr_header_class + '"';
    css_th = ' class="' + th_class + '"';
    css_table = ' class="' + table_class + '"';
  }
  else {
    css_tr = '';
    css_th = '';
    css_table = '';
  }
  document.write('<TABLE' + css_table + ' cellpadding=1 cellspacing=0 border=0 width=' + table_width + '>');
  document.write('<tr bgcolor=' + header_bg_color + css_tr + '>');
  document.write('<th' + css_th + '>' + strfont_start + 'Price' + strfont_end + '</th>');
  document.write('<th' + css_th + '>' + strfont_start + 'Station' + strfont_end + '</th>');
  document.write('<th' + css_th + '>' + strfont_start + 'Area' + strfont_end + '</th>');
  document.write('<th' + css_th + '>' + strfont_start + 'Time' + strfont_end + '</th></tr>');
  return 1;
}

function print_table_footer() {
  document.write('</TABLE>');
  return 1;
}

function print_gasbuddy_banner(font_color, row_color, header_font_color, header_bg_color, td_class, 
                        tr_class, font_face, font_size, use_font_tag, use_css) {
  var strfont_start, strfont_end, css_tr, css_td;
  if (use_font_tag == 'y') {
    strfont_start = '<font color=' + font_color + ' face=' + font_face + ' size=' + font_size + '>';
    strfont_end = '</font>';
  }
  else {
    strfont_start = '';
    strfont_end = '';
  }

  if (use_css == 'y') {
    css_tr = ' class="' + tr_class + '"';
    css_td = ' class="' + td_class + '"';
  }
  else {
    css_tr = '';
    css_td = '';
  }
  

  document.write('<tr bgcolor=' + row_color + css_tr + '><td align="center" colspan="4"' + css_td + '>' + strfont_start);
  document.write('<b>Find more gas prices in ' + display_nm + ' at <a href="http://www.' + site + 'GasPrices.com">www.' + site + 'GasPrices.com</a></b>');
  document.write(strfont_end + '</td></tr>');
  return 1;
}

function print_prices_table(price, station_nm, address, area, tme, font_color, row_color, 
                              header_font_color, header_bg_color, td_class, tr_class,
                              font_face, font_size, use_font_tag, use_css) {
  var strfont_start, strfont_end, css_tr, css_td;
  if (use_font_tag == 'y') {
    strfont_start = '<font color=' + font_color + ' face=' + font_face + ' size=' + font_size + '>';
    strfont_end = '</font>';
  }
  else {
    strfont_start = '';
    strfont_end = '';
  }

  if (use_css == 'y') {
    css_tr = ' class="' + tr_class + '"';
    css_td = ' class="' + td_class + '"';
  }
  else {
    css_tr = '';
    css_td = '';
  }
  
  document.write('<tr bgcolor=' + row_color + css_tr + '><td' + css_td + '>' + strfont_start + price + strfont_end + '</td>');
  document.write('<td' + css_td + '>' + strfont_start + '<b>' + station_nm + '</b><br>' + address + strfont_end + '</td>');
  document.write('<td' + css_td + '>' + strfont_start + area + strfont_end + '</td>');
  document.write('<td' + css_td + '>' + strfont_start + tme + strfont_end + '</td></tr>');
  return 1;
}

function main(low_prices, price_cnt, site, city_title) {
  var i, k;
  //document.write('Prices current as of: ' + last_updated + '<br>');
  document.write('<h3>10 lowest gas prices in ' + display_nm + '</h3>');

  i = print_table_header(header_font_color, header_bg_color, table_width, tr_header_class, th_class, table_class, font_face, font_size, use_font_tag, use_css);

  for (i = 0; i < price_cnt; ++ i) {
    //document.write(i);
    k = print_prices_table(low_prices[i][0], low_prices[i][1], low_prices[i][2],low_prices[i][3], low_prices[i][4],
                           font_color, row_color, header_font_color, header_bg_color, td_class, tr_class,
                           font_face, font_size, use_font_tag, use_css);
  }
	
  print_gasbuddy_banner(font_color, row_color, header_font_color, header_bg_color, td_class, tr_class,
  font_face, font_size, use_font_tag, use_css);
  print_table_footer();
	
  return 1;
}


var j;

j = main(low_prices, price_cnt, site, city_title, display_nm);
