/**************************************************************************************************/
/***
/***	TERNSTYLE (TM) SLITE JAVASCRIPT DOCUMENT (ternStyle (TM) lite,ternVENTS (TM),ternJAX (TM) lite)
/***	-----------------------------------------------------------------------
/***	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 = [];
/*-----------------------
	ternStyle (TM) lite
-----------------------*/
var ternStyle = function (i) {
	var a = ternStances,th = this,l = a.length;
	if(window == th) {
		if(i) {
			for(var b=0;b<a.length;b++) {
				if(a[b]["node"] == i) {
					return a[b]["object"];
				}
			}
			ternStances[l] = new Array();
			ternStances[l]["node"] = i;
			ternStances[l]["object"] = new ternStyle(i);
			return ternStances[l]["object"];
		}
		else {
			return new ternStyle();
		}
	}
	th.browser = this.getBrowserType();
	if(this.isArray(i)) {
		a = [];
		for(var b=0;b<i.length;b++) {
			a[b] = this.getNode(i[b]);
		}
		this.tern = a;
	}
	else if(i) {
		this.tern = this.getNode(i);
	}
	th.timer = new Array();
	th.index = (l-1);
	th.times = [];
};
ternStyle.prototype = {
	grow_way : "",
	fadeIn : 
	function (s,fn,h) {
		this.fade(s,0,100,fn,h);
	},
	fadeOut : 
	function (s,fn,h) {
		this.fade(s,100,0,fn,h);
	},
	fade : 
	function (s,o,eo,fn,h) {
		var th = this,i = th.tern,s = th.getSpeed(s),f;
		th.setOpacity(o).setStyle("visibility","visible");
		f = eo == 0 && h != false ? function () { if(fn) { fn(); }th.setStyle("visibility","hidden"); } : fn;
		th.tween("opacity",o,eo,s,f);
	},
	grow :
	function (s,a,wh,fn) {
		var th = this,i = th.isArray(th.tern) ? th.tern : [th.tern],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,s,fn,i[b]);
			}
			else if(a.indexOf("x") != -1) {
				th.tween("width",d[0],wh[0] || wh,s,fn,i[b]);
			}
			else if(a.indexOf("y") != -1) {
				th.tween("height",d[1],wh[1] || wh,s,fn,i[b]);
			}
		}
		return th;
	},
	getSpeed :
	function (s) {
		if(s == "slow") {
			if(this.browser == "mozilla") {
				return .05;
			}
			else if(this.browser == "safari") {
				return .3;
			}
			return .2;
		}
		else if(s == "medium") {
			if(this.browser == "mozilla") {
				return .2;
			}
			else if(this.browser == "safari") {
				return .5;
			}
			return .3;
		}
		else {
			return .8;
		}
	},
	tween :
	function (p,v,ev,s,f,i) {
		var th = this,i = i != undefined ? th.getNode(i) : th.tern;
		th.times[p] = 0;
		var t = (new Date()).getTime();
		if(th.timer[p]) {
			clearInterval(th.timer[p][0]);
			th.timer[p] = false;
		}
		else {
			th.timer[p] = [];
		}
		th.timer[p][0] = setInterval(function () { th.setStage(p,v,ev,t,s,f,i); },15);
	},
	setStage :
	function (p,v,ev,t,s,f,i) {
		var th = this;
		var nt = (new Date()).getTime();
		var i = i != undefined ? th.getNode(i) : th.tern;
		th.timer[p][1] = th.timer[p][1] || v;
		var it = v < ev ? parseInt((ev-v)*s) : parseInt((v-ev)*s);
		th.timer[p][1] = v < ev ? Math.floor(th.timer[p][1] + it) : Math.floor(th.timer[p][1] - it);
		if((v <= ev && th.timer[p][1] >= ev) || (v >= ev && th.timer[p][1] <= ev) || v == ev) {
			th.stage(p,ev,i);
			clearInterval(th.timer[p][0]);
			th.timer[p] = false;
			if(f) { f(); }
		}
		else {
			th.times[p]++;
			th.stage(p,th.timer[p][1],i);
		}
	},
	stage : 
	function (p,v,i) {
		var i = i != undefined ? 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 = 
function (a,i) {
	var t = i != undefined ? i : this;
	for(k in a) {
		t[k] = a[k];
	}
	return t;
}
ternStyle.prototype.extend({
	elapsor :
	function (d,c,w,f) {
		var th = this,m = ternStyle().getElementsByClass("ternMask");th.w = w || 65;
		for(var i=0;i<m.length;i++) {
			if(m[i].parentNode == th.tern) {
				th.mask = m[i];
				break;
			}
		}
		if(!th.mask) {
			th.mask = document.createElement("div");
			th.tern.appendChild(th.mask);
			ternStyle(th.mask).addClass("ternMask");
			//
			if(d.length && d.length > 0 && !th.elap) {
				th.elap = document.createElement("img");
				ternStyle(th.elap).addClass("ternElapsor");
				th.elap.src = d+"TERNSTYLE/IMAGES/elapsor.gif";
				th.mask.appendChild(th.elap);
			}
		}
		var d = th.getDimensions();
		var w = th.getWindowSize();
		var s = th.tern == document.body ? th.getScroll() : th.itemScroll();
		var sh = th.itemScroll();
		if(th.elap) {
			ternStyle(th.elap).setStyle("position","absolute").setStyle("z-index","50").setStyle("visibility","visible");
			ternStyle(th.elap).setStyle("top",(s[1]+((w[1]-100)/2))).setStyle("left",(s[0]+((w[0]-100)/2))).setStyle("height",100).setStyle("width",100);
		}
		ternStyle(th.mask).setStyle("visibility","hidden").setStyle("position","absolute").setStyle("z-index","50").setStyle("background-color",c);
		ternStyle(th.mask).setStyle("top",0).setStyle("left",0).setStyle("height",(w[1]+sh[3]+200)).setStyle("width",(w[1]+sh[2]+200)).fade("medium",0,th.w,f);
	},
	hideElapsor :
	function (w) {
		var m = this.getElementsByClass("ternMask",false)[0];
		if(w != false) {
			ternStyle(m).fade("medium",this.w,0);
		}
		else {
			ternStyle(m).getElementsByClass("ternElapsor").setStyle("visibility","hidden");
		}
	}
});
ternStyle.prototype.extend({
	addClass : 
	function (c,i) {
		var th = this;
		if(!i) {
			var i = th.isArray(th.tern) ? th.tern : [th.tern];
		}
		else {
			var i = [th.getNode(i)];
		}
		for(var a=0;a<i.length;a++) {
			if(!th.hasClass(c,i[a])) {
				i[a].className = i[a].className.length > 0 ? i[a].className + " " + c : c;
			}
		}
		return th;
	},
	removeClass : 
	function (c,i) {
		var th = this,i = i || th.tern;
		if(th.isArray(i)) {
			for(var a=0;a<i.length;a++) {
				if(i[a].className) {
					var cs = i[a].className.split(/\s+/);
					i[a].className = "";
					for(var b=0;b<cs.length;b++) {
						if(cs[b] != c) {
							i[a].className += i[a].className.length > 0 ? " " + cs[b] : cs[b];
						}
					}
				}
			}
		}
		else {
			if(i.className) {
				cs = i.className.split(/\s+/);
				i.className = "";
				for(var a=0;a<cs.length;a++) {
					if(cs[a] != c) {
						i.className += i.className.length > 0 ? " " + cs[a] : cs[a];
					}
				}
			}
		}
		return this;
	},
	hasClass :
	function (c,i) {
		var i = i || this.tern;
		if(i.className) {
			cs = i.className.split(/\s+/);
			for(var a=0;a<cs.length;a++) {
				if(cs[a] == c) {
					return true;
				}
			}
		}
		return false;
	},
	setStyle : 
	function (p,v,i) {
		var th = this,p = th.fixStyle(p);
		if(!i) {
			var i = th.isArray(th.tern) ? th.tern : [th.tern];
		}
		else {
			var i = [th.getNode(i)];
		}
		var da = new Array("top","right","bottom","left","width","height");
		for(var a=0;a<i.length;a++) {
			if(p == "align") {
				i[a].setAttribute("align",v);
			}
			else {
				var v = th.inArray(da,p) !== false && v.toString().indexOf("px") == -1 && v.toString().indexOf("%") == -1 ? v + "px" : v;
				//var v = v=="px" ? "0px" : v;
				if(th.browser == "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 th = this;
		if(!i) {
			var i = th.isArray(th.tern) ? th.tern : [th.tern];
		}
		else {
			var i = [th.getNode(i)];
		}
		for(var a=0;a<i.length;a++) {
			if(th.browser == "msie") {
				i[a].style.filter = o == 100 ? "" : "progid:DXImageTransform.Microsoft.Alpha(opacity="+o+")";
			}
			else {
				th.setStyle("opacity",o/100,i[a]);
			}
		}
		return th;
	},
	fixStyle :
	function (p) {
		if(this.browser == "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({
	getStyle : 
	function (p,i) {
		var p = this.fixStyle(p),i = i != undefined ? i : this.tern,v;
		if(p == "align") {
			v = i.getAttribute("align");
		}
		else {
			if(this.browser == "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 != undefined && v.length > 0) {
			return v;
		}
		else {
			return false;
		}
	},
	inlineStyle : 
	function (i,th) {
		var s = i.getAttribute("style"),d = [],b,c;
		if(s) {
			if(typeof(s) != "string") {
				s = s.cssText;
			}
			s = s.split(";");
			if(s.length > 0) {
				for(var a=0;a<s.length;a++) {
					if(s[a].length > 0) {
						d[d.length] = [ s[a].substr(0,s[a].indexOf(":")), s[a].substr(s[a].indexOf(":")+1) ];
					}
				}
			}
			return d;
		}
		else {
			return null;
		}
	},
	getDimensions : 
	function (i) {
		var s = [],i = i != undefined ? i : this.tern;
		if(i.innerWidth) {
			s[0] = i.innerWidth;s[1] = i.innerHeight;
			s["x"] = i.innerWidth;s["y"] = i.innerHeight;
			s["w"] = i.innerWidth;s["h"] = i.innerHeight;
			s["width"] = i.innerWidth;s["height"] = i.innerHeight;
		}
		else if(i.clientWidth) {
			s[0] = i.clientWidth;s[1] = i.clientHeight;
			s["x"] = i.clientWidth;s["y"] = i.clientHeight;
			s["w"] = i.clientWidth;s["h"] = i.clientHeight;
			s["width"] = i.clientWidth;s["height"] = i.clientHeight;
		}
		else if(i.offsetWidth) {
			s[0] = i.offsetWidth;s[1] = i.offsetHeight;
			s["x"] = i.offsetWidth;s["y"] = i.offsetHeight;
			s["w"] = i.offsetWidth;s["h"] = i.offsetHeight;
			s["width"] = i.offsetWidth;s["height"] = i.offsetHeight;
		}
		return s;
	},
	getCoords : 
	function (i) {
		var i = i != undefined ? i : this.tern,c = [],x = 0,y = 0;
		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] = x;c[1] = y;
		c["left"] = x;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 != undefined ? this.getNode(i) : this.tern,s = [];
		s[0] = this.tern.scrollLeft;
		s[1] = this.tern.scrollTop;
		s[2] = this.tern.scrollWidth;
		s[3] = this.tern.scrollHeight;
		return s;
	}
});
ternStyle.prototype.extend({
	getData : 
	function (i) {
		var th = this,i = i != undefined ? i : th.tern,s = th.getDimensions(i),
		c = th.getCoords(i),
		d = s.concat(c);
		d[d.length] = i.className ? i.className.split(" ") : "";
		d[d.length] = th.inlineStyle(i,th);
		return d;
	},
	getNode :
	function (i) {
		if(typeof(i) == "string" && document.getElementById(i)) {
			return document.getElementById(i);
		}
		else {
			return i;
		}
	},
	getElementsByClass :
	function (c,o,i,d,a) {
		var th = this;
		if(!i && !th.tern) {
			var i = document;
		}
		else {
			var i = i ? th.getNode(i) : th.tern;
		}
		var d = d ? th.getNode(d) : i,ch = d.childNodes;
		if(!a || !th.isArray(a)) {
			var a = new Array();
		}
		for(var b=0;b<ch.length;b++) {
			if(ch[b].className && th.hasClass(c,ch[b])) {
				a.push(ch[b]);
			}
			a = th.getElementsByClass(c,o,i,ch[b],a);
		}
		if(d == i) {
			if(o != false) {;
				return ternStyle(a);
			}
			else {
				return a;
			}
		}
		else {
			return a;
		}
	},
	removeChildren : 
	function (i) {
		var th = this,i = i == undefined ? th.tern : th.getNode(i);
		if(i.hasChildNodes) {
			while(i.firstChild) {
				i.removeChild(i.firstChild);
			}
		}
	}
});
ternStyle.prototype.extend({
	getWindowSize : 
	function () {
		var s = [];
		if(window.innerWidth) {
			s[0] = window.innerWidth;
			s[1] = window.innerHeight;
		}
		else if(document.body.clientWidth) {
			s[0] = document.body.clientWidth;
			s[1] = document.body.clientHeight;
		}
		else if(document.body.offsetWidth) {
			s[0] = document.body.offsetWidth;
			s[1] = document.body.offsetHeight;
		}
		return s;
	},
	getScroll : 
	function () {
		var s = [];
		if(window.pageYOffset) {
			s[0] = window.pageXOffset;
			s[1] = window.pageYOffset;
		}
		else if(document.body.scrollTop) {
			s[0] = document.body.scrollLeft;
			s[1] = document.body.scrollTop;
		}
		else if(document.documentElement.scrollTop) {
			s[0] = document.documentElement.scrollLeft;
			s[1] = document.documentElement.scrollTop;
		}
		else {
			s[0] = 0;
			s[1] = 0;
		}
		return s;
	},
	getBrowserType : 
	function () {
		var a = new Array("msie","opera","safari","mozilla");
		for(var i=0;i<a.length;i++) {
			var r = new RegExp(a[i],"");
			if(r.test(navigator.userAgent.toLowerCase())) {
				this.browser = a[i];
				return a[i];
			}
		}
		return "other";
	}
});
ternStyle.prototype.extend({
	isObject :
	function (o) {
		var th = this;
		if((typeof o == "object" && !!o) || th.isFunction(o)) {
			return true;
		}
		return false;
	},
	isIEObject :
	function (o) {
		var th = this;
		if(th.isObject(o) && typeof(o.constructor != "function")) {
			return true;
		}
		return false;
	},
	isFunction : 
	function (f) {
		return typeof f == "function";
	},
	isArray : 
	function (a) {
		var th = this;
		if(th.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) {
		for(var i=0;i<a.length;i++) {
			if(a[i] === v) {
				return i;
			}
		}
		return false;
	}
});
/*-----------------------
	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) ? i : [i],e = e == false ? th.ff : e;
		for(var a=0;a<i.length;a++) {
			var t = ternStyle().getNode(i[a]);
			if(!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;
			}
		}
	},
	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);
		}
	},
	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().getNode(i),a = th.ternVents;
		for(var b=0;b<a.length;b++) {
			if(i == a[b]["item"]) {
				th.removeEvent(a[b]["item"],a[b]["function"],a[b]["event"],a[b]["bubbling"]);
			}
		}
	},
	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;
/*-----------------------
	ternJAX (TM) lite
-----------------------*/
var ternJAX = function (i) {
	var a = jaxStances,l = a.length;
	if(window == this) {
		if(i) {
			for(var b=0;b<a.length;b++) {
				if(a[b]["node"] == i) {
					return a[b]["object"];
				}
			}
			jaxStances[l] = new Array();
			if(i) {
				jaxStances[l]["node"] = i;
			}
			jaxStances[l]["object"] = new ternJAX(i);
			return jaxStances[l]["object"];
		}
		else {
			return new ternJAX(i);
		}
	}
	this.browser = ternStyle().getBrowserType();
	this.tern = i ? ternStyle().getNode(i) : false;
	this.index = a.length-1;
};
ternJAX.prototype = {
	load :
	function (s,p,f,h,ra) {
		var th = this;th.f = f;th.p = ternStyle().getNode(p);th.loaded = 0;th.h = h;th.ra = ra;
		if(!th.tern) {
			th.loadFrame("ternLoader_"+th.index);
		}
		ternVENTS.addEvent(th.tern,function () { th.loadData(); },"load",false);
		th.fw = th.tern.contentWindow || document.frames[th.tern.name];
		th.tern.src = s;
		//th.fw.location.replace(s);
	},
	loadData :
	function () {
		var th = this;
		th.fd = th.tern.contentDocument || document.frames[th.tern.name].document;
		var h = th.fd.getElementsByTagName("head")[0].childNodes,b = th.fd.body.innerHTML,s,t,c,cn,tn,tl=0;
		for(var i=0;i<h.length;i++) {
			s = h[i].nodeName.toLowerCase();
			if(s == "script" || s == "link") {
				var t = document.createElement(s);
				if(s == "script") {
					t.type = "text/javascript";
				}
				else {
					t.type = "text/css";
				}
				if(th.browser == "opera") {
					ternVENTS.addEvent(t,function (e) {
						var s = ternVENTS.eventSource(e);
						if(s.readyState == "complete" || s.readyState == "loaded") {
							th.isLoaded(e);
						}
					},"readystatechange",false);
				}
				if(th.browser != "safari") {
					ternVENTS.addEvent(t,function (e) { th.isLoaded(e); },"load",false);
					ternVENTS.addEvent(t,function (e) {
						var s = ternVENTS.eventSource(e);
						if(s.readyState == "complete" || s.readyState == "loaded") {
							th.isLoaded(e);
						}
					},"readystatechange",false);
				}
				else {
					th.loaded++;
				}
				t.src = h[i].src;
				document.getElementsByTagName("head")[0].appendChild(t);
				tl++;
			}
		}
		if(th.ra) {
			for(var i=0;i<th.ra.length;i++) {
				th.ra[i].parentNode.removeChild(th.ra[i]);
			}
		}
		c = document.createElement("div");
		c.innerHTML = b;
		cn = c.childNodes;
		for(var i=0;i<cn.length;i++) {
			tl++;
			tn = cn[i].cloneNode(true);
			if(th.h && tn.nodeType != 3) {
				ternStyle(tn).setStyle("visibility","hidden");
			}
			th.p.appendChild(tn);
			th.loaded++;
		}
		ternVENTS.removeAllItemEvents(th.tern);
		th.tern.src = "";
		th.t = setInterval(function () {
			if(th.loaded >= tl) {
				clearInterval(th.t);
				if(th.f) {
					th.f();
				}
			}
		},300);
	},
	isLoaded :
	function (e) {
		var s = ternVENTS.eventSource(e);
		ternVENTS.removeAllItemEvents(s);
		ternScripts[ternScripts.length] = s.src;
		this.loaded++;
	},
	loadFrame :
	function (n) {
		var th = this;
		th.tern = document.createElement("iframe");
		th.tern.setAttribute("name",n);
		th.tern.setAttribute("id",n);
		ternStyle(th.tern).setStyle("width",0).setStyle("height",0).setStyle("visibility","hidden");
		document.body.appendChild(th.tern);
	}
}