/**************************************************************************************************/
/***
/***	TERNSTYLE (TM) DELUXE JAVASCRIPT DOCUMENT (ternStyle (tm),ternVENTS (tm),ternJAX (tm), ternForm (tm))
/***	-----------------------------------------------------------------------
/***	Written by Matthew Praetzel. Copyright (c) 2007 Matthew Praetzel.
/***	-----------------------------------------------------------------------
/***	All Rights Reserved. Any use of these functions & scripts without written consent is prohibited.
/***
/**************************************************************************************************/

/*-----------------------
	Initialize
-----------------------*/
var ternStances = [],jaxStances = [],ternScripts = [],ternImages = [];
/*-----------------------
	ternDOM (tm)  v1.2
-----------------------*/
var ternStyle = function (i) {
	var th = this,a = ternStances,l = a.length,v;
	if(window == th) {
		if(i) {
			v = _ternStyle.inArray(a,i,"node");
			if(v !== false) {
				return a[v]["object"];
			}
			a[l] = new Array();
			a[l]["node"] = _ternStyle.getNode(i);
			a[l]["object"] = new ternStyle(i);
			return a[l]["object"];
		}
		return new ternStyle(i);
	}
	th.getBrowserType();
	i = th.isArray(i) ? i : [i];
	th.tern = [];
	for(var b=0;b<i.length;b++) {
		th.tern[b] = th.getNode(i[b]);
	}
};
ternStyle.prototype = _ternStyle = {
	addClass : 
	function (c) {
		var i = this.tern;
		for(var a=0;a<i.length;a++) {
			if(i[a].nodeName && !this.hasClass(c,i[a])) {
				i[a].className = i[a].className.length > 0 ? i[a].className + " " + c : c;
			}
		}
		return this;
	},
	removeClass : 
	function (c) {
		var i = this.tern,n;
		for(var a=0;a<i.length;a++) {
			if(i[a].className) {
				n = i[a].className.split(/\s+/);
				i[a].className = "";
				for(var b=0;b<n.length;b++) {
					if(n[b] != c) {
						i[a].className += i[a].className.length > 0 ? " " + n[b] : n[b];
					}
				}
			}
		}
		return this;
	},
	hasClass :
	function (c,i) {
		var i = i ? i : this.tern[0],n;
		if(i.className) {
			n = i.className.split(/\s+/);
			for(var a=0;a<n.length;a++) {
				if(n[a] == c) {
					return true;
				}
			}
		}
		return false;
	},
	toggleClass :
	function (c,d) {
		var i = this.tern;
		for(var a=0;a<i.length;a++) {
			if(i[a].nodeName && !this.hasClass(c,i[a])) {
				i[a].className = i[a].className.length > 0 ? i[a].className + " " + c : c;
			}
			else {
				this.removeClass(c,i[a]);
			}
		}
		return this;
	},
	setStyle : 
	function (p,v,i) {
		var th = this,p = th.fixStyle(p),i = i ? [th.getNode(i)] : th.tern,b;
		b = new Array("top","right","bottom","left","width","height","padding","margin","background-position","font-size");
		for(var a=0;a<i.length;a++) {
			var v = th.inArray(b,p) !== false && v.toString().indexOf("px") == -1 && v.toString().indexOf("%") == -1 && v != "auto" ? v + "px" : v;
			if(th.msie) {
				eval("i[a].style."+p+"='"+v+"';");
			}
			else if(i[a].style[p]) {
				i[a].style[p] = v;
			}
			else if(i[a].style.setProperty(p,v,null)) {
				i[a].style.setProperty(p,v,null);
			}
		}
		return th;
	},
	setOpacity :
	function (o,i) {
		var i = i ? [this.getNode(i)] : this.tern;
		for(var a=0;a<i.length;a++) {
			if(this.msie) {
				i[a].style.filter = o == 100 ? "" : "progid:DXImageTransform.Microsoft.Alpha(opacity="+o+")";
			}
			else {
				this.setStyle("opacity",o/100,i[a]);
			}
		}
		return this;
	},
	fixStyle :
	function (p) {
		if(this.msie && p.indexOf("-") != -1) {
			while(p.indexOf("-") != -1) {
				p = p.substr(0,p.indexOf("-")) + p.substr(p.indexOf("-")+1,1).toUpperCase() + p.substr(p.indexOf("-")+2);
			}
		}
		return p;
	}
};
ternStyle.prototype.extend = 
function (a) {
	for(k in a) {
		this[k] = _ternStyle[k] = a[k];
	}
}
ternStyle.prototype.extend({
	getStyle : 
	function (p,i) {
		var p = this.fixStyle(p),i = i ? this.getNode(i) : this.tern[0],v;
		if(this.msie) {
			eval("v = i.style."+p);
		}
		else if(i.style[p]) {
			v = i.style[p];
		}
		else if(i.style.getPropertyValue) {
			v = i.style.getPropertyValue(p);
		}
		else {
			eval("v = i.style."+p);
		}
		if(v && v.length > 0) {
			return v;
		}
		return false;
	},
	getDimensions : 
	function (i) {
		var s = [],i = i ? this.getNode(i) : this.tern[0],w,h;
		if(i.offsetWidth) {
			w = i.offsetWidth;h = i.offsetHeight;
		}
		else if(i.clientWidth) {
			w = i.clientWidth;h = i.clientHeight;
		}
		else if(i.innerWidth) {
			w = i.innerWidth;h = i.innerHeight;
		}
		s[0] = s["x"] = s["w"] = s["width"] = w;
		s[1] = s["y"] = s["h"] = s["height"] = h;
		return s;
	},
	getCoords : 
	function (i,p) {
		var i = i ? this.getNode(i) : this.tern[0],c = [],p = p == true ? p : this.getNode(p),x = 0,y = 0;
		if(p == true) {
			x = i.offsetLeft;y = i.offsetTop;
		}
		else if(p) {
			while(i != p) {
				x += i.offsetLeft-i.scrollLeft;y += i.offsetTop-i.scrollTop;i = i.offsetParent;
				if(!i.offsetParent) { break; }
			}
		}
		else {
			if(i.offsetParent) {
				while(i.offsetParent) {
					x += i.offsetLeft-i.scrollLeft;y += i.offsetTop-i.scrollTop;i = i.offsetParent;
				}
			}
			else if (i.x) {
				x += i.x;y += i.y;
			}
		}
		c[0] = c["left"] = x;c[1] = c["top"] = y;
		return c;
	},
	getOpacity : 
	function (i) {
		var i = i != undefined ? i : this.tern;
		if(i.style.filter) {
			var o = i.filters.item("DXImageTransform.Microsoft.Alpha").opacity;
		}
		else {
			var o = this.getStyle("opacity",i)*100;
		}
		return o;
	},
	itemScroll : 
	function (i) {
		var i = i ? this.getNode(i) : this.tern[0],s = [];
		s[0] = i.scrollLeft;
		s[1] = i.scrollTop;
		s[2] = i.scrollWidth;
		s[3] = i.scrollHeight;
		return s;
	},
	getScroll : 
	function (i) {
		var i = i ? this.getNode(i) : document;
		if(window.pageYOffset) {
			return i == document ? [window.pageXOffset,window.pageYOffset] : [i.top.pageXOffset,i.top.pageYOffset];
		}
		else if(document.body.scrollTop) {
			return [i.body.scrollLeft,i.body.scrollTop];
		}
		else if(document.documentElement.scrollTop) {
			return [i.documentElement.scrollLeft,i.documentElement.scrollTop];
		}
		return [0,0];
	}
});
ternStyle.prototype.extend({
	getData : 
	function (i) {
		var th = this,i = i  ? th.getNode(i) : th.tern[0],s = th.getDimensions(i),c = th.getCoords(i),d = s.concat(c);
		d[d.length] = i.className ? i.className.split(" ") : "";
		return d;
	},
	getNode :
	function (i) {
		if(typeof(i) == "string" && document.getElementById(i)) {
			return document.getElementById(i);
		}
		return i;
	},
	getElementsByClass :
	function (c,o,z,r,i,d,a) {
		var th = this,i;
		if(!i && !th.tern) {
			i = document;
		}
		else {
			i = i ? th.getNode(i) : th.tern[0];
		}
		var d = d ? d : i,ch = d.hasChildNodes ? d.childNodes : [];
		if(!a || !th.isArray(a)) {
			var a = [];
		}
		for(var b=0;b<ch.length;b++) {
			if(ch[b].className && th.hasClass(c,ch[b]) && (!z || (z && a.length != z))) {
				a.push(ch[b]);
			}
			if(z && a.length == z) {
				break;
			}
			if(!r) {
				a = th.getElementsByClass(c,o,z,r,i,ch[b],a);
			}
		}
		if(d == i) {
			if(o != false) {;
				return ternStyle(a);
			}
			else {
				return a.length > 0 ? a : false;
			}
		}
		else {
			return a;
		}
	},
	removeChildren : 
	function (i) {
		var i = i ? this.getNode(i) : this.tern;
		if(!this.isArray(i)) {
			i = [i];
		}
		for(var a=0;a<i.length;a++) {
			if(i[a].hasChildNodes) {
				while(i[a].firstChild) {
					i[a].removeChild(i[a].firstChild);
				}
			}
		}
	},
	moveChildren :
	function (p,r) {
		var i = this.tern[0],p = this.getNode(p),c = p.childNodes;
		if(r) {
			this.removeChildren();
		}
		for(var a=0;a<c.length;a++) {
			var n = c[a].cloneNode(true);
			i.appendChild(n);
		}
		return this;
	},
	getChildIndex :
	function (i) {
		var i = i ? this.getNode(i) : this.tern[0];c = i.parentNode.childNodes;
		for(a=0;a<c.length;a++) {
			if(c[a] == i) {
				return a;
			}
		}
		return false;
	}
});
ternStyle.prototype.extend({
	getWindowSize : 
	function () {
		var s = [];
		if(self.innerHeight) {
			s[0] = self.innerWidth;
			s[1] = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight) {
			s[0] = document.documentElement.clientWidth;
			s[1] = document.documentElement.clientHeight;
		}
		else if (document.body) {
			s[0] = document.body.clientWidth;
			s[1] = document.body.clientHeight;
		}
		return s;
	},
	getScroll : 
	function () {
		var s = [];
		if(self.pageYOffset) {
			s[0] = self.pageXOffset;
			s["left"] = self.pageXOffset;
			s[1] = self.pageYOffset;
			s["top"] = self.pageYOffset;
		}
		else if(document.documentElement.scrollTop) {
			s[0] = document.documentElement.scrollLeft;
			s["left"] = document.documentElement.scrollLeft;
			s[1] = document.documentElement.scrollTop;
			s["top"] = document.documentElement.scrollTop;
		}
		else if(document.body.scrollTop) {
			s[0] = document.body.scrollLeft;
			s["left"] = document.body.scrollLeft;
			s[1] = document.body.scrollTop;
			s["top"] = document.body.scrollTop;
		}
		else {
			s[0] = 0;
			s["left"] = 0;
			s[1] = 0;
			s["top"] = 0;
		}
		s[2] = this.scrollDImensions()[0];
		s[3] = this.scrollDImensions()[1];
		return s;
	},
	scrollDImensions : 
	function () {
		var s = document.body.scrollHeight;
		var o = document.body.offsetHeight;
		var e = document.documentElement.scrollHeight;
		var d = [];
		if (s > o) {
			d[0] = document.body.scrollWidth;
			d[1] = document.body.scrollHeight;
		}
		else if(e > o) {
			d[0] = document.documentElement.scrollWidth;
			d[1] = document.documentElement.scrollHeight;
		}
		else {
			d[0] = document.body.offsetWidth;
			d[1] = document.body.offsetHeight;
		}
		return d;
	},
	getBrowserType : 
	function () {
		var a = new Array("msie","opera","safari","netscape","mozilla"),r;
		for(var i=0;i<a.length;i++) {
			r = new RegExp(a[i],"");
			if(r.test(navigator.userAgent.toLowerCase())) {
				eval("this."+a[i]+"= true;");
				return;
			}
		}
	}
});
ternStyle.prototype.extend({
	isObject :
	function (o) {
		if((typeof o == "object" && !!o) || this.isFunction(o)) {
			return true;
		}
		return false;
	},
	isFunction : 
	function (f) {
		return typeof f == "function";
	},
	isArray : 
	function (a) {
		if(this.isObject(a) && typeof(a) != "string" && a.length > 0) {
			if((a.nodeName && a.nodeName.toLowerCase() != "select") || !a.type) {
				if((a.nodeName && a.nodeName.toLowerCase() != "form") || !a.nodeName) {
					return true;
				}
			}
		}
		else {
			return false;
		}
	},
	inArray :
	function (a,v,t) {
		for(var i=0;i<a.length;i++) {
			if(a[i] === v && !t) {
				return i;
			}
			else if(a[i][t] === v) {
				return i;
			}
		}
		return false;
	}
});
/*-----------------------
	ternStyle (tm) v1.0
-----------------------*/
ternStyle.prototype.extend({
	timer : [], times : [],
	fadeIn : 
	function (s,fn,h) {
		this.fade(s,0,100,fn,h);
		return this;
	},
	fadeOut : 
	function (s,fn,h) {
		this.fade(s,100,0,fn,h);
		return this;
	},
	fade : 
	function (s,o,eo,fn,h) {
		var th = this,i = th.tern;th.s = th.getSpeed(s),f;
		th.setOpacity(o).setStyle("visibility","visible");
		var f = eo == 0 && h != false ? function () { if(fn) { fn(); }th.setStyle("visibility","hidden"); } : fn;
		th.tween("opacity",o,eo,f);
		return this;
	},
	grow :
	function (s,a,wh,fn) {
		var th = this,i = th.isArray(th.tern) ? th.tern : [th.tern];th.s = th.getSpeed(s);
		for(var b=0;b<i.length;b++) {
			var d = th.getDimensions(i[b]);
			if(a == "xy") {
				th.tween("width",d[0],wh[0] || wh,s,false,i[b]);
				th.tween("height",d[1],wh[1] || wh,fn,i[b]);
			}
			else if(a.indexOf("x") != -1) {
				th.tween("width",d[0],wh[0] || wh,fn,i[b]);
			}
			else if(a.indexOf("y") != -1) {
				th.tween("height",d[1],wh[1] || wh,fn,i[b]);
			}
		}
		return th;
	},
	move :
	function (s,a,wh,fn) {
		var th = this,i = th.isArray(th.tern) ? th.tern : [th.tern];th.s = th.getSpeed(s);
		for(var b=0;b<i.length;b++) {
			var d = th.getCoords(i[b]);
			if(a == "xy") {
				th.tween("left",i[b].offsetLeft,wh[0] || wh,s,false,i[b]);
				th.tween("top",i[b].offsetTop,wh[1] || wh,fn,i[b]);
			}
			else if(a.indexOf("x") != -1) {
				th.tween("left",i[b].offsetLeft,wh[0] || wh,fn,i[b]);
			}
			else if(a.indexOf("y") != -1) {
				th.tween("top",i[b].offsetTop,wh[1] || wh,fn,i[b]);
			}
		}
		return th;
	},
	hovers :
	function (c,f,ef) {
		var th = this,i = th.isArray(th.tern) ? th.tern : [th.tern];
		for(var a=0;a<i.length;a++) {
			if(i[a].nodeName) {
				eval('ternVENTS.addEvent(i[a],function (e) { th.addClass(c,i['+a+']);if(f) { f(e); } },"mouseover",false);');
				eval('ternVENTS.addEvent(i[a],function (e) { th.removeClass(c,i['+a+']);if(ef) { ef(e); } },"mouseout",false);');
			}
		}
		
	},
	picFader :
	function (s) {
		var th = this,i = th.tern;th.s = th.getSpeed(s);
		th.setStyle("width",0).setStyle("visibility","hidden").setOpacity(0);
		th.pci = 0;
		th.setStyle("width","100%",i[0]).setStyle("visibility","visible",i[0]).setOpacity(100,i[0]);
		var pcf = function () {
			th.tween("opacity",100,0,function () { 
				th.setStyle("width",0,i[th.pci]);
				th.pci = th.pci+1 == i.length ? 0 : th.pci+1;
				th.setStyle("width","100%",i[th.pci]).setStyle("visibility","visible").tween("opacity",0,99,function () { setTimeout(pcf,s); },i[th.pci]);
			 },i[th.pci]);
		};
		setTimeout(pcf,s);
	}
});
ternStyle.prototype.extend({
	getSpeed :
	function (s) {
		if(s == "molasses") {
			return 5000;
		}
		else if(s == "slow") {
			return 2000;
		}
		else if(s == "medium") {
			return 1000;
		}
		else {
			return 500;
		}
	},
	tween :
	function (p,v,ev,f,i,s) {
		var th = this,i = i ? th.getNode(i) : th.tern;
		if(!th.timer[p]) {
			if(s) {
				th.s = th.getSpeed(s);
			}
			th.times[p] = 1;
			th.st = new Date();
			th.timer[p] = [];
			th.timer[p][0] = setInterval(function () { th.setStage(p,v,ev,f,i); },1);
		}
	},
	setStage :
	function (p,v,ev,f,i) {
		var th = this,i = i ? th.getNode(i) : th.tern,t = th.times[p],a = th.timer[p][1];
		var pt = new Date();
		var d = (pt-th.st);
		//
		t = d < th.s ? t+Math.round(((pt-th.st)/t)*t) : t+(th.s-(t+1));
		//
		var r = (t/th.s);
		var n = v < ev ? ((ev-v)*r) : ((v-ev)*r);
		//
		a = a || v;
		a = v < ev ? Math.floor(a+n) : Math.floor(a-n);
		//a = v < ev ? (-(ev-v)*(t/=th.s)*(t-2))+a : a-(-(ev-v)*(t/=th.s)*(t-2));
		if((v <= ev && a >= ev) || (v >= ev && a <= ev) || v == ev || d > th.s) {
			th.stage(p,ev,i);
			clearInterval(th.timer[p][0]);
			th.timer[p] = false;
			if(f) { f(); }
		}
		else {
			th.stage(p,a,i);
		}
	},
	stage : 
	function (p,v,i) {
		var i = i ? i : this.tern;
		if(this.isArray(i)) {
			for(var a=0;a<i.length;a++) {
				this.step(p,v,i[a]);
			}
		}
		else {
			this.step(p,v,i);
		}
	},
	step :
	function (p,v,i) {
		if(v || v == 0) {
			if(p == "opacity") {
				this.setOpacity(v,i);
			}
			else if(p == "scrollx") {
				i.scrollLeft = v;
			}
			else if(p == "scroll") {
				window.scrollTo(0,v);
			}
			else {
				this.setStyle(p,v,i);
			}
		}
	}
});
ternStyle.prototype.extend({
	dropShadow :
	function (d,w,p) {
		var th = this,i = th.tern,c = i.cloneNode(false),dt = th.getData(),ig = document.createElement("img");
		th.removeShadow(i);
		if(th.browser == "msie") {
			ig.setAttribute("src",d.substr(0,d.indexOf("/",9))+"/ternstyle/images/blank.gif");
			ig.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + d + "',sizingMethod='scale')";
		}
		else {
			ig.setAttribute("src",d);
		}
		if(p) {
			var p = p.split(" ");
			if(p[0] == "bottom") {
				th.setStyle("top",i.offsetTop,ig);
			}
			if(p[1] == "right") {
				th.setStyle("left",i.offsetLeft,ig).setStyle("width",parseInt(dt[0]+(w)),ig);
			}
			else if(p[1] == "both") {
				th.setStyle("left",i.offsetLeft-w,ig).setStyle("width",parseInt(dt[0]+(w*2)),ig);
			}
			th.setStyle("height",dt[1]+(w),ig);
		}
		else {
			th.setStyle("width",parseInt(dt[0]+(w*2)),ig).setStyle("height",dt[1]+(w*2),ig).setStyle("top",i.offsetTop-w,ig).setStyle("left",i.offsetLeft-w,ig);
		}
		th.setStyle("display","block",ig).setStyle("position","absolute",ig).setStyle("z-index",0,ig).addClass("ternShadow",ig);
		th.setStyle("z-index",1);
		i.parentNode.insertBefore(ig,i);
		return ig;
	},
	removeShadow :
	function (i) {
		var i = i ? i : this.tern,s = ternStyle(this.tern.parentNode).getElementsByClass("ternShadow",false);
		if(s) {
			s[0].parentNode.removeChild(s[0]);
		}
		return this;
	}
});
ternStyle.prototype.extend({
	elapsor :
	function (d,c,w,f,o,t) {
		var th = this,mask,elap;th.w = w ? w : 65,i = th.tern[0];
		var w = i == document.body ? th.getWindowSize() : th.getDimensions();
		var s = i == document.body ? th.getScroll() : th.itemScroll();
		mask = th.getMask();
		elap = ternStyle(mask).getElementsByClass("ternElapsor",false,1);
		elap = elap ? elap[0] : false;
		if(!mask) {
			mask = document.createElement("div");
			ternStyle(mask).setStyle("height",0).setStyle("width",0);
			ternStyle(mask).setStyle("visibility","hidden").setStyle("position","absolute").setStyle("overflow","hidden").setStyle("z-index","50").setStyle("top",0).setStyle("left",0);
			if(i.hasChildNodes) {
				i.insertBefore(mask,i.childNodes[0]);
			}
			else {
				i.appendChild(mask);
			}
			ternStyle(mask).addClass("ternMask");
			if(d || t) {
				elap = th.createElapsor(mask,d,w,s,t);
			}
		}
		else if(d === false && elap) {
			elap.parentNode.removeChild(elap);
		}
		else if((d || t) && !elap) {
			elap = th.createElapsor(mask,d,w,s,t);
		}
		else if(t && elap) {
			th.elapsorText(t);
		}
		ternStyle(mask).setStyle("background-color",c).setStyle("height",parseInt(w[0]+(s[3]-w[0]))).setStyle("width",parseInt(w[1]+(s[2]-w[1]))).setOpacity(100);
		if(o) {
			ternStyle(mask).fade("fast",0,th.w,f);
		}
		else {
			ternStyle(mask).setOpacity(th.w).setStyle("visibility","visible");
			if(f) {
				f();
			}
		}
		return th;		
	},
	getMask :
	function () {
		var th = this,m = th.getElementsByClass("ternMask",false,1,true),mask,elap;
		if(m) {
			for(var i=0;i<m.length;i++) {
				if(m[i].parentNode == th.tern[0]) {
					return m[i];
				}
			}
		}
		return false;
	},
	createElapsor :
	function (p,d,w,s,t) {
		var e = document.createElement("div");
		if(d) {
			var i = document.createElement("img");
			i.src = d;
			e.appendChild(i);
		}
		var f = document.createElement("span");
		if(t) {
			t = document.createTextNode(t);
			f.appendChild(t);
		}
		e.appendChild(document.createElement("br"));
		e.appendChild(f);
		p.appendChild(e);
		ternStyle(e).addClass("ternElapsor").setStyle("position","absolute").setStyle("z-index","50").setStyle("visibility","visible").setStyle("font-size",11);
		ternStyle(e).setStyle("text-align","center").setStyle("top",(s[1]+((w[1])/2))).setStyle("left",(s[0]+((w[0]-300)/2))).setStyle("width",300);
		return e;
	},
	elapsorText :
	function (t) {
		var th = this,mask = th.getMask(),elap = ternStyle(mask).getElementsByClass("ternElapsor",false,1);
		elap = elap ? elap[0] : false;
		elap.getElementsByTagName("span")[0].innerHTML = t;
	},
	hideElapsor :
	function (w) {
		var th = this,m = th.getElementsByClass("ternMask",false,1,true);
		if(th.tern[0] == document.body && m.length) {
			for(var i=0;i<m.length;i++) {
				if(m[i].parentNode == document.body) {
					var m = m[i];
					break;
				}
			}
		}
		else if(m.length) {
			var m = m[0];
		}
		if(w !== false && m) {
			/*
			ternStyle(m).fade("fast",th.w,0,function () {
				ternStyle(m).setStyle("height",1).setStyle("width",1);
			});
			*/
			ternStyle(m).setStyle("visibility","hidden").setStyle("height",1).setStyle("width",1).setOpacity(0);
		}
		else if(m) {
			var m = ternStyle(m).getElementsByClass("ternElapsor",false,1);
			if(m.length) {
				ternStyle(m).setStyle("visibility","hidden").setStyle("height",1).setStyle("width",1);
			}
		}
	}
});
/*-----------------------
	ternVENTS ™
-----------------------*/
var ternVENTS = {
	ternVents : [],ff : function () { return false; },
	setEvent :
	function (e) {
		return !(e) ? window.event : e;
	},
	eventSource :
	function (e) {
		var th = this,i,e = !(e) ? th.setEvent(e) : e;
		if(e.srcElement) {
			i = e.srcElement;
		}
		else {
			i = e.target;
		}
		if(i.nodeType == 3) {
			i = i.parentNode;
		}
		return i;
	},
	mousePosition : 
	function (e) {
		var m = [],e = !(e) ? this.setEvent(e) : e;
		if(e.pageX) {
			m[0] = e.pageX;
			m[1] = e.pageY;
		}
		else if (e.clientX) {
			m[0] = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			m[1] = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
		else {
			m = false;
		}
		return m;
	},
	addEvent :
	function (i,f,e,b) {
		var th = this,l,es = th.ternVents,i = ternStyle().isArray(i) ? ternStyle(i).tern : [i],e = e == false ? th.ff : e,b = b ? b : false;
		for(var a=0;a<i.length;a++) {
			var t = ternStyle().getNode(i[a]);
			if((t.nodeName || t == window) && !th.eventRegistered(t,f,e,b)) {
				if(document.attachEvent) {
					t.attachEvent("on"+e,f);
				}
				else {
					t.addEventListener(e,f,b);
				}
				l = th.ternVents.length;
				th.ternVents[l] = new Array();
				th.ternVents[l]["item"] = t;
				th.ternVents[l]["event"] = e;
				th.ternVents[l]["bubbling"] = b;
				th.ternVents[l]["function"] = f;
				t.events = t.events || new function() {  };
				t.events[e] = f;
			}
		}
	},
	removeEvent :
	function (i,f,e,b) {
		var th = this,i = ternStyle().getNode(i),r = th.eventRegistered(i,f,e,b);
		if(r !== false) {
			if(document.attachEvent) {
				i.detachEvent("on"+e,f);
			}
			else {
				i.removeEventListener(e,f,b);
			}
			th.ternVents.splice(r,1);
			i.events[e] = null;
		}
	},
	removeAllEvents :
	function () {
		var th = this == window ? ternVENTS : this,a = th.ternVents,l = a.length;
		for(var i=0;i<l;i++) {
			th.removeEvent(a[0]["item"],a[0]["function"],a[0]["event"],a[0]["bubbling"]);
		}
	},
	removeAllItemEvents :
	function (i) {
		var th = this,i = ternStyle().isArray(i) ? ternStyle(i).tern : [ternStyle().getNode(i)],a = th.ternVents;
		for(var c=0;c<i.length;c++) {
			if(i[c]) {
				for(var b=0;b<a.length;b++) {
					if(i[c] == a[b]["item"]) {
						th.removeEvent(a[b]["item"],a[b]["function"],a[b]["event"],a[b]["bubbling"]);
						b = b-1;
					}
				}
			}
		}
	},
	eventRegistered :
	function (i,f,e,b) {
		var th = this,a = th.ternVents,i = ternStyle().getNode(i);
		for(var c=0;c<a.length;c++) {
			if(a[c]["item"] == i && a[c]["event"] == e && a[c]["bubbling"] == b && a[c]["function"] == f) {
				return c;
			}
		}
		return false;
	}
}
window.onunload = ternVENTS.removeAllEvents;
/*-----------------------
	ternForm (tm) v2.2
-----------------------*/
var ternForm = function (i) {
	var a = _ternform.instances,l = a.length;
	if(window == this) {
		for(var b=0;b<a.length;b++) {
			if(a[b]["node"] == i) {
				return a[b]["object"];
			}
		}
		a[l] = new Array();
		a[l]["node"] = i;
		a[l]["object"] = new ternForm(i);
		return a[l]["object"];
	}
	if(i) {
		this.tern = _ternStyle.getNode(i);
	}
};
ternForm.prototype = _ternform = {
	instances : [],
	initFields : {
		allow_one_checked : {
			types : ['checkbox']
		}
	},
	fields : {
		required : {
			label : 'The following fields are required:',
			types : ['text','password','textarea','select-one','select-multiple','checkbox','radio'],
			errors : ''
		},
		alpha : {
			label : 'The following fields must contain only letters:',
			types : ['text'],
			errors : ''
		},
		alphanum : {
			label : 'The following fields must be alphanumeric:',
			types : ['text'],
			errors : ''
		},
		numeric : {
			label : 'The following fields must be numeric:',
			types : ['text'],
			errors : ''
		},
		confirm : {
			label : 'The following fields do not match:',
			types : ['text','password'],
			errors : ''
		},
		email : {
			label : 'These email addresses do not seem to be properly formatted:',
			types : ['text'],
			errors : ''
		},
		length : {
			label : 'The following fields are not the correct length:',
			types : ['text','password','textarea'],
			errors : ''
		},
		agreement : {
			label : '',
			types : ['checkbox'],
			errors : ''
		},
		onechecked : {
			label : '',
			types : ['checkbox','radio'],
			errors : ''
		},
		captcha : {
			label : 'You did not answer the following questions correctly:',
			types : ['text','password','textarea','select-one'],
			errors : ''
		}
	},
	divs : { ':' : 'is','=' : 'equal to','>' : 'greater than','<' : 'less than','>=' : 'greater than or equal to','<=' : 'less than or equal to' },
	errors : [],
	validateForm :
	function (c,f,e,s) {
		var th = this;th.s = s != undefined ? s : true;
		th.tern.onsubmit = function () { return false; };
		ternVENTS.addEvent(th.tern,function () { th.validateAndHandle(c,f,e); },"submit",false);
		th.er = ternStyle(th.tern).getElementsByClass("errors_cn",false,1)[0];
		if(th.er) {
			th.ec = th.er.getElementsByTagName("div")[0];
		}
		//
		th.initForm();
		//
		return th;
	},
	initForm :
	function () {
		var a = this.tern.elements;
		for(var i=0;i<a.length;i++) {
			var p = this.getParams(a[i]);
			if(p) {
				for(k in p) {
					if(this.initFields[k] && _ternStyle.inArray(this.initFields[k].types,this.inputType(a[i])) !== false) {
						eval('this.'+k+'(a[i]);');
					}
				}
			}
		}
	},
	validateAndHandle :
	function(c,f,e) {
		var th = this;th.f = f;th.e = e;th.css = c;
		th.unlabel(c);
		this.validate();
		if(this.errors.length > 0) {
			if(th.er) {
				ternStyle(th.ec).fadeOut("fast",function () { return th.error(); });
			}
			return false;
		}
		else {
			th.resetErrorDiv();
			th.fixMultipleSelects();
			if(th.f) { th.f(th.tern); }
			this.submit();
		}
		return true;
	},
	validate :
	function () {
		var a = this.tern.elements;
		for(var i=0;i<a.length;i++) {
			if(a[i].nodeName.toLowerCase() != 'fieldset') {
				var p = this.getParams(a[i]);
				if(p) {
					for(k in p) {
						if(this.fields[k] && _ternStyle.inArray(this.fields[k].types,this.inputType(a[i])) !== false) {
							eval('this.'+k+'(a[i],p[k][0],p[k][1]);');
						}
					}
				}
			}
		}
	},
	required :
	function (i) {
		if(!this.inputValue(i)) {
			this.addErrors('required',i,'<li>' + this.getTitle(i) + '</li>');
		}
	},
	captcha :
	function (i,v) {
		if(this.inputValue(i) != v) {
			this.addErrors('captcha',i,'<li>' + this.getTitle(i) + '</li>');
		}
	},
	alpha :
	function (i) {
		var r = /^[a-zA-Z_-]+$/g;
		if(this.inputValue(i).length > 0 && !r.test(this.inputValue(i))) {
			this.addErrors('alpha',i,'<li>' + this.getTitle(i) + '</li>');
		}
	},
	alphanum :
	function (i) {
		var r = new RegExp('^[0-9a-zA-Z_-]+$','g'),t = r.test(this.inputValue(i));
		if(this.inputValue(i).length > 0 && !t) {
			this.addErrors('alphanum',i,'<li>' + this.getTitle(i) + '</li>');
		}
	},
	numeric :
	function (i) {
		var r = /^[0-9]+$/g;
		if(this.inputValue(i).length > 0 && !r.test(this.inputValue(i))) {
			this.addErrors('numeric',i,'<li>' + this.getTitle(i) + '</li>');
		}
	},
	confirm :
	function (i,v) {
		var a = this.tern.elements;
		for(var b=0;b<a.length;b++) {
			if(a[b].name == v && this.inputValue(a[b]) != this.inputValue(i)) {
				this.addErrors('confirm',i,'<li>' + this.getTitle(i) + '</li>');
			}
		}
	},
	email : 
	function (i) {
		var r = new RegExp('[a-zA-Z0-9.-_+]+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$','g'),v = this.inputValue(i); 
		if(v.length && !r.test(v)) {
			this.addErrors('email',i,'<li>' + this.getTitle(i) + '</li>');
		}
	},
	length :
	function (i,v,d) {
		if(!eval('this.inputValue(i).length '+d+' v')) {
			var e = this.divs[d];
			this.addErrors('length',i,'<li>' + this.getTitle(i) + ' - must be '+e+' '+v+' characters long.</li>');
		}
	},
	agreement :
	function (i) {
		if(!this.inputValue(i)) {
			this.addErrors('agreement',i,'<li>You must agree to the terms of use.</li>');
		}
	},
	onechecked :
	function (i) {
		var a = this.tern.elements;
		if(!i.checked) {
			for(var b=0;b<a.length;b++) {
				if(a[b].name == i.name && a[b].checked) {
					return true;
				}
			}
			this.addErrors('onechecked',i,'<li>Please select one for: '+this.getTitle(i)+'</li>');
		}
	},
	allow_one_checked :
	function (i) {
		var th = this,a = this.tern.elements;
		for(var b=0;b<a.length;b++) {
			if(a[b].name == i.name) {
				ternVENTS.addEvent(a[b],function (e) {
					i.checked = true;
					th.uncheck(e,i.name);
				},"click",false);
			}
		}
	}
}
ternForm.prototype.extend = 
function (a) {
	for(k in a) {
		this[k] = _ternform[k] = a[k];
	}
}
ternForm.prototype.extend({
	addErrors :
	function (t,i,m) {
		this.fields[t].errors += m;
		this.errors[this.errors.length] = i;
	},
	error :
	function (g) {
		this.label(this.css);
		this.showErrors(g);
		this.resetErrors();
	},
	compileErrors :
	function () {
		var f = this.fields,e='';
		for(k in f) {
			if(f[k].errors.length) {
				e += f[k].label.length ? '<ul><li><b>' + f[k].label + '</b><ul>' + f[k].errors + '</ul></li></ul>' : '<ul><li><b>' + f[k].errors + '</b></ul>';
			}
		}
		return e;
	},
	showErrors :
	function (g) {
		var th = this,f = th.e ? th.e : function(){};
		th.ec.innerHTML = th.compileErrors();
		var e = ternStyle(th.ec).getDimensions();
		if(th.er) {
			ternStyle(th.er).setStyle("visibility","visible");
			ternStyle(th.er).grow("fast","y",e[1],function () { ternStyle(th.ec).fadeIn("fast");f(); });
		}
		this.errorsOn = true;
	},
	label :
	function (c,a) {
		var a = a ? a : this.errors;
		for(k in a) {
			if(a[k]) {
				var l = this.tern.getElementsByTagName("label");
				for(var i=0;i<l.length;i++) {
					if(l[i].htmlFor != null && l[i].htmlFor.indexOf(a[k].name) != -1) {
						ternStyle(l[i]).addClass(c);
						break;
					}
				}
			}
		}
	},
	resetErrorDiv :
	function() {
		if(this.errorsOn) {
			ternStyle(this.er).grow("fast","y",0).fadeOut("fast");
			this.errorsOn = false;
		}
	},
	resetErrors :
	function () {
		var f = this.fields;
		for(k in f) {
			f[k].errors = '';
		}
		this.errors = [];
	},
	unlabel :
	function (c) {
		var ls = this.tern.getElementsByTagName("label");
		for(var i=0;i<ls.length;i++) {
			ternStyle(ls[i]).removeClass(c);
		}
	}
});
ternForm.prototype.extend({
	initHover :
	function (h,a) {
		var th = this,i = th.tern.elements,l = th.tern.getElementsByTagName("li");
		for(var b=0;b<i.length;b++) {
			i[b].onfocus = function (e) {
				var s = this;
				while(s.nodeName.toLowerCase() != "li") {
					if(s != th.tern) {
						s = s.parentNode;
					}
					else {
						break;
					}
				}
				ternStyle(l).removeClass(a);
				if(s != th.tern) {
					ternStyle(s).addClass(a);
				}
			}
			i[b].onblur = function () {
				ternStyle(l).removeClass(a);
			}
		}
		ternStyle(l).hovers(h);
		return th;
	}
});
ternForm.prototype.extend({
	submit : 
	function (f) {
		if(this.s) {
			var f = f ? f : this.tern;
			f.submit();
		}
	},
	getTitle :
	function (f) {
		var i = f.title.indexOf("::");
		return i ? f.title.substr(0,i) : f.title;
	},
	getParams :
	function (i) {
		var a=[],t = i.title.toLowerCase(),k,d,q,v;
		if(t.indexOf('::') == -1) {
			return false;
		}
		else {
			t = t.substr(t.indexOf('::')+3);
			t = t.split(' ');
			for(var b=0;b<t.length;b++) {
				k = d = q = v = null;
				for(k in this.divs) {
					if(t[b].indexOf(k) != -1) {
						d = k;
						q = t[b].split(k);
						break;
					}
				}
				k = q ? q[0] : t[b],v = q ? q[1] : '';
				a[k] = [v,d];
			}
		}
		return a;
	},
	inputValue :
	function (i,b) {
		var i = i ? _ternStyle.getNode(i) : this.tern,t = this.inputType(i),a=new Array();
		if(t == "text" || t == "password" || t == 'textarea' || t == 'submit' || t == 'reset' || t == 'hidden' || t == 'image' || t == 'button') {
			return i.value;
		}
		else if(t == "select-one") {
			return i.options[i.selectedIndex].value;
		}
		else if(t == "select-multiple") {
			for(var b=0;b<i.options.length;b++) {
				if(i.options[b].selected) {
					a.push(i.options[b].value);
				}
			}
			return a;
		}
		else if((t == "checkbox" || t == "radio") && (!b || (b && i.checked))) {
			return b ? i.value : i.checked;
		}
	},
	inputType :
	function (i) {
		var i = i ? i : this.tern;
		if(i.type) { return i.type; }
		return '';
	},
	getFromPost :
	function (f) {
		var f = f ? _ternStyle.getNode(f) : this.tern,e = f.elements,p = '',v;
		for(var i=0;i<e.length;i++) {
			if(e[i].name) {
				v = e[i].name + '=' + e[i].value;
				p += p.length > 0 ? '&' + v : v;
			}
		}
		return p;
	},
	fixMultipleSelects :
	function(s,f) {
		var f = f ? _ternstyle.getNode(f) : this.tern,e = f.elements,o,p='',s = s ? s : ",",t;
		for(var i=0;i<e.length;i++) {
			if(this.inputType(e[i]) == "select-multiple") {
				o = e[i].options;
				for(var a=0;a<o.length;a++) {
					if(o[a].selected == true) {
						p += p.length > 0 ? s + o[a].value : o[a].value;
					}
				}
				t = this.createTextInput(e[i].name,p);
				e[i].parentNode.replaceChild(t,e[i]);
				i--;
			}
		}
	},
	multiIsSelected :
	function (i) {
		var i = i != undefined ? i : this.tern;
		var o = i.options;
		var ops = "";
		for(var a=0;a<o.length;a++) {
			if(o[a].selected == true) {
				return true;
			}
		}
		return false;
	},
	createTextInput :
	function (n,v,s,c) {
		var i = this.setAttr(document.createElement('input'),{'tupe':'text','name':n,'id':n,'size':s});
		i.value = v;
		if(c) { ternStyle(i).addClass(c); }
		return i;
	},
	createTextarea :
	function (n,v,c) {
		var i = this.setAttr(document.createElement('textarea'),{'name':n,'id':n});
		i.value = v;
		if(c) { ternStyle(i).addClass(c); }
		return i;
	},
	createHidden :
	function(n,v) {
		var i = this.setAttr(document.createElement('input'),{'tupe':'hidden','name':n,'id':n});
		i.value = v;
		return i;
	},
	addHiddenToForm :
	function (n,v) {
		var f = this.tern,i = this.createHidden(n,v);
		f.appendChild(i);
	},
	setAttr :
	function (i,a) {
		for(k in a) {
			i.setAttribute(k,a[k]);
		}
		return i;
	}
});
ternForm.prototype.extend({
	allowOneChecked :
	function(n) {
		var th = this,f = th.tern,e = f.elements;
		for(var i=0;i<e.length;i++) {
			if(e[i].name == n) {
				ternVENTS.addEvent(e[i],function (v) { th.uncheck(v,n); },"click",false);
			}
		}
		return th;
	},
	uncheck :
	function (v,n) {
		var f = this.tern,e = f.elements,s = ternVENTS.eventSource(v);
		for(var i=0;i<e.length;i++) {
			if(e[i].name == n && e[i] != s) {
				e[i].checked = false;
			}
		}
	}
});
ternForm.prototype.extend({
	select :
	function (n) {
		return this.setAttr(document.createElement('select'),{'name':n,'id':n});
	},
	selectOption :
	function (v,n) {
		var o = document.createElement('option');
		o.value = v;
		o.text = n;
		return o;
	},
	addSelectOption :
	function (f) {
		var o = document.createElement('option');
		o.text = 'Select';
		o.value = '';
		f.options[0] = o;
	},
	addOption :
	function (f,o) {
		f.options[f.options.length] = o;
	},
	selectFn :
	function (f,fn) {
		ternVENTS.addEvent(f,fn,"change",false);
	}
});