$(document).ready(function()
	{
		descLimit = parseInt($("#textAreaLimit").text());
		$("#textAreaCounter").text($("#descriptionTextArea").val().length);
		$("#descriptionTextArea").keyup(function(e)
			{
				if($("#descriptionTextArea").val().length > descLimit)
					$("#descriptionTextArea").val($("#descriptionTextArea").val().substring(0, descLimit));
					
				$("#textAreaCounter").text($("#descriptionTextArea").val().length);
				// alert($("#descriptionTextArea").val().length);
			});
		$("#knownAs").focus(function()
			{
				if($(this).val() == "")
					$(this).val($("#firstName").val() + " " + $("#surname").val());
			});
		/*$("#contact").submit(function()
			{
				$requiredNull = 0;
				$("#errorMessage").empty();
				$(this + " > li").each(function()
					{
						alert($(this).html());
						// if($(this + " label[class=mandatoryField]"))
							// {
								// alert($(this + " label[class=mandatoryField]").text());
							// }
					});/*
						$captionRequired = $($(this).children()[0]).text();
						$inputRequired = $($(this).children()[1]).val();
						alert($captionRequired +": "+$inputRequired);
						if($inputRequired =="" || $inputRequired == null)
							{
								if($requiredNull == 0)
									{
										$requiredNull = 1;
										$ulError = $(document.createElement("UL"));
										$("#errorMessage").append($ulError);
										$("#errorMessage").css("display", "block");
									}
								$liError = $(document.createElement("LI"));
								$liError.text($captionRequired + " cannot be NULL.");
								$ulError.append($liError);
							}
					});*/
				/*
					SORT OUT WHEN PHONE NUMBER AND EMAIL AS THEY ARE ARRAYS
					AND DELETE FIRST 2 LINES UNDERNEATH THIS COMMENT
				*/
				// $requiredNull = 0;
				// $("#errorMessage").empty();
				
				
				/*if($requiredNull == 0)
					return true;
				else
					{*/
						// $(document).animate({scrollTo: "callbackFormTitle"}, 300);
						// return false;
					//}
			//});
	});	
function addPhoneNumber()
	{
		$tdDad = $("#addPhoneNumberId").parent().parent();
		if($tdDad.children().length < 3)
			{
				$divWrap = $(document.createElement("DIV"));
				
				$input = $(document.createElement("INPUT"));
				$input.attr("type", "text");
				$input.attr("name", "phone[]");
				$input.addClass("formInputLine");
				
				$divWrap.addClass("formExtraLine");
				$divWrap.css("opacity", "0.25");
				$divWrap.append($input);
				$tdDad.append($divWrap);
				$divWrap.show("slide", {direction: "up"}, 500).animate({opacity: 1}, 500);
			}
		else
			$("#addPhoneNumberId").css("color", "#ac4242");
	}
function addEmailAddress()
	{
		$tdDad = $("#addEmailAddressId").parent().parent();
		if($tdDad.children().length < 3)
			{
				$divWrap = $(document.createElement("DIV"));
				
				$input = $(document.createElement("INPUT"));
				$input.attr("type", "text");
				$input.attr("name", "email[]");
				$input.addClass("formInputLine");
				
				$divWrap.addClass("formExtraLine");
				$divWrap.css("opacity", "0.25");
				$divWrap.append($input);
				$tdDad.append($divWrap);
				$divWrap.show("slide", {direction: "up"}, 500).animate({opacity: 1}, 500);
			}
		else
			$("#addEmailAddressId").css("color", "#ac4242");
	}