/*
 * Savvy.js Library
 * Name: Savvy.Core
 * Version: 0.1.1.2 (Beta)
 * Required: Tested on IE6, IE7, Firefox 1.5+ and Opera 9.2. Other browser support is unknown/untested.
 * Last Updated: 16.05.2007
 * Author: Cryno Bone http://www.chronosight.net/
 ***************************************************
 * References:
 * 1. $pick() function taken directly from Mootools Framework
 * 2. Draggable and Resizable object taken with modification from dom-drag.js by www.youngpup.net
 * 3. DOM.addAfter() function taken from Dustin Diaz's Top 10 JaScript Functions at <http://www.dustindiaz.com/top-ten-javascript/>
 * 4. Few prototype function taken from <http://www.hunlock.com/blogs/Ten_Javascript_Tools_Everyone_Should_Have> and <http://20bits.com/2007/03/08/the-philosophy-of-javascript/>
*/
var Savvy = {
	version:"0.1.1.2 (Beta)",
	log:function(v) {
		try { 
			console.log(v); 
		} catch(e) { 
			alert(v); 
		}
	},
	href:function(u) {
		window.location.href = u;
	},
	browser:function() {
		return function() {
			var win = new Object;
			win.ie = win[window.XMLHttpRequest ? "ie7" : "ie6"] = (window.ActiveXObject ? true : false);
			win.khtml = ((document.childNodes && !document.all && !navigator.taintEnabled) ? true : false);
			win.gecko = (document.getBoxObjectFor != null ? true : false);
			win.opera = (window.opera ? true : false);
			return win;
		}();
	}(),
	chain:function (o, params) {
		if($null(params)) {
			var params = ({
				addDOM:function(c) { return DOM.add(this,c); },
				addTextDOM:function(t) { return DOM.addText(this,t); },
				AddBefore:function(c) { return DOM.addBefore(this,c); },
				removeDOM:function(c) { return DOM.remove(this,c); },
				setAttrib:function(a,v) { return $$.set(this,a,v); },
				getAttrib:function(a) { return $$.get(this,a); },
				removeAttrib:function(a) { return $$.remove(this,a); },
				addClass:function(a) { return $$$.add(this,a); },
				appendClass:function(a) { return $$$.append(this,a); },
				removeClass:function(a) { return $$$.remove(this,a); },
				hasClass:function(a) { return $$$.has(this,a); },
				setCSS:function(a,v) { return CSS.set(this,a,v); },
				getCSS:function(a) { return CSS.get(this,a); },
				pngCSS:function(jon) { jon.obj = this; return CSS.png(jon); },
				styler:function(jon) { return CSS.styler({obj:this,css:jon}); },
				FxToggleY:function(jon) { jon.obj = this; Animation.y.init(jon); return this; },
				FxToggleX:function(jon) { jon.obj = this; Animation.x.init(jon); return this; },
				FxOpacity:function(jon) { jon.obj = this; Opacity.init(jon); return this; },
				addHTML:function(t) { this.innerHTML = t; return this; },
				appendHTML:function(t) { this.innerHTML = this.innerHTML.concat(t); return this; },
				bind:function(t,fn) { try { this["on".concat(t)] = fn; } catch(e) { } return this; },
				bindListener:function(t,fn) { this.bindfunc = fn; Event.On({trigger:t,load_function:this.bindfunc,obj:this}); return this; },
				callback:function(fn) { this.callbackfunc = fn; this.callbackfunc(); return this;},
				each:function(fn) { for(var i=0; i<this.length; i++) { this[i].callback(fn); } }
			});
		}
		var obj = function(o) {
			function F() {}
			F.prototype = o;
			return new F();
		};
		for (key in params) {
			try {
				o[key] = params[key];
			} catch(e) { }
		}
		return obj;
	}
};

Object.prototype.extend = function(params) {
	function F() {};
	F.prototype = this;
	var o = new F();
	for (key in params) o[key] = params[key];
	return o;
};
Array.prototype.inArray = function(v){
	for (var i=0; i<this.length; i++) {
		if(this[i] === v) return true;
	}
	return false;
};
Array.prototype.each = function(f) {
	for(var i=0; i<this.length; i++) {
		if(typeof(v) == "function") {
			this.callback(f);
		}
	}
};
Array.prototype.map = function(f) {
	var r=[];
	for(var i=0; i<this.length; i++) r.push(f(this[i]));
	return r;
};
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
};
String.prototype.ltrim = function() {
	return this.replace(/^\s+/g,"");
};
String.prototype.rtrim = function() {
	return this.replace(/\s+$/g,"");
};
String.prototype.striptags = function() {
	return this.replace(/<([^>]+)>/g,"");
};
String.prototype.htmlentities = function () {
	return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
};
String.prototype.toNumber = function () {
	return parseInt(this,10);
};
Number.prototype.toNumber = function() {
	return this;
};

