//The two dates are defined in libParms and passed through in libGlobals
//var gAGMRegistrationOpens, gAGMRegistrationCutoff
var aNow = new Date();
var gAGMRegistrationNotYet = (aNow.getTime() < gAGMRegistrationOpens);
var gAGMRegistrationClosed = (aNow.getTime() > gAGMRegistrationCutoff);
//alert(aNow.toUTCString()  + '; ' + new Date(gAGMRegistrationCutoff).toUTCString() + "; Closed is " + gAGMRegistrationClosed);

// -- Action Functions
function CSOpenWindow(action) {
	var wf = "";	
	wf = wf + "width=" + action[3];
	wf = wf + ",height=" + action[4];
	wf = wf + ",resizable=" + (action[5] ? "yes" : "no");
	wf = wf + ",scrollbars=" + (action[6] ? "yes" : "no");
	wf = wf + ",menubar=" + (action[7] ? "yes" : "no");
	wf = wf + ",toolbar=" + (action[8] ? "yes" : "no");
	wf = wf + ",directories=" + (action[9] ? "yes" : "no");
	wf = wf + ",location=" + (action[10] ? "yes" : "no");
	wf = wf + ",status=" + (action[11] ? "yes" : "no");		
	window.open(action[1],action[2],wf);
}
function openWorkshopPopup(pUrl) {
	CSOpenWindow( new Array(CSOpenWindow,/*URL*/ pUrl,'_blank',600,500,false,true,false,false,false,false,false) );
}

function sFormatDate(pDate,pLang) {

// Formats a date in standard dd mon yyyy format

	if(!pDate || pDate == "") return String(pDate);
	if(isNaN(pDate)) return String(pDate);

	var aMonths;
	if (pLang == "F"){ 
	   aMonths = new Array("janv","f\xE9v","mars","avr","mai","juin","juil","ao\xFBt","sept","oct","nov","d\xE9c");
	}else{
	   aMonths = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	}
	
	return (pLang == "F") ? pDate.getDate() + " " + aMonths[pDate.getMonth()] + " " + pDate.getFullYear() : 
		aMonths[pDate.getMonth()] + " " + pDate.getDate() + ", " + pDate.getFullYear();
	
}

function MastheadFlash(pFileName) {

// Write object by javascript to get around MS restrictions
// ref: http://www.adobe.com/devnet/activecontent/articles/devletter.html

	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' height='213' width='800'>");
	document.write("<param name='movie' value='" + pFileName + "' />");
	document.write("<param name='quality' value='best' />");
	document.write("<param name='play' value='true' />");
	document.write("<embed height='213' pluginspage='http://www.macromedia.com/go/getflashplayer' src='" + pFileName + "' type='application/x-shockwave-flash' width='800' quality='best' play='true'></embed>");
	document.write("</object>\n");
// 	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="750" height="210" id="masthead" align="middle">\n');
// 	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
// 	document.write('<param name="allowFullScreen" value="false" />\n');
// 	document.write('<param name="movie" value="' + pFileName + '" /><param name="loop" value="false" /><param name="quality" value="high" /><param name="scale" value="noborder" /><param name="bgcolor" value="#ffffff" />\n');
// 	document.write('<embed src="' + pFileName + '" loop="false" quality="high" scale="noborder" bgcolor="#ffffff" width="750" height="210" name="masthead" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
// 	document.write('</object>\n');
}

function agmregister(pLang) {	
	
//alert(aNow.toUTCString()  + '; ' + new Date(gAGMRegistrationCutoff).toUTCString() + "; Closed is " + gAGMRegistrationClosed);

	if (gAGMRegistrationNotYet) {
	 	var aMess = (gLanguage == "F") ? "L'inscription en ligne commencera le " : "Online registration begins on ";
	 	aMess +=  sFormatDate(gAGMRegistrationOpens,pLang);
	 	alert(aMess);
	} else if (gAGMRegistrationClosed) {
		var aMess = (gLanguage == "F") ? 
			"D\xE9sol\xE9, l’inscription en ligne pour l’assembl\xE9e annuelle est maintenant termin\xE9e. Vous pouvez vous inscrire à l’AGA ou apporter des changements à votre inscription sur place au Delta St. John’s, à compter de 11 h le mercredi 25 mai (9 h 30 pour les participants à la CGC)." :
			"Sorry, online registration for the Annual Meeting is now closed. You can register onsite at the Delta St. John’s starting Wednesday, May 25th. Registration for CMC participants begins at 9:30 a.m. and General Registration begins at 11:00 a.m."
		alert(aMess);
	} else {
		CSOpenWindow( new Array(CSOpenWindow,/*URL*/ 'https://www.confersense-events.com/chfc/','_blank',1024,800,false,true,false,false,false,false,false) );
	}
}

function agmregisterclosed(pLang) {	
 	var aMess = (pLang == "F") ? 
		"D\xE9sol\xE9, l’inscription en ligne pour l’assembl\xE9e annuelle est maintenant termin\xE9e. Veuillez vous inscrire sur place au Centre des congres de Victoria à compter de 13 h 30 le mercredi 27 mai." :
 		"Sorry, online registration for the Annual Meeting is now closed. Please register on-site at the Victoria Conference Centre beginning at 1:30 p.m. on Wednesday, May 27th."
 	alert(aMess);
}

function agmchecklist() {
	CSOpenWindow( new Array(CSOpenWindow,/*URL*/ 'agm_checklist.html','_blank',600,500,false,true,false,false,false,false,false) );
}

function agmschedule() {
	CSOpenWindow( new Array(CSOpenWindow,/*URL*/ 'agm_schedule.html','_blank',600,500,false,true,false,false,false,false,false) );
}

