window.addEvent('domready', function() {

    //Eingabefelder stylen
    $$('#contact-form input[type="text"]').each(function(item) {
        item.removeClass("inFocus").addClass("notInFocus");
    })

    $$('#contact-form input[type="text"]').addEvent('focus',
    function() {
        $(this).removeClass("notInFocus").addClass("inFocus");
        this.select();
    });

    $$('#contact-form input[type="text"]').addEvent('blur',
    function() {
        $(this).removeClass("inFocus").addClass("notInFocus");

    });

    $$('#contact-form textarea').addEvent('focus',
    function() {
        $(this).removeClass("notInFocus").addClass("inFocus");
        this.select();
    });

    $$('#contact-form textarea').addEvent('blur',
    function() {
        $(this).removeClass("inFocus").addClass("notInFocus");

    });
	//Eingabefelder stylen ENDE


	// Wenn Formular ein- und ausgeblendet werden kann
	
	if ($('contact-form') !== null) {
		if($('contact-form').hasClass('toggleform')) {
		
			var slideForm = new Fx.Slide($('formular'));
			slideForm.hide();
			var smooth = new Fx.Scroll(window,{ duration:700 }); 
		
			$('openform').addEvent('click',function(e){
				e.stop();
				smooth.toElement('contact-form');
				slideForm.slideIn();
			});
		
			$('closeform').addEvent('click',function(e){
				e.stop();
				smooth.toElement('contact-form');
				slideForm.slideOut();
			});
		
		}
	}



    // formcheck

	var myCheck = new FormCheck('formular', {
        submit: true,
		validateDisabled:false
    });

	// dispose/register
	// console.log(myCheck);
	
	// formcheck ENDE

	// Versteckte Felder wieder vom Validations-Array entfernen
	$$('.jsHiddenValidate').each(function(item){
			myCheck.dispose(item);
	});

	if($('betreff')) {
		$('betreff').addEvent('change',function(){
			if (this.getSelected()[0].value === "sonstiges") {
				$('betreff-wrapper').show();
				myCheck.register($('sonstigerbetreff'));
			} else {
				$('betreff-wrapper').hide();
				if(myCheck.validations.contains($('sonstigerbetreff'))){
					myCheck.dispose($('sonstigerbetreff'));
				}
			}
		});
	}



});


