// ========================================================================
//	TES JavaScripts Library V1.0
//	
//	File default.js
//	
//	Copyright (c) 2002-2005 John Wiley and Sons, Inc.
// ========================================================================
function getControls()
{
	return top;
}

function validSubmit(in_form){
	if (validate(in_form)){
		in_form.submit();
	}
}


function checkPwdLength(in_inputObj){
	var s_maxLength = 25;
	if (in_inputObj.value.length > s_maxLength){
		alert("Please choose a new password that is fewer than "+ s_maxLength +" characters.");
		in_inputObj.value = "";
	}
}


function checkCommentAreaLength(in_inputObj){
	var s_maxLength = 900;
	var s_valueStore = in_inputObj.value;
	if (in_inputObj.value.length > s_maxLength){
		alert("This assignment type has a maximum character limit of 900.");
		in_inputObj.value = s_valueStore.substring(0, 899);
		return true;
	}
}

function checkTextAreaLength(in_inputObj){
	var s_maxLength = 10000;
	var s_valueStore = in_inputObj.value;
	if (in_inputObj.value.length > s_maxLength){
		alert("This assignment type has a maximum character limit of 10000.");
		in_inputObj.value = s_valueStore.substring(0, 9999);
		return true;
	}
}


function itemsSelect(in_form, in_controlObj, in_itemName){
	var switcherState = in_controlObj.checked;
	var curElm = null;
	for(var i=0; i< in_form.length; i++)
	{
		curElm = in_form.elements[i];
		if ((in_form.elements[i].name == in_itemName) || 
				((arguments[3] != null) && (in_form.elements[i].name == arguments[3])))
		{
			if (in_form.elements[i].type == 'checkbox'){
				curElm.checked = switcherState;
			}	
		}
	}
}


function containsWsOnly(in_str){
	var s_result = true;
	for(var i=0; i < in_str.length; i++)
	{
		if (in_str.charAt(i) != " " ){
			s_result = false;
			break;
		}
	}
	return s_result;
}

function callHelp(){
	var s_helpMode = "";
	if (arguments[0] != null)
	{
		s_helpMode = arguments[0];
	}
	uni_help(s_helpMode);
}

function uni_contextHelp()
{
	if (self.location==top.location){
		opener.top.uni_help("context");
	}
	else{
		top.uni_help("context");
	}
}

function notImp(feature)
{
	alert("The '" + feature + "' is not implemented yet.");
}

function makeUniqueArray(in_array){
	in_array.sort();
	
	var item = in_array[0];
	var resArray = [item];
	
	for(var i=1; i<in_array.length; i++){
		if (in_array[i] != item ){
			item = in_array[i];
			resArray.push( in_array[i] );
		}
	}
	return resArray;
}


function Is() {
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
	this.ns2 = (this.ns && (this.major == 2));
	this.ns3 = (this.ns && (this.major == 3));
	this.ns4 = (this.ns && (this.major == 4));
	this.ns5 = (this.ns && (this.major > 4));
	this.ns6 = (this.ns && (agent.indexOf('netscape6')!=-1) );
	this.ns7 = (this.ns && (agent.indexOf('netscape/7')!=-1) );
	this.ns7pr = (this.ns && (agent.indexOf('netscape/7.0b1')!=-1) );
	this.ns71 = (this.ns && (agent.indexOf('netscape/7.1')!=-1) );
	this.ns72 = (this.ns && (agent.indexOf('netscape/7.2')!=-1) );
	this.ie = (agent.indexOf("msie") != -1);
	this.ie3 = (this.ie && (this.major == 2));
	this.ie4 = (this.ie && (this.major >= 4));
	this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") != -1));
	this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") != -1));
	this.ie6 = (this.ie && (agent.indexOf("msie 6.0")!=-1));
	this.op3 = (agent.indexOf("opera") != -1);
	this.pc  = (agent.indexOf("win") != -1);
	this.mac = (agent.indexOf("mac")!=-1); // Mac detect
	this.client = ( (navigator.userAgent.indexOf('AOL')!=-1) || (navigator.userAgent.indexOf('CS 2000')!=-1) )? 1 : 0;
	this.moz = ( this.ns && (agent.indexOf("netscape/") == -1) );
	if (this.moz) this.ns = 0;
}


