//====================================================================================
function Encoded_Notes()
 {
  var enotes =  document.getElementById('notes').value;
  enotes = enotes.replace(/\n/g,'@@@@@@');
  enotes = enotes.replace(/,/g,'@@@@');
  return enotes;
 }
//====================================================================================
function Single_LocationAddress()
 {
  updatebrandnotes('');
  updatebrandnotes('From House Number (NI)');
  updatebrandnotes('');
  updatebrandnotes(document.getElementById('sngljny_location').value);
  updatebrandnotes('');
 }
//====================================================================================
function Single_HomeAddress()
 {
  updatebrandnotes(document.getElementById('sngljny_address_line_1').value); 
  updatebrandnotes('From House Number (NI)');
  updatebrandnotes(document.getElementById('sngljny_address_line_2').value);
  updatebrandnotes(document.getElementById('sngljny_address_district').value);
  updatebrandnotes(document.getElementById('sngljny_address_postcode').value);
 }
//====================================================================================
function Single_ViaAddresses()
 {
  var adrline1 = '';	 
  var adrhsn = '~~~~~';	 
  var adrline2 = '';	 
  var adrdis = '';	 
  var adrptc = '';	
  var i = 0;	
  for (i=1;i<6;i=i+1)
   {
    adrline1 = adrline1 +  document.getElementById('ipsjdvia' + i + 'adr_line_1').value + '~';
    adrline2 = adrline2 +  document.getElementById('ipsjdvia' + i + 'adr_line_2').value + '~';
    adrdis = adrdis +  document.getElementById('ipsjdvia' + i + 'adrdis').value + '~';
    adrptc = adrptc +  document.getElementById('ipsjdvia' + i + 'adrptc').value + '~';
   }
  adrline1 = adrline1 +  document.getElementById('ipsjdvia' + i + 'adr_line_1').value;
  adrline2 = adrline2 +  document.getElementById('ipsjdvia' + i + 'adr_line_2').value;
  adrdis = adrdis +  document.getElementById('ipsjdvia' + i + 'adrdis').value;
  adrptc = adrptc +  document.getElementById('ipsjdvia' + i + 'adrptc').value;
  updatebrandnotes(adrline1);                                                                                        //field[28]
  updatebrandnotes(adrhsn);                                                                                          //field[29]
  updatebrandnotes(adrline2);                                                                                        //field[30]
  updatebrandnotes(adrdis);                                                                                          //field[31]
  updatebrandnotes(adrptc);                                                                                          //field[32]
 }
//====================================================================================
function TATS_HTML_Single_Journey_Details()
 {
  bookingrecord[0] = '';
  //document.getElementById('notes').value = '';
  
  updatebrandnotes(GetToDaysShortDayName());                                                                          //field[0]
  updatebrandnotes(GetNumericDate());                                                                                 //field[1]
  updatebrandnotes(GetTime());                                                                                        //field[2]
  updatebrandnotes(document.getElementById('client_name').value);                                                     //field[3]
  updatebrandnotes(GetPickupDay(document.getElementById('sngljny_pickup_date').value));                               //field[4]
  updatebrandnotes(document.getElementById('sngljny_pickup_date').value);                                             //field[5]
  updatebrandnotes(document.getElementById('sngljny_pickup_hours').value+':'+document.getElementById('sngljny_pickup_mins').value);                                                                                                                      //field[6]
  updatebrandnotes(document.getElementById('client_phone').value+'~'+document.getElementById('client_mobile').value)  //field[7]
  updatebrandnotes(document.getElementById('sngljny_npassengers').value);                                             //field[8]
  updatebrandnotes(document.getElementById('sngljny_vehicletype').value);                                             //field[9]
  updatebrandnotes('Public');                                                                                         //field[10]
  updatebrandnotes(document.getElementById('payment_method').value);                                                  //field[11]
  updatebrandnotes('');                                                                                               //field[12]
  updatebrandnotes(document.getElementById('client_name').value);                                                     //field[13]
  updatebrandnotes(document.getElementById('client_email').value);                                                    //field[14]
  updatebrandnotes('From Passenger Names (NI)');                                                                      //field[15]
  updatebrandnotes('From Mobiles (NI)');                                                                              //field[16]
  updatebrandnotes('From Telephones (NI)');                                                                           //field[17]
  updatebrandnotes('From Organisations (NI)');                                                                        //field[18]
  var tofrom = new Array();
  tofrom = document.getElementById('sngljny_type').value.split(' ');
  tofrom[0] =  tofrom[0].trim();
  tofrom[0] =  tofrom[0].toUpperCase();
  if (tofrom[0] ==  "FROM"){Single_LocationAddress();}else {Single_HomeAddress();}
  //----------------------------------------------------------------------------------
  //From Buildings                                                                                                    //field[19]
  //From House Numbers (NI)                                                                                           //field[20]
  //From Streets                                                                                                      //field[21]
  //From Districts                                                                                                    //field[22]
  //From Post Codes                                                                                                   //field[23]
  //----------------------------------------------------------------------------------
  updatebrandnotes('Via Passenger Names (NI)');                                                                       //field[24]
  updatebrandnotes('Via Mobiles (NI)');                                                                               //field[25]
  updatebrandnotes('Via Telephones (NI)');                                                                            //field[26]
  updatebrandnotes('Via Organisations (NI)');                                                                         //field[27]
  //----------------------------------------------------------------------------------
  Single_ViaAddresses();
  //Via Buildings                                                                                                     //field[28]
  //Via House Numbers (NI)                                                                                            //field[29]
  //Via Streets                                                                                                       //field[30]
  //Via Districts                                                                                                     //field[31]
  //Via Post Codes                                                                                                    //field[32]
  //----------------------------------------------------------------------------------
  updatebrandnotes('To Passenger Names (NI)');                                                                        //field[33]
  updatebrandnotes('To Mobiles (NI)');                                                                                //field[34]
  updatebrandnotes('To Telephones (NI)');                                                                             //field[35]
  updatebrandnotes('To Organisations (NI)');                                                                          //field[36]
  if (tofrom[0] ==  "FROM"){Single_HomeAddress();} else {Single_LocationAddress();}
  //----------------------------------------------------------------------------------
  //To Building                                                                                                       //field[37]
  //To House Number (NI)                                                                                              //field[38]
  //To Street                                                                                                         //field[39]
  //To District                                                                                                       //field[40]
  //To Post Code                                                                                                      //field[41]
  //----------------------------------------------------------------------------------
  updatebrandnotes(document.getElementById('sngljny_deparr_hours').value + ':' + document.getElementById('sngljny_deparr_mins').value);                                                                                                               //field[42]
  updatebrandnotes('Flight Checkin Time (NI)');                                                                       //field[43]
  updatebrandnotes(document.getElementById('sngljny_train_number').value);                                            //field[44]
  updatebrandnotes('Flight Location (NI)');                                                                           //field[45]
  updatebrandnotes('Booking Type : ' + document.getElementById('booking_type').value + '~' +  Encoded_Notes());       //field[46]
  updatebrandnotes(document.getElementById('client_email').value);                                                    //field[47]
 }
