
// <script type="text/javascript">








var S_POPUP_LITE = "nlpopuplite";
var S_POPUP_SIMPLE = "nlpopupsimple";
var S_POPUP_EXT_LITE = "nlpopupextlite";
var S_POPUP_EXT_SIMPLE = "nlpopupextsimple";
var POPUP_LAYOUT_STYLE_DEFAULT = 0;

var POPUP_INPUT_BLOCKER_ID = "popuptimeoutblocker";

var POPUP_ZINDEX = 1000;

if (window.parentAccesible && parent != window)
{
    if (parent.popupObj != null)
    {
        addMouseEventHandlers(document, parent);
    }
}

function closePopup(bNoRest)
{
    //todo take an action as parameter
    //close popup
    
     if (window.popupObj && window.popupObj.isShowing) {
        //if ((window.popupObj.style=S_POPUP_EXT_LITE) || (window.popupObj.style=S_POPUP_EXT_LITE)) {
        //    window.popupObj.nativeTopObject.close();
        //} else {
            window.popupObj.close(bNoRest);
        //}
    }
    else if(window.parent.popupObj && window.parent.popupObj.isShowing) {
        //if ((window.parent.popupObj.style=S_POPUP_EXT_LITE) || (window.parent.popupObj.style=S_POPUP_EXT_LITE)) {
        //    window.parent.popupObj.nativeTopObject.close();
        //} else {
            window.parent.popupObj.close(bNoRest);
        //}
    }
    
    else if(typeof opener != "undefined" && opener != null)
        window.close();
    
    else if (parent.Ext.WindowMgr.getActive()!=null) {
         parent.Ext.WindowMgr.getActive().close();
    }
}


function addMouseEventHandlers(doc, win)
{
    if (document.all)
    {
        doc.attachEvent("onmouseup",  function(evnt){if (win.popupObj) win.popupObj.handleMouseUp(evnt);});
        doc.attachEvent("onmousemove",  function(evnt){if (win.popupObj) win.popupObj.handleMouseMove(evnt);});
        doc.attachEvent("onmousedown",  function(evnt){if (win.popupObj) win.popupObj.handleMouseDown(evnt);});
    }
    else
    {
        doc.addEventListener("mousedown",  function(evnt){if (win.popupObj) win.popupObj.handleMouseDown(evnt);}, false);
        doc.addEventListener("mousemove",  function(evnt){if (win.popupObj) win.popupObj.handleMouseMove(evnt);}, false);
        doc.addEventListener("mouseup",  function(evnt){if (win.popupObj) win.popupObj.handleMouseUp(evnt);}, false);
    }
}


function nlOpenPopup(window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock, bShow)
{

    if (window.popupObj == null || window.popupObj.style != style || !window.popupObj.nativeContentObject)
        window.popupObj = nlCreatePopup(window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock)
    else
        window.popupObj.init(action, triggerObject, autoHide, width, height, x, y, title, bBlock);

    window.popupObj.show(bShow);
    window.popupObj.isShowing = true;
    return window.popupObj;
}

function nlExtOpenPopup(window, style, action, triggerObject, autoHide, width, height, closeable, x, y, title, bBlock, bShow)
{
    //the style is used to differentiate between the original popups and the new ExtJS-based versions. This allows us to retain
    //the popupObj member for use in other areas of NLPopup.jsp code
    //action = addParamToURL (action, "ifrmcntnr", "T", true );    //NOTE: this does not seem to be necessary like we had to do with nlExtOpenWindow in NLUtil.jsp
    if (window.popupObj == null || window.popupObj.style != style || !window.popupObj.nativeContentObject)
        window.popupObj = nlExtCreatePopup(window, style, action, triggerObject, autoHide, width, height, closeable, x, y, title, bBlock)
    else
    {
        window.popupObj.init(action, triggerObject, autoHide, width, height, x, y, title, bBlock);
    }
    window.adjustLayout = 0;
    window.popupObj.base.show(bShow);
    window.popupObj.isShowing = true;

    return window.popupObj;
}


function nlCreatePopup(window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock)
{
    if (style==S_POPUP_LITE)
        return new nlPopupLite(window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock);
    if (style==S_POPUP_SIMPLE)
        return new nlPopupSimple(window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock);
}

function nlExtCreatePopup(window, style, action, triggerObject, autoHide, width, height, closeable, x, y, title, bBlock)
{
    if (style==S_POPUP_EXT_LITE) {
        //TODO: create ExtJS-based window or floating Panel instance
        return new nlPopupExtLite(window, style, action, triggerObject, autoHide, width, height, closeable, x, y, title, bBlock);
    }
    if (style==S_POPUP_EXT_SIMPLE) {
        //TODO: create ExtJS-based window or floating Panel instance
        return new nlPopupSimple(window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock);
    }
}



function nlPopup(window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock)
{
    this.nativeTopObject = null   // the top object that can controls show/hide/move;
    this.nativeContentObject = null; // the content object that shows the popup content;
    this.bInitialized = false;
    this.parentWindow = window;
    this.style = style;
    this.init(action, triggerObject, autoHide, width, height, x, y, title, null, bBlock);
}

nlPopup.prototype.close = function (bNoRest)
{
    if(this.delayDisplayTimer)
        clearTimeout(this.delayDisplayTimer);
    if(this.resizeTimer)
        clearTimeout(this.resizeTimer);
    if(this.autoCloseTimer)
        clearTimeout(this.autoCloseTimer);


    if (this.style == S_POPUP_EXT_LITE)
    {
        this.nativeTopObject.hide();
    }
    else if (this.style == S_POPUP_EXT_SIMPLE)
    {
        this.nativeTopObject.hide();
    }
    else
    {
        this.nativeTopObject.style.visibility = "hidden";
    }
    window.popupObj.isShowing = false;
    var iframeDoc = getIFrameDocument(this.iframeId);
    if (iframeDoc!= null && iframeDoc.parentWindow != null && iframeDoc.parentWindow.page_reset != null && !bNoRest)
        iframeDoc.parentWindow.page_reset();
    iframeDoc.location.replace ("/empty.html");

}

nlPopup.prototype.init = function (action, triggerObject, autoHide, width, height, x, y, title, bDragdrop, bBlock)
{
    if(this.delayDisplayTimer)
        clearTimeout(this.delayDisplayTimer);
    if(this.resizeTimer)
        clearTimeout(this.resizeTimer);
    if(this.autoCloseTimer)
        clearTimeout(this.autoCloseTimer);

    this.action = action;
    this.triggerObject = triggerObject;
    this.autoHide = autoHide == false ? false : true;
    this.width = width || 400;
    this.height = height || 300;
    this.x = x || 0;
    this.y = y || 0;
    this.title = title || "";
    this.mousedown = false;
    if (typeof bDragDrop != "undefined" && bDragDrop != null)
        this.bDragDrop = bDragDrop;
    else
        this.bDragDrop = false;

    if (typeof bBlock != "undefined" && bBlock != null)
        this.bBlock = bBlock;
    else
        this.bBlock = false;
}

nlPopup.prototype.isInside = function (elem, containerObj)
{
    var inside = false;
    if (elem.ownerDocument == containerObj )
        inside = true;
    else
    {
        while(elem != null)
        {
            if (elem == containerObj)
            {
                inside = true;
                break;
            }
            if (elem == elem.parentNode || elem.parentWindow == elem)
                break;
            if (elem.parentNode != null)
                elem = elem.parentNode;
            else if(elem.parentWindow != null)
                elem = elem.parentWindow.document;
            else
                elem = null;
        }
    }

    return inside;
}

nlPopup.prototype.isVisible = function ()
{
    return this.nativeTopObject && this.nativeTopObject.style.visibility != "hidden";
}

nlPopup.prototype.setStyle = function (style)
{
    this.style = style;
}


nlPopup.prototype.setAutoSize = function (bAutoSize)
{
    this.bDynamic = bAutoSize;
}

