// Event Calendar
// copyright Stephen Chapman, 10th June 2006, 30th October 2006

var tb = 'b'; // top or bottom (t or b)
var headbg = '#cccccc';  // table heading background colour
//var todaybg = '#F5EBD2'; // current selected date background colour
var todaybg = '#00FF33'; // current selected date background colour
var textclr = '#000000'; // text colour
//var linkclr = '#73086A'; // link text colour
var linkclr = '#0000FF'; // link text colour
var noMessage =  'No event messages to display for today'; // message to display when no entry in array

var dA = new Array(); var x = 0;
// first 8 characters in ccyymmdd format for single date events
// first 8 characters in 0000mmdd format for every year events
//dA[x++] = "00000101 New Year";
//dA[x++] = "00000214 Valentine's day";

dA[x++] = "20110801 <a href='http://www.cuhk.edu.hk/clear/pointer/ipl.html'>Improving Postgraduate Learning</a>";
dA[x++] = "20110802 <a href='http://www.cuhk.edu.hk/clear/pointer/ipl.html'>Improving Postgraduate Learning</a>";
dA[x++] = "20110803 <a href='http://www.cuhk.edu.hk/clear/pointer/ipl.html'>Improving Postgraduate Learning</a>";
dA[x++] = "20110804 <a href='http://www.cuhk.edu.hk/clear/pointer/ipl.html'>Improving Postgraduate Learning</a>";
dA[x++] = "20110805 <a href='http://www.cuhk.edu.hk/clear/pointer/ipl.html'>Improving Postgraduate Learning</a>";
dA[x++] = "20110829 <a href='http://www.cuhk.edu.hk/clear/pointer/seminar.html'>Professional Development Course (PDC) - Becoming an Excellent Teacher (in English)/(in Cantonese)</a>";
dA[x++] = "20110830 <a href='http://www.cuhk.edu.hk/clear/pointer/seminar.html'>Professional Development Course (PDC) - Becoming an Excellent Teacher (in English)/(in Cantonese)</a>";
dA[x++] = "20110831 <a href='http://www.cuhk.edu.hk/clear/pointer/seminar.html'>Professional Development Course (PDC) - Becoming an Excellent Teacher (in English)/(in Cantonese)</a>";
dA[x++] = "20110901 <a href='http://www.cuhk.edu.hk/clear/pointer/seminar.html'>Professional Development Course (PDC) - Becoming an Excellent Teacher (in English)/(in Cantonese)</a>";
dA[x++] = "20110902 <a href='http://www.cuhk.edu.hk/clear/pointer/seminar.html'>Professional Development Course (PDC) - Becoming an Excellent Teacher (in English)/(in Cantonese)</a>";
dA[x++] = "20110905 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-01.htm'>Quality Assurance and Student Centred Learning – can QA be a tool that helps shifting the paradigm?</a>";
dA[x++] = "20110906 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-02.htm'>Teaching for Learning</a>";
dA[x++] = "20110909 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-03.htm'>A Framework for Understanding Issues in Assessment</a>";
dA[x++] = "20110914 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-04.htm'>Using your Teaching to Get Promoted at CUHK</a>";
dA[x++] = "20110916 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-05.htm'>Evaluating your Teaching</a>";
dA[x++] = "20110920 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-06.htm'>Power of Voice</a>";
dA[x++] = "20110923 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-07.htm'>New Teaching and Learning Opportunities on Mobile Devices</a>";
dA[x++] = "20110927 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-08.htm'>Understanding Student Characteristics</a>";
dA[x++] = "20110928 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-09.htm'>Using Feedback to Support Learning</a>";
dA[x++] = "20111007 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-10.htm'>Active Learning Strategies To Teach Critical Thinking</a>";
dA[x++] = "20111011 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-11.htm'>Facilitating In-class Small Group Discussion</a>";
dA[x++] = "20111012 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-12.htm'>Turning Your Lectures into Video-clips: the Care-free Echo 360 system</a>";
dA[x++] = "20111018 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-13.htm'>Peer & Group Assessment</a>";
dA[x++] = "20111021 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-14.htm'>Teaching for Learning</a>";
dA[x++] = "20111026 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-15.htm'>Using Clickers</a>";
dA[x++] = "20111101 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-16.htm'>A Framework for Understanding Issues in Assessment</a>";
dA[x++] = "20111104 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-17.htm'>Evaluating your Teaching</a>";
dA[x++] = "20111115 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-18.htm'>Tips on Publishing Work in T&L</a>";
dA[x++] = "20111116 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-19.htm'>Dealing with Student Diversity</a>";
dA[x++] = "20111118 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-20.htm'>The Power of Voice</a>";
dA[x++] = "20111122 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-21.htm'>Blackboard Learn Series: Multimedia and Web 2.0 Tools in One Place</a>";
dA[x++] = "20111123 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-22.htm'>Teacher as Leader & Supervisor</a>";
dA[x++] = "20111124 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-28.htm'>Women in Science</a>";
dA[x++] = "20111125 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-23.htm'>A Smorgasbord of Ideas for active learning III: CUHK teachers sharing their experiences on using Web 2.0 tools for teaching and learning</a>";
dA[x++] = "20111128 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-29.htm'>Workshop on Supervisory Skills</a>";
dA[x++] = "20111129 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-24.htm'>Teaching for Learning</a>";
dA[x++] = "20111202 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-25.htm'>A Framework for Understanding Issues in Assessment</a>";
dA[x++] = "20111206 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-26.htm'>Evaluating your Teaching</a>";
dA[x++] = "20111214 <a href='http://www.cuhk.edu.hk/clear/new/1112-s1-27.htm'>Assessment – Devising Criteria for Different Types of Assessment</a>";