function gotoURL(in_url){
	window.location = in_url;
}

var stnTimer;
var stnTimeoutForMessage = "5 minutes";
var stnTimeout;
var sessionTerminated = false;
var isRestartRequired = true;

function getSTNMessage() {
    return "Due to system inactivity your WileyPLUS session will automatically timeout in " + stnTimeoutForMessage +
                     ".\nWould you like to continue working in WileyPLUS?";
}

function startSTNTimer() {
    if (typeof(stnTimeout) != "undefined" && !sessionTerminated) {
        stnTimer = setTimeout(showNotification, stnTimeout);
    }
}

function stopSTNTimer() {
    if (typeof(stnTimer) != "undefined") {
        clearTimeout(stnTimer);
    }
}

function resetSTNTimer() {
    if (typeof(stnTimer) != "undefined" && !sessionTerminated) {
        clearTimeout(stnTimer);
        if (isRestartRequired) {
            startSTNTimer();
        }
    }
}

function doOnLoadSTN(sessionTimeout, notifTimeout) {
    if (window.top == self && typeof(sessionTimeout) != "undefined" && typeof(notifTimeout) != "undefined") {
        var sessionTimeoutNum = parseInt(sessionTimeout);
        var notifTimeoutNum = parseInt(notifTimeout);
        if (sessionTimeoutNum != Number.NaN && notifTimeoutNum != Number.NaN && notifTimeoutNum > 0 && sessionTimeoutNum > notifTimeoutNum) {
            var notifTimeoutSeconds = notifTimeoutNum % 60;
            var notifTimeoutMinutes = (notifTimeoutNum - notifTimeoutSeconds) / 60;
            stnTimeoutForMessage = notifTimeoutMinutes.toString() + " minutes";
            if (notifTimeoutSeconds > 0) {
                stnTimeoutForMessage += " " + notifTimeoutSeconds.toString() + " seconds";
            }
            stnTimeout = (sessionTimeoutNum - notifTimeoutNum) * 1000;
            setSTNOnLoadListener(window);
            startSTNTimer();
        }
    }
}

function loadSTNListenerClass(wnd) {
    this.handler = function() {
        setSTNOnLoadListener(wnd);
        with (window.top) {
            if (typeof(resetSTNTimer) != "undefined")
                resetSTNTimer();
        }
    }
}

function setSTNOnLoadListener(wnd) {
    setSTNFrameOnLoadListener(wnd, wnd.document.getElementsByTagName('frame'));
    setSTNFrameOnLoadListener(wnd, wnd.document.getElementsByTagName('iframe'));
}

function setSTNFrameOnLoadListener(wnd, frms) {
    if (frms != null) {
        for (var i = 0; i < frms.length; i++) {
            var frm = frms[i];
            var frmWnd = frm.contentWindow ? frm.contentWindow : wnd.frames[i].window;
            var cls = new loadSTNListenerClass(frmWnd);
            if (window.addEventListener)
                frm.addEventListener("load", cls.handler, false);
            else if (window.attachEvent)
                frm.attachEvent("onload", cls.handler);
            setSTNOnLoadListener(frmWnd);
        }
    }
}

var setSTNPopupOnLoadListener = function(wnd) {
    if (wnd.addEventListener) {
        wnd.addEventListener("load", function() {
            var cls = new loadSTNListenerClass(wnd);
            cls.handler();
        }, false);
    } else if (wnd.attachEvent) {
        var cls = new loadSTNListenerClass(wnd);
        cls.handler();
    }
}

function showNotification() {
    var res = confirm(getSTNMessage());
    if (res) {
        requestSessionMonitor(true);
    } else {
        var res2 = confirm("Are you sure you want to log out?");
        if (res2) {
            (typeof(performLogout) != "undefined") ? performLogout() : requestSessionMonitor(false);
        } else {
            requestSessionMonitor(true);
        }
    }
}