nlPopup.prototype.handleMouseDown = function (evnt)
{
    return true;
}   
nlPopup.prototype.handleMouseMove = function (evnt)
{
    return true;
}
nlPopup.prototype.handleMouseUp = function (evnt)
{
    return true;
}

nlPopup.prototype.resize = function (bDynamic, style)
{
    if (bDynamic)
    {
        if(this.resizeTimer)
            clearTimeout(this.resizeTimer);
         
        this.prepareResize(bDynamic, style);
        this.resizeTimer = setTimeout(function ()
                            {
                                this.doResize(this.bDyanmic, this.layoutStyle);
                            }.bind(this), 100);
    }
    else
        this.doResize(bDynamic, style);
}



function nlPopupExtLite (window, style, action, triggerObject, autoHide, width, height, closeable, x, y, title, bBlock)
{
    //alert('inside nlPopupExtLite() code with style of: '+style);
    //this.base = nlPopup;
    //this.base(window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock);
    this.nativeTopObject = null   // the top object that can controls show/hide/move;
    this.nativeContentObject = null; // the content object that shows the popup content;
    this.bInitialized = false;
    this.parentWindow = window;
    this.style = style;

    //TODO: original init() method impl
    if(this.delayDisplayTimer)
        clearTimeout(this.delayDisplayTimer);
    if(this.resizeTimer)
        clearTimeout(this.resizeTimer);
    if(this.autoCloseTimer)
        clearTimeout(this.autoCloseTimer);

    this.action = action;
    this.triggerObject = triggerObject;
    this.autoHide = autoHide == false ? false : true;
    this.width = width || 400;
    this.height = height || 300;
    this.x = x || 0;
    this.y = y || 0;
    this.title = title || "";
    this.mousedown = false;

    if (typeof bDragDrop != "undefined" && bDragDrop != null)
        this.bDragDrop = bDragDrop;
    else
        this.bDragDrop = false;

    if (typeof bBlock != "undefined" && bBlock != null)
        this.bBlock = bBlock;
    else
        this.bBlock = false;

    if (typeof closeable == "undefined" || (closeable == null))
          closeable = false;



    //TODO: look at use of closeAction: 'hide'
    this.base = new Ext.Window({
            title: (title != undefined ? this.title : null),
            id: 'nlpopuplite',
            name: 'nlpopuplite',
            modal: bBlock,
            autoScroll: true, //scrollbars,
            border: false,
            bodyBorder: false,
            header: false,
            closable: closeable,
            toFrontOnShow: true,
            autoDestroy: this.autoHide,   //TODO: check to see if autoHide actually means something else
            width: (parseInt(''+this.width)+13)+'px',
            height: (parseInt(''+this.height)+20)+'px',
            //left: ''+posLeft+'px',
            //top: ''+posTop+'px',
            resizable: true,
            bodyCfg: {
                tag: 'iframe',
                id:  'nlpopuplite_f',
                src: action,
                width: ''+this.width+'px',
                height: ''+this.height+'px',
                style: 'border: 0 none'
             }
         });


    //TODO: for triggerObject calc of position
    if ((typeof this.triggerObject != "undefined") && (this.triggerObject != null)) {
        var x = findAbsolutePosX(this.triggerObject);
	    if (x + (parseInt(this.width)+13) - document.body.scrollLeft <= getDocumentClientWidth())
	        this.x= x;
	    else
	        this.x = getDocumentClientWidth() - (parseInt(this.width)+13) + document.body.scrollLeft;

	    var y = findAbsolutePosY(this.triggerObject);
	    if (y + this.triggerObject.offsetHeight + (parseInt(this.height)+20) > getDocumentClientHeight())
	    {	
	    	this.y = Math.max(y - (parseInt(this.height)+20),0);
	    }
	    else
	    {	
	    	if (isIE)
	    		this.y = y + this.triggerObject.offsetHeight - 1;
	    	else if (isNS)
	    		this.y = y + this.triggerObject.offsetHeight - 2;
	    }
    }

    //TODO: finish impl to account for true triggerObj calc from above AND how passed x/y are accounted for
    var posLeft = (this.triggerObject != null ? this.x : document.body.scrollLeft + (getDocumentClientWidth() - width)/2);
    var posTop = (this.triggerObject != null ? this.y :  document.body.scrollTop + (getDocumentClientHeight() - this.nativeTopObject.offsetHeight)/2);
    this.base.setPosition(posLeft,posTop);
    //this.init(action, triggerObject, autoHide, width, height, x, y, title, null, bBlock);

    //this.iframeObject = null;
    this.typeId = "nlpopuplite";
    this.iframeId = "nlpopuplite_f";
    this.contentId = "nlpopuplite_c";
    this.nativeTopObject = Ext.getCmp(this.typeId);
    //this.zIndex = 1000;
	//this.opacity = -1;
}

nlPopupExtLite.prototype = new nlPopup;

nlPopupExtLite.prototype.init = function(action, triggerObject, autoHide, width, height, x, y, title, bBlock)
{
    if(this.delayDisplayTimer)
        clearTimeout(this.delayDisplayTimer);
    if(this.resizeTimer)
        clearTimeout(this.resizeTimer);
    if(this.autoCloseTimer)
        clearTimeout(this.autoCloseTimer);

    this.action = action;
    this.triggerObject = triggerObject;
    this.autoHide = autoHide == false ? false : true;
    this.width = width || 400;
    this.height = height || 300;
    this.x = x || 0;
    this.y = y || 0;
    this.title = title || "";
    this.mousedown = false;
    if (typeof bDragDrop != "undefined" && bDragDrop != null)
        this.bDragDrop = bDragDrop;
    else
        this.bDragDrop = false;

    if (typeof bBlock != "undefined" && bBlock != null)
        this.bBlock = bBlock;
    else
        this.bBlock = false;

     if ((typeof this.triggerObject != "undefined") && (this.triggerObject != null)) {
        var x = findAbsolutePosX(this.triggerObject);
	    if (x + (parseInt(this.width)+20) - document.body.scrollLeft <= getDocumentClientWidth())
	        this.x= x;
	    else
	        this.x = getDocumentClientWidth() - (parseInt(this.width)+20) + document.body.scrollLeft;

	    var y = findAbsolutePosY(this.triggerObject);
	    if (y + this.triggerObject.offsetHeight + (parseInt(this.height)+20) > getDocumentClientHeight())
	    {	
	    	this.y = Math.max(y - (parseInt(this.height)+20),0);
	    }
	    else
	    {	
	    	if (isIE)
	    		this.y = y + this.triggerObject.offsetHeight - 1;
	    	else if (isNS)
	    		this.y = y + this.triggerObject.offsetHeight - 2;
	    }
    }

    //TODO: finish impl to account for true triggerObj calc from above AND how passed x/y are accounted for
    var posLeft = (this.triggerObject != null ? this.x : document.body.scrollLeft + (getDocumentClientWidth() - width)/2);
    var posTop = (this.triggerObject != null ? this.y :  document.body.scrollTop + (getDocumentClientHeight() - this.nativeTopObject.offsetHeight)/2);
    this.base.setPosition(posLeft,posTop);
    var iframeDoc = getIFrameDocument(this.iframeId);
    if (iframeDoc!= null && iframeDoc.parentWindow != null && iframeDoc.parentWindow.page_reset != null)
        iframeDoc.parentWindow.page_reset();
    iframeDoc.location.replace (this.action);
}


nlPopupExtLite.prototype.showAdjustedLayout = function (bDynamic, style)
{
    //alert('showAdjustedLayout for nlPopupExtLite object');
    this.bDynamic = bDynamic;
    //this.style = style;
    this.nativeContentObject = getIFrameDocument(this.iframeId);

    //this.renderPopupStyle(style);

    //Remove the empty title div as it creates an unnecessary white line due to its white background
    //Server side does not have a proper extension point to remove it.
    //var titleDiv = this.nativeContentObject.getElementById("div__header");
    //if (titleDiv != null)
    //    this.nativeContentObject.body.removeChild(titleDiv);

    //this.resize(bDynamic, style);

    //if(this.opacity > 0 && this.opacity <= 100)
	//	setObjectOpacity(this.opacity, this.nativeTopObject);
}

