(function($){
	// make a context var
	//var context = {height:0}
	$("#askExpertQuestionForm").submit(function(e){
		e.preventDefault();
		$("#message").html("");
		$.post($(this).attr("action"),$(this).serialize(),function(json){
			
			if(json.isOk){
				// reset height
				resetPopupHeight();
				//
				$("#askExpertQuestionForm")
				.find("#messages")
				.attr("class","")
				.addClass("thanks")				
				.html(json.message);
				// grow height
				extendPopupHeight();
				// show the shizzel
				$("#askExpertQuestionForm")
				.find("#messages")
				.show();							
			}else{			
				// reset height
				resetPopupHeight();
				//
				$("#askExpertQuestionForm")
				.find("#messages")
				.attr("class","")
				.addClass("error")
				.html(json.message);
				// grow height
				extendPopupHeight();
				// show the shizzel
				$("#askExpertQuestionForm")
				.find("#messages")
				.show();
		
			}			
		},"json");
	});
	$("#askQuestionSubmit").click(function(e){
		e.preventDefault();		
		$("#askExpertQuestionForm").submit();
	});

	function extendPopupHeight(){
		//increment
		$("#TB_ajaxContent").height(
			$("#TB_ajaxContent").height()
			+
			$("#askExpertQuestionForm").find("#messages").height()
		+"px");
	}

	function resetPopupHeight(){
		// decrement
		$("#TB_ajaxContent").height(
			$("#TB_ajaxContent").height()
			-
			$("#askExpertQuestionForm").find("#messages").height()
		+"px");
	}
})(jQuery)

