<!-- 
/*
****************************************************************************************************************
*					General javascript routines used with permission
*	Author:		Adrian Jones, woodsgood.ca
*	Date:			June 2007
****************************************************************************************************************
*/

function doemail(name,service) {
	var em=""+name+"@"+service+"";
	document.write('<a href="mailto:'+em+'">'+em+'</a>');
}

/*
****************************************************************************************************************
* 		init(): principle initiation of each page... displays all <div class="e"> (English) or <div class="f"> (French) 
*	 			  tags based on language 'cookie' value 
****************************************************************************************************************
*/

function init() {
	var t=(GetCookie("lang")=="true")?true:false;
	x=document.getElementsByTagName('div');	// get all <div> tags
   for(i=0;i<x.length;i++) {
   	if(x[i].className=="e") x[i].style.display=(t)?"none":"block";	// english
   	if(x[i].className=="f") x[i].style.display=(t)?"block":"none";	// french
   }
  	x=document.getElementsByTagName('span');	// get all <span> tags
   for(i=0;i<x.length;i++) {
   	if(x[i].className=="e") x[i].style.display=(t)?"none":"inline";	// english
   	if(x[i].className=="f") x[i].style.display=(t)?"inline":"none";	// french
   }

}

function getObject(name) {return (document.getElementById?document.getElementById(name):document.all?document.all[name]:document.layers?eval("document.layers[\"" + name + "\"]"):null);}

/*****************************************************************************************************************/
// "within-page" navigation; one <DIV> (of id "objid") is displayed while making previous DIV invisible.
var objDiv = null;										// old (or previous) DIV
function doShow(objid) {
	if (objDiv) objDiv.style.display="none";		// blank any DIV that is displayed
	objDiv=getObject(objid);							// get referenced object
	objDiv.style.display = "block";					// display it
}

var click=false;

function doNoShow(objid) {
		objDiv=getObject(objid);							// get referenced object
		objDiv.style.display = "none";					// hide it
}

function doJustShow(objid) {
	if (click) {
		click=false;
		getObject("rInfo").style.display="none";			// and hide it!
	} else {
		var tHed='<div class="t600"></div>';
		tHed  += '<div class="m600"><div style="padding:10px 30px 10px 10px;">';
		tHed  += '<div class="rInfoHed">'+getObject(objid).title+'</div>';	// create header with researcher's name
		var tFot='</div></div><div class="f600"></div>';
		var tDiv=getObject(objid).innerHTML;				// get all html within referenced object
		getObject("rInfo").innerHTML=tHed+tDiv+tFot;		// insert header and all html into the "rInfo" element
		getObject("rInfo").style.display="block";			// and display it!
		click=true;
	}
}

// toggles display of objref DIV (block/none) and image of objref IMG (minus/plus)
var oldobjref=null;
function doToggle(objref) {
	objid="t"+objref;objimg="i"+objref;
	objDivTog=getObject(objid);							// get referenced object
	objImgTog=getObject(objimg);						// get referenced image
	if(objref==oldobjref) {								// if the same object, then toggle DIV and IMG
		if(objDivTog.style.display!="block") {
			objDivTog.style.display="block";
			objImgTog.src="images/minus.gif";
		} else {
			objDivTog.style.display="none";
			objImgTog.src="images/plus.gif";
		}
	} else {		
		if(oldobjref) getObject("t"+oldobjref).style.display="none";	// if old DIV exists, hide it
		if(oldobjref) getObject("i"+oldobjref).src="images/plus.gif";	// if old IMG exists, reset to "+"
		objDivTog.style.display="block";								// display selected DIV
		objImgTog.src="images/minus.gif";								// show "-" image
	}
	oldobjref=objref;									// set old to new
}


/*
****************************************************************************************************************
* 		doQuick(ID): 	routine to display the research interest area of each researcher (based in ID), on mouse-over, 
* 		doClear(): 		routine to hide research interest area, on mouse-out
****************************************************************************************************************
*/

