function setOpacity (o,pct) {
	if (o.filters) {
		o.style.filter = "progid:DXImageTransform.Microsoft.Alpha(enabled=false)";
		o.filters.item("DXImageTransform.Microsoft.Alpha").opacity = pct*100;
		o.filters.item("DXImageTransform.Microsoft.Alpha").enabled = true;
	} else if (o.style) {
		if (o.style.opacity!=undefined) o.style.opacity = pct;
		else o.style.MozOpacity = pct;
	}
}
function replaceAll (s,c1,c2) {
	if (s==null)return s;
	if(c1==c2) return s;
	var r=s, z=c1.length, i=r.indexOf(c1);
	while (i>=0 && r.length>0) {
		r = (i==0) ? (c2+r.substr(z)) : (r.substr(0,i)+c2+r.substr(i+z));
		i = r.indexOf(c1);
	}
	return r;
}
function dequote (s) {
	return replaceAll(s,"'","&#39;");
}
function swapSections(o1,o2,o3) {
	var obj1 = document.getElementById(o1);
	var obj2 = document.getElementById(o2);
	var obj3 = document.getElementById(o3);
	if (obj1 && obj2) {	
		obj1.style.display="none";
		obj2.style.display="block";
		if (obj3) {
			if (obj3.value=="0") obj3.value="1";
			else obj3.value="0";
		}
	}
	return false;
}
function simpleSection(o) {
	var obj = document.getElementById(o);
	if (obj) {
		var st = obj.style.display;
		if (st=="none") {
			obj.style.display="";
		} else {
			obj.style.display="none";
		}
	}
	return false;
}
function initStateEvents() {
	var obj = document.getElementById("calendarState");
	var obj1 = document.getElementById("ScheduleList");
	var obj2 = document.getElementById("ScheduleCalendar");
	if (obj && obj1 && obj2) {
		if (obj.value=="0") {
			obj1.style.display="none";
			obj2.style.display="block";
		} else {
			obj1.style.display="block";
			obj2.style.display="none";
		}
	}
}

//-------------------------------------------------------------
// Namespace
//-------------------------------------------------------------
function FOBJ () {
	this.ANM = new this.animation();
	this.SLD = new this.slideshow();
	this.CAL = new this.calendar();
	this.TIP = new this.tooltip();
}

//-------------------------------------------------------------
// Slideshow
//-------------------------------------------------------------
FOBJ.prototype.slideshow = function () {
	this.currentGallery = 0;
	this.currentImage = 0;
	this.currentState = 0;
	this.imageList = [];
	this.imageCache = [];
	this.imageText = [];
	this.imgTimer = null;
	this.imgBtnOn = this.imgBtnOff = null;
	this.initialized = false;
}

FOBJ.prototype.slideshow.prototype.init = function(gallery,image,list1,list2,list3,text1,text2,text3) {
	this.currentGallery = gallery;
	this.currentImage = image;
	var nada = [];
	if (list1) this.imageList.push(list1); else this.imageList.push(nada);
	if (list2) this.imageList.push(list2); else this.imageList.push(nada);
	if (list3) this.imageList.push(list3); else this.imageList.push(nada);
	if (text1) this.imageText.push(text1); else this.imageText.push(nada);
	if (text2) this.imageText.push(text2); else this.imageText.push(nada);
	if (text3) this.imageText.push(text3); else this.imageText.push(nada);
}

