function setClock(obj,timevalue){
//set 'current time' for clock1 (hidden clock used for determining next meeting time date and if current time within valid link window), 
	clock_obj1=obj;
	clock_obj1.value=timevalue;
	window.setInterval("clock_obj1.value=new Date(Date.parse(clock_obj1.value)+1000)",1000);
}

//set time value constants
	const_hour= 1000 * 60 * 60;
	const_week= 1000 * 60 * 60 * 24 * 7;

//declare arrays
	mtg_miss= new Array();
	mtg_spec= new Array();

//define time zones
	mdt=" GMT-0600"
	mst=" GMT-0700"

//*********************************************************
//*******Ensure values set in this section are valid ******
//set meeting duration (in hours) and schedule frequency (in weeks)
	mtg_dur= const_hour * 11;
	mtg_freq = const_week * 2;
	
//**All dates to be entered in MMM DD, YYYY HH:MM:SS format. Do not include time zone value.**

//** IF YOU UPDATE THIS FILE, PLEASE CONTACT ENABIL TO PROVIDE THEM WITH THE UPDATED COPY
//** OTHERWISE, THIS FILE COULD ACCIDENTALLY BE OVERWRITTEN DURING A DEPLOYMENT.

/* Time Zone CHanges for 2012
     Sunday March 11, 2012 - Move clocks ahead 1 hour (DST Starts)
     Sunday November 4, 2012 - Move cLocks Back 1 hour. (DST Ends)
*/

//initial and max date values
			
            mtg_init="Jan 9, 2012 18:30:00";
            mtg_max="Dec 24, 2012 18:30:00";

//regular meeting dates missed within regular schedule (no meeting occuring) 

            //ensure array elements are numbered sequentially, starting from zero
			//Add 1 Hour during MDT, ex.  19:00:00 Should Actually be entered as 20:00:00 (Dates Change Evenry Year)
            mtg_miss[0]="Feb 20, 2012 18:30:00";
			mtg_miss[1]="Jul 23, 2012 18:30:00";
			mtg_miss[2]="Aug 6, 2012 18:30:00";
			mtg_miss[3]="Sept 3, 2012 18:30:00";
			mtg_miss[4]="Nov 12, 2012 18:30:00";
			mtg_miss[5]="Dec 24, 2012 18:30:00";
			
			
//meetings outside of regular schedule

            //ensure array elements are numbered sequentially, starting from zero
			//Add 1 Hour during MDT, ex.  19:00:00 Should Actually be entered as 20:00:00 (Dates Change Evenry Year)
            mtg_spec[0]="Feb 21, 2012 18:30:00";
            mtg_spec[1]="Aug 7, 2012 18:30:00";
			mtg_spec[2]="Sept 4, 2012 18:30:00";
			mtg_spec[3]="Nov 13, 2012 18:30:00";
			//mtg_spec[4]="Nov 16, 2011 09:00:00";
			//mtg_spec[5]="Nov 17, 2011 10:00:00";
			//mtg_spec[6]="Nov 18, 2011 09:00:00";


//set links
            url_live_flash_live=window.location.href + "&flash=live";
            url_live_abn_high="rtsp://154.obj.netromedia.net/cogplive/cogplive"; // Android, Blackberry, Nokia
            url_live_apple_high="http://154.obj.netromedia.net/cogplive/cogplive/playlist.m3u8"; // iPhone, iPad, iPod
            url_err="javascript:alert('There is no LIVE webcast in progress.  Please wait until the next scheduled meeting begins.')";

//******************end of section*************************
//*********************************************************

//format all given dates to and sort by numerical GMT value
	var miss_num;
	var spec_num;

	//initial and max dates 
	mtg_init=Date.parse(new Date(mtg_init));
	mtg_max=Date.parse(new Date(mtg_max));

	//missed meetings
	miss_num=mtg_miss.length;
	i=0;
	for (i=0;i<miss_num;i++) {
		mtg_miss[i]=Date.parse(new Date(mtg_miss[i]))
	}
	mtg_miss.sort(num_sort);

	//special out-of-schedule meetings
	spec_num=mtg_spec.length;
	i=0;
	for (i=0;i<spec_num;i++) {
		mtg_spec[i]=Date.parse(new Date(mtg_spec[i]))
	}
	mtg_spec.sort(num_sort);	

//function to sort array in numerical order
function num_sort(num1, num2) {

	return num1-num2;
}


//determine daylight saving time zone depending on time of year
function dst_adj(date_val) {

	var zone;

	theDate = new Date(date_val);
 	month= new Date(date_val).getMonth();
	dayofm= new Date(date_val).getDate();
	dayofw= new Date(date_val).getDay();

	if (month>3 && month <9)
		zone=mdt;
	else if (month<3 || month>9)
		zone=mst;
	else if (month==3)
		if (dayofm>=7)
		   zone=mdt; 
		else
		   if ((dayofm-dayofw)>0)
			zone=mdt;
		   else
			zone=mst;
	else if (month==9)
		if (31-dayofm>=7)
		   zone=mdt;
		else
		   if (31-dayofm+dayofw<7)
			zone=mst;
		   else
			zone=mdt;

	return zone;
}


