/* xapopup.js v1.00.0 :: Providing popup window functionality
 * Copyright (C) by AD-Software, VI 2004. All rights reserved.
 */

var xaPopupNOMENUBAR     = 0x0001;
var xaPopupNOLOCATIONBAR = 0x0002;
var xaPopupNOPERSONALBAR = 0x0004;
var xaPopupNOTOOLBAR     = 0x0008;
var xaPopupNOSTATUSBAR   = 0x0010;
var xaPopupNOSCROLLBARH  = 0x0100;
var xaPopupNOSCROLLBARV  = 0x0200;
var xaPopupNOSCROLLBARS  = 0x0300;
var xaPopupNORESIZE      = 0x1000;
var xaPopupINDEPENDENT   = 0x2000;


function xaPopupWindow (name)
{
	// consts
	this.NOMENUBAR     = 0x0001;
	this.NOLOCATIONBAR = 0x0002;
	this.NOPERSONALBAR = 0x0004;
	this.NOTOOLBAR     = 0x0008;
	this.NOSTATUSBAR   = 0x0010;
	this.NOSCROLLBARH  = 0x0100;
	this.NOSCROLLBARV  = 0x0200;
	this.NOSCROLLBARS  = 0x0300;
	this.NORESIZE      = 0x1000;
	this.INDEPENDENT   = 0x2000;
	// data
	this.name = name;
	this.url = "";
	this.width = 180;
	this.height = 200;
	this.flags = this.NOPERSONALBAR | this.NOTOOLBAR | this.NOMENUBAR | this.NOLOCATIONBAR | this.NOSTATUSBAR;
	this.launched = null;
	// methods
	this.setURL = xaPopupWindow_setURL;
	this.setWidth = xaPopupWindow_setWidth;
	this.setHeight = xaPopupWindow_setHeight;
	this.launch = xaPopupWindow_launch;
	this.destroy = xaPopupWindow_destroy;
	return this;
}


function xaPopupWindow_setURL (url)
{
	if (this.launched)
	   this.launched.location.href = url;
	this.url = url;
	return true;
}

function xaPopupWindow_setWidth (val)
{
	if (this.launched) {
	   if (document.all) this.launched.width = val;
	   else              this.launched.innerWidth = val;
	}
	this.width = val;
	return true;
}

function xaPopupWindow_setHeight (val)
{
	if (this.launched) {
	   if (document.all) this.launched.height = val;
	   else              this.launched.innerHeight = val;
	}
	this.height = val;
	return true;
}


function xaPopupWindow_launch ()
{
	if (!this.launched) {
	   var fmt = "scrollbars=" + ((this.flags & this.NOSCROLLBARS)? "no": "yes")
	           + ",menubar=" + ((this.flags & this.NOMENUBAR)? "no": "yes")
	           + ",location=" + ((this.flags & this.NOLOCATIONBAR)? "no": "yes")
	           + ",personalbar=" + ((this.flags & this.NOPERSONALBAR)? "no": "yes")
	           + ",toolbar=" + ((this.flags & this.NOTOOLBAR)? "no": "yes")
	           + ",status=" + ((this.flags & this.NOSTATUSBAR)? "no": "yes")
	           + ",resizable=" + ((this.flags & this.NORESIZE)? "no": "yes")
	           + ",dependent=" + ((this.flags & this.INDEPENDENT)? "no": "yes")
	           + ",innerWidth=" + this.width + ",innerHeight=" + this.height
	           + ",width=" + this.width + ",height=" + this.height;
	   this.launched = window.open(this.url,this.name,fmt);
	}
	return this.launched;
}

function xaPopupWindow_destroy ()
{
	if (this.launched) {
	   if (!this.launched.closed)  this.launched.close();
	   this.launched = null;
	}
	return this.launched;
}



function xaCreatePopup (name, url)
{	return xaCreatePopupXY(name, url, 480, 460)  }

function xaCreatePopupXY (name, url, width, height)
{
	var w = new xaPopupWindow(name);
	w.setWidth((100 < width)? width: 200);
	w.setHeight((100 < height)? height: 240);
	w.setURL(url);
	w.launch();
	return w;
}

