$(document).ready(function(){



$("body").removeClass("coda-slider-no-js");
$(".coda-slider").children('.panel').hide().end().prepend('<p class="loading"><br /></p>');

$('#coda-slider-1').codaSlider({
autoSlide: false,
autoSlideInterval: 6000,
autoSlideStopWhenClicked: true
});


	$("input").each(function(){
		var wert = $(this).val();
		 
		$(this)
                    .focus(function(){
                                    $(this).parent().addClass("active");
                    if ($(this).val() == wert) {
                            $(this).val("");
                    }
		})
		.blur(function(){
                    $(this).parent().removeClass();
                    if ($(this).val() == "")
                     {
                            $(this).val(wert);
                    }
		});
	});
	
	
	$('#login form').submit(function(e){
		e.preventDefault();
		var username = $("#username").attr('value');
		var password = $("#password input").attr('value');
		$.ajax({
			type: "POST",
			timeout: 7000,
			data: {username: username, password: password},
			url: "/auth/login",
			success: function(result) {
				if(result != "true") {
					$("#ajax_load").animate({opacity: 1.0}, 200).fadeOut(200);
					$("#messages").append('<div id="error">Anmeldung war nicht erfolgreich!</div>');
					$("#login").effect( "shake",{times:3}, 100 );
				}
				else {
					$("#ajax_load").fadeOut(200);
					$("#messages").append('<div id="ajax_accept">Erfolgreich, sende an System...</div>');
					$("#ajax_accept").hide().show("slow",function(){ 
						setTimeout(function(){$('#login form')[0].submit();},1200);
					});
				}
			}
		})
	});
	$(".btn_login")
			.ajaxStart(function(){
				$("#messages div").remove();
				$("#messages").append('<div id="ajax_load">Überprüfe eingegebene Daten...</div>');
	});
	
	
	
	if($('#socialshareprivacy').length > 0){
	
			$('#socialshareprivacy').socialSharePrivacy({
				services : {
					facebook : {
						'perma_option'  : 'off'
					}, 
					twitter : {
						'perma_option' : 'off'
					},
					gplus : {
						'perma_option' : 'off'
					}			
				}
			});
	
	}


	
	



});
