$(document).ready(function(){ 
	var domain = "http://"+window.location.hostname; 
	//frage frage pruefen
	
	$("#stage_frage form.frage").live('submit', function() {
		$("#stage_frage").load("ajax/startseite_frage.php?"+$(this).serialize(),function() { 
	
			$(".alarm").closest(".jqTransformInputWrapper, .jqTransformSelectWrapper, .jqTransformCheckboxWrapper, .jqTransformTextarea").addClass("alarm");
		}).fadeIn();
		return false;
	});
	
	$("#stage_empfehlung form.empfehlung").live('submit', function() {
		$("#stage_empfehlung").load("ajax/startseite_empfehlung.php?"+$(this).serialize(),function() { 
	
			$(".alarm").closest(".jqTransformInputWrapper, .jqTransformSelectWrapper, .jqTransformCheckboxWrapper, .jqTransformTextarea").addClass("alarm");
		}).fadeIn();
		return false;
	});
	
	$(".teasers .teaser").live("mouseover",function(){
		$(".teasers .teaser").removeClass("active");
		$(this).addClass("active");
	});
	
	$(".teasers .teaser").live("mouseout",function(){
		$(".teasers .teaser").removeClass("active");
	});
	
	$(".teasers .teaser").live("click",function(){
		$(".teasers .teaser").removeClass("current");
		$(this).addClass("current");
		
		$(".stage_main > div").hide();
		
		switch(this.id.substring(7)) {
			case "video":
				$("#stage_video").load("ajax/startseite_video.php?video_link=JMeKIcFB29s&autoplay=0").fadeIn();
				break;
			case "empfehlung":
				$("#stage_empfehlung").load("ajax/startseite_empfehlung.php").fadeIn();				
				break;
			/*case "frage":
				$("#stage_frage").load("ajax/startseite_frage.php",function() { $("form.jqtransform").jqTransform()}).fadeIn();
				break;*/
			case "frage":
				window.open('http://sparen.vereinswechsel.de', '_blank', "");
			default:
				$("#stage_default").fadeIn();
				break;
			
		}
		
		return false;
	});
	
	$(".stage_main_close").live("click",function() {
		$(".stage_main > div").hide();
		$("#stage_default").fadeIn();
		$(".teasers .teaser").removeClass("current");
		return false;
	});
	
	$("form[name=registrierung]").find("input[name=user_email]").blur(
    function(){
    
        $.post(domain+"/ajax/email_prufen.php",{user_email : $(this).val() },
    
      function(data){
      if(data == "ja"){
          $("#opener").html("Diese Email ist bereits bei Vereinswechsel.de registriert. <br>Bitte wähle eine andere Email Adresse, um Dich zu registrieren!")
        .dialog({
          modal : true,
          title : "Achtung!",
          buttons : {
            "schließen" : function(){
              $(this).dialog("close");
            }
          }
        });
         return false;
         }
      });
    }
  );
	
	$("form[name=registrierung]").find("input[name=user_email_w]").blur(
    function(){
    
    if( $(this).val()!=$(this).closest("form").find("input[name=user_email]").val()){      
    
          $("#opener").html("Deine Email stimmt nicht mit der ersten Eingabe überein. <br>Bitte korrigiere Deine Email-Adresse")
        .dialog({
          modal : true,
          title : "Achtung!",
          buttons : {
            "schließen" : function(){
              $(this).dialog("close");
            }
          }
        });
         return false;
         }
         }
  );
	
$("form[name=registrierung]").find("input[name=user_passwort]").blur(
  function(){
    if($(this).val().length < 6  ){
         $("#opener").html("Das Passwort muß mindestens 6 Zeichen haben!")
        .dialog({
          modal : true,
          title : "Achtung!",
          buttons : {
            "schließen" : function(){
              $(this).dialog("close");
            }
          }
        });
        $(this).addClass(".alarm");
      }
  }
);


	
	$("form[name=registrierung]").submit(
    function(){ 
    
     $(this).find(".alarm").removeClass("alarm");    
     var was = $(this);      
     /*
      $.post(domain+"/ajax/timepruf.php",function(data){
        was.attr("action","registrieren?pruftime="+data);
      });
       */
      pi("user_vorname","",$(this),"i");
      pi("user_nachname","",$(this),"i");
      pi("user_email","",$(this),"i");
      pi("user_email_w","",$(this),"i");
      pi("user_plz","",$(this),"i");
      pi("user_passwort","",$(this),"i");
      pi("user_AGB","",$(this),"c");
      
      
      return alarm_pruf($(this));
      return false;
    });


	$("#stage_carousel").CloudCarousel(		

		{			          
			xPos: 270,
			yPos: 60,
			minScale: 0.25,
			buttonLeft: $("#right-but"),
			buttonRight: $("#left-but"),
			titleBox: $("#title-box"),
			reflHeight: 0,
			reflGap:0,
			xRadius:270,
			yRadius:-50,
			speed:0.15,           
			mouseWheel:true,
			autoRotate: 'left',
			autoRotateDelay: 5500
		}
	);

	$("#stage_carousel_neu").CloudCarousel(		

		{			          
			xPos: 200,
			yPos: 60,
			minScale: 0.25,
			buttonLeft: $("#right-but"),
			buttonRight: $("#left-but"),
			titleBox: $("#title-box"),
			reflHeight: 0,
			reflGap:0,
			xRadius:192,
			yRadius:-50,
			speed:0.15,           
			mouseWheel:true,
			autoRotate: 'left',
			autoRotateDelay: 8000
		}
	);


	$(".click-info-box").live('click',function(){
		var t_id = $(this).attr("name");
		$("#black").fadeIn(500,	function(){
			$("#vorteile_cont").load("seiten/helfer/slider-start.php?t_id="+t_id);
			$("#start-info-box").fadeIn(500);  
			$(".start-info-box-carousell").jCarouselLite({
				btnNext: ".next_button_carousel",
				btnPrev: ".prev_button_carousel",
				visible: 8
			});		
		
		});
		return false;
	});
	
	$(".click-info-inbox").live('click',function(){
		var t_id = $(this).attr("name");

		$("#vorteile_cont").load("../seiten/helfer/slider-start.php?t="+new Date().getTime()+"&t_id="+t_id);

	});
	
	$("#message-box h3 span, #message-box #message-box-close").live('click', function(){
		$("#message-box").fadeOut(500,
		function(){
			$("#black").fadeOut(500);
		});

	});
	
	/*	
	$("#stage_carousel").CloudCarousel({			
		xPos: 277,
		yPos: 60,
		xRadius: 400,
		yRadius: -50,
		minScale: 0.2,
		buttonLeft: $("#left-but"),
		buttonRight: $("#right-but"),
		reflHeight: 40,
		reflGap:5,
		speed:0.15,
		mouseWheel:true
		
	});
	*/
	

if($(".loginerror").length) {
    $("#opener").attr("title","Fehler");
    $("#opener").html("Deine Anmeldung war leider nicht erfolgreich.<br />Probier es einfach nochmal!")
    $("#opener").dialog({
					autoOpen: true,
					width: 400,
					modal: true,
					buttons: {
						"Ok": function() { 
							$(this).dialog("close"); 
						} 
					}
				})
}



	setInterval( function swapAktivitaet(){
    var ainh = '<div class="akuelles_startseite display_none">'+$("#akuelles_startseite .akuelles_startseite:first").html()+'</div>';
    $("#akuelles_startseite .akuelles_startseite:eq(0)").fadeOut(1000,
      function(){
        $(this).remove();
      }
    );
    $("#akuelles_startseite .akuelles_startseite:eq(3)").removeClass("display_none");
    $("#akuelles_startseite").append(ainh);
    
    $("#partner_liste_start a:last").fadeOut(500,
    function(){
      var apl =  $("#partner_liste_start a:last");
      $("#partner_liste_start").prepend('<a href="'+apl.attr("href")+'" target="_blank" title="'+apl.attr("title")+'">'+apl.html()+'</a>');
      $("#partner_liste_start a:last").remove();
    }
   ); 
   
  },8000);

$("#vw_video_img").click(function(){
  $("#vw_video").dialog({
    modal : true,
    title : "Vereinswechsel.de Video",
    width:"auto",
    height : "auto"
  });
})

	
// ende document ready	
});

$("#nl_email").live('focus', function(){
    if($(this).val() == "Deine Email Adresse"){
		$(this).val("");
		$(this).css("color","#000000"); 
    }
});

$("#nl_email").live('blur', function(){
    if($(this).val() == ""){
		$(this).val("Deine Email Adresse");
		$(this).css("color","#AAAAAA"); 
    }
});