var $ = {};
$ = function(el) {
	var __o = new Object();
	var args = arguments;
	if(args.length === 1 && !$null(args[0])) { 
		__o = document.getElementById(el.trim());
	} else if(args.length === 2 && !$null(args[1])) {
		try {
			__o = args[0].getElementById(args[1]); 
		} catch(e) { 
			__o = document.getElementById(args[1]); 
		}
	} else return false;
	Savvy.chain(__o);
	return __o;
};
var $T = {};
$T = function(el) {
	var __o = new Object, elm ="";
	var args = arguments;
	var rXi = new RegExp(/>/);
	function hClass(obj,v,i) {
		var __o = v.trim().split(".");
		var rXc = new RegExp(/\./);
		try {
			o = obj.getElementsByTagName(__o[0].trim());
		} catch(e) {
			o = document.getElementsByTagName(__o[0].trim());
		}
		if(rXc.test(v)) {
			var __c = new Array();
			for(var i=0;i<o.length;i++) {
				var c = o[i];
				var cA = c.className.split(" ");
				if(cA.inArray(__o[1].trim())) {
					if(__c.length === 0) __c[0] = c;
					else __c.push(c);
				}
			}
			return __c;
		} else return o;
	};
	if(args.length === 2) {
		__o = hClass(args[0],args[1]);
	} else if(args.length === 1) {
		if(rXi.test(el)) {
			var obj = el.trim().split(">");
			var o = obj[0].trim();
			elm = obj[1].trim();
			__o = $(o);
			__o = hClass(__o,elm.trim());
		} else {
			__o = document;
			__o = hClass(__o,el.trim());
		} 
	}
	for(var m = 0; m < __o.length; m++) Savvy.chain(__o[m]);
	Savvy.chain(__o);
	return __o;
};
var $A = {};
$A = function(el) {
	var r = false;
	var args = arguments;
	if(args.length === 2) {
		if(!$null(args[0])) {
			try { 
				r = args[0].createElement(args[1]); 
			} catch(e) { 
				r = document.createElement(args[1]); 
			}
		} else r = document.createElement(args[1]);
	} else if(!$null(el)) r = document.createElement(el);
	Savvy.chain(r);
	return r;
};

function $null(obj) {
	return (typeof(obj) == "undefined" || obj == null); 
};

function $pick(choose,option) {
	return (!$null(choose) ? choose : option);
};

function $bind(obj,el,r) {
	var r = (!$null(r) ? r : "element");
	if(!$null(obj) && !$null(el)) {
		if($$.get(obj,"id") == el) return (r == "obj" ? obj : el);
		else return false;
	} else if (!$null(el)) return (r == "obj" ? $(el) : el);
	else if (!$null(obj)) return (r == "obj" ? obj : $$.get(obj,"id"));
	else return false;
};
var $$ = {};
$$ = {
	get:function(o,a) {
		if(!$null(o)) return o.getAttribute(a);
		else return false;
	},
	set:function(o,a,v) {
		if(!$null(o)) {
			o.setAttribute(a,v);
			return o;
		} else return false;
	},
	remove:function(o,a) {
		if(!$null(o)) {
			o.removeAttribute(a);
			return o;
		} else return false;
	}	
};

var $$$ = {};
var $$$ = {
	add:function(o,a) {
		o.className = a;
		return o;
	},
	append:function(o,a) {
		if(!$null(o.className) && o.className.trim() != "") {
			o.className = o.className+" "+a;
			return o;
		} else if($null(o.className) || o.className.trim() == "") {
			o.className = a;
			return o;
		} else return false;
	},
	remove:function(o,a) {
		if(!$null(o.className) && o.className.trim() != "") {
			var arry = o.className.split(" ");
			o.className = "";
			for(var i=0;i<arry.length;i++) {
				if(arry[i] != a) o.className = o.className+" "+a;
			}
		}
		return o;
	},
	clear:function(o,a) {
		if(!$null(o.className) && o.className.trim() != "") {
			o.className = "";
			return o;
		}
	},
	has:function(o,a) {
		if(!$null(o.className) && o.className.trim() != "") {
			var arry = o.className.split(" ");
			return arry.inArray(a);
		}
	}
};

var DOM = {};
DOM = {
	add:function(p,c) {
		if(!$null(p) && !$null(c)) {
			p.appendChild(c);
			return p;
		} else {
			try { 
				document.body.appendChild(p); 
				return p;
			} catch(e) { return false; }
		}
	},
	addText:function(p,t) {
		if(!$null(p) && t != "") return this.add(p,document.createTextNode(t));
		else return false;
	},
	addBefore:function(params) {
		var args = arguments;
		alert_r(arguments);
		if(args.length == 3 && !$null(args[0]) && !$null(args[1]) && !$null(args[2])) {
			arguments[0].insertBefore(args[1],args[2]);
			return true;
		} else if(args.length == 2 && !$null(args[0]) && !$null(args[1])) {
			args[1].parentNode.insertBefore(args[0],args[1]);
			return true;
		} else return false;
	},
	addAfter:function(params) {
		var args = arguments;

		if(!$null(r.nextSibling)) {
			if(args.length == 3 && !$null(args[0]) && !$null(args[1]) && !$null(args[2])) {
				this.addBefore(args[0],args[1],args[2].nextSibling);
				return true;
			} else {
				try {
					this.addBefore(args[0],args[1].nextSibling);
					return true;
				} catch(e) { return false; }
			}
		} else return this.add(p,c);
	},
	remove:function(params) {
		var args = arguments;
		if(args.length === 2 && !$null(args[0]) && !$null(args[1])) {
			args[0].removeChild(args[1]);
			return args[0];
		} else {
			args[0].parentNode.removeChild(args[0]);
			return args[0];
		}
	},
	change:function(params) {
		var args = arguments;
		if(args.length == 3 && !$null(args[0]) && !$null(args[1]) && !$null(args[2])) {
			args[0].replaceChild(args[1],args[2]);
		} else {
			args[1].parentNode.replaceChild(args[0],args[1]);
		}
	},
	empty:function(p) {
		if(!$null(p)) {
			if(p.hasChildNodes || p.innerHTML != "") p.innerHTML = "";
			return true;
		} else return false;
	}
};

