/**
 * global jQuery-Init part for project
 * @project MESSER/FR only
 * @mantis #12629
 */
$(document).ready(function(){

	/**
	 * digit your live: nur numbers bittä
	 */
	$("#PLZ").keyup( function() {
		var v = $("#PLZ").val();
		
		if ( !isNaN(v) )		//juchuuhhh: User hat das schon mal begriffen
		{
			if (v.length>0 && v.length<5)
			{
				$("#nrInfo").html(5-v.length);
			}
			if (v.length==5)	//den will ich
			{
				$("#nrInfo").html('');
				$("#maperror").html('');
				$("#maperror").hide();
				submitKontaktForm();
				$("#PLZ").val('');
			}
			if (v.length>5)	//C&P oder Affenschnell ;)
			{
				$("#PLZ").val( v.substr(0, 5));

				$("#nrInfo").html('');
				$("#maperror").html('');
				$("#maperror").hide();
				submitKontaktForm();
				$("#PLZ").val('');
			}
		}
		else //ups || Cpt.alert()
		{
			$("#PLZ").val( v.substr(0, v.length-1));
			$("#nrInfo").html(5-v.length+1);

			$("#maperror").html("'"+v+"' n'est pas un code postal valide ; veuillez en saisir un autre !");
			$("#maperror").show();
		}
		
	});

});

