/**
* @class PopUpWindow
* @author Matt Freer
* @version 0.1
* @description 	<ol><b><li>INTRODUCTION</li></b>
*				<b><li>USING THE CLASS</li></b>
*				<b><li>EVENTS</li></b>
*			</ol>
*
*/


/**
* @Constructor
* @p_parentWindow : pop-ups parent window
* @p_height : height of popup window (optional)
* @p_width : width of popup window (optional)
* @p_winLeft : left coord of popup window (optional)
* @p_winTop : top coord of popup window (optional)
*/
function PopUpWindow(p_parentWindow, p_height, p_width, p_winLeft, p_winTop) {
	
	// setup instance properties
	this.parentWindow = p_parentWindow;
	this.displayPause = 0;
	this.popUpURL = "undefined";
	this.displayInt = "undefined";
	
	if(arguments.length > 1){
		this.winHeight = p_height;
		this.winWidth = p_width;
		this.winLeft = p_winLeft;
		this.winTop = p_winTop;
	}else{
		// defaults
		this.winHeight = 350;
		this.winWidth = 200;
		this.winLeft = 20;
		this.winTop = 20;
	}
}



// Public Methods ------------------------------------

/**
* @showWindow
* @p_popUpURL : url for page to be displayed in popup
* @p_displayPause : duration of delay (milli-seconds) before popUp is displayed (optional). Default 0
*/
PopUpWindow.prototype.showWindow = function(p_popUpURL, p_displayPause) {
	this.popUpURL = p_popUpURL;
	
	if(arguments.length > 1){
		// over write default delay
		this.displayPause = p_displayPause;	
	}
	
	if(this.displayPause > 0){
		var ref = this; 
		// delay for set time then call displayWindow
		this.displayInt = setInterval(function(){
			ref.displayWindow();
			clearInterval(ref.displayInt);
		}, this.displayPause);
		
	}else{
		// no delay
		this.displayWindow();
	}	
}


/**
* @parentGetURL
* @targetURL : url for page to be displayed in parentWindow 
* @p_displayPause : duration of delay (milli-seconds) before popUp is displayed (optional). Default 0
*/
PopUpWindow.prototype.parentGetURL = function(targetURL) {
	this.parentWindow.location = targetURL;
}

// End Public Methods ------------------------------------




// Private Methods ------------------------------------

PopUpWindow.prototype.displayWindow = function() {
	this.parentWindow.open(this.popUpURL,"win","height=" + this.winHeight + ",width=" + this.winWidth + ",left=" + this.winLeft + ",top=" + this.winTop + ",toolbar=no,scrollbars=yes,resizable=yes")
}

// End Private Methods ------------------------------------