function requestSessionMonitor(isExtend) {
    var xmlHttpReq = false;
    var self = this;
    var str = window.location.href.split('/edugen/');
    var strURL = str[0] + "/edugen/global/session_monitor.uni";
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (self.xmlHttpReq) {
        try {
            self.xmlHttpReq.onreadystatechange = function() {
                if (self.xmlHttpReq.readyState == 4) {
                    var httpStatus = self.xmlHttpReq.status;
                    if (httpStatus == 200) {
                        // Request processed successfully.
                        if (self.xmlHttpReq.responseText.indexOf("Timeout alert") > 0 && isExtend) {
                            alert("Your WileyPLUS session has expired.");
                            if (typeof(performLogout) != "undefined") {
                                performLogout();
                            }
                        } else if (isExtend) {
                            resetSTNTimer();
                        } else {
                            sessionTerminated = true;
                            if (typeof(performLogout) != "undefined") {
                                performLogout();
                            }
                        }
                    } else {
                        alert("An error occurred while requesting the server.");
                    }
                }
            }
            self.xmlHttpReq.open("POST", strURL, true);
            self.xmlHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            var actionParam = isExtend ? "extend" : "terminate";
            self.xmlHttpReq.send("smaction=" + actionParam);
        } catch (err) {
            alert("An error occurred while requesting the server.");
        }
    }
}


function deleteServerId() {
	//document.cookie = "ServerID=; path=/edugen; expires=" + (new Date(0)).toUTCString();
}

function showDisablePlex(zindex) {
    var plex;
    if (zindex == 'fresh') {
        if (plex = document.getElementById("disablePlexId")) {
            plex.style.width = document.body.scrollWidth;
            plex.style.height = document.body.scrollHeight;
        }
        return;
    }
    plex = document.createElement('div');
    var plexOpacity = 50;
    plex.setAttribute("id", "disablePlexId");
    plex.style.position = 'absolute';
    plex.style.top = 0;
    plex.style.left = 0;
    plex.style.width = document.body.scrollWidth;
    plex.style.height = document.body.scrollHeight;
    plex.style.backgroundColor = '#FFFFFF';
    plex.style.zIndex = zindex;
    if (plex.style.opacity != undefined) plex.style.opacity = (plexOpacity / 100);
    if (plex.style.filter != undefined) plex.style.filter = 'alpha(opacity=' + plexOpacity + ')';
    plex.style.display = 'block';
    document.body.insertBefore(plex, document.body.childNodes[0]);
    setTimeout('showDisablePlex("fresh")', 512);
}

function hideDisablePlex() {
    try {
        document.body.removeChild(document.getElementById("disablePlexId"));
    } catch(e) {}
}

function showSplash() {
    try {
        var splash = document.createElement('div');
        splash.style.display = "none";
        splash.style.backgroundColor = "#FFFFFF";
        splash.style.position = "absolute";
        splash.style.width = "128px";
        splash.id = "splashDivId";
        if (arguments[0]) splash.style.zIndex = parseInt(arguments[0]);
        if (arguments[1]) showDisablePlex(arguments[1]);
        if (typeof splash.style.filter != 'undefined') splash.style.filter = "alpha(opacity=70)";
        if (typeof splash.style.opacity != 'undefined') splash.style.opacity = 0.7;
        splash.innerHTML = '<table border="1" cellspacing="0" cellpadding="6" width="100%" height="100%" rules="none">' +
        '<tr align="center"><td><img src="' + (arguments[2]?arguments[2]:'/edugen') + '/art2/common/loading.gif" width="32" height="32" alt="" border="0" />'
        + '</td></tr><tr align="center"><td><b>Loading...</b></td></tr></table>';
        splash.style.top = document.body.scrollTop + Math.round(document.body.clientHeight / 2) - 32;
        splash.style.left = document.body.scrollLeft + Math.round(document.body.clientWidth / 2) - 64;
        document.body.insertBefore(splash, document.body.childNodes[0]);
        splash.style.display = 'block';
    } catch(e) {}
}

function hideSplash() {
    try {
        document.body.removeChild(document.getElementById("splashDivId"));
    } catch(e) {}
    hideDisablePlex();
}


