/* DOMREADY - Based on Mootools */
if (typeof Event == 'undefined') Event = new Object();
Event.domReady = {
	add: function(fn) {
		if (Event.domReady.loaded) return fn();
		var observers = Event.domReady.observers;
		if (!observers) observers = Event.domReady.observers = [];
		// Arraypush is not supported by Mac IE 5
		observers[observers.length] = fn;
		if (Event.domReady.callback) return;
		Event.domReady.callback = function() {
			if (Event.domReady.loaded) return;
			Event.domReady.loaded = true;
			if (Event.domReady.timer) {
				clearInterval(Event.domReady.timer);
				Event.domReady.timer = null;
			}
			var observers = Event.domReady.observers;
			for (var i = 0, length = observers.length; i < length; i++) {
				var fn = observers[i];
				observers[i] = null;
				fn(); // make 'this' as window
			}
			Event.domReady.callback = Event.domReady.observers = null;
		};

		var ie = !!(window.attachEvent && !window.opera);
		var webkit = navigator.userAgent.indexOf('AppleWebKit/') > -1;
		if (document.readyState && webkit) {
			// Apple WebKit (Safari, OmniWeb, ...)
			Event.domReady.timer = setInterval(function() {
				var state = document.readyState;
				if (state == 'loaded' || state == 'complete') {
					Event.domReady.callback();
				}
			}, 50);
		} else if (document.readyState && ie) {
			// Windows IE
			var src = (window.location.protocol == 'https:') ? '://0' : 'javascript:void(0)';
			document.write(
				'<script type="text/javascript" defer="defer" src="' + src + '" ' +
				'onreadystatechange="if (this.readyState == \'complete\') Event.domReady.callback();"' +
				'><\/script>');
		} else {
			if (window.addEventListener) {
				// for Mozilla browsers, Opera 9
				document.addEventListener("DOMContentLoaded", Event.domReady.callback, false);
				// Fail safe
				window.addEventListener("load", Event.domReady.callback, false);
			} else if (window.attachEvent) {
			window.attachEvent('onload', Event.domReady.callback);
			} else {
				// Legacy browsers (e.g. Mac IE 5)
				var fn = window.onload;
				window.onload = function() {
					Event.domReady.callback();
					if (fn) fn();
				}
			}
		}
	}
}

Event.domReady.add(function() {
	Accordion({
		togglerClass: 'toggler',    // classname of togglers
		elementsClass: 'element',   // classname of elements
		activeClass: 'active',      // classname that is given to toggler when active
		show: 0,                    // which element should be shown at the beginning (starting with 0)
		speed: 10,                  // speed of accordion
		refresh: 10,                // refresh rate of accordion
		opacity: true               // whether to fade elements or not (can be true or false)
	});

	initDatevGallery('smoothbox');
});

/* set opacity of any object */
function opacity(obj, value) {
	obj.style.opacity = value;
	obj.style.filter = 'alpha(opacity=' + value*100 + ')';
}

/* fader functions */
var faderQueue = new Array();
var faderInterval;
function fader(options) {
	var obj = options.obj;
	var inout = options.inorout;
	var maxopacity = options.maxopacity;
	var alphastep = options.alphastep;
	var oncomplete = options.oncomplete;

	obj.oncomplete = oncomplete;
	obj.alphastep = alphastep;
	obj.maxopacity = maxopacity;
	if(!obj.currentopacity) {
		if(inout == 'in') {
			obj.currentopacity = 0;
			opacity(obj, 0);
		}
		else {
			obj.currentopacity = maxopacity;
			opacity(obj, maxopacity);
		}
	}
	obj.fade = inout;
	obj.style.display = 'block';

	faderQueue.push(obj);
	if(!faderInterval) {
		faderInterval = window.setInterval('darthFader()', 20);
	}
}

function darthFader() {
	if(faderQueue.length > 0) {
		for(i=0; i<faderQueue.length; i++) {
			var obj = faderQueue[i];

			if(obj.fade == 'in') {
				obj.currentopacity += obj.alphastep;
				opacity(obj, obj.currentopacity);

				if(obj.currentopacity >= obj.maxopacity) {
					if(obj.oncomplete) {
						obj.oncomplete(obj);
					}
					faderQueue.splice(i, 1); // remove object from queue
				}
			}
			else {
				obj.currentopacity -= obj.alphastep;
				opacity(obj, obj.currentopacity);

				if(obj.currentopacity <= 0 ) {
					obj.style.display = 'none';
					if(obj.oncomplete) {
						obj.oncomplete(obj);
					}
					faderQueue.splice(i, 1); // remove object from queue
				}
			}
		}

		if(faderQueue.length <= 0) {
			window.clearInterval(faderInterval);
			faderInterval = undefined;
		}
	}
}

