
 function addLoadEvent(func) {
  var oldonload = window.onload;
   if (typeof window.onload != 'function') {
    window.onload = func;
   } else {
    window.onload = function() {
    oldonload();
    func();
   }
  }
 }

 var xmlreqs = new Array();
 var theDiv = '';

 function CXMLReq(type,xmlhttp,theDiv) {
  this.type = type;
  this.xmlhttp = xmlhttp;
  this.theDiv = theDiv;
 }

 function xmlreqGET(url,theDiv) {
  var xmlhttp = false;
  var theDiv = theDiv;
  if (window.XMLHttpRequest) {
   xmlhttp=new XMLHttpRequest();
   xmlhttp.onreadystatechange = xmlhttpChange;
   xmlhttp.open("GET",url,true);
   xmlhttp.send(null);
  } else if (window.ActiveXObject) {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   if (xmlhttp) {
    xmlhttp.onreadystatechange = xmlhttpChange;
    xmlhttp.open("GET",url,true);
    xmlhttp.send();
   }
  }
  var xmlreq = new CXMLReq('', xmlhttp, theDiv);
  xmlreqs.push(xmlreq);
 }

 function xmlhttpChange() {
  if (typeof(window['xmlreqs']) == "undefined") return;
   for (var i=0; i < xmlreqs.length; i++) {
    if (xmlreqs[i].xmlhttp.readyState == 4) {
     if (xmlreqs[i].xmlhttp.status == 200 || xmlreqs[i].xmlhttp.status == 304) {
      handle_response(xmlreqs[i].theDiv, xmlreqs[i].xmlhttp);
      xmlreqs.splice(i,1); i--;
     } else {
      xmlreqs.splice(i,1); i--;
     }
    }
   }
 }

 function handle_response(theDiv,xmlhttp) {
  var thisResponse = xmlhttp.responseText;
  if (theDiv != '') {
   document.getElementById(theDiv).innerHTML = thisResponse;
  }
 }

 function clearElement(element) {
  document.getElementById(element).value = '';
 }

 function createRequestObject() {
  var ro;
  var browser = navigator.appName;
  if (browser == "Microsoft Internet Explorer") {
   ro = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
   ro = new XMLHttpRequest();
  }
  return ro;
 }

 /* Calling Functions */

 function prodPic(p,n) {
   xmlreqGET('_ajax/prodpic.php?pid='+p+'&num='+n,'prodLeft'); 
 }

function updateBasket() {
 var o = document.getElementById('outsideuk').checked;
 var s = document.getElementById('seasonticket').checked;
 var seat = document.getElementById('seatNumber').value;

 window.open('index.php?do=GO_updatebasket&o='+o+'&s='+s+'&seat='+seat,'_self')
}

function toggleOutsideUK(subtotal,sid) {
 var o = document.getElementById('outsideuk');
 var d = document.getElementById('deldiv');
 var t = document.getElementById('totaldiv');

 if (o.checked) {
  var total = (parseFloat(subtotal)+7.5);
  d.innerHTML='&pound;7.50';
  t.innerHTML='&pound;'+total.toFixed(2);
  xmlreqGET('_ajax/delivery.php?sid='+sid+'&del=7.50','ajaxbin'); 
 } else {
  var total = (parseFloat(subtotal)+5);
  d.innerHTML='&pound;5.00';
  t.innerHTML='&pound;'+total.toFixed(2);
  xmlreqGET('_ajax/delivery.php?sid='+sid+'&del=5.00','ajaxbin'); 
 }

}

function toggleSeasonTicket(subtotal,sid) {
 var o = document.getElementById('outsideuk');
 var d = document.getElementById('deldiv');
 var t = document.getElementById('totaldiv');
 var s = document.getElementById('seasonticket');
 var seat = document.getElementById('seatNumber').value;
 var discount = 0;

 if (o.checked) {
  var total = (parseFloat(subtotal)+7.5);

  if (s.checked) {
   discount = ((total/100)*10);
   total = (total-discount);
  }

  d.innerHTML='&pound;7.50';
  t.innerHTML='&pound;'+total.toFixed(2);
  xmlreqGET('_ajax/delivery.php?sid='+sid+'&del=7.50','ajaxbin'); 
  //xmlreqGET('_ajax/seat.php?sid='+sid+'&seat='+seat,'ajaxbin'); 

 } else {
  var total = (parseFloat(subtotal)+5);

  if (s.checked) {
   discount = ((total/100)*10);
   total = (total-discount);
  }
  
  d.innerHTML='&pound;5.00';
  t.innerHTML='&pound;'+total.toFixed(2);
  xmlreqGET('_ajax/delivery.php?sid='+sid+'&del=5.00','ajaxbin'); 
  //xmlreqGET('_ajax/seat.php?sid='+sid+'&seat='+seat,'ajaxbin'); 

 }

}

function checkout(sid,e,p) {
 var s = '';
 var season = document.getElementById('seasonticket');
 if (season.checked) {
  s = document.getElementById('seatNumber').value;
 }
 window.open('https://secure.formoda.co.uk/tufc/?sid='+sid+'&e='+e+'&p='+p+'&s='+escape(s),'_self')
}

function updateSeat(sid) {
 seat = document.getElementById('seatNumber').value;
 xmlreqGET('_ajax/seat.php?sid='+sid+'&seat='+seat,'ajaxbin'); 
}