function doQuick(did) {
/*	var tHed='<div class="rInfoHed">'+getObject(did).title+'</div>';	// create header with researcher's name
	var tDiv=getObject(did).innerHTML;				// get referenced object
	var tTxt=tDiv.toLowerCase();						// convert all text to lower case (IE capitalizes all html tags)
	var x=tTxt.indexOf("research interests:");	// find position of "research interests:" text
	if (x<0) return;										// if not found, then don't continue
	var y=tTxt.lastIndexOf("<p>",x);					// find position of previous "<p>"...
	var z=tTxt.indexOf("</p>",y);z+=4;				// ...then position of matching "</p>"; increment to include it...
	getObject("rInfo").innerHTML=tHed+tDiv.slice(y,z);	// insert text (from "<p>...</p>") into the "rInfo" element
	getObject("rInfo").style.display="block";		// display it!
	*/
	click=false; 											//ADD
}

function doClear() {
//	if (!click) getObject("rInfo").style.display="none";		// hide it!
}

/*
****************************************************************************************************************
* 		doJimg(name): 	Journal image selection... 
*							if image is available, display it, otherwise blank image placeholder
****************************************************************************************************************
*/
function doJimg(ir)	{
	tI = getObject("jImg");
	if(ir!="") {
		tI.src="journals/"+ir+"";
		tI.style.display="block";
	} else {
		tI.style.display="none";
	}
}

//******************************************************************
//
//  Cookie Functions - "Night of the Living Cookie" Version (25-Jul-96)
//
//  Written by:  Bill Dortch, hIdaho Design <bdortch@hidaho.com>
//  The following functions are released to the public domain.
//
//******************************************************************

function doCookie(num) {
	var expdate = new Date (); 			// get current date //
	FixCookieDate (expdate);  				// Correct for Mac date bug - call only once for given Date object! //
	expdate.setTime (expdate.getTime() + (30 * 24 * 60 * 60 * 1000)); // im ms, 30 days from now //
	SetCookie("lang",num,expdate); 		// set the cookie
}

//
// "Internal" function to return the decoded value of a cookie
//
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
//
//  Function to correct for 2.x Mac date bug.  Call this function to
//  fix a date object prior to passing it to SetCookie.
//  IMPORTANT:  This function should only be called *once* for
//  any given date object!
//
function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}
//
//  Function to return the value of the cookie specified by "name".
//    name - String object containing the cookie name.
//    returns - String object containing the cookie value, or null if
//      the cookie does not exist.
//
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
	i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
return null;
}

//
//  Function to create or update a cookie.
//    name - String object containing the cookie name.
//    value - String object containing the cookie value.  May contain
//      any valid string characters.
//    [expires] - Date object containing the expiration data of the cookie.  If
//      omitted or null, expires the cookie at the end of the current session.
//    [path] - String object indicating the path for which the cookie is valid.
//      If omitted or null, uses the path of the calling document.
//    [domain] - String object indicating the domain for which the cookie is
//      valid. If omitted or null, uses the domain of the calling document.
//    [secure] - Boolean (true/false) value indicating whether cookie transmission
//      requires a secure channel (HTTPS).
//
//  To set a secure cookie for path "/myPath", that expires after the
//  current session, you might code:
//
//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
//
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

//  Function to delete a cookie. (Sets expiration date to start of epoch)
//    name -   String object containing the cookie name
//    path -   String object containing the path of the cookie to delete.  This MUST
//             be the same as the path used to create the cookie, or null/omitted if
//             no path was specified when creating the cookie.
//    domain - String object containing the domain of the cookie to delete.  This MUST
//             be the same as the domain used to create the cookie, or null/omitted if
//             no domain was specified when creating the cookie.
//
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

////////////////////////////// Event Routines ///////////////////////////////////////

// Calendar and events global variables
mText = new Array('','January','February','March','April','May','June','July','August','September','October','November','December');
mTextf= new Array('','janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre');
days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
dayf = new Array('dimanche','lundi','mardi','mercredi','jeudi','verdredi','samedi');
var d=document;
var evHTML="";


/* doToday(): display events for today */
function doToday() {
	var date = new Date();
	var dy = date.getDate();if(day<10) dy="0"+dy;
	var mn = date.getMonth()+1;if(mn<10) mn="0"+mn;
	var yr = ""+date.getFullYear()+"";yr=yr.substr(2,3);
	var today=""+yr+""+mn+""+dy+"";								// build today's date as "yymmdd" format
	doShowEvent(today);												// show any events that occur today
}


/* doShowEvent(dInfo): display event for this 'dInfo' day */
function doShowEvent(dInfo) {
	evHTML="";
	doShowEventDay(dInfo);
	evBox = getObject("eventBox");evBox.innerHTML = (evHTML);
}