nlPopupExtLite.prototype.super_close = nlPopup.prototype.close;
nlPopupExtLite.prototype.close = function ()
{
    //alert('calling close on nlPopupExtLite object prototype');
    this.super_close();
    if (this.style == S_POPUP_EXT_LITE)
    {
        this.nativeTopObject.hide();
    }
    else if (this.style == S_POPUP_EXT_SIMPLE)
    {
        this.nativeTopObject.hide();
    }
}


function nlPopupLite (window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock)
{
    this.base = nlPopup;
    this.base(window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock);
    this.iframeObject = null;
    this.typeId = "nlpopuplite";
    this.iframeId = "nlpopuplite_f";
    this.contentId = "nlpopuplite_c";
    this.zIndex = 1000;
	this.opacity = -1;
}

nlPopupLite.prototype = new nlPopup;

nlPopupLite.prototype.initLayout = function initLayout()
{
    this.nativeTopObject = document.getElementById(this.typeId);
    if (this.nativeTopObject == null)
        this.nativeTopObject = this.createLayout();
    //this.setContent("loading...");
    else
        this.createIFrameInnerLayout(this.nativeTopObject);

    this.nativeTopObject.style.visibility = "hidden";
    if (document.all)
    {
        this.nativeTopObject.style.width = this.width;
        this.nativeTopObject.style.height = this.height;
    }
    else
    {
        // need to use a smaller window size so the demension of the content can be calculated correctly
        this.nativeTopObject.style.width = 4;
        this.nativeTopObject.style.height = 3;
    }
}

// Create alias to old toString method
nlPopupLite.prototype.super_close = nlPopup.prototype.close;
nlPopupLite.prototype.close = function nlPopupLite_close(bNoRest)
{
    this.super_close(bNoRest);
    if (this.bBlock)
    {
        var parentDoc = this.parentWindow.document;
        var body = parentDoc.body;
        var blocker = parentDoc.getElementById(POPUP_INPUT_BLOCKER_ID);
        if (blocker != null)
        {
            parent.nlRemoveCanvas(blocker);
            body.removeChild(blocker);
        }
        body.scroll = 'auto';
    }
}

nlPopupLite.prototype.setOpacity = function (iOpacity)
{
	this.opacity = iOpacity;
}

nlPopupLite.prototype.createLayout = function ()
{
    var div = document.createElement("DIV");
    div.id = this.typeId;
    div.style.visibility = "visible";
    div.style.backgroundColor = "white";
    div.style.position = "absolute";
    div.style.border = "1px solid #666666";
    div.style.width = this.width;
    div.style.height = this.height;
    div.style.zIndex = this.zIndex;

	this.createIFrameInnerLayout (div);

    document.body.appendChild(div);

	addMouseEventHandlers(document, window);

    return div;
}

nlPopupLite.prototype.createIFrameInnerLayout = function (divObj)
{
    var refresh = true;
    if (this.iframeObject == null)
    {
        this.iframeObject = document.getElementById(this.iframeId);
        if (this.iframeObject == null)
        {
            divObj.innerHTML = ""; //"<IFRAME id='" + this.iframeId + "' src='" + this.action + "' width=100% height=100% frameborder='0'/>";
            var iframeObject = document.createElement("IFRAME");
            iframeObject.id = this.iframeId;
            iframeObject.src = this.action;
            iframeObject.width = "100%";
            iframeObject.height = "100%";
            iframeObject.frameBorder = 0;
            divObj.appendChild(iframeObject);
            this.iframeObject = iframeObject;
            refresh = false;
        }
    }
    if (refresh )
    {
        var iframeWin = getIFrameWindow(this.iframeId);
        iframeWin.ischanged = false; // do not show the form not submitted alert
        getIFrameDocument(this.iframeId).location.replace (this.action);
    }
}



nlPopupLite.prototype.handleMouseDown = function (evnt)
{
    if (this.nativeTopObject == null || this.nativeTopObject.style.visibility != "visible")
        return;

    var elem = getEventTarget(evnt);
    // setup for drag
    if (this.isInside(elem, getIFrameDocument(this.iframeId)))
    {
        this.mouseDown = true;
    }
    else
        this.mouseDown = false;

    this.mouseX = getMouseX(evnt);
    this.mouseY = getMouseY(evnt);
}

nlPopupLite.prototype.handleMouseMove = function (evnt)
{
    if (!this.bDragDrop || this.nativeTopObject == null || this.nativeTopObject.style.visibility != "visible")
        return;

    var target = getEventTarget(evnt);

    var elem = target;

    if (this.isInside(elem, getIFrameDocument(this.iframeId)) && this.mouseDown)
    {
        var evnt = getEvent(evnt);

        this.nativeTopObject.style.left = findPosX(this.nativeTopObject) + getMouseX(evnt) - this.mouseX;
        this.nativeTopObject.style.top = findPosY(this.nativeTopObject) + getMouseY(evnt) - this.mouseY;
    }

}

nlPopupLite.prototype.handleMouseUp = function (evnt)
{
    if (this.nativeTopObject == null || this.nativeTopObject.style.visibility != "visible")
        return;

    var target = getEventTarget(evnt);

    var elem = target;

    if (!this.isInside(elem, getIFrameDocument(this.iframeId)))
    {
        if (this.autoHide)
            this.close();
    }
    this.mouseDown = false;
}




nlPopupLite.prototype.showAdjustedLayout = function (bDynamic, style)
{
    this.bDynamic = bDynamic;
    this.style = style;
    this.nativeContentObject = getIFrameDocument(this.iframeId);

    this.renderPopupStyle(style);

    //Remove the empty title div as it creates an unnecessary white line due to its white background
    //Server side does not have a proper extension point to remove it.
    var titleDiv = this.nativeContentObject.getElementById("div__header");
    if (titleDiv != null)
        this.nativeContentObject.body.removeChild(titleDiv);

    this.resize(bDynamic, style);

    if(this.opacity > 0 && this.opacity <= 100)
		setObjectOpacity(this.opacity, this.nativeTopObject);
}


nlPopupLite.prototype.renderPopupStyle = function (style)
{
    if (style == POPUP_LAYOUT_STYLE_DEFAULT)
    {
        this.nativeTopObject.style.border = "0";
        this.nativeContentObject.body.style.border = "0";
        //this.iframeObject.style.overflow="hidden";
		this.makeTransparent();
	}
    else
    {
        this.nativeContentObject.body.className = 'bgmd';
        this.nativeContentObject.body.style.borderTop = "#ffffff 1px solid";
        this.nativeContentObject.body.style.borderRight = "#bdbdbd 1px solid";
        if (document.all)  //IE only, in ff the bottom of the body is not at the bottom of the popup
            this.nativeContentObject.body.style.borderBottom = "#bdbdbd 1px solid";
        else
            this.nativeContentObject.body.style.borderBottom = "#bdbdbd 0px solid";
        this.nativeContentObject.body.style.borderLeft = "#ffffff 1px solid";
        this.nativeContentObject.body.style.margin = 0;
    }

    if (this.bBlock)
        this.blockInput(style);
}

nlPopupLite.prototype.prepareResize = function nlPopupLite_prepareResize(bDynamic, style)
{
    this.bDyanmic = bDynamic;
    this.layoutStyle = style;
    this.nativeTopObject.style.overflow='hidden';
    this.nativeTopObject.style.height = 1;
    this.nativeTopObject.style.width = 1;
    this.nativeContentObject.body.style.overflow='hidden';
    this.nativeContentObject.body.style.margin = "0px";
}

