$(document).ready(function(){

	$("input, textarea").focus(function(){
		$(this).parents("div.form-input").addClass("focus");
	});

	$("input, textarea").keyup(function(){
		if($(this).hasClass("validate")){
			if(this.value != ""){
				$(this).parent().siblings("div.form-tip").html('<img src="/images/ajax/loader.gif" alt="" />').load("/ajax.php", { name : $(this).attr("id"), value : this.value });
			}
		}
	})
	.blur(function(){
		$(this).parents("div.form-input").removeClass("focus");
		if($(this).hasClass("validate")){
			if(this.value != ""){
				$(this).parent().siblings("div.form-tip").html('<img src="/images/ajax/loader.gif" alt="" />').load("/ajax.php", { name : $(this).attr("id"), value : this.value });
			}
		}
	});

	$("input#phone")
	.focus(function(){
		if($(this).val() == "(___) ___-____"){
			$(this).val("");
		}
		$(this).attr("alt", "phone");
		$("input#phone").setMask();
	})
	.blur(function(){
		if($(this).val() == ""){
			$(this).removeAttr("alt");
			$(this).val("(___) ___-____");
		}
	});

	$("input[type=radio]").focus(function(){
		$(this).parent().parent().siblings("div.form-tip").html('<img src="/images/ajax/loader.gif" alt="" />').load("/ajax.php", { name : $(this).attr("id"), value : this.value });
	});

	//$(".password").pstrength();

	$("form.autofocus input:first").focus();

	/*$("div").bt({
		//trigger: ['keydown', 'blur'],
		positions: ['right']
	});*/
});