FOBJ.prototype.slideshow.prototype.galleryLoad = function() {
	var i;
	if (!this.initialized) {
		// Read the current state of the gallery -- state is in fields galleryState, gallerySelection and galleryImage
		var obj0 = document.getElementById("galleryState");
		var obj1 = document.getElementsByName("gallerySelection"); // radio button
		var obj2 = document.getElementById("galleryImage");
		if (obj0) this.currentState = parseInt(obj0.value,10);
		if (obj2) this.currentImage = parseInt(obj2.value,10);
		if (obj1 && obj1.length && obj1.length>0) {
			for (i=0; i<obj1.length; i++) {
				if (obj1[i].checked) {
					this.currentGallery = i;
					break;
				}
			}
		}
		obj0 = document.getElementById("galleryOn");
		obj1 = document.getElementById("galleryOff");
		if (obj0 && this.currentState==0) obj0.className =  obj0.className + "-selected";
		if (obj1 && this.currentState==1) obj1.className =  obj1.className + "-selected";
		this.initialized = true;
	}
	var img, obj = document.getElementById("galleryCaption");
	if (obj) {
		obj.innerHTML = "loading images...";
	}
	var c = [];
	for (i=0; i< this.imageList[this.currentGallery].length; i++) {
		img = new Image();
		img.src = "imgs_gallery/" + this.imageList[this.currentGallery][i];
		c.push(img);
	}
	this.imageCache[this.currentGallery] = c;
	this.imgTimer = window.setTimeout("F.SLD.galleryCallback1()", 250);
}
FOBJ.prototype.slideshow.prototype.galleryCallback1 = function() {
	// Check if all images have loaded
	var img, allComplete = true;
	for (var i=0; i<this.imageCache[this.currentGallery].length; i++) {
		img = this.imageCache[this.currentGallery][i];
		if (!img.complete) {
			allComplete = false;
			break;
		}
	}
	// If not loaded, retry
	if (!allComplete) {
		this.imgTimer = window.setTimeout("F.SLD.galleryCallback1()", 250);
	// Once loaded, set the initially displayed image up and initalize the "sled" for animation
	} else {
		var aObj0 = document.getElementById("galleryBox");
		var aObj1 = document.getElementById("gallerySled");
		var obj0 = document.getElementById("galleryImg0");
		var obj1 = document.getElementById("galleryImg1");
		var obj2 = document.getElementById("galleryImg2");
		if (obj0 && obj1 && obj2) {
			var c1 = this.currentImage;
			var c2 = this.currentImage+1;
			c2 = (c2>this.imageCache[this.currentGallery].length-1)?0:c2;
			// First "galleryBox" contains a centered image
			obj0.src = this.imageCache[this.currentGallery][c1].src;
			aObj0.style.display = "block";
			aObj0.style.position = "absolute";
			aObj0.style.zIndex = "1";
			aObj0.style.backgroundColor= "transparent";
			obj0.style.display = "block";
			obj0.style.position = "absolute";
			this.scaleImage(obj0,aObj0);
			obj0.style.top = Math.floor((aObj0.offsetHeight-obj0.offsetHeight)/2)+"px";
			obj0.style.left = Math.floor((aObj0.offsetWidth-obj0.offsetWidth)/2)+"px";
			// Now set up incoming image to be similar
			aObj1.style.display = "block";
			aObj1.style.position = "absolute";
			aObj1.style.left = "0px";
			aObj1.style.top = "0px";
			aObj1.style.zIndex = "2";
			aObj1.style.width = aObj0.offsetWidth + "px";
			aObj1.style.backgroundColor= "transparent";
			obj1.style.position = "absolute";
		}
		obj = document.getElementById("galleryCaption");
		if (obj && this.imageText[this.currentGallery]) {
			if (this.imageText[this.currentGallery] && this.imageText[this.currentGallery][this.currentImage])
				obj.innerHTML = this.imageText[this.currentGallery][this.currentImage];
			else
				obj.innerHTML = "";
		}
		if (this.currentState==0) this.imgTimer = window.setInterval("F.SLD.galleryCallback2()", 5000);
//		this.imgTimer = window.setTimeout("F.SLD.galleryCallback2()", 6000);
	}
}

FOBJ.prototype.slideshow.prototype.galleryCallback2 = function() {
	this.currentImage++;
	this.saveImage();
	this.go();
}

FOBJ.prototype.slideshow.prototype.scaleImage = function (obj1,obj0) {
	// Scale obj1 to fit inside obj0
	obj1.style.width="";
	obj1.style.height="";
	var r,w=obj1.offsetWidth,h=obj1.offsetHeight;
	if (h>obj0.offsetHeight) {
		r = obj0.offsetHeight/h;
		obj1.style.height = obj0.offsetHeight+"px";
		w = Math.floor(w*r);
		obj1.style.width = w+"px"; 
	}
	if (w>obj0.offsetWidth) {
		r = obj0.offsetWidth/w;
		obj1.style.width = obj0.offsetWidth+"px";
		h = Math.floor(h*r);
		obj1.style.height = h+"px"; 
	}
}
FOBJ.prototype.slideshow.prototype.go = function() {
	if (this.currentImage>this.imageCache[this.currentGallery].length-1) this.currentImage = 0;
	if (this.currentImage<0)this.currentImage = this.imageCache[this.currentGallery].length-1;
	this.saveImage();
	var aObj0 = document.getElementById("galleryBox");
	var aObj1 = document.getElementById("gallerySled");
	var obj0 = document.getElementById("galleryImg0");
	var obj1 = document.getElementById("galleryImg1");
	var obj2 = document.getElementById("galleryImg2");
	if (obj0 && obj1 && obj2) {
		// Put the image we are moving onto display into the second object
		setOpacity(aObj1,0);
		setOpacity(aObj0,1);
		aObj1.style.display = "block";
		obj1.src = this.imageCache[this.currentGallery][this.currentImage].src;
		obj1.style.display = "block";
		this.scaleImage(obj1,aObj0);
		obj1.style.top = Math.floor((aObj0.offsetHeight-obj1.offsetHeight)/2)+"px";
		obj1.style.left = Math.floor((aObj0.offsetWidth-obj1.offsetWidth)/2)+"px";
		var eff1 = new F.ANM.effect("fade",2,null,null,F.SLD.resetSlide,0,1,null,null);
		var eff2 = new F.ANM.effect("fade",2,null,null,F.SLD.resetSlide,1,0,null,null);

		// Slide the sled into place
		F.ANM.animate(aObj1.id,eff1);
		F.ANM.animate(aObj0.id,eff2);
	}
	obj = document.getElementById("galleryCaption");
	if (obj && this.imageText[this.currentGallery]) {
		if (this.imageText[this.currentGallery] && this.imageText[this.currentGallery][this.currentImage])
			obj.innerHTML = this.imageText[this.currentGallery][this.currentImage];
		else
			obj.innerHTML = "";
	}
}
FOBJ.prototype.slideshow.prototype.resetSlide = function() {
	var aObj0 = document.getElementById("galleryBox");
	var aObj1 = document.getElementById("gallerySled");
	var obj0 = document.getElementById("galleryImg0");
	var obj1 = document.getElementById("galleryImg1");
	var obj2 = document.getElementById("galleryImg2");
	if (obj0 && obj1 && obj2) {
		// Show the gallery box
		setOpacity(aObj0,1);
		aObj0.style.display = "block";
		obj0.src = F.SLD.imageCache[F.SLD.currentGallery][F.SLD.currentImage].src;
		F.SLD.scaleImage(obj0,aObj0);
		obj0.style.top = Math.floor((aObj0.offsetHeight-obj0.offsetHeight)/2)+"px";
		obj0.style.left = Math.floor((aObj0.offsetWidth-obj0.offsetWidth)/2)+"px";
		
		// Hide the fader box
		setOpacity(aObj1,0);
		aObj1.style.display = "none";
	}
}
FOBJ.prototype.slideshow.prototype.setState = function(on) {
	obj0 = document.getElementById("galleryOn");
	obj1 = document.getElementById("galleryOff");
	var was = this.currentState;
	this.currentState = (on)?0:1;
	if (was!=this.currentState && obj0 && obj1) {
		var cs = obj0.className;
		if (cs.indexOf("-selected")>=0) cs = obj1.className;
		if (this.currentState==0) obj0.className =  obj0.className + "-selected";
		else obj0.className = cs;
		if (this.currentState==1) obj1.className =  obj1.className + "-selected";
		else obj1.className = cs;
		obj0 = document.getElementById("galleryState");
		if (obj0) obj0.value = this.currentState;
	}
}
FOBJ.prototype.slideshow.prototype.saveImage = function() {
	var obj = document.getElementById("galleryImage");
	if (obj) obj.value = this.currentImage;
}

