﻿Type.registerNamespace("Telerik.Web.UI");


// ---------- Overlay Class ----------
Telerik.Web.UI.Overlay = function(targetElement)
{
	this._targetElement = targetElement;
	this._element = null;
}

Telerik.Web.UI.Overlay.IsSupported = function ()
{
	return $telerik.isIE;
}

Telerik.Web.UI.Overlay.prototype = 
{
	initialize: function()
	{
		//Using this workaround to set the contents of the iframe (required for sectio 508 compliance)
		
		var placeholder = document.createElement("div");
		placeholder.innerHTML = "<iframe>Your browser does not support inline frames or is currently configured not to display inline frames.</iframe>";
		this._element = placeholder.firstChild;
		this._element.src = "javascript:'';";
		this._targetElement.parentNode.insertBefore(this._element, this._targetElement);
		
		if (this._targetElement.style.zIndex > 0)
		{
			this._element.style.zIndex = this._targetElement.style.zIndex - 1;
		}
		
		this._element.style.position = "absolute";	
		this._element.style.border = "0px";	
		this._element.frameBorder = 0;
		this._element.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
		this._element.tabIndex = -1;
		
		if (!$telerik.isSafari)
			placeholder.outerHTML = null;
			
		this.updatePosition();
	},
	
	dispose: function()
	{
		if (this._element.parentNode)
		{
			this._element.parentNode.removeChild(this._element);
		}

		this._targetElement = null;
		this._element = null;
	},
	
	get_targetElement : function ()
	{
		return this._targetElement;
	},
	
	set_targetElement : function (value)
	{
		this._targetElement = value;
	},
	
	get_element: function()
	{
	    return this._element;
	},
	
	updatePosition: function()
	{
		this._element.style.top = this._toUnit(this._targetElement.style.top);
		this._element.style.left = this._toUnit(this._targetElement.style.left);
		this._element.style.width = this._targetElement.offsetWidth + "px";
		this._element.style.height = this._targetElement.offsetHeight + "px";	
	},
	
	_toUnit: function(value)
	{
		if (!value) return "0px";
		return parseInt(value) + "px";
	}
}

Telerik.Web.UI.Overlay.registerClass('Telerik.Web.UI.Overlay', null, Sys.IDisposable);


if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();