// JavaScript Document

hex.Blackout = {
	Version			: "1.0.0.1"
	,ID			: "hex_blackout"
	,Depth		: 900
	,Colour		: "#000000"
	,Opacity	: 0.5
	,onClick	: null
	,Created	: false
	,Animate	: false
	
	,$			: function () {
		return	(this.Created) ? hex.$(this.ID) : null
	}
	,Show		: function () {
		this.Create()
		if (this.Animate && (hex.Effects && (hex.Effects.doFade))) {
			this.$().style.opacity = 0
			this.$().style.filter = "Alpha(Opacity='" + (0) + "')"
			this.$().style.display = "block"
			hex.Effects.doFade(this.$(),0,this.Opacity,20,50)
		}else{
			this.$().style.display = "block"
		}
	}
	,Hide		: function () {
		if (this.Animate && (hex.Effects && (hex.Effects.doFade))) {
			hex.Effects.doFade(this.$(),this.$().style.opacity,0,20,50,function() {hex.Blackout.$().style.display = "none"})
		}else{
			this.$().style.display = "none"
		}
	}
	,Create		: function () {
		if (!this.Created) {
			var objBlackout = document.createElement("div")
			objBlackout.id	= this.ID
			objBlackout.style.backgroundColor = this.Colour
			objBlackout.style.position = "absolute"
			objBlackout.style.zIndex = this.Depth
			objBlackout.style.width = this.winWidth() + "px"
			objBlackout.style.height = this.winHeight() + "px"
			objBlackout.style.opacity = this.Opacity
			objBlackout.style.filter = "Alpha(Opacity='" + (this.Opacity *100) + "')"
			objBlackout.style.display = "none"
			objBlackout.style.left = 0;
			objBlackout.style.top = 0;
			objBlackout.style.right = 0;
			objBlackout.style.bottom = 0;
			document.body.insertBefore(objBlackout,document.body.childNodes[0])
			
			objBlackout.onclick = this.onClick
			
			this.Created = true
		}
	}
	,winWidth		: function() {
		var blnIE = (window.innerWidth > 0) ? false : true
		var intWinWidth = (blnIE) ? document.documentElement.clientWidth : window.innerWidth
		var intBodyWidth = (blnIE) ? document.body.scrollWidth : document.body.scrollWidth
		return (intBodyWidth > intWinWidth) ? intBodyWidth : intWinWidth
	}
	,winHeight		: function() {
		var blnIE = (window.innerHeight > 0) ? false : true
		var intWinHeight = (blnIE) ? document.documentElement.clientHeight : window.innerHeight
		var intBodyHeight = (blnIE) ? document.body.scrollHeight : document.body.scrollHeight
		return (intBodyHeight > intWinHeight) ? intBodyHeight : intWinHeight
	}
}