$(document).ready(function(){
	// check for what is/isn't already checked and match it on the fake ones
				$("input:checkbox").each( function() {
					(this.checked) ? $("#fake"+this.id).addClass('fakechecked') : $("#fake"+this.id).removeClass('fakechecked');
				});
				// function to 'check' the fake ones and their matching checkboxes
				$(".fakecheck").click(function(){
					($(this).hasClass('fakechecked')) ? $(this).removeClass('fakechecked') : $(this).addClass('fakechecked');
					$(this.hash).trigger("click");
					return false;
				});
				
				$("label").click(function() {
						$(this).next(".transparent").focus();
					});
			
				$("input").each(function(){
					var val = $(this).val();
					if(val!="") {
						$(this).prev("label").stop().css("color", "#fff");
					}
				});
				
				$("input:empty").focus(function(){
					var val = $(this).val();
					if(val=="") {
						$(this).prev("label").stop().css("color", "#ddd");
					}
				});
				
				$("input:empty").keydown(function(){
					$(this).prev("label").stop().css("color", "#fff");
				});
				
				$("input").keyup(function(){
					var val = $(this).val();
					if(val=="") {
						$(this).prev("label").stop().css("color", "#ddd");
						
					}
				});
				
				$("input").blur(function(){
					var val = $(this).val();
					if(val=="") {
						$(this).prev("label").stop().css("color", "#7d6f65");
					}
				});
				
				$("textarea").each(function(){
					var val = $(this).val();
					if(val!="") {
						$(this).prev("label").stop().css("color", "#fff");
					}
				});
				
				$("textarea:empty").focus(function(){
					var val = $(this).val();
					if(val=="") {
						$(this).prev("label").stop().css("color", "#ddd");
					}
				});
				
				$("textarea:empty").keydown(function(){
					$(this).prev("label").stop().css("color", "#fff");
				});
				
				$("textarea").keyup(function(){
					var val = $(this).val();
					if(val=="") {
						$(this).prev("label").stop().css("color", "#ddd");
						
					}
				});
				
				$("textarea").blur(function(){
					var val = $(this).val();
					if(val=="") {
						$(this).prev("label").stop().css("color", "#7d6f65");
					}
				});
				
				$("#contactForm").validate({
					rules: { 
						company: "required", 
						name: "required", 
						email: { 
							required: true, 
							email: true 
						}, 
						citystate: "required", 
						nextsteps: "required"
					}, 
					messages: { 
						company: "Enter your company", 
						name: "Enter your full name", 
						email: { 
							required: "Enter your email address", 
							minlength: "Enter your email address"
						}, 
						citystate: "Enter your location", 
						nextsteps: "What's next?"
					},
					submitHandler:function(form) {
						jQuery(form).ajaxSubmit(options);
					}		
				});

				
				var options = { 
					target:        'form',   // target element(s) to be updated with server response 
					//beforeSubmit:  formValidation,  // pre-submit callback 
					success:       showResponse  // post-submit callback 
			 
					// other available options: 
					//url:       url         // override for form's 'action' attribute 
					//type:      type        // 'get' or 'post', override for form's 'method' attribute 
					//dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
					//clearForm: true        // clear all form fields after successful submit 
					//resetForm: true        // reset the form after successful submit 
			 
					// $.ajax options can be used here too, for example: 
					//timeout:   3000 
				};
				
				
				function showResponse(responseText, statusText)  { 
					// for normal html responses, the first argument to the success callback 
					// is the XMLHttpRequest object's responseText property 
				 
					// if the ajaxForm method was passed an Options Object with the dataType 
					// property set to 'xml' then the first argument to the success callback 
					// is the XMLHttpRequest object's responseXML property 
				 
					// if the ajaxForm method was passed an Options Object with the dataType 
					// property set to 'json' then the first argument to the success callback 
					// is the json data object returned by the server 
				 
					//alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
						//'\n\nThe output div should have already been updated with the responseText.'); 
				} 
	
	$(".dropdown").mousedown(function(){
		if($.browser.msie) {
			$(this).css("width","280px");
		}
	});
	$(".dropdown").change(function(){
		if ($.browser.msie) {
			$(this).css("width","153px");
		}
	});
	$(".dropdown").blur(function(){
		if ($.browser.msie) {
			$(this).css("width","153px");
		}
	});
	$('.obfuscate').nospam({ filterLevel: 'low' });
});