jQuery(function($){
	jQuery.extend({
		_toIntegersAtLease: function(n) {    
	        return n < 10 ? '0' + n : n.toString();
	    },
		clientday: function(format) {
			var today = new Date();
			format = format.replace('YYYY', today.getFullYear());
			format = format.replace('MM', 	jQuery._toIntegersAtLease(today.getMonth() + 1));
			format = format.replace('DD', 	jQuery._toIntegersAtLease(today.getDate()));
			format = format.replace('HH24', jQuery._toIntegersAtLease(today.getHours()));
			format = format.replace('HH', 	jQuery._toIntegersAtLease(today.getHours() - 12));
			format = format.replace('MI', 	jQuery._toIntegersAtLease(today.getMinutes()));
			return format;
		},
		message: function(options, func) {
	    	options = jQuery.extend({
	    		title: "&nbsp;",
	    		height: 150,
	    		message: "&nbsp;",
	    		confirm: false
	    	}, options);

			var buttons = [];
			buttons.push('"확인":  function() { $(this).dialog("close"); if(jQuery.isFunction(func)) func.apply(); }');
			
			if (options.confirm) {
				buttons.push('"취소":  function() { $(this).dialog("close"); }');
			}

			$('<div/>').html(options.message).dialog({
				title: "",
				width: options.width,
				height: options.height,
				modal: true,
				bgiframe: true,
				overlay: { opacity: 0.45, background: "#000" },
				buttons: eval("arr = {" + buttons.join(",") + "}"),
				open: function() {
					$(this).parent().next().find('button:first').focus();
					return false;
				},
				close: function() {
					$(this).dialog("destroy").remove(); 
					return false;
				}
			});
		}
	});
});