function leaveConfirm (url) {
	var proceed = confirm("Proceed to this session?");
	if (proceed) {
		window.open(url, "_self");
		//self.location.replace(url);
	}
}

function cancel_booking (url) {
	var proceed = confirm("Proceed to cancel your booking?");
	if (proceed) {
		url = url + "?cancel=1";
		window.open(url, "_self");
		//self.location.replace(url);
	}
}


function pad(number,length) {
    var str = '' + number;
    while (str.length < length)
        str = '0' + str;
    return str;
}

var clockID = 0;
function UpdateClock( year, month, date, day, hour, min, sec ) {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }
	
	var tDate = new Date();
	tDate.setFullYear (year, month, date);	
	tDate.setHours (hour);
	tDate.setMinutes (min);
	tDate.setSeconds (sec);
	
	year = tDate.getFullYear();
	month = tDate.getMonth();
	date = tDate.getDate();
	day = tDate.getDay();	
	hour = tDate.getHours();
	min = tDate.getMinutes();
	sec = parseInt (tDate.getSeconds()) + 1;

	var months=new Array(12);
	months[0] = "Jan";
	months[1] = "Feb";
	months[2] = "Mar";
	months[3] = "Apr";
	months[4] = "May";
	months[5] = "Jun";
	months[6] = "Jul";
	months[7] = "Aug";
	months[8] = "Sep";
	months[9] = "Oct";			
	months[10] = "Nov";
	months[11] = "Dec";		

	var weekdays=new Array(7);
	weekdays[0]="Sun";
	weekdays[1]="Mon";
	weekdays[2]="Tue";
	weekdays[3]="Wed";
	weekdays[4]="Thu";
	weekdays[5]="Fri";
	weekdays[6]="Sat";

   document.theClock.theTime.value = "" 
   									+ pad (date, 2) + "-" 
   									+ months[month] + "-" 
   									+ year + " " 
   									+ "(" + weekdays[day] + ") "
                                   + pad (hour, 2) + ":" 
                                   + pad (min, 2) + ":" 
                                   + pad (sec, 2);
   clockID = setTimeout("UpdateClock(" + year + "," + month + "," + date + "," + day + "," + hour + "," + min + "," + sec + ")", 1000);
}

function StartClock( year, month, date, day, hour, min, sec ) {
   clockID = setTimeout("UpdateClock(" + year + "," + month + "," + date + "," + day + "," + hour + "," + min + "," + sec + ")", 500);
}

function KillClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }
}