//====================================================================================
function Return_LocationAddress()
 {
  updatebrandnotes('');
  updatebrandnotes('From House Number (NI)');
  updatebrandnotes('');
  updatebrandnotes(document.getElementById('retnjny_location').value);
  updatebrandnotes('');
 }
//====================================================================================
function Return_HomeAddress()
 {
  updatebrandnotes(document.getElementById('retnjny_address_line_1').value); 
  updatebrandnotes('From House Number (NI)');
  updatebrandnotes(document.getElementById('retnjny_address_line_2').value);
  updatebrandnotes(document.getElementById('retnjny_address_district').value);
  updatebrandnotes(document.getElementById('retnjny_address_postcode').value);
 }
//====================================================================================
function Return_ViaAddresses()
 {
  var adrline1 = '';	 
  var adrhsn = '~~~~~';	 
  var adrline2 = '';	 
  var adrdis = '';	 
  var adrptc = '';	
  var i = 0;	
  for (i=1;i<6;i=i+1)
   {
    adrline1 = adrline1 +  document.getElementById('iprjdvia' + i + 'adr_line_1').value + '~';
    adrline2 = adrline2 +  document.getElementById('iprjdvia' + i + 'adr_line_2').value + '~';
    adrdis = adrdis +  document.getElementById('iprjdvia' + i + 'adrdis').value + '~';
    adrptc = adrptc +  document.getElementById('iprjdvia' + i + 'adrptc').value + '~';
   }
  adrline1 = adrline1 +  document.getElementById('iprjdvia' + i + 'adr_line_1').value;
  adrline2 = adrline2 +  document.getElementById('iprjdvia' + i + 'adr_line_2').value;
  adrdis = adrdis +  document.getElementById('iprjdvia' + i + 'adrdis').value;
  adrptc = adrptc +  document.getElementById('iprjdvia' + i + 'adrptc').value;
  updatebrandnotes(adrline1);                                                                                        //field[28]
  updatebrandnotes(adrhsn);                                                                                          //field[29]
  updatebrandnotes(adrline2);                                                                                        //field[30]
  updatebrandnotes(adrdis);                                                                                          //field[31]
  updatebrandnotes(adrptc);                                                                                          //field[32]
 }