nlPopupLite.prototype.adjustPopupSize = function nlPopupLite_adjustPopupSize(bDynamic, style, bPosition)
{
    if (typeof bDynamic == "undefined")
        bDynamic = this.bDynamic;
    if (typeof style == "undefined")
        style = this.style;

    var width = this.nativeContentObject.body.scrollWidth;     // avoid scroll bar
    if (width == 0)  //FF 1.0 bug
        width = 600;

    var height = this.nativeContentObject.body.scrollHeight;   // avoid scroll bar
    if (height == 0) //FF 1.0 bug
        height = 450;

    if (style == POPUP_LAYOUT_STYLE_DEFAULT)
    {
        this.nativeTopObject.style.border = "0";
        this.nativeContentObject.body.style.border = "0";
    }

    while (1.0*height/width > .75)
    {
        width += 50;
        this.nativeTopObject.style.width = width;
        if (height == this.nativeContentObject.body.scrollHeight)
            break;
        width = this.nativeContentObject.body.scrollWidth;
        height = this.nativeContentObject.body.scrollHeight;
    }

    if (document.all)
    {
        this.nativeTopObject.style.width = width + getRuntimeSize(this.nativeTopObject, "borderLeftWidth") + getRuntimeSize(this.nativeTopObject, "borderRightWidth") + 2;
        this.nativeTopObject.style.height = height + getRuntimeSize(this.nativeTopObject, "borderTopWidth") + getRuntimeSize(this.nativeTopObject, "borderBottomWidth") + 2;
    }
    else
    {
        width += getRuntimeSize(this.nativeContentObject.body, "borderLeftWidth") +  getRuntimeSize(this.nativeContentObject.body, "borderLeftWidth") + getRuntimeSize(this.nativeContentObject.body, "marginLeft") +  getRuntimeSize(this.nativeContentObject.body, "marginRight");
        
        height += getRuntimeSize(this.nativeContentObject.body, "borderTopWidth") +  getRuntimeSize(this.nativeContentObject.body, "borderBottomWidth") + + getRuntimeSize(this.nativeContentObject.body, "marginTop") +  getRuntimeSize(this.nativeContentObject.body, "marginBottom");
        this.nativeTopObject.style.width = width - getRuntimeSize(this.nativeTopObject, "paddingLeft") - getRuntimeSize(this.nativeTopObject, "paddingRight");
        this.nativeTopObject.style.height = height - getRuntimeSize(this.nativeTopObject, "paddingTop") - getRuntimeSize(this.nativeTopObject, "paddingBottom");

    }

    //this.iframeObject.onresize = this.adjustPopupSize;
    if (bPosition != false)
        this.setPosition();
 
    
    this.nativeTopObject.style.visibility = "visible";
    
}

nlPopupLite.prototype.doResize = function nlPopupLite_doResize(bDynamic, style, bPosition)
{
    this.adjustPopupSize(bDynamic, style, bPosition)  ;
}

nlPopupLite.prototype.blockInput = function (style)
{
	var parentDoc = this.parentWindow.document;
	var div = parentDoc.getElementById(POPUP_INPUT_BLOCKER_ID);
	if (div != null)
		return; // don't put up a blocker if one's already there
	div = parentDoc.createElement("div");
	div.id = POPUP_INPUT_BLOCKER_ID;
	div.style.position = "absolute";
	div.style.zIndex = POPUP_ZINDEX -1;
    var body = parentDoc.body;
	div.style.top = body.scrollTop - 5;
	div.style.left = 0;
    if (document.all)
    {
        div.style.height = "100%";
        div.style.width = "100%";
    }
    else
    {
        div.style.height = parentDoc.body.scrollHeight;
        div.style.width = parentDoc.body.scrollWidth;
    }
    div.style.margin = parentDoc.body.style.margin;
	div.style.backgroundColor = "#CCCCCC";
	setObjectOpacity(80,div);
	body.appendChild(div);
	if (document.all)
	    parent.nlInsertCanvas( div );
    body.scroll = 'no';
}

nlPopupLite.prototype.makeTransparent = function ()
{
	this.iframeObject.allowTransparency = true;
	this.nativeContentObject.body.style.backgroundColor = "transparent";
	this.nativeTopObject.style.backgroundColor = "transparent";
}

nlPopupLite.prototype.setContent = function (content)
{
	if (this.nativeContentObject != null)
        this.nativeContentObject.innerHTML = content;
}

nlPopupLite.prototype.show = function ()
{
    // prepare to show, the popup will be visible after te content is loaded
    this.initLayout();
    this.setPosition();
    //this.nativeTopObject.style.visibility = "visible";
    //this.populate();
    //this.resize();
}

nlPopupLite.prototype.setPosition = function nlPopupLite_setPosition()
{
    if (this.triggerObject != null)
    {
         NLDropdown.prototype.positionDiv(this.triggerObject, this.nativeTopObject);
    }
    else
    {
        this.nativeTopObject.style.left = document.body.scrollLeft + (getDocumentClientWidth() - this.nativeTopObject.offsetWidth)/2;

        this.nativeTopObject.style.top = document.body.scrollTop + (getDocumentClientHeight() - this.nativeTopObject.offsetHeight)/2;
    }
}

function nlPopupSimple (window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock)
{
    this.base = nlPopup;
    this.base(window, style, action, triggerObject, autoHide, width, height, x, y, title, bBlock);
    this.iframeObject = null;
    this.typeId = "nlpopupsimple";
    this.contentId = "nlpopupsimple_c";
    this.zIndex = POPUP_ZINDEX;
}

nlPopupSimple.prototype = new nlPopup;

nlPopupSimple.prototype.initLayout = function initLayout()
{
    this.nativeTopObject = document.getElementById(this.typeId);
    if (this.nativeTopObject == null )
        this.nativeTopObject = this.createLayout();
    else if (!this.nativeContentObject)
        this.nativeContentObject = this.nativeTopObject;

    if (document.all && !this.bBlock)  //IE; no blocking, otherwise canvas will be inserted behind block div
    {
        nlInsertCanvas(this.nativeTopObject);
        nlSyncCanvas(this.nativeTopObject);
    }
    this.setContent("");

}

nlPopupSimple.prototype.close = function ()
{
    if(this.delayDisplayTimer)
        clearTimeout(this.delayDisplayTimer);
    if(this.resizeTimer)
        clearTimeout(this.resizeTimer);
    if(this.autoCloseTimer)
        clearTimeout(this.autoCloseTimer);

    nlRemoveCanvas(this.nativeTopObject);
    this.nativeTopObject.style.visibility = "hidden";
    if (this.bBlock)
    {
        var blocker = document.getElementById(POPUP_INPUT_BLOCKER_ID);
        if (blocker != null)
        {
            nlRemoveCanvas(blocker);
            document.body.removeChild(blocker);
        }
    }
    this.nativeTopObject.style.width = 1;
    this.nativeTopObject.style.height = 1;
}

nlPopupSimple.prototype.createLayout = function ()
{
    this.nativeTopObject = document.getElementById(this.typeId);
    if (this.nativeTopObject == null)
    {

        var div = document.createElement("DIV");
        div.id = this.typeId;
        div.style.visibility = "visible";
        div.style.backgroundColor = "transparent";
        div.style.overflow = "auto";
        div.style.position = "absolute";
        div.style.border = "1px solid #666666";
        div.style.width = this.width;
        div.style.height = this.height;
        div.style.zIndex = this.zIndex;

        document.body.appendChild(div);

        this.nativeTopObject = div;
        this.nativeContentObject = div;

        if (document.all)
            this.parentWindow.document.attachEvent("onmouseup",  function(evnt){if (window.popupObj) window.popupObj.handleMouseUp(evnt);});
        else
            document.addEventListener("mouseup",  function(evnt){if (window.popupObj) window.popupObj.handleMouseUp(evnt);}, false);
    }
    if (!this.nativeContentObject)
        this.nativeContentObject = this.nativeTopObject;

    if (this.bBlock)
        this.blockInput(null);

    return this.nativeTopObject;
}


nlPopupSimple.prototype.handleMouseUp = function (evnt)
{
    if (this.nativeTopObject == null || this.nativeTopObject.style.visibility != "visible")
        return;

    var target = getEventTarget(evnt);

    var elem = target;

    if (!this.isInside(elem, this.nativeTopObject))
    {
        if (this.autoHide) {
            this.isShowing = false;  
            this.close();
        }
    }
    this.mouseDown = false;
}

