		var ContactForm = function() {
  			 this.main=gebi('contact');
  			 this.title=gebtn(this.main,'a')[0];
  			 this.form=gebi('contact_form');
  			 this.error=gebi('feedback_error');
  			 this.inputs=[gebi('name'),gebi('phone'),gebi('email'),gebi('msg')];
  			 for(var i=0;i<this.inputs.length;i++) {
  			 	addHandler(this.inputs[i],'focus',(function(){this.focused=true;this.clearTimer()}).bind(this));
  			 	addHandler(this.inputs[i],'blur',(function(){this.focused=false;this.trySetTimer()}).bind(this));
  			 }
  			 this.timer=0;
  			 this.focused=false;
  			 this.overed=false;
  			 this.height=fullHeight(this.form);
  			 this.lock();
  		}
  		ContactForm.prototype = {
  			open : function(event) {
  				if(this.status=='idle' && this.closed) {
	                this.status='progress';
	                this.form.style.height='0px';
 	               	var t=new tween(this.form,'height',0,this.height,0.7,2);
  	             	this.unlock();
   	             	t.addEventListener('Complete',(function(){this.status='idle';}).bind(this));
                }
  			},
  			close : function(event) {
  				if(this.status=='idle' && !this.closed) {
  					this.error.innerHTML='';
					this.clearTimer();
                	this.status='progress';
                	var t=new tween(this.form,'height',this.height,0,0.7,2);
                	t.addEventListener('Complete',(function(){this.lock();}).bind(this));
     			}
  				e=(event||window.event);
  				if(e) {
	  				if(e.preventDefault) e.preventDefault();
 	 				e.returnValue=false;
 	 			}
  			},
  			lock : function() {
  				this.main.className='';
  				this.closed=true;
  				this.open_func=this.open.bind(this);
  				addHandler(this.title,'click',this.open_func);
  				this.status='idle';
  				removeHandler(this.title,'click',this.close_func);
  				removeHandler(this.main,'click',this.clear_timer_func);
  				//removeHandler(this.main,'mouseout',this.set_timer_func);
  				this.overed=false;
  				this.focused=false;
  			},
  			unlock : function() {
  				removeHandler(this.title,'click',this.open_func);
  				this.main.className='floated';
  				this.closed=false;
  				this.set_timer_func=(function(){this.overed=false;this.trySetTimer();}).bind(this);
  				//addHandler(this.main,'mouseout',this.set_timer_func);
  				this.clear_timer_func=(function(){this.overed=true;this.clearTimer();}).bind(this);
  				addHandler(this.main,'click',this.clear_timer_func);
  				this.close_func=this.close.bind(this);
  				addHandler(this.title,'click',this.close_func,true);
  			},
  			setTimer : function() {
  				this.timer=setTimeout(this.close.bind(this),5000);
  			},
  			clearTimer : function() {
  				clearTimeout(this.timer);
  			},
  			trySetTimer : function() {
                if(!this.focused && !this.overed) this.setTimer();
  			}
  		}

		function feedback_sent(data){
		 	var f  =gebi('contact_form');
		  	var err=gebi('feedback_error');
		  	err.innerHTML="";
		  	if(data.err){err.innerHTML=data.err;return false;}
		  	else {
		  		location.replace('kontakt-formular/');
		  	}
		  	return true;
		}