function getFlashVersion() {
    function getControlFlashVersion() {
        var version;
        var axo;
        // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
        try {
            // version will be set for 7.X or greater players
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
            version = axo.GetVariable("$version");
        } catch (e) {}
        if (!version) {
            try {
                // version will be set for 6.X players only
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                // installed player is some revision of 6.0
                // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
                // so we have to be careful.
                // default to the first public version
                version = "WIN 6,0,21,0";

                // throws if AllowScripAccess does not exist (introduced in 6.0r47)
                axo.AllowScriptAccess = "always";
                // safe to call for 6.0r47 or greater
                version = axo.GetVariable("$version");
            } catch (e) {}
        }
        if (!version)
        {
            try {
                // version will be set for 4.X or 5.X player
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
                version = axo.GetVariable("$version");
            } catch (e) {}
        }
        if (!version) {
            try {
                // version will be set for 3.X player
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
                version = "WIN 3,0,18,0";
            } catch (e) {}
        }
        if (!version) {
            try {
                // version will be set for 2.X player
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
                version = "WIN 2,0,0,11";
            } catch (e) {
                version = -1;
            }
        }
        return version;
    }
    // NS/Opera version >= 3 check for Flash plugin in plugin array
    var flashVer = -1;
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            var versionRevision = descArray[3];
            if (versionRevision == "") {
                versionRevision = descArray[4];
            }
            if (versionRevision[0] == "d") {
                versionRevision = versionRevision.substring(1);
            } else if (versionRevision[0] == "r") {
                versionRevision = versionRevision.substring(1);
                if (versionRevision.indexOf("d") > 0) {
                    versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                }
            }
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        }
    }
    // MSN/WebTV 2.6 supports Flash 4
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    // WebTV 2.5 supports Flash 3
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
        // older WebTV supports Flash 2
        else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
            else if ((navigator.appVersion.indexOf("MSIE") != -1) && (navigator.appVersion.toLowerCase().indexOf("win") != -1) && (navigator.userAgent.indexOf("Opera") == -1)) {
                    flashVer = getControlFlashVersion();
                }
    return flashVer;
}

