<!--
/****************************************************
*			    	General Routines
*             ==================
*            Please edit with care...
*****************************************************/

// used in body as <... onLoad="MM_preloadImages('/images/xxx.jpg','/images/yyy.jpg',...">

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// used in <... onMouseOut="MM_swapImgRestore()">

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// used in <... onMouseOver="MM_swapImage('image_name_and_ID','','swap_image_source',1)">

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Used to fade between one colour (rgb_start) and another (rgb_final).
// To create an effect of a link changing between colours, use: <a href="...". id="unique_id" onMouseOver="KW_fade(r_start,g_start,b_start,r_final,g_final,b_final,speed,this.id)" onMouseOut="KW_fade(r_final,g_final,b_final,r_start,g_start,b_start,speed,this.id)"
// speed is ~20?  don't know the units.

function KW_s(r, g, b, el) {
// changes colour of element (el) to hex value of rgb
    d=document;hr=r.toString(16);hg=g.toString(16);hb=b.toString(16);
	hr=(hr.length==1)?"0"+hr:hr;hg=(hg.length==1)?"0"+hg:hg;hb=(hb.length==1)?"0"+hb:hb;
	if (d.getElementById) d.getElementById(el).style.color="#"+hr+hg+hb;
}

function KW_c(a,b,s,i) { return Math.floor(a*((s-i)/s)+b*(i/s)) }

function KW_fade(r,g,b,e,n,l,s,o){
// fades colour (rgb) of object (o) to (enl) at speed (s)

    for(i=0;i<=s;i++)setTimeout("KW_s("+KW_c(r,e,s,i)+","+KW_c(g,n,s,i)+","+KW_c(b,l,s,i)+",'"+o+"');",i*s);
}

// writes the copyright information on page
function doCopy() {
	document.write('<div id="copy">Construction Specifications Canada (CSC), Ottawa Chapter, P.O. Box 5624, Ottawa, ON K2C 3M1<br /> Copyright © 2003-2012 CSC Ottawa Chapter. All rights reserved.</div>');
}

////////////////////////////// Breadcrumbs //////////////////////////////////
function spawn(expr,qty,reversed){
	var spawnee = [expr];
	for(s = 1;s<qty;s++){spawnee[s] = expr+spawnee[s-1];}
	if(reversed){
		return spawnee.reverse()
	}else{
	return spawnee
	}
}

function breadcrumbs(divider,default_page,root ) {
	if(!divider) divider="&nbsp;&#187;&nbsp;";
	if(!default_page) default_page="index.html";
	if(!root) root="Home";
	var m=location.toString(),h="";
	m=m.substring(m.indexOf("/")+1);
	m=m.split("/");
	var howmany=spawn("../",m.length,true);
	howmany[m.length]=default_page;
	for(i=1;i<m.length-1;i++){
		h+=("<a href="+howmany[i+2]+">"+unescape( m[i]+"</a>"+divider))
	}
	h += document.title;
	if(root) {
		h=h.replace(eval("/"+location.host+"/"),root)
	}
//	alert(h);
	document.write("<div class=\"breadcrumb\">" + h +"</div>");
}

/*****************************************************************************************************************/
// "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
}

// returns the "name" Object
function getObject(name) {
	return (document.getElementById?document.getElementById(name):document.all?document.all[name]:document.layers?eval("document.layers[\"" + name + "\"]"):null);
}

////////////////////////////// Event Routines ///////////////////////////////////////
// doShowEvents(dInfo) displays ALL events in the given year and month.  dInfo is "yymm" format

