/**************************************************************************************************/
/***
/***	TERNSTYLE (TM) DOM JAVASCRIPT DOCUMENT (ternDOM tm version 1.2)
/***	-----------------------------------------------------------------------
/***	Written by Matthew Praetzel. Copyright (c) 2007 Matthew Praetzel.
/***	-----------------------------------------------------------------------
/***	All Rights Reserved. Any use of these functions & scripts without written consent is prohibited.
/***
/**************************************************************************************************/

/*-----------------------
	ternEvents (tm) v2.0
-----------------------*/
var ternEvents = {
	instances : [],
	setEvent :
	function (e) {
		return e ? e : window.event;
	},
	eventSource :
	function (e) {
		var i,e = e ? e : ternEvents.setEvent(e);
		i = e.srcElement ? e.srcElement : e.target;
		if(i.nodeType == 3) {
			i = i.parentNode;
		}
		return i;
	},
	mousePosition : 
	function (e) {
		var e = e ? e : this.setEvent(e);
		if(e.pageX) {
			return [e.pageX,e.pageY];
		}
		else if(e.clientX) {
			return [event.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,event.clientY+document.body.scrollTop+document.documentElement.scrollTop];
		}
		return false;
	},
	addEvent :
	function (i,f,e,b) {
		var l,i = ternStyle(i).tern,b = b ? b : false;
		for(var a=0;a<i.length;a++) {
			var t = _ternStyle.getNode(i[a]);
			if(t && (t.nodeName || t == window) && !this.eventRegistered(t,f,e,b)) {
				if(document.attachEvent) {
					t.attachEvent('on'+e,f);
				}
				else {
					t.addEventListener(e,f,b);
				}
				l = this.instances.length;
				this.instances[l] = new Array();
				this.instances[l]['item'] = t;
				this.instances[l]['event'] = e;
				this.instances[l]['bubbling'] = b;
				this.instances[l]['function'] = f;
			}
		}
	},
	removeEvent :
	function (i,f,e,b) {
		var i = _ternStyle.getNode(i),r = this.eventRegistered(i,f,e,b);
		if(r !== false) {
			if(document.attachEvent) {
				i.detachEvent('on'+e,f);
			}
			else {
				i.removeEventListener(e,f,b);
			}
			this.instances.splice(r,1);
		}
	},
	removeAllEvents :
	function () {
		var t = this == window ? ternEvents : this,a = t.instances,l = a.length;
		for(var i=0;i<l;i++) {
			t.removeEvent(a[0]['item'],a[0]['function'],a[0]['event'],a[0]['bubbling']);
		}
	},
	removeAllItemEvents :
	function (i) {
		var i = ternStyle(i).tern,a = this.instances;
		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']) {
						this.removeEvent(a[b]['item'],a[b]['function'],a[b]['event'],a[b]['bubbling']);
						b = b-1;
					}
				}
			}
		}
	},
	eventRegistered :
	function (i,f,e,b) {
		var a = this.instances,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 = ternEvents.removeAllEvents;
/*-----------------------
	ternDOM (tm)  v1.2
-----------------------*/
var ternStyle = function (i) {
	var th = this,a = _ternStyle.instances,l = a.length,v;
	if(window == th) {
		if(i) {
			i = _ternStyle.getNode(i);
			v = _ternStyle.inArray(a,i,'node');
			if(v !== false) {
				return a[v]['object'];
			}
			a[l] = new Array();
			a[l]['node'] = 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 = {
	instances : [],
	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,i) {
		var i = i ? [this.getNode(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 (a,i) {
		var i = i ? [this.getNode(i)] : this.tern,b,p;
		b = new Array('top','right','bottom','left','width','height','padding','margin','background-position','font-size');
		for(k in a) {
			p = this.fixStyle(k);
			var v = this.inArray(b,p) !== false && a[k].toString().indexOf('px') == -1 && a[k].toString().indexOf('%') == -1 && a[k] != 'auto' ? a[k] + 'px' : a[k];
			for(var c=0;c<i.length;c++) {
				if(this.msie) {
					eval("i[c].style."+p+"='"+v+"';");
				}
				else if(i[c].style[p]) {
					i[c].style[p] = v;
				}
				else if(i[c].style.setProperty(p,v,null)) {
					i[c].style.setProperty(p,v,null);
				}
			}
		}
		return this;
	},
	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;
		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.3
-----------------------*/
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' : 'visible'}); } : 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('ternEvents.addEvent(i[a],function (e) { th.addClass(c,i['+a+']);if(f) { f(e); } },"mouseover",false);');
				eval('ternEvents.addEvent(i[a],function (e) { th.removeClass(c,i['+a+']);if(ef) { ef(e); } },"mouseout",false);');
			}
		}
		
	}
});
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 {
				eval('this.setStyle({"'+p+'" : v},i);');
			}
		}
	}
});
ternStyle.prototype.extend({
	/*
		image : '',
		color : '#fff',
		opacity : 65,
		func : function,
		text : ''
	*/
	elapsor :
	function (a) {
		var i = this.tern[0];
		this.w = i == document.body ? this.getWindowSize() : this.getDimensions();
		this.s = i == document.body ? this.getScroll() : this.itemScroll();
		a.opacity = a.opacity ? a.opacity : 65;
		//mask
		if(!this.mask) {
			this.mask = document.createElement('div');
			ternStyle(this.mask).setStyle({ display : 'none',position : 'absolute',overflow : 'hidden','z-index' : 50,top : 0,left : 0 });
			//
			if(i.hasChildNodes()) {
				i.insertBefore(this.mask,i.childNodes[0]);
			}
			else {
				i.appendChild(this.mask);
			}
			//
			ternStyle(this.mask).addClass('ternMask');
		}
		//elapsor
		if(a.image || a.text) {
			this.createElapsor(a);
		}
		else if(this.elap) {
			ternStyle(this.elap).setStyle({ display : 'none' });
		}
		//
		ternStyle(this.mask).setOpacity(a.opacity).setStyle({ 'background-color' : a.color,height : parseInt(this.w[0]+(this.s[3]-this.w[0])),width : parseInt(this.w[1]+(this.s[2]-this.w[1])),display : 'block' });
		if(a.func) { a.func(); }
		//
		return this;
	},
	createElapsor :
	function (a) {
		if(this.elap) {
			this.image.src = a.image;
			if(a.text) {
				this.elapsorText(a.text);
			}
		}
		else {
			this.elap = document.createElement('div');
			if(a.image) {
				this.image = document.createElement('img');
				this.image.src = a.image;
				this.elap.appendChild(this.image);
				this.elap.appendChild(document.createElement('br'));
			}
			//
			if(a.text) {
				this.text = document.createElement('span');
				this.text.appendChild(document.createTextNode(a.text));
				this.elap.appendChild(this.text);
			}
			//
			this.mask.appendChild(this.elap);
			//
			ternStyle(this.elap).addClass('ternElapsor').setStyle({
				position : 'absolute',
				'width' : 300,
				'z-index' : 50,
				'text-align' : 'center',
				'font-size' : 11
			});
		}
		ternStyle(this.elap).setStyle({ 'top' : (this.s[1]+((this.w[1])/2)),'left' : (this.s[0]+((this.w[0]-300)/2)),display : 'block' });
		//
		return this.elap;
	},
	elapsorText :
	function (t) {
		this.text.innerHTML = t;
	},
	hideElapsor :
	function () {
		if(this.mask) {
			ternStyle(this.mask).setStyle({ display : 'none',width : 1,height : 1 });
		}
	}
});
/*-----------------------
	ternAjax (tm) v2.1
-----------------------*/
var ternAjax = function (i) {
	var a = _ternAjax.instances,l = a.length,v;
	if(window == this) {
		if(i) {
			v = _ternStyle.inArray(a,i,'id');
			if(v !== false) {
				return a[v]['o'];
			}
			a[l] = new Array();
			a[l]['id'] = i;
			a[l]['o'] = new ternAjax(i);
			return a[l]['o'];
		}
		return new ternAjax(i);
	}
	_ternStyle.getBrowserType.apply(this);
	this.q = [];
	this.id = i;
	this.qparams = {};
};
ternAjax.prototype = _ternAjax = {
	instances :[],
	scripts : [],
	params : ['type','func','efunc','pass','qfunc','node','empty','amsg','emsg','arsp','script'],
	init :
	function (a) {
		for(k in a) {
			this[k] = a[k];
		}
		return this;
	},
	ajax : 
	function (a) {
		this.queue(a);
		if(!this.iq) {
			this.iq = true;
			this.openAjax();
		}
	},
	queue :
	function (a) {
		if(!this.q) { this.q = []; }
		this.q[this.q.length] = a;
	},
	unqueue :
	function () {
		this.q.splice(0,1);
		if(this.q.length > 0) {
			this.openAjax();
		}
		else {
			if(this.qfunc) {
				this.qfunc();
			}
			this.a = this.iq = this.r = null;
		}
	},
	openAjax :
	function () {
		var th = this;th.a = th.q[0];th.r = null;
		//
		for(k in th.params) {
			eval('var p = this.a.'+th.params[k]+';');
			eval('th.qparams.'+th.params[k]+' = p ? p : this.'+th.params[k]+';');
		}
		//
		if(th.a.script) {
			th.loadScripts();
			return;
		}
		//
		_ternStyle.getBrowserType();
		if(window.ActiveXObject) {
			th.r = new ActiveXObject('Microsoft.XMLHTTP');
		}
		else if(window.XMLHttpRequest) {
			th.r = new XMLHttpRequest();
		}
		if(th.r != null) {
			if(th.netscape) {
				th.r.onload = function () { th.process() };
			}
			else {
				th.r.onreadystatechange = function () { th.process() };
			}
			th.r.open(th.qparams.type,th.a.url,true);
			th.r.setRequestHeader('User-Agent','XMLHTTP/1.0');
			if(th.qparams.type == 'post') {
				th.r.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			}
			th.r.send(th.a.post);
		}
		else {
			alert("We're sorry, your browser does not support this functionality.");
		}
	},
	process : 
	function () {
		if(this.r.readyState == 4) {
			var t = this.r.responseText;
			if(this.r.status == 200) {
				if(this.qparams.node) {
					var n = _ternStyle.getNode(this.qparams.node);
					if(this.qparams.empty) {
						n.innerHTML = this.r.responseText;
					}
					else {
						var f = document.createElement('div');
						f.innerHTML = this.r.responseText;
						ternStyle(n).moveChildren(f);
					}
				}
				if(this.qparams.func) {
					var w = this.qparams.pass ? this.r.responseText : '';
					this.qparams.func(w);
				}
			}
			else if(this.qparams.efunc) {
				this.qparams.efunc();
				if(this.qparams.amsg) {
					this.error();
				}
			}
			if(this.qparams.arsp) {
				this.response();
			}
			this.unqueue();
		}
	},
	error : 
	function () {
		if(this.qparams.emsg && this.qparams.emsg.length > 0) {
			alert(this.qparams.emsg);
		}
		else {
			alert("There was an error processing your request. Please try again.");
		}
	},
	response : 
	function () {
		alert(this.r.responseText);
	},
	loadScripts :
	function () {
		var th = this,a = th.a.scripts,s,n;th.total = th.loaded = 0;
		for(k in a) {
			for(var i=0;i<a[k].length;i++) {
				if(_ternStyle.inArray(th.scripts,a[k][i])) {
					continue;
				}
				th.total++;
				t = k == 'js' ? 'script' : 'link';
				s = document.createElement(t);
				if(k == 'js') {
					s.type = 'text/javascript';
					ternEvents.addEvent(s,function (e) {
						th.isLoaded(e);
					},'load',false);
					ternEvents.addEvent(s,function (e) {
						n = ternEvents.eventSource(e);
						if(n.readyState == 'complete' || n.readyState == 'loaded') {
							th.isLoaded(e);
						}
					},'readystatechange',false);
					s.src = a[k][i];
				}
				else if(k == 'css') {
					s.type = 'text/css';
					s.setAttribute('rel','stylesheet');
					s.href = a[k][i];
					th.isLoaded(a[k][i]);
				}
				document.getElementsByTagName('head')[0].appendChild(s);
			}
		}
		th.timer = setInterval(function () {
			if(th.loaded >= th.total) {
				clearInterval(th.timer);
				if(th.qparams.func) {
					th.qparams.func();
				}
				th.unqueue();
			}
		},300);
	},
	isLoaded :
	function (e) {
		if(typeof(e) == 'string') {
			this.scripts[this.scripts.length] = e;
		}
		else {
			var s = ternEvents.eventSource(e);
			ternEvents.removeAllItemEvents(s);
			this.scripts[this.scripts.length] = s.src;
		}
		this.loaded++;
	}
};