FOBJ.prototype.slideshow.prototype.clear = function() {
	if (this.imgTimer) window.clearTimeout(this.imgTimer);
	this.imgTimer = null;
	this.setState(false);
}
FOBJ.prototype.slideshow.prototype.stopSlideshow = function() {
	this.clear();
	return false;
}
FOBJ.prototype.slideshow.prototype.startSlideshow = function() {
	this.setState(true);
	this.galleryCallback1();
	this.currentImage++;
	this.saveImage();
	this.go();
	return false;
}
FOBJ.prototype.slideshow.prototype.goFirstSlideshow = function() {
	this.clear();
	this.currentImage = 0;
	this.saveImage();
	this.go();
	return false;
}
FOBJ.prototype.slideshow.prototype.goLastSlideshow = function() {
	this.clear();
	this.currentImage = this.imageCache[this.currentGallery].length-1;
	this.saveImage();
	this.go();
	return false;
}
FOBJ.prototype.slideshow.prototype.goNextSlideshow = function() {
	this.clear();
	this.currentImage++;
	this.saveImage();
	this.go();
	return false;
}
FOBJ.prototype.slideshow.prototype.goPrevSlideshow = function() {
	this.clear();
	this.currentImage--;
	this.saveImage();
	this.go();
	return false;
}
FOBJ.prototype.slideshow.prototype.switchGallery = function(thisObj,thisEvt) {
	var i = parseInt(thisObj.value,10);
	if (thisObj.checked) {
		if (this.imgTimer) window.clearTimeout(this.imgTimer);
		this.imgTimer = null;
		var aObj0 = document.getElementById("galleryBox");
		aObj0.style.display = "none";
		this.currentGallery = i;
		this.currentImage = 0;
		this.saveImage();
		this.galleryLoad();
	}
}


//-------------------------------------------------------------
// Animation
//-------------------------------------------------------------
FOBJ.prototype.animation = function () {
	this.animationTimer = null;
	this.animationObjects = [];
}

// Basic usage scenario:
// 1)	Construct an effect object that describes the desired animation effect
//		var effect = new F.ANM.effect(params);
// 2)	Animate an object (usually a div)
//		F.ANM.animate(objid,effect);
// 3)	Optionally halt animation before it completes
//		F.ANM.unanimate(objid,effect);

