

function _(_id){
	if(document.getElementById && document.getElementById(_id)) return document.getElementById(_id);
	else return null;
}

var myAccordion;
var cur;



function init_togglers(){
	var controls = $$('#main h2');
	var subcontrols = $$('#main h3');
	var stretchers = $$('#main blockquote');
	
	controls.each(function(item){
		item.onmouseover=item.onmouseout=function(){h2_hover(this)};
	});
	
	myAccordion = new Fx.Accordion(controls, stretchers, { 	
		opacity: false,
		//start: 'first-open', 
		transition: Fx.Transitions.quadOut,
			
		onActive: function(obj, i){
			controls[i].className=subcontrols[i].className="act";
			if(i!=0) stretchers[0].className="";
			cur=i;
		},
		onBackground: function(obj, i){
			controls[i].className=subcontrols[i].className="";
		},
		onComplete:function(obj, i){
			if(cur==0) stretchers[0].className="act";
		}
	});

};


function h2_hover(obj){
	if(obj.className=="act")return;
	obj.className=(obj.className=="hover"?"":"hover");
}

function init_mail(id){
	var mail=_(id).title+"@"+_(id).name;
	_(id).href="mailto:"+mail;
	_(id).innerHTML=mail;
	_(id).title="";
}

function setLang(name) {
	document.form_lang.lang.value=name; 
	document.form_lang.submit(); 
	return false;
}


var email_pattern=/^([a-zA-Z_]*)@(([A-Za-z\-]*)\.){1,2}([A-Za-z]{2,3})$/;

function check_form(form){
	req=form.getElementsByTagName("label");
	for(i=0;i<req.length;i++){
		if(!((k=req[i].lang) && (obj=form.elements[k]))) continue;
		if(obj.value==""){
			alert("Bitte überprüfen Sie Ihre Eingabe");
			obj.focus();
			return false;
		}
		if(obj.name=="email" && !email_pattern.test(obj.value)){
			alert("Bitte geben Sie eine gültige E-Mail an!");
			obj.focus();
			return false;
		}
	}
	return true;
}