/* init gallery */
var galleryObjects = new Array();
var activeGalleryObj;
function initDatevGallery(galleryclass) {
	var eles = document.getElementsByTagName('*');
	var container = document.getElementById(galleryclass + '_container');
	if(!container) {
		container = document.createElement('div');
		container.id = galleryclass + '_container';
		container.className = "gallerycontainer";
		opacity(container, 0);
		document.body.appendChild(container);
	}
	var loading = document.getElementById(galleryclass + '_loading');
	if(!loading) {
		loading = document.createElement('div');
		loading.id = galleryclass + '_loading';
		loading.className = "galleryloading";
		document.body.appendChild(loading);
	}
	var content = document.getElementById(galleryclass + '_content');
	if(!content) {
		content = document.createElement('div');
		content.id = galleryclass + '_content';
		content.className = "gallerycontent";
		content.style.position = 'absolute';
		content.style.top = '50%';
		content.style.left = '50%';
		content.style.width = 800 + 'px';
		content.style.height = 600 + 'px';
		content.style.marginTop = -400 + 'px';
		content.style.marginLeft = -300 + 'px';
		content.style.background = '#fff';
		content.style.display = 'none';
		content.style.overflow = 'hidden';
		opacity(content, 0);
		document.body.appendChild(content);
	}
	for(i=0; i<eles.length; i++) {
		if(eles[i].className.indexOf(galleryclass) > -1) {
			eles[i].number = i;
			eles[i].galleryclass = galleryclass;
			galleryObjects.push(eles[i]);
			eles[i].onclick = function() {
				activeGalleryObj = this;
				fader({
					obj: document.getElementById(activeGalleryObj.galleryclass + '_container'), 
					inorout: 'in',
					maxopacity: 0.7,
					alphastep: 0.1,
					oncomplete: function(container) {
						var content = document.getElementById(activeGalleryObj.galleryclass + '_content');
						content.innerHTML = '<a class="closer" href="#"><span>Schließen</span></a>';
						if(activeGalleryObj.className.indexOf('iframe') > -1) {
							var title = activeGalleryObj.title;
							if(title) {
								content.innerHTML += '<div class="title">' + title + '</div>';
							}
							content.innerHTML += '<iframe frameborder="0" src="' + activeGalleryObj.href + '"></iframe>';
							var iframe = content.getElementsByTagName('iframe')[0];
							content.style.display = 'block';
							content.style.width = (iframe .offsetWidth+40) + 'px';
							content.style.height = (iframe.offsetHeight+40) + 'px';
							content.style.marginTop = 0-Math.round((iframe.offsetHeight+40)/2) + 'px';
							content.style.marginLeft = 0-Math.round((iframe .offsetWidth+40)/2) + 'px';
							fader({
								obj: content, 
								inorout: 'in',
								maxopacity: 1,
								alphastep: 0.1,
								oncomplete: function() {
									var closer = document.getElementById(activeGalleryObj.galleryclass + '_content').getElementsByTagName('a')[0];
									closer.onclick = document.getElementById(activeGalleryObj.galleryclass + '_container').onclick;
								}
							});
						}
						else {
							content.innerHTML += '<div class="text"><img src="#" alt="" /></div>';
							var img = content.getElementsByTagName('img')[0];
							if(img) {
								img.onload = function() {
									document.getElementById(activeGalleryObj.galleryclass + '_loading').style.display = 'none';
									var content = document.getElementById(activeGalleryObj.galleryclass + '_content');
									content.style.display = 'block';
									var imgwidth = this.offsetWidth + 40;
									var imgheight = this.offsetHeight + 40;
									content.style.width = imgwidth + 'px';
									content.style.height = imgheight + 'px';
									content.style.marginTop = 0-Math.round(imgheight/2) + 'px';
									content.style.marginLeft = 0-Math.round(imgwidth/2) + 'px';
									content.style.textAlign =  'center';
									fader({
										obj: content, 
										inorout: 'in',
										maxopacity: 1,
										alphastep: 0.1,
										oncomplete: function() {
											var closer = document.getElementById(activeGalleryObj.galleryclass + '_content').getElementsByTagName('a')[0];
											closer.onclick = document.getElementById(activeGalleryObj.galleryclass + '_container').onclick;
										}
									});
								}
								img.src = activeGalleryObj.href;
							}
						}
						container.onclick = function() {
							document.getElementById(activeGalleryObj.galleryclass + '_content').innerHTML = "";
							fader({
								obj: document.getElementById(activeGalleryObj.galleryclass + '_content'), 
								inorout: 'out',
								maxopacity: 1,
								alphastep: 0.1,
								oncomplete: function() {
								}
							});
							fader({
								obj: document.getElementById(activeGalleryObj.galleryclass + '_container'), 
								inorout: 'out',
								maxopacity: 1,
								alphastep: 0.1,
								oncomplete: function() {
									document.getElementById(activeGalleryObj.galleryclass + '_container').onclick = function() {};
								}
							});
							document.getElementById(activeGalleryObj.galleryclass + '_loading').style.display = 'none';
						}
						var loading = document.getElementById(activeGalleryObj.galleryclass + '_loading');
						loading.style.display = 'block';
						loading.onclick = container.onclick;
					}
				});
				return false;
			}
		}
	}
}






<!--//--><![CDATA[//><!--
function formsubmit(obj) {
    
    specialfields = new Object();
    specialfields.email = new Object();
    specialfields.email.check1 = 'checkEmail,nicht korrekt';
    
    errors = validateForm(obj,specialfields);

    if (errors.length>0){
        showFormErrors(errors);
        return false;
    }
    
    return true;

}
//--><!]]>
