function showCourseSeason(theCourse) {
// alert("Showing Course Season for "+ theCourse + ".");	
document.getElementById('courseSeasonMessage').style.display = "block";
}
function checkParticipantTotal() {
	var myCount = document.getElementById('particiTotalNew').innerHTML;

	if(1*myCount > 0) {
	document.getElementById('submitBooking').innerHTML = '<input class="input" type="submit" name="submitMedical" value="Complete Booking >>" style="width:175px;"/>';
	}
}


function closeiFrame(postcode,course,cdate) {
alert('Updating Booking');
document.getElementById('lbMain').style.display='none';
document.getElementById('lbOverlay').style.display='none';
updateAJAX('updateParticipants','otherparts','course='+course + "&postcode="+postcode + "&date="+cdate);
checkParticipantTotal();
}
function updateFrame(postcode,course,cdate) {
updateAJAX('updateParticipants','otherparts','course='+course + '&postcode='+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 showNews(newsid) {
new Effect.BlindUp('newsArticle', {duration: 1});
setTimeout('loadContent(\'' + newsid + '\',\'newsArticle\')',1000);
}
function showSessions(course,courseDate) {
var mysuffix = "course=" + course + "&courseDate=" + courseDate;
updateAJAX('getSessions','dynamicCalendar',mysuffix);
}


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 loadContent(myfile,targetDiv) {
  url="./media/news/news_" + myfile + ".inc";
  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="./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('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('booking_findtimes','slotList','kitid=' + mykit + '&date=' + mydate);
}
