// JavaScript Document

var Y_focusField;

YAHOO.util.Event.on(window, "load", function() {

// alert dialog
	YAHOO.namespace("alert");
	YAHOO.alert._buttons = [];
	YAHOO.alert.handleOK = function() {
		YAHOO.alert.dialog.hide();
		if (Y_focusField) {
			Y_focusField.focus();
		}
	}
	YAHOO.alert.dialog = new YAHOO.widget.Dialog("YAHOOalertContainer", {
		width: "340px",
		visible: false,
		fixedcenter: true,
		position: "absolute",
		modal: true
	});
	YAHOO.alert.dialog.setFooter("<span id=\"buttonSpan\" class=\"Y_buttonSpan\" ></span><br />&nbsp;");
	YAHOO.alert.dialog.setBody("body");
	YAHOO.alert.dialog.showEvent.subscribe(function() {
		if (this._buttons.length == 0) {
			this._buttons[0] = new YAHOO.widget.Button({
				type: "button",
				label: "OK",
				container: "buttonSpan"
			});
			this._buttons[0].on("click", YAHOO.alert.handleOK);
		}

	}, YAHOO.alert, true);
	YAHOO.alert.dialog.render(document.body);
	
// loading/wait dialog
	YAHOO.namespace("loading");
	YAHOO.loading.Y_wait = 
		new YAHOO.widget.Panel("Y_wait",  
			{ width:"400px", 
			  fixedcenter:true, 
			  close:false, 
			  draggable:false, 
			  position: "absolute",
			  modal:true,
			  visible:false 
			} 
		);

	YAHOO.loading.Y_wait.setHeader("Please wait...");
	YAHOO.loading.Y_wait.setBody("<span id=\"Y_waitText\"></span><br /><img src=\"images/wait_activity.gif\"/>");
	YAHOO.loading.Y_wait.render(document.body);



});

function Y_alert (msg, field, title, width, height) {
	if (title == null) {
		title = "Note...";
	}
	YAHOO.alert.dialog.setHeader(title);
	if (width == null) {
		width = "300px";
	}
	YAHOO.alert.dialog.cfg.setProperty("width",width);
	if (height) {
		YAHOO.alert.dialog.cfg.setProperty("height",height);
	}
	Y_focusField = field;
	YAHOO.alert.dialog.setBody("<center><p style=\"font-size: 12px;\">"+msg+"</center>"); 
	YAHOO.alert.dialog.show();
}


