$(document).ready(function() {
	$("span#domain_available").html("<img src=\"/images/icons/info.png\" alt=\"\" />Der Kontonamen muss mindestens ein Zeichen lang sein, darf nur aus Groß-/Kleinbuchstaben, Zahlen und Bindestrichen bestehen und muss mit einem Buchstabe beginnen.");
    $("input#mandator_subdomain").keyup(function() {
		if ($("input#mandator_subdomain").val().length > 0) {
			$.post("/anmeldung/check_subdomain", 
				{subdomain: $("input#mandator_subdomain").val()},
				function(response) {
					if (response.domain_available == true) 
						$("span#domain_available").html("<img src=\"/images/icons/accept_green.png\" alt=\"\" />Kontonamen ist verfügbar");
					else
						$("span#domain_available").html("<img src=\"/images/icons/minus_round.png\" alt=\"\" />Kontonamen ist leider bereits vergeben");
				},
				"json");
			$("span.domain").html($("input#mandator_subdomain").val());
		}
	}).blur(function() {
		if ($("input#mandator_subdomain").val().length > 0) {
			$.post("/anmeldung/check_subdomain", 
				{subdomain: $("input#mandator_subdomain").val()},
				function(response) {
					if (response.domain_available == true) 
						$("span#domain_available").html("<img src=\"/images/icons/accept_green.png\" alt=\"\" />Kontonamen ist verfügbar");
					else
						$("span#domain_available").html("<img src=\"/images/icons/minus_round.png\" alt=\"\" />Kontonamen ist leider bereits vergeben");
				},
				"json");
			$("span.domain").html($("input#mandator_subdomain").val());
		}
	});
})