var td=false;
/* doNextEvents(ndays): display events for the next 'ndays' days */
function doNextEvents(ndays) {
	var n=parseInt(ndays,10);if(n<1 || n>40) {n=7;}
	var myDate=new Date();td=true;
	evHTML="";
	for(x=0;x<n;x++) {
		var dy = myDate.getDate();if(dy<10) dy="0"+dy;
		var mn = parseInt(myDate.getMonth()+1,10);if(mn<10) mn="0"+mn;
		var yr = ""+myDate.getFullYear()+"";yr=yr.substr(2,3);
		var today=""+yr+""+mn+""+dy+"";								// build today's date as "yymmdd" format
		doShowEventDay(today);									// show any events that occur today
		myDate.setDate(myDate.getDate()+1);
		td=false;
	}
	evBox = getObject("eventBox");evBox.innerHTML = (evHTML);
}

/* doMonthEvents(): display events for the current calendar month */
function doMonthEvents() {
	var date = new Date();
	var myDate=new Date();
	var m = date.getMonth()+1;										// current month
	var yr = ""+myDate.getFullYear()+"";yr=yr.substr(2,3);
	evHTML="";
		for(x=1;x<32;x++) {
		var dy = x;  if(x<10)  dy="0"+dy;
		var mn = m;  if(mn<10) mn="0"+mn;
		var today=""+yr+""+mn+""+dy+"";						// build today's date as "yymmdd" format
		doShowEventDay(today);									// show any events that occur today		
	}
	evBox = getObject("eventBox");evBox.innerHTML = (evHTML);
}

/* doAnyMonthEvents(): display events for ANY month (Format is (y,m) where y=200x and m = 1-12 */
function doAnyMonthEvents(y,m) {
	var yr = parseInt(y,10)-2000;if(yr<10) yr="0"+yr;		// year
	var mn = parseInt(m,10);if(mn<10) mn="0"+mn;			// month
	evHTML="";
	for(x=1;x<32;x++) {
		var dy = x;  if(x<10) dy="0"+dy;
		var today=""+yr+""+mn+""+dy+"";						// build today's date as "yymmdd" format
		doShowEventDay(today);									// show any events that occur today		
	}
	evBox = getObject("eventBox");evBox.innerHTML = (evHTML);
}

/* doShowEventDay(dInfo): displays ALL events that match the given year, month and day ("yymmdd" format) */
function doShowEventDay(dInfo) {
	var t=(GetCookie("lang")=="true")?true:false;
	var yr = parseInt(dInfo.substr(0,2),10);				// year
	var mn = parseInt(dInfo.substr(2,2),10);				// month
	var dy = parseInt(dInfo.substr(4,2),10);				// day
	var ne = ev.length;											// total number of events
	var found=false;												// reset unique date write flag
	for (i=0;i<ne;i++) {
		var eI = ev[i][evDateNum]; 			  				// date information of event
		var ey = parseInt(eI.substr(0,2),10);				// year
		var em = parseInt(eI.substr(2,2),10);				// month
		var ed = parseInt(eI.substr(4,2),10);				// day
		if (ey == yr && em == mn && ed == dy) {
			if(!found) {											// write out date of event
				var day=dayofweek(ed,em,(2000+ey));			// day of week then date
				// alert(day+","+ed+":"+em+":"+(2000+ey))
																		// if event is today then change class
				evHTML += (td)?'<div class="calEventDateT">':'<div class="calEventDate">';
																		// if event is today then write "Aujourd'hui" or "Today" ;
				if(td) {var r=(t)?"Aujourd'hui":"Today";}else{r=day+', '+ed+' ';r+=(t)?mTextf[em]:mText[em];}
				evHTML += r+'</div>';
				found=true;											// set flag... maybe more than one event this day
			}															// write out each unique event
			var s=(t)?ev[i][evNameTxtf]:ev[i][evNameTxt];
			evHTML += '<div class="calEventHead"><strong>'+s+'</strong></div>';
			evHTML += '<div class="calEventHead">'+ev[i][evPlaceTxt]+': '+ev[i][evTimeTxt]+'</div>';
			evHTML += '<div class="calEventText">'+ev[i][evVenueTxt];
			if (ev[i][evLinkTxt]!="") {					// only if there is a link
				evHTML += '<a target="_blank" href="'+ev[i][evLinkTxt]+'">';
				evHTML += '<img src="'+arrowImg+'" alt="Détails ~ Details" title="Détails ~ Details" class="catEventImg"></a>';
			}
			evHTML += '</div>';
		}
	}
}

