﻿
function llx_popupWindow() {
	var modalBK = undefined
	var This=this

	this.showWindow = function(w) {
		w.style.position = 'absolute'
		//w.style.visibility = 'hidden'
		w.style.display = 'block'
		BringToFront(w)
		w.style.top = (document.documentElement.offsetHeight / 2) - (w.offsetHeight / 2) + document.documentElement.scrollTop * 1 + "px"
		w.style.left = (document.documentElement.offsetWidth / 2) - (w.offsetWidth / 2) +  document.documentElement.scrollLeft * 1 + "px"
		if ((w.offsetTop*1) < (document.documentElement.scrollTop * 1)) { w.style.top =(document.documentElement.scrollTop * 1)+ 'px' }
		if ((w.offsetLeft * 1) < (document.documentElement.scrollLeft * 1)) { w.style.left = (document.documentElement.scrollLeft * 1) + 'px' }
		w.style.visibility = 'visible'
		w.style.display = 'none'
		$(w).fadeIn(300)
	}
	this.showModalWindow = function(w) {
		modalBK = document.createElement("div")
		document.body.appendChild(modalBK)
		modalBK.style.backgroundColor = 'black'
		modalBK.style.position = 'absolute'
		modalBK.style.top = '0px'
		modalBK.style.left = '0px'
		modalBK.style.width = (document.documentElement.offsetWidth * 1) + 'px'
		if ((document.documentElement.offsetHeight * 1) > (document.body.offsetHeight * 1)) { modalBK.style.height = (document.documentElement.offsetHeight * 1) + 'px' } else { modalBK.style.height = (document.body.offsetHeight * 1) + 'px' }
		try { modalBK.style.filter = 'alpha(opacity=60)' } catch (e) { }
		try { modalBK.style.opacity = .6 } catch (e) { }
		//$(modalBK).fadeIn(300)
		This.showWindow(w)
	}
	this.hideWindow = function(w) {
		$(w).fadeOut(300, function() {w.style.display='none' })
		if (modalBK) { document.body.removeChild(modalBK) }
	}

	function BringToFront(w) {
		document.body.appendChild(w)
		var o = document.getElementsByTagName(w.tagName)
		var i=0
		for (i = 0; i < o.length; i++) {if (o[i].style.zIndex * 1 >= w.style.zIndex * 1) { w.style.zIndex = o[i].style.zIndex * 1 + 1 } }
	 }

 }