/**
 * ProblemReportingSystem Javascript Library (v01.00)
 * --------------------------------------
 * 
 * Authors:
 * 			- Quanbit Software SA (http://www.quanbit.com)
 * 			- Eduardo Casey
 */
(function(window){
	var ProblemReportingSystem = function(){};
	
	/**
	 * Returns a new instance.
	 * 
	 * @returns ProblemReportingSystem prototype.
	 */
	ProblemReportingSystem.newInstance = function(urlForContent){
		var temp = new this();
		
		temp._isShow = false;
		temp._urlForContent = urlForContent;
		temp._shadow = document.getElementById("prs_shadow");
		temp._window = document.getElementById("prs_window");
		temp._window_titleBar = document.getElementById("prs_window_titleBar");
		temp._window_contentBody = document.getElementById("prs_window_contentBody");
		
		return temp;
	};
	
	ProblemReportingSystem.prototype.show = function(){
		if (!this._isShow)
		{
			this._shadow.style.height = this._getDocumentHeight() + "px";
			this._shadow.setAttribute("class", " ");
			this._shadow.setAttribute("className", " ");
			
			this._window_contentBody.src = this._urlForContent;
			
			this._window.setAttribute("class", " ");
			this._window.setAttribute("className", " ");
			
			this._isShow = true;
		}
	};
	
	ProblemReportingSystem.prototype.hide = function(){
		if (this._isShow)
		{
			this._shadow.style.height = "auto";
			this._shadow.setAttribute("class", "hideMe");
			this._shadow.setAttribute("className", "hideMe");
			this._window.setAttribute("class", "hideMe");
			this._window.setAttribute("className", "hideMe");
			
			this._window_contentBody.src = "about:blank";
			this._isShow = false;
		}
	};
	
	ProblemReportingSystem.prototype._getDocumentHeight = function()
	{
		var D = window.document;
		var value =
			Math.max(Math.max(D.body.scrollHeight ? D.body.scrollHeight : 0, D.documentElement.scrollHeight ? D.documentElement.scrollHeight : 0),
			         Math.max(D.body.offsetHeight ? D.body.offsetHeight : 0, D.documentElement.offsetHeight ? D.documentElement.offsetHeight : 0),
			         Math.max(D.body.clientHeight ? D.body.clientHeight : 0, D.documentElement.clientHeight ? D.documentElement.clientHeight : 0));
		
		return value;

	};

	
	
	/* Sets the global object */
	window.ProblemReportingSystem = ProblemReportingSystem;
})(window);
