var uploadValidator;
	
$(document).ready(function() {
	$('#uploadDialog').dialog({
		autoOpen: false,
		modal: true,
		resizable: false,
		width: 470,
		height: 170,
		buttons: {
         	'Upload File': function() {
            	if (uploadValidator.form())
            	{
                   	$('#uploadDialog form').submit();
                }
           	},
            'Cancel': function() {
            	$(this).dialog('close');
            }
        }
	});
});
	
function showUploadDialog(documentType) {
	var astr = 'documentType='+documentType;
	$('#uploadDialog').html('Loading...');
    $('#uploadDialog').dialog('open');
    $.ajax({
     	url: 'document_upload.php?'+astr,
        context: document.body,
        success: function(data) {
           	$("#uploadDialog").html(data);
            initUploadForm();
        }
    });
}
    
function initUploadForm()
{
    uploadValidator = $("#uploadDialog form").validate({
    	onkeyup: false
	});
}
