function welcome() {
document.write("<!-- Welcome to the Dev Site -->");
}

function accent(theButton,theMode) {
buttonToToggle = document.getElementById('button'+theButton);
	if(theMode>0) {
	buttonToToggle.style.backgroundPosition = "right -40px";
	} else {
	buttonToToggle.style.backgroundPosition = "right 1px";
	}
}

function startBooking(course) {
var thisCourse = course;
var thisDate = document.getElementById("start_" + thisCourse).value;
	if(thisDate!="0000-00-00") {
	// alert('Booking a Course for course id of: ' + thisCourse + " on " + thisDate);
	window.location = "/book-online.php?course=" + thisCourse + "&date=" + thisDate;
	} else {
	alert('Please choose a date for this course.');
	}
}

function closeiFrame(postcode,course,cdate) {
// alert('Updating Booking');
Lightview.hide()
updateAJAX('updateParticipants','otherparts','course='+course + "&pcc="+postcode + "&date="+cdate);
checkParticipantTotal();
}
function updateFrame(postcode,course,cdate) {
updateAJAX('updateParticipants','otherparts','course='+course + '&pcc='+postcode + '&date='+cdate);
}

function updateParts() {
var newname = document.getElementById('fullname1').value;
document.getElementById('lead').innerHTML = "<li>" + newname + "</li>";
}

function notAvailable(theDate) {
alert("Sorry, but the course running on " + theDate + " is fully booked.\nPlease choose another day or ring us to check for last-minute cancellations.");
}

function updateAJAX(myfile,targetDiv,mysuffix) {
  url="./assets/includes/" + myfile + ".php?" + mysuffix;
  document.getElementById(targetDiv).innerHTML = ' Fetching data...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {loadcontentDone(url, targetDiv);};
    req.open("GET", url, true);
    req.send("");
  }
  new Effect.BlindDown(targetDiv, {duration: 0.5});

}




function loadcontentDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
   	thisHtml = req.responseText;
    document.getElementById(target).innerHTML = thisHtml;
    if(target=="otherparts") {checkParticipantTotal();}
    } else {
      document.getElementById(target).innerHTML=" Sorry - Data Retrieval Error:\n"+ req.status + "\n" +url + "\n".req.statusText;
    }
  }
}


function loadPage(myfile,targetDiv,mysuffix) {
  url="/assets/includes/" + myfile + ".php?" + mysuffix;
  document.getElementById(targetDiv).innerHTML = ' Fetching data...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {loadcontentDone(url, targetDiv);};
    req.open("GET", url, true);
    req.send("");
  }
  new Effect.BlindDown(targetDiv, {duration: 0.5});

}

function findKitAvailable() {
var mysport = document.tickerform.sportsSubscribed.value;
var mydate = document.tickerform.date.value;
// alert ('I will check for ' + mysport + " & " + mydate);
loadPage('platinum_booking_findkit','kitlist','sport=' + mysport + '&date=' + mydate);
}

function findStartTimes() {
var mysport = document.tickerform.sportsSubscribed.value;
var mykit = document.tickerform.kitid.value;
var mydate = document.tickerform.date.value;
// alert ('I am looking for Available slots on ' + mydate + ' for kitid=' + mykit);
// loadPage into slotList with kitid and Date
loadPage('platinum_booking_findtimes','slotList','kitid=' + mykit + '&date=' + mydate);
}