function showMod(attr) {
    if (!document.body) {
        alert("Cannot show modal window without 'document.body'.");
        return null;
    }
    var modBorderColor = '#ECC113', shadeColor = '#CCCCCC', plexColor = '#FFFFFF', modColor = '#FFEFAF';
    function getScrollWidth() {
        return document.body.scrollWidth;
    }
    function getScrollHeight() {
        return document.body.scrollHeight;
    }
    function getScrollTop() {
        return document.body.scrollTop;
    }
    function getScrollLeft() {
        return document.body.scrollLeft;
    }
    function getWindowWidth() {
        return document.body.clientWidth;
    }
    function getWindowHeight() {
        return document.body.clientHeight;
    }
    function getPlexId() {
        return "plexiglass" + attr.id;
    }
    function getShadeId() {
        return "shade" + attr.id;
    }
    function getModalId() {
        return "modal" + attr.id;
    }
    var curScrollWidth = getScrollWidth();
    var curScrollHeight = getScrollHeight();
    var curScrollTop = getScrollTop();
    var curScrollLeft = getScrollLeft();
    var curWindowWidth = getWindowWidth();
    var curWindowHeight = getWindowHeight();
    if ((!attr) || (!attr.id)) attr = {'id': attr.toString()};
    var defaultAttr = {'width': 256, 'height': 128, 'index': 1, 'top': 0, 'left': 0, 'opacity': 40, 'modBorder': 2, 'shadeDelta': 6, 'startX': 0, 'startY': 0, 'startCenter': 0};
    function getCorrectAttrValue(attrName) {
        var str = "if (!attr." + attrName + ") attr." + attrName + " = defaultAttr." + attrName + ";";
        str += "attr." + attrName + " = parseInt(attr." + attrName + ");";
        str+="if((attr."+attrName+"==NaN)||(attr."+attrName+"<0))attr."+attrName+"=defaultAttr"+attrName+";";
        eval(str);
    }
    for (var i in defaultAttr) getCorrectAttrValue(i);
    function getModLeft(width) {
        if (attr.startCenter > 0) return curScrollLeft + Math.round((curWindowWidth - attr.width) / 2) + attr.left;
        if (attr.startX > 0) return attr.startX - Math.round(attr.width / 2) + attr.left;
        return Math.round((width - attr.width) / 2) + attr.left;
    }
    function getModTop(height) {
        if (attr.startCenter > 0) return curScrollTop + Math.round((curWindowHeight - attr.height) / 2) + attr.top;
        if (attr.startY > 0) return attr.startY - Math.round(attr.height / 2) + attr.top;
        return Math.round((height - attr.height) / 2) + attr.top;
    }
    var div;
    if ((!attr.id) || (!(div = document.getElementById(attr.id)))) {
        attr.id = 'dataDivId' + Math.round(Math.random()*8192);
        div = document.createElement('div');
        div.setAttribute("id", attr.id);
        //div.setAttribute("style", "display: none;");
        div.style.display = 'none';
        div.innerHTML = "Source for this modal window not found!<br/><form action=''>" +
        "<input type='button' value='Close' onclick='try{document.body.removeChild(document.getElementById(\"" + getPlexId() + "\"));" +
        "document.body.removeChild(document.getElementById(\"" + getShadeId() + "\"));" +
        "document.body.removeChild(document.getElementById(\"" + getModalId() + "\"));}catch(e){}'/></form>";
        document.body.appendChild(div);
    }
    var modal = document.createElement('div');
    modal.setAttribute("id", getModalId());
    modal.style.position = 'absolute';
    modal.style.top = 0;
    modal.style.left = 0;
    function setModalLayout(modaler, modalTop, modalLeft) {
        modaler.style.top = modalTop;
        modaler.style.left = modalLeft;
        modaler.style.width = attr.width;
        modaler.style.height = attr.height;
    }
    modal.style.backgroundColor = modColor;
    modal.style.border = attr.modBorder + 'px outset ' + modBorderColor;
    var index = 0, tmp;
    if (document.body.style && (tmp = document.body.style.zIndex)) index = tmp;
    index += attr.index;
    modal.style.zIndex = index + 5;
    modal.style.visibility = 'hidden';
    modal.style.display = 'block';
    modal.style.width = attr.width;
    modal.innerHTML = div.value.replace(/_textarea/g, 'textarea');
    document.body.appendChild(modal);
    if (attr.doOnOpen) {
        try {
            eval(attr.doOnOpen);
        } catch(e){}
    }
    if (modal.offsetWidth > attr.width) {
        attr.width = modal.offsetWidth;
        modal.style.width = attr.width;
    }
    if (modal.offsetHeight > attr.height) attr.height = modal.offsetHeight;
    setModalLayout(modal, getModTop(curWindowHeight), getModLeft(curWindowWidth));
    var plexiglass = document.createElement('div');
    plexiglass.setAttribute("id", getPlexId());
    plexiglass.style.position = 'absolute';
    function setPlexiglassLayout(plex, plexWidth, plexHeight) {
        plex.style.top = 0;
        plex.style.left = 0;
        plex.style.width = plexWidth;
        plex.style.height = plexHeight;
    }
    setPlexiglassLayout(plexiglass, curScrollWidth, curScrollHeight);
    plexiglass.style.backgroundColor = plexColor;
    plexiglass.style.zIndex = index + 1;
    if (plexiglass.style.opacity != undefined) plexiglass.style.opacity = (attr.opacity / 100);
    if (plexiglass.style.filter != undefined) plexiglass.style.filter = 'alpha(opacity=' + attr.opacity + ')';
    plexiglass.style.display = 'block';
    document.body.appendChild(plexiglass);
    
    var shadeIF = document.createElement('iframe');
    shadeIF.setAttribute("id", getShadeId()+"iframe");
    shadeIF.setAttribute("src", "about:blank");
    shadeIF.setAttribute("frameborder", "0");
    shadeIF.setAttribute("scrolling", "no");
    shadeIF.style.position = 'absolute';
    setShadeLayout(shadeIF, getModTop(curWindowHeight), getModLeft(curWindowWidth));
    shadeIF.style.backgroundColor = shadeColor;
    shadeIF.style.zIndex = index + 2;
    shadeIF.style.display = 'block';
    document.body.appendChild(shadeIF);
    
    var modalIF = document.createElement('iframe');
    modalIF.setAttribute("id", getModalId()+"iframe");
    modalIF.setAttribute("src", "about:blank");
    modalIF.setAttribute("frameborder", "0");
    modalIF.setAttribute("scrolling", "no");
    modalIF.style.position = 'absolute';
    setModalLayout(modalIF, getModTop(curWindowHeight), getModLeft(curWindowWidth));
    modalIF.style.backgroundColor = modColor;
    modalIF.style.zIndex = index + 4;
    modalIF.style.display = 'block';
    document.body.appendChild(modalIF);
    
    
    var shade = document.createElement('div');
    shade.setAttribute("id", getShadeId());
    shade.style.position = 'absolute';
    function setShadeLayout(shader, shadeTop, shadeLeft) {
        shader.style.top = shadeTop + attr.shadeDelta + attr.modBorder;
        shader.style.left = shadeLeft + attr.shadeDelta + attr.modBorder;
        shader.style.width = attr.width;
        shader.style.height = attr.height;
    }
    setShadeLayout(shade, getModTop(curWindowHeight), getModLeft(curWindowWidth));
    shade.style.backgroundColor = shadeColor;
    shade.style.zIndex = index + 3;
    shade.style.display = 'block';
    document.body.appendChild(shade);
    if (attr.doOnshow) {
        try {
            eval(attr.doOnshow);
        } catch(e){}
    }
    modal.style.visibility = 'visible';
    function closeDiv(dv) {
        try {
            dv.style.display = 'none';
            dv.innerHTML = '';
            dv.setAttribute('id', '');
            document.body.removeChild(dv);
        } catch(e){}
    }
    var closeThis = function() {
            if (!plexiglass.getAttribute('id')) return true;
        if (attr.doOnBeforeClose) {
            try {
                eval(attr.doOnBeforeClose);
            } catch(e) {}
        }
            closeDiv(modal);
            closeDiv(shade);
            closeDiv(plexiglass);
            try {
                document.body.removeChild(modalIF);
                document.body.removeChild(shadeIF);
            } catch(e) {}
        if (attr.doOnClose) {
            try {
                eval(attr.doOnClose);
            } catch(e) {}
        }
    };
    var resizeThis = function() {
        try {
            //moveFlag = false;
            curScrollWidth = getScrollWidth();
            curScrollHeight = getScrollHeight();
            curWindowWidth = getWindowWidth();
            curWindowHeight = getWindowHeight();
            curScrollTop = getScrollTop();
            curScrollLeft = getScrollLeft();
            setPlexiglassLayout(plexiglass, curScrollWidth, curScrollHeight);
						setShadeLayout(shadeIF, getModTop(curWindowHeight), getModLeft(curWindowWidth));
            setShadeLayout(shade, getModTop(curWindowHeight), getModLeft(curWindowWidth));
            setModalLayout(modalIF, getModTop(curWindowHeight), getModLeft(curWindowWidth));
            setModalLayout(modal, getModTop(curWindowHeight), getModLeft(curWindowWidth));
            return true;
        } catch(e) {
            return false;
        }
    };
    var moveFlag = false;
    var x = attr.left;
    var y = attr.top;
    var startMoveThis = function(e) {
        try {
            moveFlag = true;
            x = e.clientX;
            y = e.clientY;
            return true;
        } catch(e) {
            return false;
        }
    };
    var endMoveThis = function() {
        moveFlag = false;
    };
    var moveThis = function(e) {
        try {
            if (moveFlag) {
                var _x = e.clientX, _y = e.clientY;
                    attr.left -= x - _x;
                    attr.top -= y - _y;
                    x = _x, y = _y;
                    setShadeLayout(shadeIF, getModTop(curWindowHeight), getModLeft(curWindowWidth));
                    setShadeLayout(shade, getModTop(curWindowHeight), getModLeft(curWindowWidth));
                    setModalLayout(modalIF, getModTop(curWindowHeight), getModLeft(curWindowWidth));
                    setModalLayout(modal, getModTop(curWindowHeight), getModLeft(curWindowWidth));
            }
            return true;
        } catch(e) {
            return false;
        }
    };
    return {'id': attr.id, 'close': closeThis, 'resize': resizeThis, 'move': moveThis, 'startMove': startMoveThis, 'endMove': endMoveThis};
}


// ========================================================================

