﻿
/*----------------------------------------------------
$Date: 07-05-02
$Author: okano

//Usage
	-Default
		window.onload = function() {
			WindowManager.setPopup("id", "windowName", 320, 240)
		}

	-Use Option
		window.onload = function() {
			WindowManager.setPopup("id", "windowName", 320, 240, {location:"yes", directories:"yes", menubar:"yes", resizable:"yes"})
		}

//window option property
	location
	directories
	menubar
	resizable
	scrollbars
	status
	titlebar
	toolbar

----------------------------------------------------*/
var WindowManager = {
	setPopup: function(id, winname, w, h, opt) {
		var _opt = {width:w, height:h, location:"no", directories:"no", menubar:"no", resizable:"no", scrollbars:"no", status:"no", titlebar:"no", toolbar:"no"};
		if(opt) {
			for(var _prop in _opt) {
				for(var prop in opt) {
					if(_prop == prop) {
						_opt[_prop] = opt[prop];
					}
				}
			}
		}
		var o = new Array();
		for(var _prop in _opt) {
			o.push(_prop + "=" + _opt[_prop]);
		}
		o = o.join(",");
		var trg = document.getElementById(id);
		trg.onclick = function() {
			window.open(this.href, winname, o);
			return false;
		}
	},
	setBack: function(id) {
		var b = navigator.userAgent.toLowerCase();
		var safari = /webkit/.test(b);
		var trg = document.getElementById(id);
		trg.onclick = function() {
			if(safari) {
				trg.href = "javascript:history.back()";
			} else {
				history.back();
				return false;
			}
		}
	},
	setClose: function(id) {
		var trg = document.getElementById(id);
		trg.onclick = function() {
			window.close();
			return false;
		}
	}
}