function doShowEvents(dInfo) {
	mText = new Array('','January','February','March','April','May','June','July','August','September','October','November','December');
	var d=document;
	var yr = parseInt(dInfo.substr(0,2),10);	// year
	var mn = parseInt(dInfo.substr(2,2),10);	// month
	var ne = evInfo.length;						// total number of events
//		alert (yr+":"+mn);
	var evHTML="";
	for (i=0;i<ne;i++) {
		var eI = evInfo[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
//		alert (ey+":"+em+":"+ed);
		if (ey == yr && em == mn) {
			evHTML +=  '<table align="center" class="eventTable" cellspacing="0" cellpadding="0" border="0">';
			evHTML += '<tr><td class="le">Event:</td><td class="re"><strong>'+evInfo[i][evNameTxt]+'</strong></td></tr>';
			eyTxt = (ey<10)?"200"+ey+"":"20"+ey+"";
			evHTML += '<tr><td class="le">Date and Time:</td><td class="re">'+ed+'&nbsp;'+mText[em]+'&nbsp;'+eyTxt+',&nbsp;'+evInfo[i][evTimeTxt]+'</td></tr>';
			evHTML += '<tr><td class="le">Venue: </td><td class="re">'+evInfo[i][evVenueTxt]+'</td></tr>';
			evHTML += '<tr><td class="le">Registration:</td><td class="re">'+evInfo[i][evRegTxt]+'</td></tr>';
			evHTML += '<tr><td colspan="2" height="2"></td>';
			evHTML += '</table>';
		}
	}
   evBox = getObject("eventsBox");
   yrTxt = (yr<10)?"200"+yr+"":"20"+yr+"";
   evBox.innerHTML = ('<h2>'+mText[mn]+'&nbsp;'+yrTxt+'</h2>'+evHTML);
}

////////////////////////////// Event Routines ///////////////////////////////////////
// doShowEvent(dInfo) displays ALL events in the given year, month and day!!!.  dInfo is "yymmdd" format

function doShowEvent(dInfo) {
	mText = new Array('','January','February','March','April','May','June','July','August','September','October','November','December');
	var d=document;
	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 = evInfo.length;						// total number of events
//		alert (yr+":"+mn);
	var evHTML="";
	for (i=0;i<ne;i++) {
		var eI = evInfo[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
//		alert (ey+":"+em+":"+ed);
		if (ey == yr && em == mn && ed == dy) {
			evHTML +=  '<table align="center" class="calendarEventTable" cellspacing="0" cellpadding="0" border="0">';
			evHTML += '<tr><td class="calEventHead">'+evInfo[i][evNameTxt]+'</td></tr>';
			eyTxt = (ey<10)?"200"+ey+"":"20"+ey+"";
			evHTML += '<tr><td class="calEventText1">'+ed+' '+mText[em]+'&nbsp;'+eyTxt+', '+evInfo[i][evTimeTxt]+'</td></tr>';
			evHTML += '<tr><td class="calEventText">Venue: '+evInfo[i][evVenueTxt], evInfo[i][evRegTxt]+'</td></tr>';
			evHTML += '<tr><td colspan="2" height="2"></td>';
			evHTML += '</table>';
		}
	}
   evBox = getObject("eventBox");
   evBox.innerHTML = (evHTML);
}


/////////////////////////////// Calendar ////////////////////////////////////////////////

//function eventlink(month,day ){
//	eventbooked= new Array ('3/23','4/20','5/12','5/13','5/3','5/18','6/1','8/11');
//	linkbooked= new Array ("mar05","apr05","may05_1","may05_2","may05_3","may05_3","jun05","aug05","sep05");
//	root = "Events/calendar.html#"
//	for (i=0; i<eventbooked.length; i++){
//		if (eventbooked[i]==month+"/"+day ) {return '<a href="'+root+linkbooked[i]+'">'+day+'</a>'}
//	}
//	return day
//}

function eventlink(mn,dy,yr){
//	alert (yr+":"+mn+":"+dy);
	for (i=0; i<evInfo.length; i++){
		var eI = evInfo[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 class="evDay" href="javascript:doShowEvent(\''+eIText+'\');">'+dy+'</a>';}
	}
	return dy;
}

var doneToday = false;
function calendar(date) {
	//If no parameter is passed use the current date.
	if(date == null) date = new Date();
	day = date.getDate();
	month = date.getMonth();
	year = date.getFullYear();
	months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	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));
  	calendar_html = '<h1>Events Calendar</h1>';
   calendar_html += '<table id="datetable" cellspacing="0" align="center">';
   calendar_html += '<tr><td class="datetableHead"><a href="javaScript:calendar(previous_month)">&#171</a></td><td colspan="5" align="center" class="datetableHead">' + months[month] + ' ' + year + '</td><td class="datetableHead"><a 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>';
//   alert (calendar_html);
	cal = getObject("calendarBox")
	cal.innerHTML = calendar_html;		//Display the calendar.
}

////////////////////////////// Sliding Menus ////////////////////////////////////////////

function doMenus() {
	//   var yPosition = 251;
	//  ypSlideOutMenu(id, dir, left, top, width, height)  //
 	new ypSlideOutMenu("menu1", "right", 120,  30, 200,  72);	// Memberships
 	new ypSlideOutMenu("menu2", "right", 120,  56, 180,  144);	// Events - 18 x 11 = 198; 18 x 9 = 162 lines; 18 x (8 or less) = 144
 	new ypSlideOutMenu("menu3", "right", 120,  83, 230,  54);  	// Programs (18px per menu item)
	new ypSlideOutMenu("menu4", "right", 120, 109, 180,  36); 	// Newsletter
}

// Memberships
function doMenu1(level) {
	var msg = "";
	msg += '<div id="menu1Container"><div id="menu1Content">';
   msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu1\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu1\')" href="'+level+'executive.html">Executive Contact Details</a>';
   msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu1\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu1\')" href="'+level+'members.html">Certified &amp; Registered Members</a>';
   msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu1\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu1\')" href="'+level+'fellows.html">Honoured Chapter Members</a>';
   msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu1\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu1\')" href="'+level+'membership.html">Becoming a Member</a>';
	msg += '</div></div>';
	document.write (msg);
}

// Events
function doMenu2(level) {
	var msg = "";
	msg += '<div id="menu2Container"><div id="menu2Content">';
	msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="'+level+'calendar.html">Calendar of Events</a>';
//	msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="'+level+'Cafe2009.html">Connections Caf&eacute; 2009</a>';
//	msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="'+level+'2008_11.html">Seminar on Glazing Films</a>';
	msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="'+level+'DirectorsReport2008Fall.pdf">Director\'s Report (pdf)</a>';
	msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="'+level+'ChairsMessage2009Fall.pdf">Chairman\'s Report (pdf)</a>';
	msg += ' <a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="'+level+'notices.html">Notices</a>';
	msg += ' <a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="'+level+'conferences.html">Conferences</a>';
	msg += '</div></div>';
   	document.write (msg);
}

// OLD events (was 140 height):
//	msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu2\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu2\')" href="'+level+'acm.html">Annual Chapter Meeting Registration</a>';


// Programs
function doMenu3(level) {
	var msg = "";
	msg += '<div id="menu3Container"><div id="menu3Content">';
	msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu3\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu3\')" href="'+level+'professional.html">Professional Development Programs</a>';
	msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu3\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu3\')" href="'+level+'technical.html">Technical Program Info</a>';
	msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu3\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu3\')" href="'+level+'social.html">Social Program Notices</a>';
	msg += '</div></div>';
	document.write (msg);
}

// Events + Newsletter
function doMenu4(level) {
	var msg = "";
	msg += '<div id="menu4Container"><div id="menu4Content">';
	msg += '<a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu4\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu4\')" href="'+level+'Current.pdf">Current Newsletter</a>';
	msg += ' <a class="rollmenu" onmouseover="ypSlideOutMenu.showMenu(\'menu4\')" onmouseout="ypSlideOutMenu.hideMenu(\'menu4\')" href="'+level+'specifier.html">Newsletter Archives</a>';
	msg += '</div></div>';
	document.write (msg);
}

////////////////////////////// Slide Out Menus //////////////////////////////////

ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 650
ypSlideOutMenu.hideDelay = 325
ypSlideOutMenu.minCPUResolution = 10

// constructor
function ypSlideOutMenu(id, dir, left, top, width, height)
{
	this.ie  = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0

	if (this.ie || this.ns4 || this.dom) {
		this.id			 = id
		this.dir		 = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType	 = dir == "right" || dir == "down" ? "-" : "+"
		this.dim		 = this.orientation == "h" ? width : height
		this.hideTimer	 = false
		this.aniTimer	 = false
		this.open		 = false
		this.over		 = false
		this.startTime	 = 0

		// global reference to this object
		this.gRef = "ypSlideOutMenu_"+id
		eval(this.gRef+"=this")

		// add this menu object to an internal list of all menus
		ypSlideOutMenu.Registry[id] = this

		var d = document
		d.write('<style type="text/css">')
		d.write('#' + this.id + 'Container { visibility:hidden; ')
		d.write('left:' + left + 'px; ')
		d.write('top:' + top + 'px; ')
		d.write('overflow:hidden; }')
		d.write('#' + this.id + 'Container, #' + this.id + 'Content { position:absolute;z-index:1000; ')
		d.write('width:' + width + 'px; ')
		d.write('height:' + height + 'px; ')
		d.write('clip:rect(0 ' + width + ' ' + height + ' 0); ')
		d.write('}')
		d.write('</style>')

		this.load()
	}
}

ypSlideOutMenu.prototype.load = function() {
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	var temp

	if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100)
	else {
		this.container	= obj1
		this.menu		= obj2
		this.style		= this.ns4 ? this.menu : this.menu.style
		this.homePos	= eval("0" + this.dirType + this.dim)
		this.outPos		= 0
		this.accelConst	= (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen

		// set event handlers.
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
//		this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')")
//		this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')")

		//set initial state
		this.endSlide()
	}
}

ypSlideOutMenu.showMenu = function(id)
{
	var reg = ypSlideOutMenu.Registry
	var obj = ypSlideOutMenu.Registry[id]

	if (obj.container) {
		obj.over = true

		// if this menu is scheduled to close, cancel it.
		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }

		// if this menu is closed, open it.
		if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
	}
}