// Names and arguments for effects
//
// fade		Fade out the object off display or fade the object onto display (modify opacity)
//			speed:	Ranges from 1 (fastest) to 9 (slowest)
// 			param1:	Starting opacity.  Opacity ranges from 0 (not visible) to 1 (fully visible)
//			param2: Ending opacity.	 Opacity ranges from 0 (not visible) to 1 (fully visible)
//			To fade something in,  make the ending opacity greater than the start opacity.  E.g., param1=0 param2=1
//			To fade something out, make the starting opacity greater than the end opacity.  E.g., param1=1, param2=0
// show		Shows more (or less) of an object (increases the height and/or width of an object)
//			speed:	Ranges from 1 (fastest) to 9 (slowest). Usually set to 1 or 2.
// 			param1:	Starting height in pixels (if -1, height isn't changed during effect)
//			param2: Ending height in pixels
// 			param3:	Starting width in pixels (if -1, width isn't changed during effect)
//			param4: Ending width in pixels
//			For example to "unfurl" a menu, set the starting height to 0, the ending height to 300, the width to -1
//			Note for "show" to work well, the object should be set up with an initial height and width AND overflow should be set to hidden on the object
// move		Change the position of an object (changes left and/or top of the object)
//			speed:	Ranges from 1 (fastest) to 9 (slowest).  Usually set to 1 or 2.
// 			param1:	Starting left position (in pixels), -1 if left/right position doesn't change
//			param2: Ending left position in pixels
// 			param1:	Starting top position (in pixels), -1 if top/bottom position doesn't change
//			param4: Ending right position in pixels
//			For example to move an object from left to right, set param1 to 1000, param2 to 0 and param3 to -1
//			Note for "move" to work well, the object should be set up with an initial height and width AND overflow should be set to hidden on the object

// Effect description object
FOBJ.prototype.animation.prototype.effect = function (name,speed,startcallback,drawcallback,endcallback,param1,param2,param3,param4) {
	this.effect = name;
	this.speed  = speed;
	this.param1 = param1;
	this.param2 = param2;
	this.param3 = param3;
	this.param4 = param4;
	this.startcallback = startcallback;
	this.endcallback = endcallback;
	this.drawcallback = drawcallback;
}

// Primary function -- add one or more animation effects to a div and start the effect
// Argument = one animationEffect object (defined above) OR an array of animationEffect objects
FOBJ.prototype.animation.prototype.animate = function (objid,effect) {
	if (objid && effect) {
		// Convert argument to array if need be
		var effects = effect;
		if (effect && effect.length==undefined) {
			effects = [effect];
		}
		// Check that the object exists
		var i,j,o,e,obj = document.getElementById(objid);
		if (obj) {
			var created = 0;
			for (i=0; i<effects.length; i++) {
				o = effects[i];
				if (o.effect=="fade") {
					F.ANM.checkEndTimer(obj,"fade");
					n = new F.ANM.animationObject();
					n.obj = obj;
					n.effect = "fade";
					n.speed = (o.speed>0&&o.speed<10)?o.speed:1;
					n.intervalCounter = n.speed;
					n.param1 = o.param1;
					n.param2 = o.param2;
					n.state1 = n.param1;
					n.startcallback = o.startcallback;
					n.endcallback = o.endcallback;
					n.drawcallback = o.drawcallback;
					F.ANM.animationObjects.push(n);
					created++;
					setOpacity(n.obj,o.param1);
					if (n.obj.style.display!="block") n.obj.style.display = "block";
				} else if (o.effect=="show") {
					F.ANM.checkEndTimer(obj,"show");
					var diff,slice;
					n = new F.ANM.animationObject();
					n.obj = obj;
					n.effect = "show";
					n.speed = (o.speed>0&&o.speed<10)?o.speed:1;
					n.intervalCounter = n.speed;
					n.param1 = o.param1;
					n.param2 = o.param2;
					n.param3 = o.param3;
					n.param4 = o.param4;
					n.state1 = n.param1;
					n.state2 = n.param3;
					n.startcallback = o.startcallback;
					n.endcallback = o.endcallback;
					n.drawcallback = o.drawcallback;
					if (n.state1>=0) {
						diff = Math.abs(n.param1-n.param2);
						slice = Math.floor(diff/50);
						if (slice < 0) slice = 3;
						if (diff>100) slice = 6;
						if (diff>200) slice = 9;
						n.state5 = n.state3 = (n.param1<n.param2)?slice:-slice;
					} 
					if (n.state2>=0) {
						diff = Math.abs(n.param3-n.param4);
						slice = Math.floor(diff/50);
						if (slice < 0) slice = 3;
						if (diff>100) slice = 6;
						if (diff>200) slice = 9;
						n.state6 = n.state4 = (n.param3<n.param4)?slice:-slice;
					}
					F.ANM.animationObjects.push(n);
					created++;
				} else if (o.effect=="move") {
					F.ANM.checkEndTimer(obj,"move");
					var diff,slice;
					n = new F.ANM.animationObject();
					n.obj = obj;
					n.effect = "move";
					n.speed = (o.speed>0&&o.speed<10)?o.speed:1;
					n.intervalCounter = n.speed;
					n.param1 = o.param1;
					n.param2 = o.param2;
					n.param3 = o.param3;
					n.param4 = o.param4;
					n.state1 = n.param1;
					n.state2 = n.param3;
					n.startcallback = o.startcallback;
					n.endcallback = o.endcallback;
					n.drawcallback = o.drawcallback;
					if (n.state1!=null) {
						diff = Math.abs(n.param1-n.param2);
						if (diff<10) slice = 1;
						else if (diff<100) slice = 2;
						else if (diff<200) slice = 4;
						else if (diff<300) slice = 8;
						else slice = 10;
						n.state5 = n.state3 = (n.param1<n.param2)?slice:-slice;
						n.state1 = n.obj.offsetLeft;
					} 
					if (n.state2!=null) {
						diff = Math.abs(n.param3-n.param4);
						if (diff<10) slice = 1;
						else if (diff<100) slice = 2;
						else if (diff<200) slice = 4;
						else if (diff<300) slice = 815;
						else slice = 6;
						n.state6 = n.state4 = (n.param3<n.param4)?slice:-slice;
						n.state2 = n.obj.offsetTop;	
					}
					F.ANM.animationObjects.push(n);
					created++;
				}
			}
			if (created>0) F.ANM.startTimer();
		}
	}
}
// Secondary function -- stop an animation
FOBJ.prototype.animation.prototype.unanimate = function (objid, effect) {
	var obj = document.getElementById(objid);
	var eff = effect.toLowerCase();
	if (obj) {
		if (eff=="fade") {
			F.ANM.checkEndTimer(obj,"fade");
		} else if (eff=="move") {
			F.ANM.checkEndTimer(obj,"move");
		} else if (eff=="show") {
			F.ANM.checkEndTimer(obj,"show");
		}
	}
}

