function Ajax(url) {
	this.method = Ajax.method.GET;
	this.async = true;
	this.output = Ajax.output.XML;
	this.contentType = "application/x-www-form-urlencoded";
	this.xmlhttp = (XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"));
	this.xmlhttp.url = url;
	this.xmlhttp.onreadystatechange = Function.bind(this.onstatechange, this);
}
Ajax.method = {
	GET: "GET",
	POST: "POST"
};
Ajax.output = {
	XML: 0,
	TEXT: 1
};
Ajax.prototype = {
	_onload: function(response, status, statusText) {},
	_onerror: function(response, status, statusText) {},
	send: function(s, t) {
		this.xmlhttp.open(this.method, this.xmlhttp.url, this.async);
		if (this.async) {
			this.xmlhttp.setRequestHeader("Content-Type", this.contentType);
			this.xmlhttp.setRequestHeader("Content-Length", (s ? s.length : 0));
			if (this.soapAction) {
				this.xmlhttp.setRequestHeader("SOAPAction", this.soapAction);
			}
		}
		this.xmlhttp.send(s);
		if (!this.async) {
			return (this.xmlhttp["response" + (this.output == Ajax.output.XML ? "XML" : "Text")]);
		}
	},
	onstatechange: function() {
		if (this.xmlhttp.readyState == 4) {
			this["_on" + (this.xmlhttp.status == 200 ? "load" : "error")](this.xmlhttp["response" + (this.output == Ajax.output.XML ? "XML" : "Text")], this.xmlhttp.status, this.xmlhttp.statusText);
		}
	}
};
function AjaxForm(form) {
	this.form = form;
	Event.attach(form, "submit", this.submit, this, [ Event.actions.PREVENT_DEFAULT ]);
}
AjaxForm.prototype = {
	submit: function() {
		var ajax = new Ajax(this.form.getAttribute("action"));
		ajax.method = Ajax.method.POST;
		ajax.output = Ajax.output.TEXT;
		Event.attach(ajax, "load", this.submitCb, this);
		Event.attach(ajax, "error", function(response, code, text) { this._onerror(response, code, text); }, this);

		var values = [];
		var inputs = $t("input", this.form);
		for (var i = 0, input; input = inputs[i]; i++) {
			var type = input.getAttribute("type").toLowerCase();
			if (type == "text" || type == "password" || type == "hidden" || ((type == "checkbox" || type=="radio") && input.checked)) {
				values.push(input.getAttribute("name") + "=" + encodeURIComponent(input.value));
			}
		}
		
		var texts = $t("textarea", this.form);
		for (var i = 0, text; text = texts[i]; i++) {
			values.push(text.getAttribute("name") + "=" + encodeURIComponent(text.value));
		}
		
		this.setClass("loading");
		ajax.send(values.join("&"));
	},
	submitCb: function(response, code, text) {
		if ((response.toLowerCase && response.toLowerCase() == "false") || this._onsubmit(response, code, text) == false) {
			this._onerror(response, code, text);
		} else {
			this.setClass("success");
		}
	},
	setClass: function(name) {
		Class[name == "loading" ? "add" : "remove"](this.form, "loading");
		Class[name == "success" ? "add" : "remove"](this.form, "success");
		Class[name == "error" ? "add" : "remove"](this.form, "error");
	},
	_onsubmit: function(response, code, text) {},
	_onerror: function(response, code, text) {
		this.setClass("error");
	}
};
var Class = {
	add: function (o, c) {
		var cn = o.className;
		var m = new RegExp("\\b" + c + "\\b", "i").exec(cn);
		if (!m) {
			o.className += (cn.length > 0 ? " " : "") + c;
		}
	},

	remove: function (o, c) {
		var cn = o.className;
		var m = new RegExp("\\b" + c + "\\b", "i").exec(cn);
		if (m) {
			o.className = (cn.replace(new RegExp(m), ""));
		}
	},
	
	get: function(o, c) {
		return o.className.match(new RegExp("\\b" + c + "\\b"));
	}
};
function Coordinate(e) {
	this.x = (e.pageX || e.x || 0);
	this.y = (e.pageY || e.y || 0);
	if ((!this.x || !this.y) && e.offsetParent) {
		var i = e;
		while (i.offsetParent) {
			this.x += i.offsetLeft;
			this.y += i.offsetTop;
			i = i.offsetParent;
		}
	}
}
var Easing = {
	linear: function(t, b, c, d) { return c*t/d + b; },
	easeIn: function(t, b, c, d) { return c*(t/=d)*t*t + b; },
	easeOut: function(t, b, c, d) { return c*((t=t/d-1)*t*t + 1) + b; },
	easeInOut: function(t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	}
};
if (!Event) {
	var Event = {};
}
Event.modify = function(obj, event, fnct, context, actions, attach) {
	var fn = Function.bind(fnct, (context || obj));
	var custom = obj["_on" + event];
	if (custom && attach) {
		obj["_on" + event] = function() {
			return ((custom.apply(this, arguments) !== false ? true : false) && (fn.apply(this, arguments) !== false ? true : false));
		};
	} else if (!custom) {
		var handle = Function.bind(Event.handle, Event, fn, actions);
		if (obj.addEventListener) {
			obj[(attach ? "add" : "remove") + "EventListener"](event, handle, false);
		} else {
			obj[(attach ? "at" : "de") + "tachEvent"]("on" + event, handle);
		}
	}
};
Event.attach = function (obj, event, fnct, context, actions) { Event.modify(obj, event, fnct, context, actions, true); };
Event.detach = function (obj, event, fnct, context, actions) { Event.modify(obj, event, fnct, context, actions, false); };
Event.handle = function(fnct, actions, e) {
	e = (e || window.event);
	if (!e.target) {
		e.target = e.srcElement;
	}
	if (actions) {
		for (var i = 0, action; action = actions[i]; i++) {
			switch (action) {
				case Event.actions.PREVENT_DEFAULT:
					if (e.preventDefault) {
						e.preventDefault();
					} else {
						e.returnValue = false;
					}
					break;
				
				case Event.actions.STOP_PROPAGATION:
					if (e.stopPropagation) {
						e.stopPropagation();
					} else {
						e.cancelBubble = true;
					}
					break;
				
				case Event.actions.BLUR:
					if (e.target && e.target.blur) {
						e.target.blur();
					}
					break;
			}
		}
	}
	fnct(e);
};
Event.actions = {
	PREVENT_DEFAULT: 1,
	STOP_PROPAGATION: 2,
	BLUR: 4
};
Function.bind = function(fnct, context) {
	var args = $a(arguments).slice(2, arguments.length);
	var cache = Function.bind.cache;
	for (var i = 0, cacheFnct; cacheFnct = cache[i]; i++) {
		if (cacheFnct.fnct == fnct && cacheFnct.context == context && cacheFnct.args.length == args.length) {
			var t = true;
			for (var j = 0, a1, a2; (a1 = cacheFnct.args[j]) && (a2 = a[j]); j++) {
				t = (a1 == a2);
				if (!t) {
					break;
				}
			}
			if (t) {
				return cacheFnct.method;
			}
		}
	}
	
	var newFnct = {
		fnct: fnct,
		obj: context,
		args: args,
		method: function() {
			return fnct.apply(context, (args ? args.concat($a(arguments)) : arguments));
		}
	};
	
	cache.push(newFnct);
	return newFnct.method;
};
Function.bind.cache = [];
function $a(a) {
	var r = new Array();
	for (var i = 0, l = a.length; i < l; i++) {
		r.push(a[i]);
	}
	return r;
}
function Fx(node, duration, easing) {
	this.node = node;
	this.duration = (duration || 1);
	this.easing = (easing || Easing.easeOut);
	this.totalFrames = 30 * this.duration;
	this.animations = [];
}
Fx.animations = {
	FADE: function(node, opac) {
			node.style.height = "200px";
			node.style.opacity = opac / 100;
			node.style.filter = "alpha(opacity=" + opac + ")";
		},
	RESIZE: function(node, width, height) {
			node.style.width = width + "px";
			node.style.height = height + "px";
		},
	MOVE: function (node, coordX, coordY) {
			node.style.marginLeft = coordX + "px";
			node.style.marginTop = coordY + "px";
		},
	SCROLL: function(node, left, top) {
			node.scrollTo(left, top);
		}
};
Fx.prototype = {
	addFx: function(animation, startX, endX, startY, endY) {
		this.animations.push({
				fnct: animation,
				startX: startX,
				endX: endX,
				startY: startY,
				endY: endY
			});
	},
	go: function() {
		this._onstart();
		this.currentFrame = 0;
		this.started = new Date();
		this.action();
	},
	_onstart: function() {},
	action: function() {
		if (this.currentFrame < this.totalFrames) {
			this.computeFrame();
			for (var i = 0, animation; animation = this.animations[i]; i++) {
				var resultX = ((animation.startX && animation.endX) !== undefined ? this.easing(this.currentFrame, animation.startX, (animation.endX - animation.startX), this.totalFrames) : 0);
				var resultY = ((animation.startY && animation.endY) !== undefined ? this.easing(this.currentFrame, animation.startY, (animation.endY - animation.startY), this.totalFrames) : 0);
				animation.fnct(this.node, resultX, resultY);
			}
			setTimeout(Function.bind(this.action, this), 1);
		} else {
			this._onend();
		}
	},
	_onend: function() {},
	computeFrame: function() {
		var time = (new Date() - this.started);
		var calcFrame = Math.round((time * this.totalFrames) / (this.duration * 500)) + 1;
		this.currentFrame = (calcFrame <= this.totalFrames ? calcFrame : this.totalFrames);
	}
};
function ScrollingAnchors(parent) {
	var anchors = $t("a", parent);
	var hashRe = new RegExp("^#|" + window.location.href.replace(/#.*$/, "") + "#");
	for (var i = 0, anchor; anchor = anchors[i]; i++) {
		var href, id = ((href = anchor.getAttribute("href")) && href ? href.replace(hashRe, "") : null);
		if (id && $i(id)) {
			Event.attach(anchor, "click", function() {
					var id = this.getAttribute("href").replace(hashRe, "");
					var obj;
					if (id && (obj = $i(id))) {
						var fx = new Fx(window);
						var de = document.documentElement;
						fx.addFx(Fx.animations.SCROLL, (window.scrollX || de.scrollLeft), 0, (window.scrollY || de.scrollTop), new Coordinate(obj).y);
						fx.go();
					}
				}, null, [ Event.actions.PREVENT_DEFAULT, Event.actions.BLUR ]);
		}
	}
}
function InputTitle(input) {
	this.input = input;
	Event.attach(input, "focus", this.focus, this);
	Event.attach(input, "blur", this.blur, this);
	this.blur();
}
InputTitle.prototype = {
	focus: function() {
		var input = this.input;
		if (input.value == input.title) {
			input.value = "";
			Class.remove(input, "empty");
		}
	},

	blur: function() {
		var input = this.input;
		if (input.value == "") {
			input.value = input.title;
			Class.add(input, "empty");
		}
	}
};
function $i(s, p) {
	return (p || document).getElementById(s);
}
function $t(t, p) {
	return (p || document).getElementsByTagName(t || "*");
}
function $c(c, t, p) {
	var a = [];
	var ts = $t(t, p);
	var r = new RegExp("\\b" + c + "\\b");
	for (var i = 0, t; t = ts[i]; i++) {
		if (t.className.match(r)) {
			a.push(t);
		}
	}
	return a;
}
function Tabs(parent, tabClass) {
	this.parent = parent;
	this.tabs = [];
	var anchors = (tabClass ? $c(tabClass, "a", parent) : $t("a", parent));
	for (var i = 0, anchor; anchor = anchors[i]; i++) {
		var tab = new Tab(this, anchor, $i(anchor.id.replace(Tabs.idRe, "")), anchor.parentNode);
		this.tabs.push(tab);
		Event.attach(anchor, "click", tab.click, tab, [ Event.actions.PREVENT_DEFAULT, Event.actions.BLUR ]);
	}
}
Tabs.idRe = /-[^-]+$/;
Tabs.prototype = {
	_onchange: function(newTab, oldTab) {},
	select: function(selectTab) {
		var oldTab;
		for (var i = 0, tab; tab = this.tabs[i]; i++) {
			if (Class.get(tab.parent, "selected")) {
				oldTab = tab;
			}
			Class[tab == selectTab ? "add" : "remove"](tab.parent, "selected");
			if (tab.content) {
				Class[tab == selectTab ? "add" : "remove"](tab.content, "selected");
			}
		}
		this._onchange(selectTab, oldTab);
	},
	clear: function() {
		for (var i = 0, tab; tab = this.tabs[i]; i++) {
			Class.remove(tab.parent, "selected");
			if (tab.content) {
				Class.remove(tab.content, "selected");
			}
		}
	}
};
function Tab(container, anchor, content, parent) {
	this.container = container;
	this.anchor = anchor;
	this.content = content;
	this.parent = parent;
}
Tab.prototype = {
	click: function() {
		this.container.select(this);
	}
};