dA[x++] = "20120202 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-01.htm'>Teaching for Learning</a>";
dA[x++] = "20120207 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-02.htm'>A Framework for Understanding Issues in Assessment</a>";
dA[x++] = "20120208 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-03.htm'>Evaluating your Teaching</a>";
dA[x++] = "20120216 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-04.htm'>New Teaching and Learning Opportunities on Mobile Devices</a>";
dA[x++] = "20120223 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-05.htm'>Questioning techniques in class</a>";
dA[x++] = "20120228 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-06.htm'>Peer & Group Assessment</a>";
dA[x++] = "20120308 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-07.htm'>New CUHK eLearning system Series: functions that lead to convenience and efficiency</a>";
dA[x++] = "20120313 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-08.htm'>Teaching for Learning</a>";
dA[x++] = "20120322 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-09.htm'>Evaluating your Teaching</a>";
dA[x++] = "20120329 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-10.htm'>Understanding Student Characteristics</a>";
dA[x++] = "20120412 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-11.htm'>Teaching for Learning</a>";
dA[x++] = "20120420 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-12.htm'>A Smorgasbord of Ideas for Active Learning IV: Classroom Activities that Make Learning Active</a>";
dA[x++] = "20120424 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-13.htm'>New CUHK eLearning System Series: Multimedia and Web 2.0 Tools in One Place</a>";
dA[x++] = "20120504 <a href='http://www.cuhk.edu.hk/clear/new/1112-s2-14.htm'>A Smorgasbord of Ideas for Active Learning V: Lecture recording in practice</a>";

