var errorStr = '';		//Globally used errorStr for client-side verification
var retCon = 0;			//Used for ajax calls. Decrements when async request sent, Increments when request returns
var submitOk = false;
var intervalId;			//Global Interval ID. Used for clearInterval function
var siteURL = 'http://www.ecooffice.com.sg/';

//Creating namespace for Container
YAHOO.namespace("example.container");

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

//returns document.getElementById for provided element
function goc(elem) {
	return document.getElementById(elem);
}

function error(err) {
	errorStr += "<li>" + err + "</li>";
}

function empty(str) {
	return (str.trim() == "" );
}

function checkRetCon() {
	if (retCon == 0) {
		clearInterval(intervalId);
		if (errorStr != '') {
			YAHOO.example.container.simpledialog1.setBody(errorStr);
			YAHOO.example.container.simpledialog1.show();
		} else {
			goc('frm').submit(true);
		}
	}
}

function dlgInit() {
	// Define various event handlers for Dialog
	var handleClose = function() {
		this.hide();
	};

	// Instantiate the Dialog
	YAHOO.example.container.simpledialog1 = new YAHOO.widget.SimpleDialog("simpledialog1", 
	 { width: "300px",
	   fixedcenter: true,
	   visible: false,
	   draggable: false,
	   close: true,
	   modal: true,
	   icon: YAHOO.widget.SimpleDialog.ICON_WARN,
	   constraintoviewport: true,
	   buttons: [ { text:"OK", handler:handleClose, isDefault:true } ]
	 } );
	YAHOO.example.container.simpledialog1.setHeader("Validation Error!");

	// Render the Dialog
	YAHOO.example.container.simpledialog1.render(document.body);

}