function ajax_form(form, loader, sbm, retmsg, isremove, onerror, oncomplete)
{
	$('#'+form).submit(function(){
		$('#'+loader).show();
		$('#'+form+' > p.form-error').removeClass('form-error');
		$('#'+sbm).attr('disabled', true);
		$.ajax({
			type: "POST",
			url: $(this).attr('action'),
			data: $(this).serialize(),
			dataType:'json',
			success: function(msg){
				switch(msg.s){
					case 'OK': 
						$('#'+retmsg).addClass('form-success').html(msg.msg);
						$('#'+loader).hide();
						$('#'+sbm).attr('disabled', false);
						if(isremove) $('#'+form).remove();
						if(typeof oncomplete == 'function') oncomplete();
					break;
					default:
						$('#'+retmsg).removeClass('foot').addClass('form-error').html(msg.msg);
						$('#p_'+msg.elem).addClass('form-error');
						$("#"+msg.elem).focus();
						$('#'+loader).hide();
						$('#'+sbm).attr('disabled', false);
						if(typeof onerror == 'function') onerror();
					break;
				}
			}
		});
		return false;		
	});
}
function loadup(){
	$('#p_img').load(SITEURL+'?m=imhuman', function(){
		$('.imhuman-item').click(function(){
				e = $(this).hasClass('imhuman-sel');
				$("input[name='"+this.id+"']").attr('checked', !e);
				$(this).toggleClass('imhuman-sel', !e);
			});
			$('.imhuman-chk').hide();
	 });
}
$(document).ready(function(){
	$('#refresh').click(function(){ loadup(); });
	$('.overlay').click(function(e){
		e.preventDefault();
		$('#bglayer').show(); $('#inlayer').show();
		$('#incon').html('<img src="t/images/load.gif" style="margin:20% 48%" />').load( $(this).attr('href'));		
	});
	$('#close').click(function(){ $('#inlayer').hide();$('#bglayer').hide(); });
});
$(document).keyup(function(event){
    if (event.keyCode == 27) {
        $('#inlayer').hide();$('#bglayer').hide();
    }
});
