function llx3_dhtmlWindow(wFrame, wContent, folder, modal) {
    var This = this;
    var ModalBg = null;
    var ppW = null;
    var ppC = null;
    var MouseDown = false;
    var mX = 0;
    var my = 0;
    this.effectSpeed = 300;
    this.autoSize = false;
    this.contentUrl = "";
    this.iframe = undefined;

    function CreateModalBG() {
        ModalBg = document.createElement("DIV");
        ModalBg.style.backgroundColor = '#000000';
        ModalBg.style.position = GetFixedPos();
        ModalBg.style.left = '0px';
        ModalBg.style.top = '0px';
        ModalBg.style.width = '100%';
        ModalBg.style.height = '100%';
        ModalBg.style.opacity = '.5';
        ModalBg.style.filter = 'alpha(opacity=50)';
        ModalBg.style.zIndex = '10000';
        document.body.appendChild(ModalBg);
        ModalBg.onmousedown = function () { This.hide(); }
        //ModalBg.onmousemove = onMouseMove;
    }
    function setPPW() {
    	$(wFrame).each(function () { ppW = this });
    	$(wContent).each(function () { ppC = this });
    	document.body.appendChild(ppW); ppW.style.position = GetFixedPos(); ppW.style.display = 'none';
        ppW.onmousedown = function (e) { SetCapture(); if (e == undefined) { mX = event.clientX - ppW.offsetLeft; mY = event.clientY - ppW.offsetTop; } else { mX = e.pageX - ppW.offsetLeft; mY = e.pageY - ppW.offsetTop; } MouseDown = true; return false; }
        ppW.onmouseup = function () { MouseDown = false; RelCapture(); }
        ppW.onselectstart = function () { return false; }
        ppW.ondragstart = function () { return false; }
        AddEvent(ppW, "mousemove", onMouseMove);
        AddEvent(document.body, "mousemove", onMouseMove);//non ie
        AddEvent(document.body, "click", function () { MouseDown = false; }); //non ie
        ppW.style.zIndex = 10000;
    }

    function onMouseMove(e) {
        //return true!
        if (MouseDown == false) return true;
        if (e == undefined) return true;
        //return false!
        if (document.all) { ppW.style.left = (event.clientX - mX) + 'px'; ppW.style.top = (event.clientY - mY) + 'px'; } else { ppW.style.left = (e.pageX - mX) + 'px'; ppW.style.top = (e.pageY - mY) + 'px' }; return false;
    }

    this.showLoader = function () {
        var imgsrc = folder + 'img/loader.gif'
        if (imgsrc == undefined) return false;
        if (imgsrc == "") return false;
        ModalBg.style.backgroundImage = "url('" + imgsrc + "')";
        ModalBg.style.backgroundPosition = "center";
        ModalBg.style.backgroundRepeat = "no-repeat";
    }
    this.show = function (x, y) {
    	if (modal == true) {
    		if (ModalBg == null) { CreateModalBG(); }
    		ModalBg.style.display = 'block';
    		This.showLoader();
    		if ((GetIeVersion() < 7) && (GetIeVersion() > 0)) { $('SELECT').each(function () { this.style.visibility = 'hidden' }) }
    		ModalBg.style.backgroundImage = "";
    	}
    	setPPW();
    	makeIframe();
    	ppW.style.display = 'block';
    	ppW.style.visibility = 'hidden';
    	if (x == null) x = ((GetWindowWidth() / 2) - (ppW.offsetWidth / 2)); if (GetFixedPos() == "absolute") x += document.documentElement.scrollLeft;
    	ppW.style.left = x + 'px';
    	if (y == null) y = ((GetWindowHeight() / 2) - (ppW.offsetHeight / 2)); if (GetFixedPos() == "absolute") y += document.documentElement.scrollTop;
    	ppW.style.top = y + 'px';
    	ppW.style.display = 'none';
    	ppW.style.visibility = 'visible';
    	$(wFrame).each(function () { });
    	$(wFrame).fadeIn(This.effectSpeed);
    }
    this.showUrl = function (url, x, y) {
    	This.contentUrl = url;
    	This.show(x, y);
    }

    this.hide = function () {
        MouseDown = false;
        $(wFrame).fadeOut(This.effectSpeed, function () { if (modal == true) ModalBg.style.display = 'none'; });
        if ((GetIeVersion() < 7) && (GetIeVersion() > 0)) { $('SELECT').each(function () { this.style.visibility = 'visible' }) }
    }

    function GetFixedPos() {
        if ((GetIeVersion() < 7) && (GetIeVersion() > 0)) return 'absolute';
        return 'fixed';
    }

    function makeIframe() {
    	if (This.contentUrl != "") {
    		if (This.iframe ==undefined) {
    			This.iframe = document.createElement("IFRAME");
    			This.iframe.style.position = "absolute";
    			This.iframe.style.top = "0px";
    			This.iframe.style.left = "0px";
    			This.iframe.style.width = "100%";
    			This.iframe.style.height = "100%";
    			This.iframe.style.backgroundColor = "#fff";
    			This.iframe.frameBorder = "0";
    			ppC.appendChild(This.iframe);
    		}
    	}
    	This.iframe.src = "_blank";
    	This.iframe.src = This.contentUrl;
    }

    function GetIeVersion() {
    	
        var i0 = window.navigator.appVersion.indexOf('MSIE');
        if (i0 < 0) return 0;
        var i1 = window.navigator.appVersion.indexOf(';', i0);
        return window.navigator.appVersion.substring(i0 + 4, i1) * 1;
    }

    function SetCapture() { if (ppW.setCapture) ppW.setCapture(); }
    function RelCapture() { if (ppW.releaseCapture) ppW.releaseCapture(); }

    function AddEvent(obj, name, handler) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            obj.attachEvent('on' + name, handler);
        } else {
            obj.addEventListener(name, handler, true);
        }
    }

    function GetWindowHeight() {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return document.documentElement.offsetHeight;
        } else {
            return window.innerHeight;
        }
    }
    function GetWindowWidth() {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return document.documentElement.offsetWidth;
        } else {
            return window.innerWidth;
        }
    }

}