//******************************************************************
// Animation TIMER control block
//******************************************************************
// Object used to run an effect
FOBJ.prototype.animation.prototype.animationObject = function () {
	this.obj = null;
	this.effect = "";
	this.param1 = 1;
	this.param2 = 0;
	this.param3 = 0;
	this.param4 = 0;
	this.state1 = 0;
	this.state2 = 0;
	this.state3 = 0;
	this.state4 = 0;
	this.state5 = 0;
	this.state6 = 0;
	this.speed = 5;
	this.intervalCounter = 0;
	this.startcallback = null;
	this.endcallback = null;
	this.drawcallback = null;
}

//******************************************************************
// Animation TIMER callback
//******************************************************************
FOBJ.prototype.animation.prototype.timerCallback = function () {
	var i,o;
	for (i=0; i<F.ANM.animationObjects.length; i++) {
		o = F.ANM.animationObjects[i];
		if (o && o.obj) {
			o.intervalCounter--;
			if (o.intervalCounter <=0) {
				o.intervalCounter = o.speed;
				if (o.effect=="fade") {
					var was = o.obj;
					var iv = (o.speed==1)?0.20:((o.speed==2)?0.10:((o.speed=3)?0.05:0.025));
					if (o.param1>o.param2) {
						o.state1 = o.state1 - iv;
						if (o.state1 < .05) {
							setOpacity(o.obj,1);
							o.obj.style.display = "none";
							o.obj = null;
						} else {
							setOpacity(o.obj,o.state1);
						}
					} else {
						o.state1 = o.state1 + iv;
						if (o.state1 > 0.95) {
							setOpacity(o.obj,1);
							o.obj = null;
						} else {
							setOpacity(o.obj,o.state1);
						}
					}
					if (o.drawcallback!=null) o.drawcallback.call(this,was);
					if (o.obj==null) {
						if (o.endcallback!=null) o.endcallback.call(this,was);
					}
				} else if (o.effect=="show") {
					var hDone=false;
					var vDone=false;
					if (o.state1>=0) {
						o.state1 = o.state1 + o.state3;
						if ((o.param1<o.param2 && o.state1>=o.param2) || (o.param1>=o.param2 && o.state1<=o.param2)) {
							o.state1 = o.param2;
							hDone = true;
						}
						if (o.obj.offsetHeight!=o.state1) o.obj.style.height = o.state1+"px";
					} else hDone = true;
					if (o.state2>=0) {
						o.state2 = o.state2 + o.state4;
						if ((o.param3<o.param4 && o.state2>=o.param4) || (o.param3>=o.param4 && o.state2<=o.param4)) {
							o.state2 = o.param4;
							vDone = true;
						}
						if (o.obj.offsetWidth!=o.state2) o.obj.style.width = o.state2+"px";
					} else vDone = true;
					if (vDone && hDone) o.obj = null;
				} else if (o.effect=="move") {
					var hDone=false, vDone=false;
					var sgn,pct,diff,cpos, third;
					if (o.state1!=null && o.state1!=-1) {
						o.state1 = o.state1 + o.state3;
						if ((o.param1<o.param2 && o.state1>=o.param2) || (o.param1>=o.param2 && o.state1<=o.param2)) {
							o.state1 = o.param2;
							hDone = true;
						}
						if (o.obj.offsetLeft!=o.state1) o.obj.style.left = Math.floor(o.state1)+"px";
					} else hDone = true;
					if (o.state2!=null && o.state2!=-1) {
						o.state2 = o.state2 + o.state4;
						if ((o.param3<o.param4 && o.state2>=o.param4) || (o.param3>=o.param4 && o.state2<=o.param4)) {
							o.state2 = o.param4;
							vDone = true;
						}
						if (o.obj.offsetTop!=o.state2) o.obj.style.top = o.state2+"px";
					} else vDone = true;
					if (hDone) o.state1 = -1;
					if (vDone) o.state2 = -1;
					if (vDone && hDone) o.obj = null;
					if (o.drawcallback!=null) o.drawcallback.call(this,o.obj);
					if (vDone && hDone) {
						if (o.endcallback!=null) o.endcallback.call(this,o.obj);
						o.obj = null;
					}
				}
			}
		}
	}
	while (F.ANM.animationObjects.length>0 && F.ANM.animationObjects[F.ANM.animationObjects.length-1].obj==null) {
		o =	F.ANM.animationObjects.pop();
		delete o;
	}
	F.ANM.checkEndTimer();
}