nlPopupSimple.prototype.prepareResize = function nlPopupSimple_prepareSize(bDynamic, style)
{
    this.bDyanmic = bDynamic;
    this.layoutStyle = style;
    this.nativeTopObject.style.overflow='hidden';
    this.nativeContentObject.style.height = 1;
    this.nativeContentObject.style.width = 1;
}

nlPopupSimple.prototype.resize = function (bDynamic, style)
{
    if (bDynamic)
    {
        if(this.resizeTimer)
            clearTimeout(this.resizeTimer);
         
        this.bDyanmic = bDynamic;
        this.layoutStyle = style;
        this.nativeTopObject.style.overflow='hidden';
        this.nativeContentObject.style.height = this.height;
        this.nativeContentObject.style.width = this.width;
        this.resizeTimer = setTimeout(function ()
                            {
                                this.doResize(this.bDyanmic, this.layoutStyle);
                            }.bind(this), 100);
    }
    else
        this.doResize(bDynamic, style);
}


nlPopupSimple.prototype.doResize = function nlPopupSimple_doResize(bDynamic, style, bPosition)
{
    if (! bDynamic)
        bDynamic = false;

    if (style == POPUP_LAYOUT_STYLE_DEFAULT)
    {
        this.nativeTopObject.style.border = "0";
    }

    if (bDynamic)
    {
        var width = this.nativeContentObject.scrollWidth;     // avoid scroll bar
        if (width == 0)  //FF 1.0 bug
            width = this.width;

        var height = this.nativeContentObject.scrollHeight;   // avoid scroll bar
        if (height == 0) //FF 1.0 bug
            height = this.height;

        if (document.all)
        {
            
            var runtimeStyle = this.nativeTopObject.runtimeStyle;
            this.nativeTopObject.style.width = width + runtimeStyle.paddingLeft + runtimeStyle.paddingLeft + runtimeStyle.borderLeft + runtimeStyle.borderRight;
            this.nativeTopObject.style.height = height + runtimeStyle.paddingTop + runtimeStyle.paddingBottom + runtimeStyle.borderTop + runtimeStyle.borderBottom;
        }
        else
        {
            this.nativeTopObject.style.width = width;
            this.nativeTopObject.style.height = height;
        }

        this.nativeTopObject.style.overflow='';
        this.width = width;
        this.height = height;
    }

    nlSyncCanvas(this.nativeTopObject);
}

nlPopupSimple.prototype.setContent = function (content)
{
    if (this.nativeContentObject != null)
        this.nativeContentObject.innerHTML = content;
}

nlPopupSimple.prototype.show = function (bShow)
{
    this.initLayout();
    this.setPosition();
    if (bShow)
        this.nativeTopObject.style.visibility = "visible";
	else
		this.nativeTopObject.style.visibility = "hidden";
		
    this.populate();
    this.resize();
}

nlPopupSimple.prototype.display = function (bDisplay, delay)
{
    if(delay > 0)
    {
        if(this.delayDisplayTimer)
            clearTimeout(this.delayDisplayTimer);
        
        this.bDisplay = bDisplay;
        this.delayDisplayTimer = setTimeout(function() { this.display(this.bDisplay);}.bind(this), delay);
    }
    else
    {
        if (bDisplay)
            this.nativeTopObject.style.visibility = "visible";
        else
            this.nativeTopObject.style.visibility = "hidden";
    }
}

nlPopupSimple.prototype.setPosition = function (left, top)
{

    if ( (top && left) || this.triggerObject != null)
    {
        if (!(top && left))
        {
            var top = findAbsolutePosY(this.triggerObject);
            var left = findAbsolutePosX(this.triggerObject) + this.triggerObject.offsetWidth;
        }
        if (top + this.height > getDocumentHeight())
            top =  getDocumentHeight() - this.height - 15;
        if (left + this.width > getDocumentWidth())
            left =  getDocumentWidth() - this.width - 15;

        this.nativeTopObject.style.top = top;
        this.nativeTopObject.style.left = left;

    }
    else
    {
        this.nativeTopObject.style.left = document.body.scrollLeft + (getDocumentClientWidth() - this.nativeTopObject.offsetWidth)/2;

        this.nativeTopObject.style.top = document.body.scrollTop + (getDocumentClientHeight() - this.nativeTopObject.offsetHeight)/2;
    }
}


nlPopupSimple.prototype.populate = function ()
{
    var content = "";

    if (typeof this.action == "string")
    {
        //this.iframeObject.document.location = this.action;
    }
    else
    {
        content = this.action.getContent();
        this.setContent(content);
    }
}


nlPopupSimple.prototype.blockInput = function (style)
{
	var doc = document;
	var div = doc.getElementById(POPUP_INPUT_BLOCKER_ID);
	if (div != null)
		return; // don't put up a blocker if one's already there
	div = doc.createElement("div");
	div.id = POPUP_INPUT_BLOCKER_ID;
	div.style.position = "absolute";
	div.style.zIndex = POPUP_ZINDEX -1;
    var body = doc.body;
	div.style.top = body.scrollTop - 5;
	div.style.left = 0;
    if (document.all)
    {
        div.style.height = "100%";
        div.style.width = "100%";
    }
    else
    {
        div.style.height = doc.body.scrollHeight;
        div.style.width = doc.body.scrollWidth;
    }
    div.style.margin = doc.body.style.margin;
	div.style.backgroundColor = "#FFFFFF";
	setObjectOpacity(0,div);
	body.appendChild(div);
	if (document.all)
	    parent.nlInsertCanvas( div );
}


function nlPickColor(triggerObj, updateObjId, visualObjId, formObjId)
{
    var colorPicker = new nlColorPicker();
    colorPicker.updateObjId = updateObjId;
    colorPicker.visualObjId = visualObjId;
    colorPicker.formObjId = formObjId;
    var popup = nlOpenPopup(window, S_POPUP_SIMPLE, colorPicker, triggerObj, true, 123, 80, null, null, null, false, true);
    popup.resize(true);
}

function nlColorPicker (controlId)
{
    this.visualObjId = "";
    this.updateObjId = "";
    // Code to populate color picker window
    this.colors = new Array("#000000","#993300","#333300","#003300","#003366","#000080","#333399","#333333",
                            "#800000","#ff6600","#808000","#008000","#008080","#0000ff","#666699","#808080",
                            "#ff0000","#ff9900","#99cc00","#339966","#33cccc","#3366ff","#800080","#999999",
                            "#ff00ff","#ffcc00","#ffff00","#00ff00","#00ffff","#00ccff","#993366","#c0c0c0",
                            "#ff99cc","#ffcc99","#ffff99","#ccffcc","#ccffff","#99ccff","#cc99ff","#ffffff"
                            );

}

nlColorPicker.prototype.getContent = function()
{
    var width = 8;
    var total = this.colors.length;
    var content = '<TABLE CELLSPACING=3 CELLPADDING=0 style="background-color: #efefef; border-top: 1px solid #ffffff; border-right: 1px solid #cccccc; border-bottom: 1px solid #cccccc; border-left: 1px solid #ffffff;">';
    for (var i=0; i<total; i++)
    {
        if ((i % width) == 0) { content += "<TR>"; }
        content += '<td><div style="cursor:hand; cursor: pointer; width:12px; height: 12px; overflow:hidden; margin: 0px; border: 1px solid #888888;background-color:' + this.colors[i] + '" onClick="pickColor(\''+this.colors[i]+'\', \''+this.updateObjId + '\', \'' + this.visualObjId + '\', \'' + this.formObjId + '\');"></div></td>';
        if ( ((i+1)>=total) || (((i+1) % width) == 0))
        {
            content += "</TR>";
        }
    }
    content += "</TABLE>";

    return content;
}

