/* bus - rail - bus ticket adviser */
var url01 = "https://kiosk.iristickets.co.uk/kiosk?oneticket&item_type=3&duration=";

dur = new Array();
dur[""] = "";
dur[0] = "A week pass";
dur[1] = "A month pass";
dur[2] = "An annual ticket";

url_dur = new Array("1WEEK", "4WEEK", "1YEAR");

function checkresult() {
  checkstart();
  ticketselected();
  }

function checkstart() {
  /* specify ticket type by starting station */
  if (loc1 !="X") {
    zone = stations[loc1][0];
    line = zones[zone][3];
    document.forms.chooseticket.mapresult.value = zone + " - " + line
    }
  else {
    document.forms.chooseticket.mapresult.value = ""; 
    document.forms.chooseticket.textarea.value = "";
    }
  }

function ticketselected() {
  /* specify ticket by station and duration */
  tickettype = document.forms.chooseticket.tickettype.value;
  if (loc1!="X" && tickettype!="X") {
    duration = dur[tickettype]; 
    zone = stations[loc1][0];
    line = zones[zone][3];
    price = String.fromCharCode(163) +zones[zone][tickettype].toFixed(2);
    preposition = (zone=="J065") ? ' in ' : ' on ';
    result = duration + ", zone " + zone + preposition + "the " + line + " (" + price + ")";
    }
  else {
    result = "";
    }
  document.forms.chooseticket.textarea.value = result;
  }

function buy(screen) {
  window.open("bus_rail.pdf");  
  }

function buy_from_kiosk(scr) {
  /* open kiosk in separate window in window dims (x,y) */
  tickettype = document.forms.chooseticket.tickettype.value;
  duration = url_dur[tickettype]; 
  url = url01 + duration;
  x = scr.width * 0.75;
  y = scr.height * 0.75;
  window.open(url, "", "width="+x+",height="+y);
  }
