function ajaxFileUpload( action )
{
	$("#loadingUpload")
	.ajaxStart(function(){
		$(this).show();
		$("#resultProcessUpload").html('');
	})
	.ajaxComplete(function(){
		$(this).hide();
	});

	$.ajaxFileUpload
	(
		{
			url: action ,
			secureuri:false,
			fileElementId:'fileToUpload',
			dataType: 'json',
			success: function (data, status)
			{
				if(typeof(data.error) != 'undefined')
				{
					if(data.error != '')
					{
						$("#resultProcessUpload").html( data.error );
						var action = $("#flagAction").attr("value");
						var target = $("#flagTarget").attr("value");
						if( action != undefined && target != undefined )
							$( '#'+target ).load( action );						
							
						var flagRedirect = $("#flagRedirect").attr("value");
						if( flagRedirect )
						{
							window.setTimeout( "window.location='"+flagRedirect+"'", 1000 );
						}	
						
					}else
					{
						$("#resultProcessUpload").html( data.msg );
						var flagRedirect = $("#flagRedirect").attr("value");
						if( flagRedirect )
						{
							window.setTimeout( "window.location='"+flagRedirect+"'", 1000 );
						}							
					}
				}
			},
			error: function (data, status, e)
			{
				alert(e);
			}
		}
	)
	return false;
}