//******************************************************************
// HELPER functions
//******************************************************************

FOBJ.prototype.animation.prototype.startTimer = function () {
	if (F.ANM.animationTimer==null) {
		F.ANM.animationTimer = window.setInterval("F.ANM.timerCallback()",12);
	}
}

FOBJ.prototype.animation.prototype.endTimer = function () {
	if (F.ANM.animationTimer!=null) {
		window.clearTimeout(F.ANM.animationTimer);
		F.ANM.animationTimer = null;
	}
}
FOBJ.prototype.animation.prototype.checkEndTimer = function (obj,effect) {
	if (obj && effect && effect.length>0) {
		var i,o;
		for (i=0; i<F.ANM.animationObjects.length; i++) {
			o = F.ANM.animationObjects[i];
			if (o.obj==obj && o.effect==effect.toLowerCase()) {
				o.obj = null;
			}
		}
		while (F.ANM.animationObjects.length>0 && F.ANM.animationObjects[F.ANM.animationObjects.length-1].obj==null) {
			o =	F.ANM.animationObjects.pop();
			delete o;
		}
	}
	if (F.ANM.animationObjects.length==0 && F.ANM.animationTimer) F.ANM.endTimer();
}

//-------------------------------------------------------------
// Calendar
//-------------------------------------------------------------
FOBJ.prototype.calendar = function () {
	this.events = null;
	this.calObj = null;
	this.listObj = null;
	this.monthNames = ["January","February","March","April","May","June","July","August","September","October","November","December"];
	this.dayNames = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
	this.months = [];
	this.firstMonth = null;
	this.firstYear = null;
	this.lastMonth = null;
	this.lastYear = null;
	this.adjLastMonth = null;
	this.currentMonth = 0;
	this.absMonthCount = 0;
}