ypSlideOutMenu.hideMenu = function(id)
{
	// schedules the menu to close after <hideDelay> ms, which
	// gives the user time to cancel the action if they accidentally moused out
	var obj = ypSlideOutMenu.Registry[id]
	   if (obj.container) {
		   if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		   obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
	   }
}

ypSlideOutMenu.hide = function(id)
{
	var obj = ypSlideOutMenu.Registry[id]
	obj.over = false

	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)

	// flag that this scheduled event has occured.
	obj.hideTimer = 0

	// if this menu is open, close it.
	if (obj.open && !obj.aniTimer) obj.startSlide(false)
}

ypSlideOutMenu.prototype.startSlide = function(open) {
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime()
	this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}

ypSlideOutMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
	else {
		var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
		if (this.open && this.dirType == "-")		d = -d
		else if (this.open && this.dirType == "+")	d = -d
		else if (!this.open && this.dirType == "-")	d = -this.dim + d
		else										d = this.dim + d

		this.moveTo(d)
	}
}

ypSlideOutMenu.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	if ((this.open && !this.over) || (!this.open && this.over)) {
		this.startSlide(this.over)
	}
}

ypSlideOutMenu.prototype.setVisibility = function(bShow) {
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}
ypSlideOutMenu.prototype.moveTo = function(p) {
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : (p) + "px"
}
ypSlideOutMenu.prototype.getPos = function(c) {
	return parseInt(this.style[c])
}

// events
ypSlideOutMenu.prototype.onactivate		= function() { }
ypSlideOutMenu.prototype.ondeactivate	= function() { }
-->

