﻿///<reference path="../TESCO.js" />
/*
	Example:
	
	var win = new TESCO.system.Window("/help/default.aspx", "help", "menubar=yes,width=720,height=600,toolbar=no,scrollbars=yes,status=no,resizable=yes,location=yes,titlebar=yes");
		win.open();
*/

TESCO.system.Window = (function() {
	
	//  constructor
	function _constructor(url, name, options) {
		///	<summary>creates a reference to a window</summary>
		///	<param name="url">string</param>
		///	<param name="name">string</param>
		///	<param name="options">string</param>
		///	<returns>instance</returns>
		this.url = url;
		this.win = { "closed" : true }
		this.name = name;
		this.options = options;
		return this;
	}

	_constructor.prototype.NAME = "TESCO.system.Window";

	_constructor.prototype.open = function(reload) {
		///	<summary>Open the window, optionally reload it if it's already open. Focus on new window.</summary>
		///	<param name="reload">boolean</param>
		if (this.win.closed || reload) {
			this.win = window.open(this.url, this.name, this.options);
		}
		this.win.focus();
	}

	//  return _constructor as function pointer
	return _constructor;
})();