//determines if timezone shift has occured due to daylight saving time between two dates
function dst_shift(date1, date2) {

	tzdates= new Array()
	tzdiff= new Array()

	tzdates[0]=date1
	tzdates[1]=date2


	for (i=0;i<2;i++) {
	 	month= new Date(tzdates[i]).getMonth();
		dayofm= new Date(tzdates[i]).getDate();
		dayofw= new Date(tzdates[i]).getDay();

		if (month>3 && month <9)
			zone=mdt;
		else if (month<3 || month>9)
			zone=mst;
		else if (month==3)
			if (dayofm>=7)
			   zone=mdt;
			else
			   if ((dayofm-dayofw)>0)
				zone=mdt;
			   else
				zone=mst;
		else if (month==9)
			if (31-dayofm>=7)
			   zone=mdt;
			else
			   if (31-dayofm+dayofw<7)
				zone=mst;
			   else
				zone=mdt;

		tzdiff[i]=zone;
	}
		    
	if (tzdiff[0]==tzdiff[1])
		shift=0;
	else if (tzdiff[0]==mdt && tzdiff[1]== mst)
		shift=1*const_hour;
	else if (tzdiff[0]==mst && tzdiff[1]== mdt)
		shift=-1*const_hour;

	return shift;
}


//gets next valid meeting date
function getmtgdate() {

	// declare vars
	var mtgdate;
	var setmtg;
	var i;
	var j;
	var dt_now;
	
	//set value for current date and time
	dt_now= new Date();
	dt_now= Date.parse(clock_obj1.value);
	
	mtgdate=mtg_init; 
	
	
	//check each scheduled interval from initial date to see if less than current date
	while ((mtgdate<dt_now) && ((mtgdate+mtg_dur>dt_now) != true)){
		i=0;
		setmtg=false;

		//check for exceptions within current interval
		while (i<spec_num && setmtg==false) {
    
			if (mtg_spec[i]>mtgdate && (mtg_spec[i]+mtg_dur>dt_now) && mtg_spec[i]<mtgdate+mtg_freq) {
				mtgdate=mtg_spec[i];
				setmtg=true		
			}
			i++
		}

		//check if next intervals should be skipped
		i=0;
		while (i<miss_num) {
			
			if (mtg_miss[i]==mtgdate+mtg_freq) {
			
				mtgdate=mtgdate+mtg_freq;
				
				//check for exceptions within interval of regular meeting that was skipped 
				j=0;
				while (j<spec_num && setmtg==false) {
				
					if (mtg_spec[j]>mtgdate && (mtg_spec[j]+mtg_dur>dt_now) && mtg_spec[j]<mtgdate+mtg_freq) {
						mtgdate=mtg_spec[j];
						setmtg=true
					}		
					j++ 
				}
			}
			i++ 
		} 

		//if exception not found within interval, skip to next interval
		if (setmtg==false) 
			{
				mtgdate=mtgdate+mtg_freq;
			}
	}
			
	//return next date found, unless beyond max date, then send blank date

	if (mtgdate<=mtg_max) {
	
			if (dst_adj(mtgdate) == " GMT-0600")
			{
				return mtgdate - const_hour;
			}
			else
			{
				return mtgdate;
			}
		}
	else
		return 0;


}
//determines which link to follow depending on dates
function golink(bandwidth,timevalue) {

	var mtgdate_start, mtgdate_end;
	var dt_now;

	//set value for current date and time
	dt_now= new Date();
	dt_now= Date.parse(clock_obj1.value);

	//set bandwidth options
	if (bandwidth==0) 
		bsuffix="h";
	else
		bsuffix="l";
	
	//get next meeting times
	mtgdate_start=getmtgdate();
	mtgdate_end=mtgdate_start+mtg_dur;

	//compare against current time
	if (dt_now >= mtgdate_start && dt_now < mtgdate_end) {
	    if (bandwidth==0)
		    window.location.href= eval("url_live_flash_live");
		else if (bandwidth==1)
			window.location.href= eval("url_live_abn_high");
		else if (bandwidth==2)
			window.location.href= eval("url_live_apple_high");
    }
	else
		window.location.href= url_err;
		//window.location.href= eval("url_live_flash_live"); // for testing when no live broadcast
}

// The following code was from: http://blog.stevenlevithan.com/archives/date-time-format
/*
 * Date Format 1.2.3
 * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
 * MIT license
 *
 * Includes enhancements by Scott Trenda <scott.trenda.net>
 * and Kris Kowal <cixar.com/~kris.kowal/>
 *
 * Accepts a date, a mask, or a date and a mask.
 * Returns a formatted version of the given date.
 * The date defaults to the current date/time.
 * The mask defaults to dateFormat.masks.default.
 */

var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date;
		if (isNaN(date)) throw SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};


