/**
* @version $1.0$
* @package JavaScript library
* @subpackage Windows
* @copyright (c) 2005 Análisis, Diseño e Implementación Software, S.L. "ADI Software" <adisoftware.com>
* @license http://www.gnu.org/copyleft/gpl.html. GNU Public License
* @author Juanfran Calderín <info@adisoftware.com>
* @date (2005/09/01)
*/
/**
* Class for auxiliar window management.
*/
function AuxWindow() {
	/**
	* Determines if current window exists and it is not closed.
	* @return bool Is current window opened?
	*/
	this.isOpened = function() {
		return ((this.h) && (!this.h.closed));
	} // isOpened
	
	/**
	* Closes current window, if necessary.
	*/
	this.close = function() {
		if (this.isOpened()) {
			this.h.close();
		}
		this.h = null;
	} // close
	
	/**
	* Determines if current URL is different from the given.
	* @param string URL
	* @return bool Is the URL different?
	*/
	this.isDifferentUrl = function(href) {
		var objLocation, aux;
		objLocation = this.h.location;
		aux = objLocation.pathname + objLocation.search; // Relative path
		if (aux == href) {
			return false;
		}
		return (objLocation.href != href); // Absolute path
	} // isDifferentUrl
	
	/**
	* Opens a URL in a window with a given coordinates and dimensions.
	* @param string URL
	* @param int X coordinate
	* @param int Y coordinate
	* @param int Width
	* @param int Height
	*/
	this.open = function(href, x, y, width, height) {
		if ((this.isOpened()) && (this.isDifferentUrl(href))) {
			this.close();
		}
		if (!this.isOpened()) {
			this.h = window.open(href, 'AuxWindow', 'left=' + x + ',top=' + y + ',width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes');
		}
		this.h.focus();
	} // open
	//
	this.close();
} // AuxWindow