// permission is granted to use this javascript provided that the below code is not altered
var pageLoaded = 0; window.onload = function() {pageLoaded = 1;}
function loaded(i,f) {if (document.getElementById && document.getElementById(i) != null) f(); else if (!pageLoaded) setTimeout('loaded(\''+i+'\','+f+')',100);
}
function monthlength(month,year) {var dd = new Date(year, month, 0);return dd.getDate();}
var moy = ['January','February','March','April','May','June','July','August','September','October','November','December'];var today = new Date();var selDate = today.getFullYear()+getmmdd(today.getMonth()+1,today.getDate());
function dispCal(yy,mm) {if (mm < 0 || mm > 12) {alert('month must be between 1 and 12'); return false;} if (yy != 0 && (yy < 1901 || yy > 2100)) {alert('year must be after 1900 and before 2101'); return false;} 
var dow = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']; var calendar = new Date();  var today = calendar.getDate(); calendar.setDate(1); 
if (yy > 1900) calendar.setFullYear(yy); 
if (mm > 0) calendar.setMonth(mm - 1);
var yy = year = calendar.getFullYear(); var month = calendar.getMonth(); calendar.setDate(today); var weekday = calendar.getDay(); var daysInMonth = monthlength(month+1,year); 
if (document.getElementById) {var mmb = month;  mm = month + 1; var yya = yyb = yy; if (mmb <1) {mmb += 12; yyb--;} var mma = month + 2; if (mma > 12) {mma -= 12; yya++;} var yb = yy -1; var ya = yy +1; 
var hilite_start = '<td width="30" style="background:' + todaybg + '" align="center"><b>'; var td_start = '<td width="30" align="center">';
var cal = '<div id="cal"><div style="border:1pt solid #cccccc;height:150px;width:190px"><table border="0" cellspacing="0" cellpadding="0" width="188"><tr style="background:' + headbg + '"><td width="18"><a href="#" onclick="if (cala = dispCal('+yb+','+mm+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}"><<</a></td><td width="18" align="center"><a href="#" onclick="if (cala = dispCal('+yyb+','+mmb+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}"><</a></td><td colspan="3" style="background:' + headbg + '" align="center" width="136"><b>' + moy[month]  + ' ' + year + '<\/b><\/td><td align="center" width="18"><a href="#" onclick="if (cala = dispCal('+yya+','+mma+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}">></a></td><td align="right" width="18"><a href="#" onclick="if (cala = dispCal('+ya+','+mm+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}">>></a></td><\/tr><tr>';
for(dex=0; dex < 7; dex++) {cal += td_start + dow[dex] + '</td>';} cal += '<\/tr><tr>'; var day2 = today; for (dex = today; dex > 6; dex -=7) day2 = dex; weekday -= day2 - 1; while (weekday < 0) weekday += 7; for(dex=0; dex < weekday; dex++) cal += td_start + ' <\/td>'; for(dex=1; dex <= daysInMonth; dex++) {if(weekday == 7) {cal += '</tr><tr>'; weekday = 0;} 
if(selDate==year+getmmdd(month+1,dex)) 
	cal += hilite_start +'<span '+clickDate(dex,month,year) + '>'+ dex + '<\/span><\/b><\/td>'; 
else cal += td_start + '<span '+clickDate(dex,month,year) + '>' + dex + '<\/span><\/td>'; weekday += 1;}
for(dex=weekday; dex < 7; dex++) cal += td_start + ' <\/td>'; cal += '<\/tr><\/table><\/div>';


//cal += '<table border="0" cellspacing="0" cellpadding="2" width="190"><tr><td><a href="#" onclick="if (cala = dispCal('+yb+','+mm+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}"><<</a></td><td><a href="#" onclick="if (cala = dispCal('+yyb+','+mmb+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}"><</a></td><td align="right"><a href="#" onclick="if (cala = dispCal('+yya+','+mma+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}">></a></td><td align="right"><a href="#" onclick="if (cala = dispCal('+ya+','+mm+')) {document.getElementById(\'cal\').innerHTML = cala; return false;}">>></a></td></tr></table>';
} else {cal += '<div> </div>';} cal += '</div>'; return cal;}
function start() {var x = '<div id="calDate" style="border:1pt solid #cccccc;width:190px"><\/div>'; var y = ''; if (tb == 't') y = x + dispCal(0,0); else y = dispCal(0,0) + x; document.getElementById('calendar').innerHTML = y; ev();}
loaded('calendar',start);
function clickDate(day, month, year) {var ct = nextDate(year + getmmdd(month+1,day));if (ct == '') ct = nextDate('0000' + getmmdd(month+1,day));if (ct == '') return 'style="color:'+textclr+'"'; else return 'style="font-weight:bold;cursor:pointer;color:'+linkclr+'" onclick="selDate = '+year+ getmmdd(month+1,day)+'; isDate(' + day + ',' + month + ',' + year + ');return false;"';}function isDate(dayVal,monthVal,yearVal) {var ct = nextDate(yearVal + getmmdd(monthVal+1,dayVal));if (ct == '') ct = nextDate('0000' + getmmdd(monthVal+1,dayVal));if (ct == '') ct = noMessage;document.getElementById('calDate').innerHTML = convertD(selDate) + ':<br \/>' +ct; return false;}function nextDate(yymmdd) {var x = dA.length;for (var i = 0; i < x; i++) {if (dA[i].substr(0,8) == yymmdd) return dA[i].substr(8);}return '';}function getmmdd(mm,dd) {return (mm > 9 ? '' + mm : '0' + mm) + (dd > 9 ? dd : '0' + dd);}
//alert('day= '+day+' mon= '+month+' day= '+day);
function convertD(date) {date=''+date; var out; var year; var month; var day; year=date.substring(0,4); month=date.substring(4,6); if(month.charAt(0)=='0'){month=month.substring(1,2);} month=moy[parseInt(month)-1]; day=date.substring(6,8);  out=day+' '+month+' '+year; return out;}
function ev() {var ct = nextDate(selDate);var ct = nextDate(selDate);if (ct == '') ct = nextDate('0000' + selDate.substr(4));if (ct == '') ct = noMessage; document.getElementById('calDate').innerHTML = convertD(selDate) + ':<br \/> ' +ct;}

