var ac_options = {
		minChars	: 1,
		delay		: 500,
		width		: 200,
		autoFill	: true,
		mustMatch	: true,
		matchSubset	: false
		};
		
$(function(){
	$("a.tooltip").hover(
		function(){$("#" + $(this).attr("rel")).fadeIn('fast')},
		function(){$("#" + $(this).attr("rel")).fadeOut('fast')}
		);
	
	$(".submit").click(function(){
		var form_id = $(this).attr("rel");
		if(!form_validate(form_id)) {
			return false;
			}
		
		$("#"+form_id).submit();
		
		return false;
		});
		   
	});

function form_validate(form_id){
	ok = true;
	$("#"+form_id+" input.required, #"+form_id+" textarea.required,#"+form_id+" select.required").each(function(){
		if($(this).val() == ""){
			
			form_mark_error(this);
			if(ok)
				$(this).focus();
			ok = false;
			}
		});
	
	return ok;
	}
	
function form_mark_error(obj){
	var error_class = "error";
	$(obj).addClass(error_class);
	
	$(obj).change(function(){$(this).removeClass(error_class)});
	}