FOBJ.prototype.calendar.prototype.init = function(cal,list,evts) {
	// Event (input) = date,time,linkid,long-text,short-text
		// date = date string of form "mm/dd/yyyy"
		// time = time string (any form, not parsed)
	//					0			   1    2      3         4           5               6
	// Event (parsed) = date-as-object,time,linkid,long-text,short-text, date-as-string, day-of-week-as-string
	this.calObj = document.getElementById(cal);
	this.listObj = document.getElementById(list);
	this.events = evts;
	var i,s,ln,lne,z;
	if (this.events && this.events.length>0) {
	
		// Calculate the dates for each event
		z = this.events.length;
		for (i=0; i<z; i++) {
			ln = this.events[i];
			ln[0] = new Date(ln[0]);
			ln[5] = this.monthNames[ln[0].getMonth()]  + " " + ln[0].getDate();
			ln[6] = this.dayNames[ln[0].getDay()];
		}
		this.events.sort(function(a,b) { return ((a[0].getTime()<b[0].getTime())?-1:((a[0].getTime()==b[0].getTime())?0:+1)); });
		// Calculate the Months covered by the calendar
		this.firstMonth = this.events[0][0].getMonth();
		this.firstYear = this.events[0][0].getFullYear();
		this.lastMonth = this.events[this.events.length-1][0].getMonth();
		this.lastYear = this.events[this.events.length-1][0].getFullYear();
		this.adjLastMonth = (this.lastMonth>=this.firstMonth)?this.lastMonth:(this.lastMonth+12); 
		this.absMonthCount = (this.adjLastMonth-this.firstMonth)+1;

		// Render the List -- there is only one list on display and it currently shows all things
		var MONTHSTR = this.monthNames[this.firstMonth];
		if (this.firstYear!=this.lastYear) MONTHSTR = MONTHSTR + " " + this.firstYear;
		if (this.firstMonth!=this.lastMonth) {
			MONTHSTR = MONTHSTR + " - " + this.monthNames[this.lastMonth];
			if (this.firstYear!=this.lastYear) MONTHSTR = MONTHSTR + " " + this.lastYear;
		}
		if (this.firstYear==this.lastYear) MONTHSTR = MONTHSTR + " " + this.firstYear;
		if (this.listObj) {
			var str = "<table width='100%' cellspacing='0' cellpadding='2' border='0'><tbody>";
			str = str + "<tr><td colspan='2' style='padding-bottom:8pt'>";
			str = str + "<table width='100%' cellspacing='0' cellpadding='0' border='0' class='Calendar-Header'><tbody>"
			str = str + "<tr><td valign='middle' align='right' class='Calendar-HeaderSpacer' />";
			str = str + "<td valign='middle' align='center' class='Calendar-HeaderText'>" + MONTHSTR + "</td>";
			str = str + "<td valign='middle' align='right' class='Calendar-HeaderSpacer'>";
			s = "<a href='#' class='scheduleLink' ";
			s = s + 'onclick="' + "return swapSections('ScheduleList','ScheduleCalendar','calendarState');" + '" ';
			s = s + ">Show as calendar</a>";
			str = str + s + "</td>";
			str = str + "</tr></tbody></table>";
			str = str + "</td></tr>";
			z = this.events.length;
			for (i=0; i<z; i++) {
				ln  = this.events[i];
				s = "<tr><td class='scheduleLineLeft' valign='top'>";
				s = s + "<a href='#" + ln[2] + "'>" + ln[5] + ", " + ln[1] + " (" + ln[6] + ")</a></td>";
				s = s + "<td class='scheduleLineRight' valign='top'>" + ln[3] + "</td></tr>";
				str = str + s;
			}
			str = str + "</tbody></table>";
	
			this.listObj.innerHTML = str;
		}
		// Render this month in the calendar
		if (this.calObj) {
			var m,mm,absFirstSunday,check,firstDayOfMonth,curMonth,curYear=this.firstYear;
			for (mm = this.firstMonth; mm<=this.adjLastMonth; mm++) {
				if (mm>11) {
					m = mm-12;
					if (m==0) curYear++;
				} else {
					m = mm;
				}

				firstDayOfMonth = new Date();
				firstDayOfMonth.setDate(1);
				firstDayOfMonth.setHours(0, 1, 0, 0);
				firstDayOfMonth.setYear(curYear);
				firstDayOfMonth.setMonth(m);
				absFirstSunday = firstDayOfMonth.getDay();
				check = 8;
				while(absFirstSunday!=0 && check>0) {
					firstDayOfMonth.setDate(firstDayOfMonth.getDate()-1);			
					absFirstSunday = firstDayOfMonth.getDay();
					check--;
				}

				var str = "<table width='100%' cellspacing='0' cellpadding='0' border='0'><tbody>";
				str = str + "<tr><td valign='top' align='left'>";
				str = str + "<table width='100%' cellspacing='0' cellpadding='0' border='0' class='Calendar-Header'><tbody>"
				str = str + "<tr>";
				str = str + "<td valign='middle' align='right' class='Calendar-HeaderSpacer' />"
				if (this.absMonthCount>1 && mm!=this.firstMonth)
					str = str + "<td valign='middle' align='right' class='Calendar-HeaderButton'><a class='Calendar-HeaderLinkL' href='#' title='previous month' onclick='return F.CAL.prevMonth();'><img src='imgs/1x1.gif' alt='previous month' title='previous month' border='0'></a></td>"
				else
					str = str + "<td valign='middle' align='right' class='Calendar-HeaderButton'>&nbsp;</td>"
				str = str + "<td valign='middle' align='center' class='Calendar-HeaderText'>"+this.monthNames[m]+" "+curYear+"</td>"
				if (this.absMonthCount>1 && mm!=this.adjLastMonth)
					str = str + "<td valign='middle' align='left'  class='Calendar-HeaderButton'><a class='Calendar-HeaderLinkR' href='#' title='next month' onclick='return F.CAL.nextMonth();'><img src='imgs/1x1.gif' alt='next month' title='next month' border='0'></a></td>";					
				else 
					str = str + "<td valign='middle' align='left'  class='Calendar-HeaderButton'>&nbsp;</td>";					
				str = str + "<td valign='middle' align='right' class='Calendar-HeaderSpacer'>";
				s = "<a href='#' class='scheduleLink' ";
				s = s + 'onclick="' + "return swapSections('ScheduleCalendar','ScheduleList','calendarState');" + '" ';
				s = s + ">Show as list</a>";
				str = str + s + "</td>";
				str = str + "</tr>";
				str = str + "</tbody></table>";
				str = str + "</td></tr>";
				str = str + "<tr><td valign='top' align='left'>"
				str = str + "<table width='100%' cellspacing='0' cellpadding='0' border='0' class='Calendar-Body'><tbody>";
				str = str + "<tr>";
				for (i=0; i<7; i++) {
					str = str + "<td valign='middle' align='center' class='Calendar-HeaderWeekday'>"+this.dayNames[i]+"</td>";
				}
				// Core grid code
				var done = false;
				var thisDay = firstDayOfMonth;
				var wkDay=0;
				var ss,cls = "";
				while (!done) {
					cls = (thisDay.getMonth()==m)?"Calendar-ThisMonthDay":"Calendar-MonthDay";
					if (this.dateToday(thisDay)) cls = "Calendar-Today";
					if (wkDay==0) str = str + "<tr>";
					str = str + "<td valign='top' align='left' class='"+cls+"'>";
					str = str + thisDay.getDate();
					ln = this.findEvent(thisDay);
					for (i=0; ln!=null && i<ln.length; i++) {
						lne = ln[i];
						ss = 'F.TIP.showTip("'+dequote(lne[1])+'","'+dequote(lne[3])+'",event)';
						s = "<a onmouseover='"+ss+"' onmouseout='F.TIP.hideTip()' class='Calendar-content' href='events.html#" + lne[2] + "'>"+lne[4]+ "</a>";
						str = str + s;			
					}
					str = str + "</td>";
					wkDay++;
					if (wkDay>6) wkDay=0;
					if (wkDay==0) str = str + "</tr>";
					thisDay.setDate(thisDay.getDate()+1);
					if (m==0) {
						if (thisDay.getMonth()==1) done = true;
					} else if (m==11) {
						if (thisDay.getMonth()==0) done = true;
					} else {
						if (thisDay.getMonth()>m) done = true;
					}
				}
				if (wkDay>0) {
					for (wkDay; wkDay<7; wkDay++) {
						str = str + "<td valign='top' align='left' class='Calendar-MonthDay'>";
						str = str + thisDay.getDate();
						ln = this.findEvent(thisDay);
						for (i=0; ln!=null && i<ln.length; i++) {
							lne = ln[i];
							ss = 'F.TIP.showTip("'+dequote(lne[1])+'","'+dequote(lne[3])+'",event)';
							s = "<a onmouseover='"+ss+"' onmouseout='F.TIP.hideTip()' class='Calendar-content' href='events.html#" + lne[2] + "'>"+lne[4]+ "</a>";
							str = str + s;			
						}
						str = str + "</td>";
						thisDay.setDate(thisDay.getDate()+1);
					}
					str = str + "</tr>";
				}
				str = str + "</tr>";
	
				str = str + "</tbody></table>";
				this.months.push(str);
			}
			this.calObj.innerHTML = this.months[this.currentMonth];
		}
	}
}
FOBJ.prototype.calendar.prototype.findEvent = function(d) {
	var r=null, ln, z = this.events.length;
	for (var i=0; i<z; i++) {
		ln = this.events[i];
		if (this.datesEqual(ln[0],d)) {
			if (r==null) r = [];
			r.push(ln);
		} else {
			if (this.datesGreaterThan(ln[0],d)) break;
		}
	}
	return r;
}