/* ======================================================================================
   eventlink(mn,dy,yr): creates link if date match is found in event dataBase [ev]
	====================================================================================== */
function eventlink(mn,dy,yr){
	for (i=0; i<ev.length; i++){
		var eI = ev[i][evDateNum]; 							// date information of event
		var ey = 2000+parseInt(eI.substr(0,2),10);		// year
		var em = parseInt(eI.substr(2,2),10);				// month
		var ed = parseInt(eI.substr(4,2),10);				// day
		eIText = ""+eI+"";
		if (ey == yr && em == mn && ed == dy) {return '<a title="see day\'s events" class="evDay" href="javascript:doShowEvent(\''+eIText+'\');">'+dy+'</a>';}
	}
	return dy;
}

/*
==============================================================================
      calendar (date): creates calendar from today's date
==============================================================================
*/

var doneToday = false;
function calendar(date) {
	var t=(GetCookie("lang")=="true")?true:false;			// french / english
	//If no parameter is passed use the current date.
	if(date == null) date = new Date();
	day = date.getDate();
	month = date.getMonth();
	year = date.getFullYear();
	this_month = new Date(year, month, 1);
	next_month = new Date(year, month + 1, 1);
	previous_month= new Date(year, month - 1, 1);

	//Find out when this month starts and ends.
   first_week_day = this_month.getDay();
   days_in_this_month = Math.floor((next_month.getTime() - this_month.getTime()) / (1000 * 60 * 60 * 24));
   var mT=year*100+month;
  	calendar_html = '';
   calendar_html += '<table id="datetable" cellspacing="0" cellpadding="0">';
   calendar_html += '<tr><td class="datetableHead"><a title="last month" href="javaScript:calendar(previous_month)">&#171;</a>';
   calendar_html += '</td><td colspan="5" align="center" class="datetableHead">';
   if(mFlag) calendar_html += '<a title="events ~ événements" href="javascript:doAnyMonthEvents(\''+year+'\',\''+(month+1)+'\');">';
   calendar_html += (t)?mTextf[month+1]+ ' ' + year:mText[month+1] + ' ' + year;
   if(mFlag) calendar_html += '</a>';
   calendar_html += '</td><td class="datetableHead"><a title="next month" href="javaScript:calendar(next_month)">&#187;</a></td></tr>';
	calendar_html += '<tr>';

	//Fill the first week of the month with the appropriate number of blanks.
	for (week_day = 0; week_day < first_week_day; week_day++) {
		calendar_html += '<td class="datetableCells"> </td>';
	}
	week_day = first_week_day;
	for (day_counter = 1; day_counter <= days_in_this_month; day_counter++) {
		week_day %= 7;
		if (week_day == 0) calendar_html += '</tr><tr>';

	//Do something different for the current day.
		if(day == day_counter && !doneToday) {
			calendar_html += '<td class="datetableToday">'+eventlink(month+1,day_counter,year)+ '</td>';
			doneToday = true;
		} else {
			calendar_html += '<td class="datetableCells">'+eventlink(month+1,day_counter,year)+ '</td>';
		}
 		week_day++;
	}
	calendar_html += '</tr>';
	calendar_html += '</table>';
	cal = getObject("calendarBox");
	cal.innerHTML = calendar_html;		//Display the calendar.
}


/*
==============================================================================
      Day of Week Function (derived from http://javascript.internet.com/math-related/day-of-week.html)
==============================================================================
*/

function dayofweek(di,mi,yi) {
	var t=(GetCookie("lang")=="true")?true:false;
	var y = parseInt(yi,10);
	var m = parseInt(mi,10)-1;		// Note that month comes in as 1-12 so adjust to 0-11
	var d = parseInt(di,10);
	var c = new Date(y,m,d);		
	var dayOfWeek = c.getDay();
    var r=(t)?dayf[dayOfWeek]:days[dayOfWeek];
	return(r);
}

// ******************************* end of routines *************************** //
-->
