		$(document).ready(function(){
	//Initilize inital form values in var textValues = new Array();
		var textValues = new Array();
		var currentId;
		$('.txtinpt').each(function(){
			currentId = $(this).attr('id');
			textValues[currentId] = $(this).attr('value');
		});
	//Remove text onfocus and store inital value and set check for non-entry
		$('.txtinpt').focusin(function(){
			currentId = $(this).attr('id');
			currentFormId = $(this).parents("div:first").attr('id');
			switch (currentFormId){
				case 'blogForm':
					$(this).css('color','#666');
				break;
				case 'form_one':
					$(this).css('background','#9e843a');
				break;
				case 'form_two':
					$(this).css('background','#ffffff');
				break;
				case 'form_three':
					$(this).css('background','#dddddd');
				break;
				case 'form_four':
					$(this).css('background','#ffffff');
				break;
				default:
					$(this).css('background','#dddddd');
			}
			if ($(this).attr('value') == textValues[currentId]) {
				$(this).attr('value','');
			}
			$(this).one('focusout', function(){
				textClearCheck(currentId);
			});
		});
		$('.submitButton').one('click',submitButtonFunction); //Bind button functions
	//Check form input
		function submitButtonFunction(){
			var currentFormName = $(this).parents("div:first").attr('id');
			var formInputValues = 'currentForm='+escape(currentFormName)+'&';
			var errors = new Array();
			var errorNo = 0;
			$("#"+currentFormName+" input:text").each(function(){
				currentId = $(this).attr('id');
				currentFormInputType = textValues[currentId];
				var testString = $(this).val();
				switch (currentFormInputType) {
					case 'Email Address':
					case 'Enter Your Email Address Here':
						testString = testString.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)
						if (testString){
							formInputValues = formInputValues+currentId+'='+escape(testString)+'&';
						}
						else {
							inputError = 1;
							errors[errorNo] = currentId;
							errorNo++;
						}
					break;
					case 'Zip Code':
						testString = testString.match(/\d{5}(?:.?\d{4})?/);
						if (testString)
							formInputValues = formInputValues+currentId+'='+escape(testString)+'&';
						else {
							inputError = 1;
							errors[errorNo] = currentId;
							errorNo++;
						}
					break;
					case 'Phone Number':
						testString = testString.match(/^\+?(\d[ -]?)?\(?\d{3}\)?[ -]?\d{3}[ -]?\d{4}$/)
						if (testString)
							formInputValues = formInputValues+currentId+'='+escape(testString)+'&';
						else {
							inputError = 1;
							errors[errorNo] = currentId;
							errorNo++;
						}
					break;
					default: 
						if (testString != currentFormInputType)
							formInputValues = formInputValues+currentId+'='+escape(testString)+'&';
						else {
							inputError = 1;
							errors[errorNo] = currentId;
							errorNo++;
						}
				}
			});
			//Hard coded fix to allow for the text area 
			testString = $("#"+currentFormName+" textarea").val();
			if (testString != 'What area are you looking to improve? ') {
				formInputValues = formInputValues+'message1='+escape(testString)+'&';
			}
			else {
					inputError = 1;
					errors[errorNo] = 'message1';
					errorNo++;
			}
			//end of fix
			if(!errorNo) {
				$('#'+currentFormName).find('.fdeOut').fadeOut(200);
				$('#'+currentFormName).find('.error').fadeOut(200);
				$('#'+currentFormName).find('input').fadeOut(200, function(){
					$('#'+currentFormName).find('.sending').fadeIn(200);
				});
				//iterate through all names and store the id + = + value in array + & in string to pass with ajax	
				//alert(formInputValues.slice(1,-1));
				$.ajax({
					url: "/include/form_handle.php",
					cache: false,
					type: 'POST',
					data: formInputValues.slice(0, -1),
					success: function(html){
						$('#'+currentFormName).find('.sending').fadeOut(200, function(){
							$('#'+currentFormName).find('.submitted').fadeIn(200);
						});
						//alert(html)
						//$('#'+currentFormName).append(html);
					}
				});
			}
			else{
				switch(currentFormName) {
					case 'blogForm':
						for (x in errors){
							$('#'+errors[x]).css('color','#c00');	
						}
					break;
					default:
						for (x in errors){
							$('#'+errors[x]).css('background','red');
						}
				}
				$('#'+currentFormName).find('.error').fadeIn(200);
				//alert("Please Fix the selected areas");
				$(this).one('click',submitButtonFunction);
			}
		};
	//Input inital value if nothing was entered in
		function textClearCheck(currentId) {
			var currentTextValue = jQuery.trim($('#'+currentId).attr('value'));
			if (currentTextValue.length == 0){
				$('#'+currentId).attr('value',textValues[currentId]);
			}
		}
	});