var CSS = {
	styler:function(__) {
		var o = __.obj;
		var cT = new Array();
		cT = __.css;
		for(var i = 0;i < cT.length; i++) {
			for(var inst in cT[i]) {
				if(cT[i].hasOwnProperty(inst)) { this.set(o,inst,cT[i][inst]); }
			}
		}
		return o;
	},
	set:function(o,a,v) {
		try { 
			o.style[a] = v;
			return o;
		} catch(e) { return false; }
	},
	get:function(o,a) {
		try {
			return o.style[a];
		} catch(e) { return false; }
	},
	png:function(__) {
		var o = $bind(__.obj,__.element,"obj");
		__.gecko = $pick(__.gecko,"");
		__.ie = $pick(__.ie,"scale");
		if(window.ActiveXObject) {
			this.set(o,"filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+__.uri+"',sizingMethod='"+__.ie+"')");
		} else {
			this.set(o,"background","url('"+__.uri+"') "+__.gecko);
		}
		return o;
	}
};

var Opacity = {
	step:new Array(),
	speed:new Array(),
	istart:new Array(),
	iend:new Array(),
	ifunc:new Array(),
	interval:new Array(),
	init:function(__) {
		var elm = $bind(__.obj,__.element);
		if(!$null(this.interval[elm])) {
			clearInterval(this.interval[elm]);
			this.interval[elm] = null;
		}
		var o = $(elm);
		__.delay = (__.delay && __.delay > 0 ? __.delay : 1);
		this.step[elm] = 1;
		this.istart[elm] = __.start;
		this.iend[elm] = __.end;
		this.ifunc[elm] = $pick(__.oncomplete,null);
		this.speed[elm] = (__.speed && __.speed > 0 ? __.speed : 1);
		if(__.start > __.end) {
			this.fadeout(elm);
			this.interval[elm] = setInterval("Opacity.fadeout('"+elm+"')",__.delay);
		} else if(__.start < __.end) { 
			this.fadein(elm);
			this.interval[elm] = setInterval("Opacity.fadein('"+elm+"')",__.delay);
		}
	},
	set: function(g,v) {
		v = (v > 100 ? 100 : (v < 0 ? 0 : v));
		try {
			var o = $(g);
			if(v == 0 && o.getCSS("visibility") != "hidden") 
				o.setCSS("visibility","hidden");
			else if(v > 0 && o.getCSS("visibility") != "visible")
				o.setCSS("visibility","visible");
			if (window.ActiveXObject || Savvy.browser.ie == true) {
				if (!o.currentStyle || !o.currentStyle.hasLayout) o.setCSS("zoom",1);
				o.setCSS("filter",(v < 100 ? "alpha(opacity="+v+")" : ""));
			} else {
				o.setCSS("opacity",(v/100));
				o.setCSS("MozOpacity",(v/100));
			}
		} catch(e) { }
	},
	fadein: function(g) {
		var f = this.step[g]++, s = this.istart[g], e = this.iend[g];
		f = (f*this.speed[g]);
		s = Math.round(s+f);
		if(s < e) this.set(g,s);
		else {
			this.set(g,e);
			var f = this.ifunc[g];
			if(f != null && typeof(f) == "function") {
				$(g).callback(f);
			}
			clearInterval(this.interval[g]);
			this.interval[g] = null;
		}
		this.istart[g] = s;
	},
	fadeout: function(g) {
		var f = this.step[g]++, s = this.istart[g], e = this.iend[g];
		f = (f*this.speed[g]);
		s = Math.round(s-f);
		if(s>e) Opacity.set(g,s);
		else {
			this.set(g,e);
			var f = this.ifunc[g];
			if(f != null && typeof(f) == "function") {
				$(g).callback(f);
			}
			clearInterval(this.interval[g]);
			this.interval[g] = null;
		}
		this.istart[g] = s;
	},
	power:function(s,e,st) {
		var dif = (Math.abs(s-e) - 1);
		var step = 1;
		for(var i = 1; i < st; i++) 
			step += i;
		if(dif>step) return true;
		else return false;			
	}
};

var Test = {
	string:function(v) {
		return (typeof(v) == "string" && v != "" && isNaN(v));
	},
	integer:function(v) {
		return (!isNaN(v) && v != "");
	},
	email:function(v) {
		var rX = new RegExp(/^[\w-\.\']{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,}$/);
		return (v != "" && rX.test(v));
	},
	birthdate:function(v) {
		var rX = new RegExp(/^[0-9]{1,2}\.[0-9]{1,2}\.(200[0-9]|19[2-9][0-9])$/);
		return (v != "" && rX.test(v));
	},
	phone:function(v) {
		var rX1 = new RegExp(/^\+?(([\s]?[\-\(\)\/,]?[\s]?)?[0-9]+){5,}[\s]?[\)]?$/);
		var rX2 = new RegExp(/^(123|0123|000)/);
		var rX3 = new RegExp(/(00000|12345)/);
		return (v != "" && rX1.test(v) && !rX2.test(v) && !rX3.test(v));
	},
	selectbox:function(v) {
		return (v != "0" && v != "a");
	},
	lengths:function(r,v) {
		var epx = r.split("-");
		if(epx[0] == "max") 
			return (v.length <= epx[1].toNumber() ? true : false); 
		else if(epx[0] == "min") 
			return (v.length >= epx[1].toNumber()? true : false);
		else if(epx[0] == "exact") 
			return (v.length == epx[1].toNumber()? true : false);
	},
	ip:function(v) {
		var rX = new RegExp(/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/);
		return (v != "" && rX.test(v));
	}
};
var File = {
	path:function(n) {
		var rX = new RegExp(/(.*)\/([^\/\\]+)(\.\w+)$/);
		var f = n.match(rX);
		return {path:m[1],file:m[2],extension:m[3]};
	}
};
var Form = {
	first:new Array(),
	confirm:function(v) {
		if(!v || v.trim() == "") 
			v = "Do you really want to run this action?";
		return confirm(v);
	},
	clear:function(o) {
		var x = "", obj = o.elements;
		for (var i=0; i < obj.length; i++){
			var _o = obj[i];
			if(_o.type == "text" || _o.type == "password" || _o.type == "textarea") 
				_o.value = "";
		}
	},
	validate:function(o) {
		var elm = o.getAttrib("id");
		var x = "", obj = $T(o,"*");
		Form.first[elm] = null;
		

			
		var tn = new Array("INPUT","SELECT","TEXTAREA");
		obj.each(function() {
			if(tn.inArray(this.tagName) && this.type != "image" && this.type != "submit") {
			//for(var i = 0; i <obj.length;i++) {
				var _o = this;
				if (_o.name != "") {
					
					_o.onchange = function() { 	Form.validate($(elm)) };
					var cha = new RegExp("(max|min|exact)\-(\d*)");
					if(!_o.className) 
						_o.className = "";
					var thisClass = _o.name.split(" ");
					
					if(thisClass.inArray("tx_t4tproof_request_pers_vorname") && !Test.string(_o.value)) {
						Form.error(o, _o, "" , false);
						Form.mark(o);
					} else if(thisClass.inArray("tx_t4tproof_request_pers_nachname") && !Test.string(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);					
					} else if(thisClass.inArray("tx_t4tproof_request_pers_geburtstag_group[tx_t4tproof_request_pers_geburtstag]") && !Test.birthdate(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);
					} else if(thisClass.inArray("tx_t4tproof_request_pers_email") && !Test.email(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);
					} else if(thisClass.inArray("tx_t4tproof_request_pers_anschrift_group[tx_t4tproof_request_pers_strasse]") && !Test.string(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);
					} else if(thisClass.inArray("tx_t4tproof_request_pers_anschrift_group[tx_t4tproof_request_pers_hausnummer]") && !Test.string(_o.value) && !Test.integer(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);
					} else if(thisClass.inArray("tx_t4tproof_request_pers_plzwohnort_group[tx_t4tproof_request_pers_plz]") && (!Test.lengths("exact-5",_o.value) || !Test.integer(_o.value))) {
						Form.error(o, _o, "", false);
						Form.mark(o);
					} else if(thisClass.inArray("tx_t4tproof_request_pers_plzwohnort_group[tx_t4tproof_request_pers_wohnort]") && !Test.string(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);
					} else if(thisClass.inArray("tx_t4tproof_request_pers_telefonnummer") && !Test.phone(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);
					} else if(thisClass.inArray("tx_t4tproof_request_pers_berufsgruppe") && !Test.selectbox(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);
					} else if(thisClass.inArray("tx_t4tproof_request_other_datenschutz_group[tx_t4tproof_request_other_datenschutz]") && _o.checked != true) {
						Form.error(o, _o, unescape("Bitte Datenschutzerkl%E4rung best%E4tigen"), true);
						Form.mark(o);						
					}
					else if(thisClass.inArray("tx_t4tproof_request_gwv_anzahl_mitarbeiter") && !Test.selectbox(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);						
					}
					else if(thisClass.inArray("tx_t4tproof_request_gwv_branche") && !Test.string(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);
					}
					else if(thisClass.inArray("tx_t4tproof_request_gwv_risiken") && !Test.string(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);
					}
					else if(thisClass.inArray("tx_t4tproof_request_gwv_firmenname") && !Test.string(_o.value)) {
						Form.error(o, _o, "", false);
						Form.mark(o);
					}
					else {
						if((tn[0] == this.tagName || tn[2] == this.tagName) && this.type != "checkbox") {
							//CSS.set(_o,"border","1px solid #7F9DB9;");
							//CSS.set(_o,"border","1px solid green;");
							_o.setCSS("border","1px solid #7F9DB9");
							
						}
						else if(this.type == "checkbox") {
							_o.parentNode.setCSS("color","#000000");
							_o.setCSS("border","0");
						}
						if(tn[1] == this.tagName) {
							//CSS.set(_o,"border","1px solid #7F9DB9;");
							_o.setCSS("border","1px solid #7F9DB9");
							_o.setCSS("background-color","#fff");
							//_o.parentNode.parentNode.setCSS("color","#000000");
							_o.setCSS("color","#000000");
						}
					}
					for(var ii = 0; ii < thisClass.length; ii++) {
						if(thisClass[ii].match(cha)) {
							if(!Test.lengths(thisClass[ii],_o.value)) {
								var matcherror = thisClass[ii].split("-");
								Form.error(o, _o, "Require "+matcherror[0]+" of "+matcherror[1]+" characters.",true);
								Form.mark(o);
							}
						}
					}
					
					if (_o.type == "checkbox" && _o.checked == true) {
						x = x + "&" + _o.name + "=" + Replacer.html(_o.value);
					} else if (_o.type == "radio" && _o.checked == true) {
						x = x + "&" + _o.name + "=" + Replacer.html(_o.value);
					} else if (_o.type != "checkbox" && _o.type != 'radio') {
						x = x + "&" + _o.name + "=" + Replacer.html(_o.value);
					}
				}
			}
		});
		if(!$null(Form.first[elm])) { 
			Form.first[elm].focus();		
			var oE = $A("div").setAttrib("id","cForm_error").addTextDOM(unescape("Bitte %DCberpr%FCfen Sie Ihre Eingaben."));
			oE.className = "form_error";
			var elem = document.getElementById("cForm_error");
			var elem2 = document.getElementById("Fehler");
			if(elem) DOM.remove(elem2,elem);
			DOM.add(elem2,oE);	
			
			var elem3 = document.getElementById("cForm_ok");
			if(elem3) DOM.remove(elem2,elem3);
			
			return false; 
		} else {
			var elem = document.getElementById("cForm_error");
			var elem2 = document.getElementById("Fehler");
			if(elem) {
				DOM.remove(elem2,elem);
				var oE = $A("div").setAttrib("id","cForm_ok").addTextDOM("Alle Daten wurden korrekt eingegeben.");
				oE.className = "form_ok";
				var elem = document.getElementById("cForm_ok");
				var elem2 = document.getElementById("Fehler");
				if(elem) DOM.remove(elem2,elem);
				DOM.add(elem2,oE);	
			}
			return x;
		}
	},
	mark:function(o) {
		var elm = o.getAttrib("id");
		if($null(Form.first[elm])) {
			Form.first[elm] = o;
		}
	},
	error: function(obj,o,msg,bool) {
		Savvy.chain(o);
		var elm = obj.getAttrib("id");
		var boolean = bool;
		var tn = new Array("INPUT","SELECT","TEXTAREA");
		
		if(boolean == false) {
				
			if(msg != "") {
				var oE = $A("div").setAttrib("id",o.name+"_error").addTextDOM(msg);
				oE.className = "form_error";
				var elem = document.getElementById(o.name+"_error");
				var elem3 = document.getElementById("Fehler");
				if(elem) DOM.remove(elem3,elem);
				DOM.add(elem3,oE);	
			}
			o.setCSS("border","1px solid #CC0000");	
			if(tn[1] == o.tagName) {
				//o.parentNode.parentNode.setCSS("color","#CC0000");
				o.setCSS("color","#CC0000");
			}			
			o.onchange = function() {
	
					var elem = document.getElementById(o.name+"_error");
					var elem3 = document.getElementById("Fehler");
					if(elem) DOM.remove(elem3,elem);				
					Form.validate($(elm));			
				
			};
		} else if( boolean == true) {
			if(msg != "") {
				var oE = $A("div").setAttrib("id",o.name+"_error").addTextDOM(msg);
				oE.className = "form_error";
				var elem = document.getElementById(o.name+"_error");
				if(elem) DOM.remove(o.parentNode,elem);
			}
				
			DOM.add(o.parentNode,oE);

			if("checkbox" == o.type) {
				o.parentNode.setCSS("color","#CC0000");
			}
			o.setCSS("border","1px solid #CC0000");
			o.onchange = function() {
			
				if(o.checked == true) { 
					if(oE) DOM.remove(o.parentNode,oE);
					o.parentNode.setCSS("color","#000");
					Form.first[elm] = null;
					Form.validate($(elm))					
				}
				else {

					Form.validate($(elm))
				}
			};
			
		}
	},
	quickAJAX:function(__) {
		var o = $bind(__.obj,__.element,"obj");
		var params = Form.validate(o);
		if(params) {
			params = (__.params ? __.params : "")+params;
			AJAX.submit({
				parameters:params,
				uri:__.uri,
				method:"POST"
			});
			return true;
		} else return false;
	},
	xtendedInput: function(__) {
		var o = $bind(__.obj,__.element,"obj");
		var pL = 0;
		o.onkeyup = function() {
			if(o.value.length >= __.init_start && o.value.length < __.init_limit) {
				if(o.value.length > pL) o.size = o.size+1;
				else if(o.value.length < pL) o.size = o.size-1;
			}
			if((__.init_row && __.init_row != "undefined") && o.value.length >= l) {
				var nTA = $A("textarea");
				$$.set(nTA,"cols",__.init_limit);
				$$.set(nTA,"rows",__.init_row);
				nTA.value = o.value;
				$$.set(nTA,"name", $$.get(o,"name"));
				DOM.change(nTA,o);
				$$.set(nTA,"id",g);
			}
			pL = o.value.length;
		};
	},
	tick_rows: function(int_start, int_end, var_id) {
		var checker = $("ticker_" + int_start + "_" + int_end), x = false, swap = false;
		if(checker.checked == true) { 
			x = true;
			swap = true;
		}
		for(var i = int_start; i <= int_end; i++) $(var_id+i).checked = x;
		$("ticker_" + int_start + "_" + int_end).checked = swap;
	}
};

var Replacer = {
	and:function(v) {
		s = new String(v);
		s = s.replace(/&/g,"[n]");
		s = s.replace(/\+/g,"[a]");
		return s;
	},
	html:function(v) {
		s = new String(v);
		s = this.and(s);
		s = escape(s);
		return s;
	},
	trim:function(v) {
		s = new String(v);
		s = s.replace(/^\s+/g,"");
		s = s.replace(/\s+$/g,"");
		return s;
	},
	xml:function(v) {
		s = new String(v);
		s = s.replace(/\[lt\]/g,"<");
		s = s.replace(/\[gt\]/g,">");
		s = s.replace(/\[n\]/g,"&");
		s = s.replace(/\&quot\;/g,"\"");
		s = s.replace(/\&rsquo\;/g,"\'");
		s = s.replace(/\[br\]/g,"\n");
		s = s.replace(/\[break\]/g,"<br />");
		return s;
	}
};

var AJAX = {
	obj:null,
	debug:false,
	reply:null,
	method:null,
	responseID:null,
	timeOut:5000,
	init:function(){
		var xhttp = false;
		if(window.XMLHttpRequest) xhttp = new XMLHttpRequest();
		else if(window.ActiveXObject) {
			var msxml = ["MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
			for(var i=0;i < msxml.length; i++) {
				try {
					xhttp = new ActiveXObject(msxml[i]);
					break;
				} catch(e) {}
			}
		}
		if(!xhttp) { 
			Savvy.log("Sorry, your browser doesn't support AJAX!"); 
			return false;
		} else {
			AJAX.obj = xhttp;
			return true;
		}
	},
	submit:function(__) {
		if(AJAX.obj == null) AJAX.init(); 
		var req = AJAX.obj;
		this.method = (!__.method || __.method != "GET" ? "POST" : "GET");
		AJAX.debug = (__.debug ? __.debug : false);
		if (req.readyState == 4 || req.readyState == 0) {
			if(this.method == "POST") {
				req.open("POST",__.uri, true);
				req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				req.send(__.parameters);
			} else {
				req.open("GET",__.uri+__.parameters, true);
				req.send("");
			}
			if(__.oncomplete) req.onreadystatechange = __.oncomplete;
			else req.onreadystatechange = this.response;
		} else {
			setTimeout("AJAX.submit({parameters:'"+__.parameters+"',uri:'"+__.uri+"',method:'"+this.method+"'})",AJAX.timeOut);
		}
	},
	response:function() {
		var req = AJAX.obj;
		if(req.readyState == 4) {
			this.reply = req.responseText;
			if(AJAX.debug == true) Savvy.log(req.responseText);
			if(Replacer.trim(req.responseText) != "" && req.status == 200) {
				var a = eval("("+req.responseText+")");
				if(!$null(a.alertpop) && Replacer.trim(a.alertpop) != "") 
					alert(a.alertpop);
				if(!$null(a.jumpto) && Replacer.trim(a.jumpto) != "") 
					Savvy.href(a.jumpto);
				if(!$null(a.add2id) && Replacer.trim(a.add2id) != "" && a.result != "") {
					$(a.add2id).innerHTML = Replacer.xml(a.result);
				}
				if(!$null(a.exec) && Replacer.trim(a.exec) != "") { 
					try { a.exec(a.result); } 
					catch(e) { eval("parent."+a.exec+"(a.result);"); }
				}
			} else AJAX.onabort();
		}
	},
	onabort:function() {
		var req = AJAX.obj;
		req.abort();
		AJAX.obj = null;
		Savvy.log("No response from server!");
	}
};

var Event = {
	On: function(__) {
		var obj = $pick(__.obj,window);
		var t = __.trigger.toString();
		var f = __.load_function;
		var r;
		if(obj.addEventListener) {
			try { 
				r = obj.addEventListener(t,f,false);
				return r;
			} catch(e) { }
		} else if(obj.attachEvent) {
			try { obj.attachEvent("on".concat(t),f); }
			catch(e) { }
			return true;
		} else obj["on"+t] = f;
	},
	Off: function(__) {
		var r = false;
		var obj = (!__.obj || __.obj == "undefined" ? window : __.obj);
		if(obj.removeEvent) {
			try { r = obj.removeEvent("on"+__.trigger, __.load_function); } 
			catch(e) { 
				try { r = obj.removeEventListener(__.trigger,__.load_function,false); }
				catch(e) { r = "Unable to load window.attachEvent: "+e; }
			}
		} else { 
			try { r = obj.removeEventListener(__.trigger,__.load_function,false); }
			catch(e) { r = "Unable to load window.addEventListener: "+e; }
		}
		return r;
	}
};

var Scroll = {
	
};

var Windows = {
	getScroll: function () {
		var scrOfX = 0, scrOfY = 0;
		if(typeof window.pageYOffset == "number") {
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}
		return [scrOfX,scrOfY];
	},
	getRelative:function(o) {
		var curwidth = 0;
		var curheight = 0;
		var curtop = 0;
		var curleft = 0;
		if(o.offsetParent) {
			curwidth = o.offsetWidth;
			curheight = o.offsetHeight;
			while(o.offsetParent) {
				curtop += o.offsetTop;
				curleft += o.offsetLeft;
				o = o.offsetParent;
			}
		} else {
			curwidth = $pick(o.width,0);
			curheight = $pick(o.height,0);
			curtop = $pick(o.y,0);
			curLeft = $pick(o.x,0);
		}
		
		return [curwidth,curheight,curtop,curleft];
	},
	getPositionCenter:function(oW,oH) {
		var d = document.body;
		var hW = d.offsetWidth.toNumber();
		var hH = d.offsetHeight.toNumber();
		var sXY = Windows.getScroll();
		var xS = Math.round(((hW-oW)/2)+sXY[0]);
		var yS = Math.round((((screen.height-200)-oH)/2)+sXY[1]);
		xS = (xS < 0 ? 0 : xS);
		yS = (yS < 0 ? 0 : yS);
		return [yS,xS];
	}
};
var Draggable = {
	obj:null,
	init:function(__) {
		var o = __.obj;
		o.onmousedown = Draggable.start;
		o.root = $pick(__.objRoot,o);
		o.hmode	= true;
		o.vmode	= true;
		if(isNaN(CSS.get(o.root,"left").toNumber())) CSS.set(o.root,"left","0px");
		if(isNaN(CSS.get(o.root,"top").toNumber())) CSS.set(o.root,"top","0px");
		o.minX = $pick(__.minX,null);
		o.maxX = $pick(__.maxX,null);
		o.minY = $pick(__.minY,null);
		o.maxY = $pick(__.maxY,null);
		o.root.onDragStart = new Function();
		o.root.onDragEnd = new Function();
		o.root.onDrag = new Function();
	},
	start:function(e) {
		var o = Draggable.obj = this;
		e = Draggable.fixE(e);
		var y = CSS.get(o.root,"top").toNumber();
		var x = CSS.get(o.root,"left").toNumber();
		o.root.onDragStart(x,y);
		o.lastMouseX = e.clientX;
		o.lastMouseY = e.clientY;
		if(o.minX != null) o.minMouseX = e.clientX - x + o.minX;
		if(o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX;
		if(o.minY != null) o.minMouseY = e.clientY - y + o.minY;
		if(o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY;
		document.onmousemove = Draggable.drag;
		document.onmouseup = Draggable.end;
		return false;
	},
	drag:function(e){
		e = Draggable.fixE(e);
		var o = Draggable.obj;
		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = CSS.get(o.root,"top").toNumber();
		var x = CSS.get(o.root,"left").toNumber();
		var nx, ny;
		if (o.minX != null) ex = Math.min(ex, o.mixMouseX);
		if (o.maxX != null) ex = Math.max(ex, o.maxMouseX);
		if (o.minY != null) ey = Math.min(ey, o.minMouseY);
		if (o.maxY != null) ey = Math.max(ey, o.maxMouseY);
		nx = x + ((ex - o.lastMouseX) * 1);
		ny = y + ((ey - o.lastMouseY) * 1);
		CSS.set(o.root,"left",nx+"px");
		CSS.set(o.root,"top",ny+"px");
		o.lastMouseX = ex;
		o.lastMouseY = ey;
		o.root.onDrag(nx, ny);
		return false;
	},
	end:function(){
		document.onmousemove = null;
		document.onmouseup = null;
		Draggable.obj.root.onDragEnd(Draggable.obj.root.style.left.toNumber(),
			Draggable.obj.root.style.top.toNumber(), Draggable.obj.root);
		Draggable.obj = null;
	},
	fixE : function(e){
		if ($null(e)) e = window.event;
		if ($null(e.layerX)) e.layerX = e.offsetX;
		if ($null(e.layerY)) e.layerY = e.offsetY;
		return e;
	}
};
var Resizable = {
	obj:null,
	init:function(__) {
		// __.obj, __.oRoot, __.minX, __.maxX, __.minY, __.maxY
		var o = __.obj;
		o.onmousedown = Resizable.start;
		o.root = $pick(__.objRoot,o);
		o.hmode	= true;
		o.vmode	= true;
		o.minX = $pick(__.minX,null);
		o.minY = $pick(__.minY,null);
		o.maxX = $pick(__.maxX,null);
		o.maxY = $pick(__.maxY,null);
		o.root.onResizeStart = new Function();
		o.root.onResizeEnd = new Function();
		o.root.onResize	= new Function();
	},
	start:function(e){
		var o = Resizable.obj = this;
		e = Resizable.fixE(e);
		var y = CSS.get(o.root,"height").toNumber();
		var x = CSS.get(o.root,"width").toNumber();
		o.root.onResizeStart(x,y);
		o.lastMouseX = e.clientX;
		o.lastMouseY = e.clientY;
		if(o.minX != null) o.minMouseX = e.clientX - x + o.minX;
		if(o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX;
		if(o.minY != null) o.minMouseY	= e.clientY - y + o.minY;
		if(o.maxY != null) o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		document.onmousemove = Resizable.resize;
		document.onmouseup = Resizable.end;
		return false;
	},
	resize : function(e){
		e = Resizable.fixE(e);
		var o = Resizable.obj;
		var ey = e.clientY;
		var ex = e.clientX;
		var y = CSS.get(o.root,"height").toNumber();
		var x = CSS.get(o.root,"width").toNumber();
		var ow = x;
		var oh = y;
		var nx, ny;
		if (o.minX != null) ex = Math.max(ex, o.minMouseX);
		if (o.maxX != null) ex = Math.min(ex, o.maxMouseX);
		if (o.minY != null) ey = Math.max(ey, o.minMouseY);
		if (o.maxY != null) ey = Math.min(ey, o.maxMouseY);
		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));
		CSS.set(o.root,"width",(ow+(nx-x))+"px");
		CSS.set(o.root,"height",(oh+(ny-y))+"px");
		o.lastMouseX	= ex;
		o.lastMouseY	= ey;
		o.root.onResize(Math.round(nx-x), Math.round(ny-y));
		return false;
	},
	end : function(){
		document.onmousemove = null;
		document.onmouseup   = null;
		Resizable.obj.root.onResizeEnd(Resizable.obj.root.style.width.toNumber(),
			Resizable.obj.root.style.height.toNumber(),Resizable.obj.root);
		Resizable.obj = null;
	},
	fixE : function(e){
		if (typeof(e) == "undefined") e = window.event;
		if (typeof(e.layerX) == "undefined") e.layerX = e.offsetX;
		if (typeof(e.layerY) == "undefined") e.layerY = e.offsetY;
		return e;
	},
	childResize:function(__) {
		var o = __.obj;
		var child = __.child;
		for(var i = 0; i < child.length; i++) {
			try {
				CSS.set(child[i],"width",(CSS.get(child[i],"width").toNumber()+__.width)+"px");
			} catch(e) {}
			CSS.set(child[i],"height",(CSS.get(child[i],"height").toNumber()+__.height)+"px");
		}
	}
};
var Activity = {
	status:null,
	show:function(b) {
		b = $null(b) ? true : b;
		if(b == true) this.overlay.on();
		var o = $A("img");
		var imgPreload = new Image();
		this.status = "loading";
		imgPreload.onload = function() {
			if(!$null(Activity.status)) {
				o.src = savvy_activity;
				this.status = "loaded";
				var dimension = Windows.getPositionCenter(this.width,this.height);
				o.styler([{
					"width":this.width+"px",
					"height":this.height+"px"
				}]);
				var d = $A("div").setAttrib("id","loaderv2").styler([{
					"position":"absolute",
					"width":this.width+"px",
					"height":this.height+"px",
					"top":dimension[0]+"px",
					"left":dimension[1]+"px",
					"zIndex":50
				}]).addDOM(o);
				DOM.add(document.body,d);
			}
		};
		imgPreload.src = savvy_activity;
	},
	hide:function(b) {
		var o = $("loaderv2");
		this.status = null;
		b = ($null(b) ? true : b);
		if(b == true) this.overlay.off();
		if(o) DOM.remove(o);
	},
	overlay : {
		on:function() {
			var d = document.body, lb = $("lboverlay");
			if(lb && lb.getCSS("width") == "0px") {
				lb.styler([{
					"width":d.offsetWidth+"px",
					"height":d.offsetHeight+"px"
				}]).FxOpacity({
					start:0,
					end:75,
					delay:1,
					speed:300
				});
			} else if(lb && lb.getCSS("width") != "0px") {
				lb.FxOpacity({
					start:0,
					end:75,
					delay:1,
					speed:300
				});
			} else if(!lb) {
				var o = $A("div").styler([{
					"background":"#000",
					"position":"absolute",
					"top":"0px",
					"left":"0px",
					"display":"block",
					"zIndex":"50",
					"width":d.offsetWidth+"px",
					"height":d.offsetHeight+"px"
				}]).setAttrib("id","lboverlay");
				DOM.add(d,o);
				o.FxOpacity({
					start:0,
					end:75,
					delay:1,
					speed:300
				});
			} 
		},
		off:function() {
			$("lboverlay").FxOpacity({
				start:75,
				end:0,
				delay:1,
				speed:300
			});
		},
		onerror:function() {
			var lb = $("lboverlay");
			if(lb && lb.offsetWidth > 0) {
				lb.styler([{
					"width":"0px",
					"height":"0px"
				}]);
			}
		}
	}
};