//====================================================================================
function TATS_HTML_Return_Journey_Details()
 {
  bookingrecord[0] = '';
  //document.getElementById('notes').value = '';
  
  updatebrandnotes(GetToDaysShortDayName());                                                                          //field[0]
  updatebrandnotes(GetNumericDate());                                                                                 //field[1]
  updatebrandnotes(GetTime());                                                                                        //field[2]
  updatebrandnotes(document.getElementById('client_name').value);                                                     //field[3]
  updatebrandnotes(GetPickupDay(document.getElementById('retnjny_pickup_date').value));                               //field[4]
  updatebrandnotes(document.getElementById('retnjny_pickup_date').value);                                             //field[5]
  updatebrandnotes(document.getElementById('retnjny_pickup_hours').value+':'+document.getElementById('retnjny_pickup_mins').value);                                                                                                                      //field[6]
  updatebrandnotes(document.getElementById('client_phone').value+'~'+document.getElementById('client_mobile').value)  //field[7]
  updatebrandnotes(document.getElementById('retnjny_npassengers').value);                                             //field[8]
  updatebrandnotes(document.getElementById('retnjny_vehicletype').value);                                             //field[9]
  updatebrandnotes('Public');                                                                                         //field[10]
  updatebrandnotes(document.getElementById('payment_method').value);                                                  //field[11]
  updatebrandnotes('');                                                                                               //field[12]
  updatebrandnotes(document.getElementById('client_name').value);                                                     //field[13]
  updatebrandnotes(document.getElementById('client_email').value);                                                    //field[14]
  updatebrandnotes('From Passenger Names (NI)');                                                                      //field[15]
  updatebrandnotes('From Mobiles (NI)');                                                                              //field[16]
  updatebrandnotes('From Telephones (NI)');                                                                           //field[17]
  updatebrandnotes('From Organisations (NI)');                                                                        //field[18]
  var tofrom = new Array();
  tofrom = document.getElementById('retnjny_type').value.split(' ');
  tofrom[0] =  tofrom[0].trim();
  tofrom[0] =  tofrom[0].toUpperCase();
  if (tofrom[0] ==  "FROM"){Return_LocationAddress();}else {Return_HomeAddress();}
  //----------------------------------------------------------------------------------
  //From Buildings                                                                                                    //field[19]
  //From House Numbers (NI)                                                                                           //field[20]
  //From Streets                                                                                                      //field[21]
  //From Districts                                                                                                    //field[22]
  //From Post Codes                                                                                                   //field[23]
  //----------------------------------------------------------------------------------
  updatebrandnotes('Via Passenger Names (NI)');                                                                       //field[24]
  updatebrandnotes('Via Mobiles (NI)');                                                                               //field[25]
  updatebrandnotes('Via Telephones (NI)');                                                                            //field[26]
  updatebrandnotes('Via Organisations (NI)');                                                                         //field[27]
  //----------------------------------------------------------------------------------
  Return_ViaAddresses();
  //Via Buildings                                                                                                     //field[28]
  //Via House Numbers (NI)                                                                                            //field[29]
  //Via Streets                                                                                                       //field[30]
  //Via Districts                                                                                                     //field[31]
  //Via Post Codes                                                                                                    //field[32]
  //----------------------------------------------------------------------------------
  updatebrandnotes('To Passenger Names (NI)');                                                                        //field[33]
  updatebrandnotes('To Mobiles (NI)');                                                                                //field[34]
  updatebrandnotes('To Telephones (NI)');                                                                             //field[35]
  updatebrandnotes('To Organisations (NI)');                                                                          //field[36]
  if (tofrom[0] ==  "FROM"){Return_HomeAddress();} else {Return_LocationAddress();}
  //----------------------------------------------------------------------------------
  //To Building                                                                                                       //field[37]
  //To House Number (NI)                                                                                              //field[38]
  //To Street                                                                                                         //field[39]
  //To District                                                                                                       //field[40]
  //To Post Code                                                                                                      //field[41]
  //----------------------------------------------------------------------------------
  updatebrandnotes(document.getElementById('retnjny_deparr_hours').value + ':' + document.getElementById('retnjny_deparr_mins').value);                                                                                                               //field[42]
  updatebrandnotes('Flight Checkin Time (NI)');                                                                       //field[43]
  updatebrandnotes(document.getElementById('retnjny_train_number').value);                                            //field[44]
  updatebrandnotes('Flight Location (NI)');                                                                           //field[45]
  updatebrandnotes('Booking Type : ' + document.getElementById('booking_type').value + '~' + Encoded_Notes());        //field[46]
  updatebrandnotes(document.getElementById('client_email').value);                                                    //field[47]
 }
//====================================================================================
function dispbkginHTML()
 {
  var alertmsg = '';
  alertmsg = alertmsg + 'File: booking_emailbody_tats.js\n';
  alertmsg = alertmsg + 'Function: dispbkginHTML()\n';
  alertmsg = alertmsg + 'TATS: display the booking in HTML\n';
  alertmsg = alertmsg + 'only Single journey implemented.\n';
  alertmsg = alertmsg + 'TATS switchable.';
  
  //alert(alertmsg);
 
  var bt = document.getElementById('booking_type').value;
  bt = bt.trim();
  bt = bt.toUpperCase();
  if(bt=='SINGLE'){TATS_HTML_Single_Journey_Details();}
  else {TATS_HTML_Return_Journey_Details();}
  
  //alert(bookingrecord[0]);
 
  EMailDisp(0);
 
 }
//====================================================================================
 