function pickColor (color, updateObjId, visualObjId, formObjId)
{
    var updateObj = null;
    if ( formObjId == "undefined" || formObjId == null)
        updateObj = document.getElementById(updateObjId);
    else
        updateObj = document.forms[formObjId].elements[updateObjId];

    if (updateObj != null && updateObj.value != color)
    {
        updateObj.value = color;
        window.ischanged = true;
        if (typeof updateObj.onchange == "function")
            updateObj.onchange();   
    }

    var visualObj = document.getElementById(visualObjId);
    if (visualObj != null)
        visualObj.style.backgroundColor = color;

    if (window.popupObj != null) {
        window.popupObj.isShowing = false;    
        window.popupObj.close();
    }
}



function nlShowMessage(message, title, style, bCustom)
{
    var messageContent = new nlMessageContent(message, title, style, bCustom);
    var popup = nlOpenPopup(window, S_POPUP_SIMPLE, messageContent, null, false, 400, 200, 0, 0, null,true, true);
    popup.resize(true, POPUP_LAYOUT_STYLE_DEFAULT);
    popup.setPosition();
    popup.display(true, 200);
}

var MSG_STYLE_INFO = 1;
var MSG_STYLE_WARNING = 2;
var MSG_STYLE_ERROR = 3;

var msgPopupIcons = new Array();
msgPopupIcons[MSG_STYLE_INFO] = "/images/icons/popup/info.gif";
msgPopupIcons[MSG_STYLE_WARNING] = "/images/icons/popup/warning.gif";
msgPopupIcons[MSG_STYLE_ERROR]= "/images/icons/popup/info.gif";

function nlMessageContent (message, title, style, bCustom)
{
    this.message = message;
    this.title = title;
    this.style = style;
}

nlMessageContent.prototype.getContent = function(contentTemplate)
{
    var content = contentTemplate;
    if (!content)
        content = MSG_POPUP_SHELL;

    if (typeof this.message != "undefined" && this.message != null)
        content = content.replace("<messagecontent/>", this.message);
    if (typeof this.title != "undefined" && this.title != null)
        content = content.replace("<messagetitle/>", this.title);
    if (typeof this.style != "undefined" && this.style != null)
    {
        var img = "<image src=\"" + msgPopupIcons[this.style] + "\" />";
        content = content.replace("<messageicon/>", img);
    }

    return content;
}

function nlShowConfirm(message, title, style, okAction, cancelAction)
{
    var confirmContent = new nlConfirmContent(message, title, style, okAction, cancelAction);
    var popup = nlOpenPopup(window, S_POPUP_SIMPLE, confirmContent, null, false, 400, 200, null, null, false, true);
    popup.resize(true, POPUP_LAYOUT_STYLE_DEFAULT);
    popup.setPosition();
    popup.display(true, 200);
}

function nlConfirmContent (message, title, style, okAction, cancelAction)
{
    this.constructor(message, title, style);
    this.okAction = okAction;
    this.cancelAction = cancelAction;
}

nlConfirmContent.prototype = new nlMessageContent;
nlConfirmContent.prototype.getContent = function()
{
    var content = this.constructor.prototype.getContent.call(this,CONFIRM_POPUP_SHELL);
    if (!this.okAction)
        this.okAction = "";
    content = content.replace("<okaction/>", this.okAction);
    if (!this.cancelAction)
        this.cancelAction = "";
    content = content.replace("<cancelaction/>", this.cancelAction);

    return content;
}

function nlShowPet(okAction, submitAsCaseAction, petDataHtml)
{
	var petContent = new nlPetContent(okAction, submitAsCaseAction, petDataHtml);
	var popup = nlOpenPopup(window, S_POPUP_SIMPLE, petContent, null, false, 400, 400, null, null, false, true);
	popup.resize(true, POPUP_LAYOUT_STYLE_DEFAULT);
    popup.setPosition();
    popup.display(true, 200);
}

function nlPetContent(okAction, submitAsCaseAction, petDataHtml)
{
	this.okAction = okAction;
    this.submitAsCaseAction = submitAsCaseAction;
	this.petDataHtml = petDataHtml;
	
	if(this.petDataHtml)
		this.petDataNonHtml = petDataHtml.replace(/[\n\r]/g, ' ').replace(/<p>\s*<\/p>\s*|<p>\s*|<\/p>\s*/gi, '\n\n').replace(/<br>\s*|<\/div>\s*/gi, '\n')
							  .replace(/<[^>]tr>/g, '\n').replace(/<[^>]*>/g, '').replace(/&nbsp;/gi, ' ').replace(/[ \t\f\v]+/g, ' ');
	else
		this.petDataNonHtml = "";
	
	window['nlPetContent_instance'] = this;
}

function get_nlPetContent()
{
	return window['nlPetContent_instance'];
}

nlPetContent.prototype.getContent = function(contentTemplate)
{
	var content = contentTemplate;
    if (!content)
        content = PET_POPUP_SHELL;
	
	if (!this.okAction)
        this.okAction = "";
	
	 content = content.replace("<okaction/>", this.okAction);
	
	if (!this.submitAsCaseAction)
        this.submitAsCaseAction = "";
	
	content = content.replace("<submitascaseaction/>", this.submitAsCaseAction);
	
	if (!this.petDataHtml)
        this.petDataHtml = "";
	
	content = content.replace("<petdata/>", this.petDataHtml);
	
	if(!this.petDataNonHtml)
		this.petDataNonHtml = ""
	
	return content;
}

nlPetContent.prototype.submitAsCase = function nlPetContent_submitAsCase()
{
	
		return false;	
	
}

function nlShowProgress(message, title, action)
{
    var progressContent = new nlProgressContent(message, title, action);
    var popup = nlOpenPopup(window, S_POPUP_SIMPLE, progressContent, null, false, 400, 200, null, null, false, true);
    popup.resize(true, POPUP_LAYOUT_STYLE_DEFAULT);
    popup.setPosition();
}


function nlProgressContent (message, title, action)
{
    this.message = message;
    this.title = title;
    this.action = action;
}

nlProgressContent.prototype.getContent = function()
{
    var content = PROGRESS_POPUP_SHELL;
    if (typeof this.message != "undefined" && this.message != null)
        content = content.replace("<messagecontent/>", this.message);
    if (typeof this.title != "undefined" && this.title != null)
        content = content.replace("<messagetitle/>", this.title);

    var img = "<image src=\"/images/icons/progress/progress_waitBar.gif\" />";
    content = content.replace("<messageicon/>", img);

    if (typeof this.action != "undefined" && this.action != null)
        content = content.replace("<cancelaction/>", this.action);

    return content;
}

function nlShowSaveConf(message, title, style, okAction)
{
    var saveContent = new nlSaveContent(message, title, style, okAction);
    var popup = nlOpenPopup(window, S_POPUP_SIMPLE, saveContent, null, false, 400, 200, null, null, false, true);
    popup.resize(true, POPUP_LAYOUT_STYLE_DEFAULT);
    popup.setPosition();
    popup.display(true, 200);
}

function nlSaveContent (message, title, style, okAction)
{
    this.constructor(message, title, style);
    this.okAction = okAction;
}

nlSaveContent.prototype = new nlMessageContent;
nlSaveContent.prototype.getContent = function()
{
    var content = this.constructor.prototype.getContent.call(this,SAVE_POPUP_SHELL);
    if (!this.okAction)
        this.okAction = "";
    content = content.replace("<okaction/>", this.okAction);

    return content;
}

