var Kontaktlayer = {
    init: function(){
    	//Set href (Functional without JS!)
    	jQuery('#contact-layer a.btn-layer').attr('href', '#');
    	    	
    	//Register Actions!
    	jQuery('#contact-layer a.btn-layer').click(function() {
			Kontaktlayer.toggle();
		});
		
		jQuery('#contact-layer a.btn-close').click(function() {
			Kontaktlayer.close();
		});
		
		jQuery(document).keyup(function(e) {
		  if (e.keyCode == 27) {// esc
			  Kontaktlayer.close();
		  }   
		});
		
		//Initial state is closed!
		Kontaktlayer.close();
		
		Kontaktlayer._initContent();
    },
    _initContent: function(){
    	//In Field Labens init
		jQuery("div#contact-layer-content label").inFieldLabels({
			fadeOpacity: 0.3, // Once a field has focus, how transparent should the label be
			fadeDuration: 300 // How long should it take to animate from 1.0 opacity to the fadeOpacity	
		});
		
    	//No Autocomplete!
		jQuery("div#contact-layer-content input").attr("autocomplete","off");
    },
    open: function(){
    	jQuery('#contact-layer div#contact-layer-content').show('fast', function() {
		  	jQuery('#contact-layer a.btn-close').show('fast', function() { });
		  	var windowHeight = jQuery(document).height();
		    jQuery('body').append('<div id="darken" style="height:'+windowHeight+'px;"></div>');	
		  });
    },
    close: function(){
    	jQuery('#contact-layer div#contact-layer-content').hide('fast', function() {
			jQuery('#contact-layer img.btn-close').hide('fast', function() { });
			jQuery('#darken').remove();
    	});
    	jQuery("#contact-layer img").addClass("closed");
    },
    isOpen: function(){
    	return jQuery('#contact-layer div#contact-layer-content').is(':visible');
    },
    isClosed: function(){
    	return !Kontaktlayer.isOpen();
    },
    toggle: function(){
    	if(Kontaktlayer.isOpen()){
    		Kontaktlayer.close();
    	} else {
    		Kontaktlayer.open();
    	}
    }
}
