/***** This is the Code to get today's date ******/

Date.prototype.getFullYear = getFullYear;
Date.prototype.getActualMonth = getActualMonth;
Date.prototype.getActualDay = getActualDay;
Date.prototype.getCalendarMonth = getCalendarMonth;

	function getFullYear() {
		var n = this.getYear();
		if (n < 2000) { n += 1900;}
		return n;
	}

	function getActualMonth() {
		var n = this.getMonth();
		n += 1;
		return n;
	}

	function getActualDay() {
		var n = this.getDate();
		if (n<10) {
			n = "0" + n;
		}
		return n;
	}


	function getCalendarMonth() {
		var n = this.getMonth() + 1;
		if (n < 10) {
			n = "0" + n;
		}
		return n;
	}

var today = new Date();
var fullDate = today.getFullYear().toString() + today.getCalendarMonth().toString() + today.getActualDay().toString();
fullDate = parseInt(fullDate);

/********** Date code ends ***********/

eventInstituition_array = new Array();
eventDates_array = new Array();
eventSpeaker_array = new Array();
eventTitle_array = new Array();
eventLink_array = new Array();

function decipherDate(date_str) {
	date_str = date_str + ''; // Convert number to string
	year_str = date_str.substring(0,4);
	month_str =  date_str.substring(4,6);
	if (month_str.charAt(0) == "0") {
		month_str = month_str.substring(1,2);
	}
    month = parseInt(month_str);
	months_array = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	month_str = months_array[month - 1];
	day_str =  date_str.substring(6,8);
	if (day_str.charAt(0) == "0") {
		day_str = day_str.substring(1,2);
	}
	return month_str + " " + day_str + ", " + year_str;
}

function insertEvent() {
	var counter = 0;
	for (i=0;i<eventInstituition_array.length;i++) {
		if (eventDates_array[i] >= fullDate) {
			insertText(i);
			break;
		}
	}
}

function seminarList() {
	for (i=0;i<eventInstituition_array.length;i++) {
		insertSeminarLine(i);
	}
}

function addEvent(eventDates,eventTitle,eventSpeaker,eventInstitution,eventLink) {
	eventDates_array.push(eventDates);
	eventSpeaker_array.push(eventSpeaker);
	eventInstituition_array.push(eventInstitution);
	eventTitle_array.push(eventTitle);
	eventLink_array.push(eventLink);
}

function insertText(item) {
	document.write('<h3>' + eventTitle_array[item] + '<\/h3>');
	document.write('<p>' + decipherDate(eventDates_array[item]) + "<br \/><strong>Speaker: " + eventSpeaker_array[item] + "<\/strong><br \/>" + eventInstituition_array[item] + '<\/p>');
	document.write('<p align="right"><a href="' + eventLink_array[item] + '">more info &gt;<\/a><\/p>');
}
function insertSeminarLine(item) {
	document.write('<div class="seminarList">');
	document.write('<h3><a href="' + eventLink_array[item] + '">' + eventTitle_array[item] + '<\/a><\/h3>');
	document.write('<p><b>' + eventSpeaker_array[item] + '</b> - ');
	document.write(eventInstituition_array[item] + '<br \/>');
	document.write('<i>'  + decipherDate(eventDates_array[item]) + '<\/i><\/p>');
	document.write('<\/div>');
}
/*
TO ADD AN EVENT CUT-AND-PASTE THE FOLLOWING LINE OF
CODE FOR EACH EVENT TO THE END OF THIS JS FILE
(Note: Date format is YYYYMMDD):

addEvent(20070911,"Title","Speaker Name","Institution","ABSOLUTE_URL");
*/

addEvent(20081009,"Kinesin and Dynein Regulate Stress Granule Dynamics","Graciela L. Boccaccio Ph.D. ","Fundaci&oacute;n Instituto Leloir, Buenos Aires, Argentina","http://www.anatomy.uic.edu/seminars/20081009-Boccaccio.html");
addEvent(20081021,"Uncoupling of the phosphatase activity of Ci-VSP produces a deeper relaxation of the Voltage Sensing Domain","Carlos Villalba-Galea, Ph.D","University Of Chicago","http://www.anatomy.uic.edu/seminars/20081021-Villalba-Galea.html");
addEvent(20081028,"Developing the anatomical model of the calyx ending.  A Works in Progress seminar","Anna Lysakowski, PhD","University Of Illinios at Chicago","http://www.anatomy.uic.edu/seminars/20081028-Lysakowski.html");
addEvent(20081125,"Structural diversity of amyloid oligomers","Charles G. Glabe, Ph.D.","University Of California Irvine","http://www.anatomy.uic.edu/seminars/20081125-Glabe.html");
addEvent(20081209,"Modulating brain plasticity in Alzheimer's disease","Orly Lazarov, Ph.D.","University of Illinois at Chicago","http://www.anatomy.uic.edu/seminars/20081209-Lazarov.html");
addEvent(20090203,"Ankyrins: Molecular keys to the code for establishing specialized membrane domains","Vann Bennett, M.D.,Ph.D.","Duke University Medical Center","http://www.anatomy.uic.edu/seminars/20090203-Bennett.html");
addEvent(20090220,"Molecular Physiology of the hair cell ribbon synapse","Tobias Moser, M.D.","University of Goettingen","http://www.anatomy.uic.edu/seminars/20090220-Moser.html");
addEvent(20090224,"Cytoskeletal Regulation of Myelin Formation","Carmen Melendez, Ph.D.","Hunter College","http://www.anatomy.uic.edu/seminars/20090224-Melendez.html");
addEvent(20090414,"Evolution and Physiological Ligand Selectivity of SH2 Domains","Piers Nash, Ph.D.","University of Chicago","http://www.anatomy.uic.edu/seminars/20090414-Nash.html");
addEvent(20090421,"Lipid targets for Alzheimer's disease","Brett Garner, Ph.D.","Prince of Wales Medical Research Institute","http://www.anatomy.uic.edu/seminars/20090421-Garner.html");
addEvent(20090505,"The von Hippel-Lindau Tumor Suppressor Protein: Insights into Oxygen Sensing and Cancer","William G Kaelin Jr, Ph.D.","Harvard Medical School","http://www.anatomy.uic.edu/seminars/20090505-Kaelin.html");
addEvent(20090519,"Insights into Neurodegeneration from Genetic Models of ALS","Larry Hayward, M.D., Ph.D.","UMass Medical School","http://www.anatomy.uic.edu/seminars/20090519-Hayward.html");
addEvent(20090602,"Neural Stem Cells for the Treatment of Alzheimer's Disease","Frank M. LaFerla, Ph.D. ","University Of California Irvine","http://www.anatomy.uic.edu/seminars/20090602-LaFerla.html");
addEvent(20090605,"Synaptic Noise and the Stem-Cell Approach<","D. Kent Morest, M.D.","Univ. of Connecticut Health Center","http://www.anatomy.uic.edu/seminars/20090605-Morest.html");
