jQuery(document).ready( function () {


	//Audio

	jQuery("#p-1186").find("div.play").toggle(
		function() {
			audioelement	=	jQuery(this).find("audio").get(0);
			audioelement.currentTime=0;
			audioelement.play();
			jQuery(this)
				.css({"background-image":"url(http://greencore-events.de/wp-content/themes/events/images/buttons/stop.png)"})
		},
		function() {
			audioelement.pause();
			jQuery(this)
				.css({"background-image":"url(http://greencore-events.de/wp-content/themes/events/images/buttons/play.png)"})
		}
	);

	var hcp_info	=	jQuery("#p-1186").find(".content .hcp .hcp_info");
	var hcp_audio	=	jQuery("#p-1186").find(".content .hcp audio");

	jQuery(hcp_info)
		.animate({
			"height"	:	0
		},	1000);

	jQuery(hcp_audio)
		.animate({
			marginTop	:	"180px"
		},	1000);

	jQuery("#p-1186")
		.find(".content .hcp")
		.hover(	function() {
			
			jQuery(this).find(".hcp_info").stop()
				.animate({
					"height"	:	"30px"
				},	400);

			jQuery(this).find("audio").stop()
				.animate({
					marginTop	:	"125px"
				},	400)

		},	function() {

			jQuery(this).find(".hcp_info").stop()
				.animate({
					"height"	:	0
				},	1000);
		
			jQuery(this).find("audio").stop()
				.animate({
					marginTop	:	"180px"
				},	1000);

		});

	//Sitemap Toggle
	
	jQuery("a#sitemap_toggle").toggle(function() {
	
		jQuery("ul#menu").stop().animate({
			height: "214px",
			marginTop: "-223px"
		},800);
		
		jQuery(this).find("img").replaceWith("<img src='http://greencore-events.de/wp-content/themes/events/images/menu/toggle_down.png' alt='Sitemap Toggle' />");
		jQuery("a#schatten_link").find("img").replaceWith("<img src='http://greencore-events.de/wp-content/themes/events/images/menu/schatten_down.png' alt='Schatten' />")
		
	}, function() {

		jQuery("ul#menu").stop().animate({
			height: "43px",
			marginTop: "-52px"
		},400);

		jQuery(this).find("img").replaceWith("<img src='http://greencore-events.de/wp-content/themes/events/images/menu/toggle_up.png' alt='Sitemap Toggle' />");
		jQuery("a#schatten_link").find("img").replaceWith("<img src='http://greencore-events.de/wp-content/themes/events/images/menu/schatten_up.png' alt='Schatten' />")

	});	
	
	
	//Menu Button Hover
	
	jQuery("#menu a[id!='schatten_link']").find("img").hover(function() {
	
		jQuery(this).css({"background-color": "rgba(255, 255, 255,0.7)"});

		jQuery(this).stop().delay(31).stop().animate({
			backgroundColor: "rgba(255, 255, 255, 0.4)"
		}, 100);
		
		jQuery(this).stop().delay(132).stop().animate({
			backgroundColor: "rgba(255, 255, 255, 0.2)"
		}, 300)
	}, function() {
	
		jQuery(this).stop().animate({
			backgroundColor: "rgba(1,1,1,0.65)"
		}, 500);
			
		jQuery(this).stop().delay(501).stop().animate({
			backgroundColor: "rgba(1,1,1,0)"
		}, 1000)
	
	});	
	
	
	//Contact
		jQuery('input[type!=submit]').each(function(){
            var wert = jQuery(this).val();
            jQuery(this).focus(function(){
                    if (jQuery(this).val() == wert) {
                        jQuery(this).val('')
                    }
                })
                .blur(function(){
                    if (jQuery.trim(jQuery(this).val()) == '') {
                        jQuery(this).val(wert)
                    }
                })
        });
	
	    jQuery(function() {
        try {
            if (typeof _wpcf7 == 'undefined' || _wpcf7 === null)
                _wpcf7 = {};

            _wpcf7 = jQuery.extend({ cached: 0 }, _wpcf7);

            jQuery('div.wpcf7 > form').ajaxForm({
                beforeSubmit: function(formData, jqForm, options) {
                    jqForm.wpcf7ClearResponseOutput();
                    return true;
                },
                beforeSerialize: function(jqForm, options) {
                    jqForm.find('.wpcf7-use-title-as-watermark.watermark').each(function(i, n) {
                        jQuery(n).val('');
                    });
                    return true;
                },
                data: { '_wpcf7_is_ajax_call': 1 },
                dataType: 'json',
                success: function(data) {
                    var ro = jQuery(data.into).find('div.wpcf7-response-output');
                    jQuery(data.into).wpcf7ClearResponseOutput();

                    if (data.invalids) {
                        jQuery.each(data.invalids, function(i, n) {
                            jQuery(data.into).find(n.into).wpcf7NotValidTip(n.message);
                        });
                        ro.addClass('wpcf7-validation-errors');
                    }

                    if (data.captcha)
                        jQuery(data.into).wpcf7RefillCaptcha(data.captcha);

                    if (data.quiz)
                        jQuery(data.into).wpcf7RefillQuiz(data.quiz);

                    if (1 == data.spam)
                        ro.addClass('wpcf7-spam-blocked');

                    if (1 == data.mailSent) {
                        jQuery(data.into).find('form').resetForm().clearForm();
                        ro.addClass('wpcf7-mail-sent-ok');
                        
                        jQuery(".wpcf7-submit").css({	"background"	:	"#81974B"	}).attr("value", "Gesendet");

                        if (data.onSentOk)
                            jQuery.each(data.onSentOk, function(i, n) { eval(n) });
                    } else {
                        ro.addClass('wpcf7-mail-sent-ng');
                    }

                    if (data.onSubmit)
                        jQuery.each(data.onSubmit, function(i, n) { eval(n) });

                    jQuery(data.into).find('.wpcf7-use-title-as-watermark.watermark').each(function(i, n) {
                        jQuery(n).val(jQuery(n).attr('title'));
                    });

                    ro.append(data.message).slideDown('fast');
                }
            });

            jQuery('div.wpcf7 > form').each(function(i, n) {
                if (_wpcf7.cached)
                    jQuery(n).wpcf7OnloadRefill();

                jQuery(n).wpcf7ToggleSubmit();

                jQuery(n).find('.wpcf7-acceptance').click(function() {
                    jQuery(n).wpcf7ToggleSubmit();
                });

                jQuery(n).find('.wpcf7-exclusive-checkbox').each(function(i, n) {
                    jQuery(n).find('input:checkbox').click(function() {
                        jQuery(n).find('input:checkbox').not(this).removeAttr('checked');
                    });
                });

                jQuery(n).find('.wpcf7-use-title-as-watermark').each(function(i, n) {
                    var input = jQuery(n);
                    input.val(input.attr('title'));
                    input.addClass('watermark');

                    input.focus(function() {
                        if (jQuery(this).hasClass('watermark'))
                            jQuery(this).val('').removeClass('watermark');
                    });

                    input.blur(function() {
                        if ('' == jQuery(this).val())
                            jQuery(this).val(jQuery(this).attr('title')).addClass('watermark');
                    });
                });
            });

        } catch (e) {
        }
    });

    jQuery.fn.wpcf7ToggleSubmit = function() {
        return this.each(function() {
            var form = jQuery(this);
            if (this.tagName.toLowerCase() != 'form')
                form = jQuery(this).find('form').first();

            if (form.hasClass('wpcf7-acceptance-as-validation'))
                return;

            var submit = form.find('input:submit');
            if (! submit.length) return;

            var acceptances = form.find('input:checkbox.wpcf7-acceptance');
            if (! acceptances.length) return;

            submit.removeAttr('disabled');
            acceptances.each(function(i, n) {
                n = jQuery(n);
                if (n.hasClass('wpcf7-invert') && n.is(':checked')
                || ! n.hasClass('wpcf7-invert') && ! n.is(':checked'))
                    submit.attr('disabled', 'disabled');
            });
        });
    };

    jQuery.fn.wpcf7NotValidTip = function(message) {
        return this.each(function() {
            jQuery('input, textarea',this).addClass('wrongval').css({'background-color' : '#F2C2C2'});
            jQuery('.wrongval').focus(function() {
                jQuery(this).css({'background-color' : '#FBFBFB'});
            });
            jQuery('p.wpcf7-error').css({'background-color' : '#F2C2C2', 'padding' : '5px', 'margin' : '0 10px'}).append(message + '<br />');
        });
        
    };

    jQuery.fn.wpcf7OnloadRefill = function() {
        return this.each(function() {
            var url = jQuery(this).attr('action');
            if (0 < url.indexOf('#'))
                url = url.substr(0, url.indexOf('#'));

            var id = jQuery(this).find('input[name="_wpcf7"]').val();
            var unitTag = jQuery(this).find('input[name="_wpcf7_unit_tag"]').val();

            jQuery.getJSON(url,
                { _wpcf7_is_ajax_call: 1, _wpcf7: id },
                function(data) {
                    if (data && data.captcha)
                        jQuery('#' + unitTag).wpcf7RefillCaptcha(data.captcha);

                    if (data && data.quiz)
                        jQuery('#' + unitTag).wpcf7RefillQuiz(data.quiz);
                }
            );
        });
    };

    jQuery.fn.wpcf7RefillQuiz = function(quiz) {
        return this.each(function() {
            var form = jQuery(this);

            jQuery.each(quiz, function(i, n) {
                form.find(':input[name="' + i + '"]').clearFields();
                form.find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').text(n[0]);
                form.find('input:hidden[name="_wpcf7_quiz_answer_' + i + '"]').attr('value', n[1]);
            });
        });
    };

    jQuery.fn.wpcf7ClearResponseOutput = function() {
        return this.each(function() {
            jQuery(this).find('div.wpcf7-response-output').hide().empty().removeClass('wpcf7-mail-sent-ok wpcf7-mail-sent-ng wpcf7-validation-errors wpcf7-spam-blocked');
        });
    };

})
