function WindowOnLoad() {
	this.calls = new Array();
	this.register = function (execObj) {
		this.calls[this.calls.length+1] = execObj;
	}

	this.executeAll = function () {
		for( key in this.calls ) {
			try {
				this.calls[key].execute();
			} catch ( e ) {
				alert( e.message );
			}
		}
	}
}

var WINDOW_ON_LOAD_LOADER = new WindowOnLoad();
window.onload = function () {
	WINDOW_ON_LOAD_LOADER.executeAll();
}

	function getObjectByName(obj) {
		if(obj.toString().toLowerCase().indexOf("object") < 0) {
			var objs = document.getElementsByName(obj);
			if(!objs || !objs[0]) {
				alert("Object name [ "+ obj +" ] not found in document.");
				return false;
			}
			obj = objs[0];
		}
		return obj;
	}
	
	var nWindow = false;
	function OpenPopUp(wUrl, wTarget) {
		switch (wTarget) {
			case "PopUp":
				nWindow = window.open('popup.php?'+wUrl, wTarget, 'left=50,top=50, width=350,height=200,status=0,resizable=1,scrollbars=1,location=0,tollbars=0');
				break;
			default :
				nWindow = window.open('popup.php?'+wUrl, wTarget, 'left=50,top=50, width=350,height=200,status=0,resizable=1,scrollbars=1,location=0,tollbars=0');
				break;
		}
		if(nWindow) { nWindow.focus(); }
		return false;
	}

	function showOrderBlank(a) {
		window.open(''+a.href, '', 'left=100,top=50,width=267,height=365,resizable=1,menubar=0,location=0,toolbar=0,scrollbars=1');
		return false;
	}

	function HandleOrderBlankLinks() {
		this.execute = function () {
			var num = document.links.length;
			for (i = 0; i < num; i++) {
				var a = document.links.item(i);
				var att = a.getAttribute( "ob" );
				if( att != null && att == "1" ) {
					a.onclick = function() {
						showOrderBlank( this );
						return false;
					}
				}
			}
		}
	}
	WINDOW_ON_LOAD_LOADER.register( new HandleOrderBlankLinks() ); 


	function showSmartPopup(href) {
		var tn = href.getAttribute("popupName");
		var constr = href.getAttribute("popupConstraints");
	
		if( null == tn ) tn = "";
		if( null == constr ) 
			constr = "left=50,top=50,width=200,height=200,resizable=1,"
				+"menubar=1,location=1,toolbar=1,scrollbars=1";
		
		var popupWin = window.open(''+href.href, tn, constr);
		if( popupWin && popupWin.focus ) {
			popupWin.focus();
		}
	}

	function HandlePopups() {
		this.execute = function () {
			var num = document.links.length;
			for (i = 0; i < num; i++) {
				var a = document.links.item(i);
				if( a.target != null && a.target.toLowerCase() == "smartpopup" ) {
					a.onclick = function() {
						showSmartPopup( this );
						return false;
					}
				}
			}
		}
	}
	WINDOW_ON_LOAD_LOADER.register( new HandlePopups() ); 
	

// ===================================== 

	function foreach(obj) { /* developer function */
		var s = "";
		for (k in obj) s += k+": "+obj[k]+"\n";
		return s;
	}