var MSG_POPUP_SHELL = "<TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">     <TBODY>         <TR>             <TD style=\"width:10; height:30\" colspan=2>                 <IMG width=\"10\" height=\"100%\" border=\"0\" src=\"/images/icons/popup/pdiv_header_l.gif\"/>             </TD>             <TD style=\"height:30\">                 <TABLE width=\"100%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" >                     <TBODY>                         <TR>          <TD valign=\"middle\" nowrap=\"\" style=\"padding-left: 2px; background-image: url(/images/icons/popup/pdiv_header_bg.gif);\">         </TD>         <TD align=\"center\" nowrap=\"\" class=\"smalltextb\" style=\"padding-right: 1px; background-image: url(/images/icons/popup/pdiv_header_bg.gif);\">         <FONT color=\"#000000\"><messagetitle/></FONT>         </TD>                         </TR>                     </TBODY>                 </TABLE>             </TD>             <TD style=\"width:10;height:30\" colspan=2>                 <IMG width=\"10\" height=\"100%\" border=\"0\" src=\"/images/icons/popup/pdiv_header_r.gif\"/>             </TD>         </TR>         <TR style=\"background:#ffffff\">             <TD width=1 bgcolor=\"#999999\"><img src=\"/images/nav/ns_x.gif\" width=1 height=1 alt=\"\"></TD>            <TD width=9 bgcolor=\"#FFFFFF\" style=\"background-image: url(/images/icons/popup/pdiv_b_gradient.gif); background-repeat: repeat-x; background-position: bottom;\"><img src=\"/images/nav/ns_x.gif\" width=9 height=1 alt=\"\"/></TD>             <TD width=100% align=\"center\" style=\"background-image:url(/images/icons/popup/pdiv_b_gradient.gif); background-position:bottom; background-repeat:repeat-x\">  ";
var CONFIRM_POPUP_SHELL = "<TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">     <TBODY>         <TR>             <TD style=\"width:10; height:30\" colspan=2>                 <IMG width=\"10\" height=\"100%\" border=\"0\" src=\"/images/icons/popup/pdiv_header_l.gif\"/>             </TD>             <TD style=\"height:30\">                 <TABLE width=\"100%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" >                     <TBODY>                         <TR>          <TD valign=\"middle\" nowrap=\"\" style=\"padding-left: 2px; background-image: url(/images/icons/popup/pdiv_header_bg.gif);\">         </TD>         <TD align=\"center\" nowrap=\"\" class=\"smalltextb\" style=\"padding-right: 1px; background-image: url(/images/icons/popup/pdiv_header_bg.gif);\">         <FONT color=\"#000000\"><messagetitle/></FONT>         </TD>                         </TR>                     </TBODY>                 </TABLE>             </TD>             <TD style=\"width:10;height:30\" colspan=2>                 <IMG width=\"10\" height=\"100%\" border=\"0\" src=\"/images/icons/popup/pdiv_header_r.gif\"/>             </TD>         </TR>         <TR style=\"background:#ffffff\">             <TD width=1 bgcolor=\"#999999\"><img src=\"/images/nav/ns_x.gif\" width=1 height=1 alt=\"\"></TD>            <TD width=9 bgcolor=\"#FFFFFF\" style=\"background-image: url(/images/icons/popup/pdiv_b_gradient.gif); background-repeat: repeat-x; background-position: bottom;\"><img src=\"/images/nav/ns_x.gif\" width=9 height=1 alt=\"\"/></TD>             <TD width=100% align=\"center\" style=\"background-image:url(/images/icons/popup/pdiv_b_gradient.gif); background-position:bottom; background-repeat:repeat-x\">  ";
var PROGRESS_POPUP_SHELL = "<TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">     <TBODY>         <TR>             <TD style=\"width:10; height:30\" colspan=2>                 <IMG width=\"10\" height=\"100%\" border=\"0\" src=\"/images/icons/popup/pdiv_header_l.gif\"/>             </TD>             <TD style=\"height:30\">                 <TABLE width=\"100%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" >                     <TBODY>                         <TR>          <TD valign=\"middle\" nowrap=\"\" style=\"padding-left: 2px; background-image: url(/images/icons/popup/pdiv_header_bg.gif);\">         </TD>         <TD align=\"center\" nowrap=\"\" class=\"smalltextb\" style=\"padding-right: 1px; background-image: url(/images/icons/popup/pdiv_header_bg.gif);\">         <FONT color=\"#000000\"><messagetitle/></FONT>         </TD>                         </TR>                     </TBODY>                 </TABLE>             </TD>             <TD style=\"width:10;height:30\" colspan=2>                 <IMG width=\"10\" height=\"100%\" border=\"0\" src=\"/images/icons/popup/pdiv_header_r.gif\"/>             </TD>         </TR>         <TR style=\"background:#ffffff\">             <TD width=1 bgcolor=\"#999999\"><img src=\"/images/nav/ns_x.gif\" width=1 height=1 alt=\"\"></TD>            <TD width=9 bgcolor=\"#FFFFFF\" style=\"background-image: url(/images/icons/popup/pdiv_b_gradient.gif); background-repeat: repeat-x; background-position: bottom;\"><img src=\"/images/nav/ns_x.gif\" width=9 height=1 alt=\"\"/></TD>             <TD width=100% align=\"center\" style=\"background-image:url(/images/icons/popup/pdiv_b_gradient.gif); background-position:bottom; background-repeat:repeat-x\">  ";
var TOOLTIP_POPUP_SHELL = "<table cellSpacing=\"0\" cellPadding=\"0\" width=\"250\" border=\"0\">   <tr>     <td colSpan=\"2\"><IMG height=\"5\" alt=\"\" src=\"/images/icons/popup/balloon/wb_ul.png\" width=\"5\" border=\"0\" /></td>     <td width=\"100%\" background=\"/images/icons/popup/balloon/wb_t.png\"><IMG height=\"5\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"1\" /></td>     <td colSpan=\"2\"><IMG height=\"5\" alt=\"\" src=\"/images/icons/popup/balloon/wb_ur.png\" width=\"5\" border=\"0\" /></td>   </tr>   <tr>     <td width=\"3\" background=\"/images/icons/popup/balloon/wb_l.png\"><IMG height=\"1\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"3\" /></td>     <td style=\"background-image: url(/images/icons/popup/balloon/wb_bg.png)\" width=\"2\"><IMG height=\"1\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"2\" /></td>     <td style=\"background-image: url(/images/icons/popup/balloon/wb_bg.png)\" width=\"100%\">       <table cellSpacing=\"0\" cellPadding=\"3\" border=\"0\">         <tr>           <td valign=\'top\'>             <messageicon/>           </td>           <td>             <div><messagetitle/></div>             <div>               <div style=\"background-position: center center; background-image: url(/images/icons/popup/balloon/wb_divider.png); background-REPEAT: repeat-x\"><img height=\"2\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"1\" vspace=\"3\" /></div>               <messagecontent/>             </div>           </td>         </tr>       </table>     </td>     <td style=\"background-image: url(/images/icons/popup/balloon/wb_bg.png)\" width=\"2\"><IMG height=\"1\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"2\" /></td>     <td width=\"3\" background=\"/images/icons/popup/balloon/wb_r.png\"><IMG height=\"1\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"3\" /></td>   </tr>   <tr>     <td colSpan=\"2\"><img height=\"5\" alt=\"\" src=\"/images/icons/popup/balloon/wb_ll.png\" width=\"5\" border=\"0\" /></td>     <td width=\"100%\" background=\"/images/icons/popup/balloon/wb_b.png\"><img height=\"5\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"1\" /></td>     <td colSpan=\"2\"><img height=\"5\" alt=\"\" src=\"/images/icons/popup/balloon/wb_lr.png\" width=\"5\" border=\"0\" /></td>   </tr> </table> ";
var MESSAGE_TOOLTIP_POPUP_SHELL = "<table cellSpacing=\"0\" cellPadding=\"0\" width=\"125\" border=\"0\">   <tr>     <td colSpan=\"2\"><IMG height=\"5\" alt=\"\" src=\"/images/icons/popup/balloon/wb_ul.png\" width=\"5\" border=\"0\" /></td>     <td width=\"100%\" background=\"/images/icons/popup/balloon/wb_t.png\"><IMG height=\"5\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"1\" /></td>     <td colSpan=\"2\"><IMG height=\"5\" alt=\"\" src=\"/images/icons/popup/balloon/wb_ur.png\" width=\"5\" border=\"0\" /></td>   </tr>   <tr>     <td width=\"3\" background=\"/images/icons/popup/balloon/wb_l.png\"><IMG height=\"1\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"3\" /></td>     <td style=\"background-image: url(/images/icons/popup/balloon/wb_bg.png)\" width=\"2\"><IMG height=\"1\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"2\" /></td>     <td style=\"background-image: url(/images/icons/popup/balloon/wb_bg.png)\" width=\"100%\">       <table cellSpacing=\"0\" cellPadding=\"3\" border=\"0\">         <tr>           <td>               <messagecontent/>           </td>         </tr>       </table>     </td>     <td style=\"background-image: url(/images/icons/popup/balloon/wb_bg.png)\" width=\"2\"><IMG height=\"1\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"2\" /></td>     <td width=\"3\" background=\"/images/icons/popup/balloon/wb_r.png\"><IMG height=\"1\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"3\" /></td>   </tr>   <tr>     <td colSpan=\"2\"><img height=\"5\" alt=\"\" src=\"/images/icons/popup/balloon/wb_ll.png\" width=\"5\" border=\"0\" /></td>     <td width=\"100%\" background=\"/images/icons/popup/balloon/wb_b.png\"><img height=\"5\" alt=\"\" src=\"/images/nav/ns_x.gif\" width=\"1\" /></td>     <td colSpan=\"2\"><img height=\"5\" alt=\"\" src=\"/images/icons/popup/balloon/wb_lr.png\" width=\"5\" border=\"0\" /></td>   </tr> </table> ";
var PET_POPUP_SHELL = "<TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">     <TBODY>         <TR>             <TD style=\"width:10; height:30\" colspan=2>                 <IMG width=\"10\" height=\"100%\" border=\"0\" src=\"/images/icons/popup/pdiv_header_l.gif\"/>             </TD>             <TD style=\"height:30\">                 <TABLE width=\"100%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" >                     <TBODY>                         <TR>          <TD valign=\"middle\" nowrap=\"\" style=\"padding-left: 2px; background-image: url(/images/icons/popup/pdiv_header_bg.gif);\">         <IMG border=\"0\" src=\"/images/icons/nps/netsuite.gif\" style=\"height:20px\"/>         </TD>         <TD align=\"center\" nowrap=\"\" class=\"smalltextb\" style=\"padding-right: 1px; background-image: url(/images/icons/popup/pdiv_header_bg.gif);\">         </TD>                         </TR>                     </TBODY>                 </TABLE>             </TD>             <TD style=\"width:10;height:30\" colspan=2>                 <IMG width=\"10\" height=\"100%\" border=\"0\" src=\"/images/icons/popup/pdiv_header_r.gif\"/>             </TD>         </TR>         <TR style=\"background:#ffffff\">             <TD width=1 bgcolor=\"#999999\"><img src=\"/images/nav/ns_x.gif\" width=1 height=1 alt=\"\"></TD>            <TD width=9 bgcolor=\"#FFFFFF\" style=\"background-image: url(/images/icons/popup/pdiv_b_gradient.gif); background-repeat: repeat-x; background-position: bottom;\"><img src=\"/images/nav/ns_x.gif\" width=9 height=1 alt=\"\"/></TD>             <TD width=100% align=\"center\" style=\"background-image:url(/images/icons/popup/pdiv_b_gradient.gif); background-position:bottom; background-repeat:repeat-x\">  ";
var SAVE_POPUP_SHELL = "<TABLE width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">     <TBODY>         <TR>             <TD style=\"width:10; height:30\" colspan=2>                 <IMG width=\"10\" height=\"100%\" border=\"0\" src=\"/images/icons/popup/pdiv_header_l.gif\"/>             </TD>             <TD style=\"height:30\">                 <TABLE width=\"100%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" >                     <TBODY>                         <TR>          <TD valign=\"middle\" nowrap=\"\" style=\"padding-left: 2px; background-image: url(/images/icons/popup/pdiv_header_bg.gif);\">         </TD>         <TD align=\"center\" nowrap=\"\" class=\"smalltextb\" style=\"padding-right: 1px; background-image: url(/images/icons/popup/pdiv_header_bg.gif);\">         <FONT color=\"#000000\"><messagetitle/></FONT>         </TD>                         </TR>                     </TBODY>                 </TABLE>             </TD>             <TD style=\"width:10;height:30\" colspan=2>                 <IMG width=\"10\" height=\"100%\" border=\"0\" src=\"/images/icons/popup/pdiv_header_r.gif\"/>             </TD>         </TR>         <TR style=\"background:#ffffff\">             <TD width=1 bgcolor=\"#999999\"><img src=\"/images/nav/ns_x.gif\" width=1 height=1 alt=\"\"></TD>            <TD width=9 bgcolor=\"#FFFFFF\" style=\"background-image: url(/images/icons/popup/pdiv_b_gradient.gif); background-repeat: repeat-x; background-position: bottom;\"><img src=\"/images/nav/ns_x.gif\" width=9 height=1 alt=\"\"/></TD>             <TD width=100% align=\"center\" style=\"background-image:url(/images/icons/popup/pdiv_b_gradient.gif); background-position:bottom; background-repeat:repeat-x\">  ";