FOBJ.prototype.calendar.prototype.datesGreaterThan = function(d1,d2) {
	var y1 = d1.getFullYear();
	var y2 = d2.getFullYear(0);
	if (y1>y2) return true;
	var m1 = d1.getMonth();
	var m2 = d2.getMonth();
	m2 = m2 + ((y2-y1)*12);
	if (m1>m2) return true;
	if (m1==m2 && (d1.getDate()>d2.getDate())) return true;
	return false;
}
FOBJ.prototype.calendar.prototype.datesEqual = function(d1,d2) {
	if ((d1.getFullYear()==d2.getFullYear()) && (d1.getMonth()==d2.getMonth()) && (d1.getDate()==d2.getDate()))
		return true;
	return false;
}
FOBJ.prototype.calendar.prototype.dateToday = function(d1) {
	var d2 = new Date();
	if ((d1.getFullYear()==d2.getFullYear()) && (d1.getMonth()==d2.getMonth()) && (d1.getDate()==d2.getDate()))
		return true;
	return false;
}
FOBJ.prototype.calendar.prototype.nextMonth = function() {
	this.currentMonth++;
	if (this.currentMonth >= this.absMonthCount) this.currentMonth = this.absMonthCount-1;
	this.calObj.innerHTML = this.months[this.currentMonth];
}
FOBJ.prototype.calendar.prototype.prevMonth = function() {
	this.currentMonth--;
	if (this.currentMonth <0) this.currentMonth = 0;
	this.calObj.innerHTML = this.months[this.currentMonth];
}


//-------------------------------------------------------------
// Tooltip
//-------------------------------------------------------------
FOBJ.prototype.tooltip = function () {
	this.div = null;
	this.currentDiv = null;
}

FOBJ.prototype.tooltip.prototype.showTip = function (str1,str2,evt) {
	evt = (evt) ? evt : ((event) ? event: null);
	if (evt) {
		var tgt = ((evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null));
		if (this.div==null) {
			this.div = document.createElement("DIV");
			this.div.setAttribute("ID","FARNWR_TIP");
			this.div.className = "calendarTip";
			this.div.style.display = "none";
			this.div.style.position = "absolute";
			this.div.style.left = "10px";
			this.div.style.top = "10px";
			this.div.style.zIndex = "999";
			document.body.appendChild(this.div);
		}
		if (tgt) {
			var X = tgt.offsetLeft;
			var Y = tgt.offsetTop;
			p = tgt.offsetParent;
			while (p) {
				X = X + p.offsetLeft;
				Y = Y + p.offsetTop;
				p = p.offsetParent;
			}
			this.div.style.width = "";
			this.div.style.left = (X+20)+"px";
			this.div.style.top = (Y+tgt.offsetHeight+16)+"px";
			var x = "<table border='0' cellpadding='0' cellspacing='0'><tr><td valign='top' width='68'>"+str1+"</td><td valign='top'>"+str2+"</td></tr></table>";
			this.div.innerHTML = x;
			this.div.style.display = "block";
			if (this.div.offsetWidth>450) this.div.style.width="450px";
			
		}
	}
}
FOBJ.prototype.tooltip.prototype.hideTip = function () {
	if (this.div) this.div.style.display = "none";
}

if ((typeof F) == 'undefined' || !F) { var F = new FOBJ(); }
