// Functions specific to the TSE locator.
// For a NEWLOCATOR, create a new version of this file. 
// All of the functions in this file must be present in new
// locators, even if they don't do anything.

var apptype = "tse";

// Perform any required processing prior to invoking the ajax call.
function appPreSubmit() {

}

/**
 * return a div element for the printable results table
 */
function getPrintableResults(location, index) {
   var resultDiv = document.createElement('div');
   // split the payment_type into two lines
   var paymentType = "";
   if (location['PAYMENT_TYPE']) {
      var words = location['PAYMENT_TYPE'].split(' ');
      for (var i = 0; i < words.length; i++) {
         paymentType += words[i] + " ";
         if (i%2 == 0 && i < words.length-1) {
            paymentType += "<br>";
         }
      }
   }

   var result_html = "<b>" + location['SITE_NAME'] + "</b><br>" +
      location['STREET_ADDRESS'] + "<br>" +
      location['CITY'] + ", " +
      location['STATE'] + " " +
      location['ZIP'] + "<br>" +
      "<b>Phone:</b> " + location['PHONE'] + "<br>";

   if(location["DISTANCE"] != undefined) {
      result_html += "<b>Distance</b>: " + location['DISTANCE'] + " Miles" + "<br>";
   }

   if(location["STATION_TYPE"]) {
	   result_html += "<b>Brand:</b> " + location['STATION_TYPE'] + "<br>";
   }

   if(location["INTERSECTION_DIRECTIONS"]) {
	   result_html += "<b>Intersection Directions:</b> " + location['INTERSECTION_DIRECTIONS'] + "<br>";
   }

   if(paymentType) {
      result_html += "<b>Payment:</b> " + paymentType + "<br>";
   }

   result_html += "<b>Access:</b> " + location['ACCESS_TYPE'];

   resultDiv.innerHTML = result_html;
   return resultDiv;
}