function preload(data)
{

    if (typeof document.body == "undefined")
    {
        if (document.all)
            window.attachEvent("onload", preload(data).bind(this));
        else
        {
            window.addEventListener("load", preload(data).bind(this));
        }
    }
    else
    {
        var div = document.createElement("div");
        div.style.position="absolute";
        div.style.visibility="hidden";
        document.body.appendChild(div);
        div.innerText = data;
        this.div = div;
    }
    return this;
}

preload.prototype.getData = function preload_getData()
{
    return this.div.innerText;
}


function nlShowTooltip(mouseX, mouseY, triggerObj, title, icon, detail, timeout)
{
    var tooltipContent = new nlTooltipContent(title, icon, detail);
    var popup = nlOpenPopup(window, S_POPUP_SIMPLE, tooltipContent, triggerObj, false, 20, 10, null, null, null, false, false);
    popup.resize(true, POPUP_LAYOUT_STYLE_DEFAULT);
    var left = mouseX;
    var top = mouseY;
    if (mouseX && mouseY)
    {
        left += 10;
        top += 10;
    }
    popup.setPosition(left, top);
    popup.display(true, 200);

    
    if (popup.autoCloseTimer)
        clearTimeout(popup.autoCloseTimer)

	if (!timeout)
	{
		timeout = 5000;
	}
	popup.autoCloseTimer = setTimeout(function(){this.close();}.bind(popup), timeout);
    return popup;

}

function nlTooltipContent (title, icon, detail)
{
    this.title = title;
    this.icon = icon;
    this.detail = detail;
}

nlTooltipContent.prototype.getContent = function()
{
    var content = TOOLTIP_POPUP_SHELL;
    if (typeof this.title != "undefined" && this.title != null)
        content = content.replace("<messagetitle/>", this.title);
    if (typeof this.detail != "undefined" && this.detail != null)
        content = content.replace("<messagecontent/>", this.detail);
    if (typeof this.icon != "undefined" && this.icon != null)
        content = content.replace("<messageicon/>", this.icon);

    return content;
}

function nlShowMessageTooltip(triggerObj, message)
{
    var title = null;
	var icon = null;
	var detail = message;
	var timeout = null;

	// Make sure that the button is disabled.
	if (!triggerObj.disabled)
		return;

    var tooltipContent = new nlMessageTooltipContent(message);
    var popup = nlOpenPopup(window, S_POPUP_SIMPLE, tooltipContent, triggerObj, false, 20, 10, null, null, null, false, false);
    popup.resize(true, POPUP_LAYOUT_STYLE_DEFAULT);
    var left = findGlobalPosX(triggerObj);
    var top = findGlobalPosY(triggerObj);
	top += 30;

    popup.setPosition(left, top);
	popup.display(true, 200);

    
    if (popup.autoCloseTimer)
        clearTimeout(popup.autoCloseTimer)

    return popup;

}

function nlMessageTooltipContent (message)
{
    this.message = message;
}
nlMessageTooltipContent.prototype.getContent = function()
{
    var content = MESSAGE_TOOLTIP_POPUP_SHELL;
    if (typeof this.message != "undefined" && this.message != null)
        content = content.replace("<messagecontent/>", this.message);

    return content;
}


// </script>

