// ************************************* DIALOG OBJECT ****************************************************
// This is the base class for dialog bones.  A dialog represents a "mini-window".  This bone is a super class
// for the editor bone which allows users to edit some other component on the page.
// Examples: object browser, sort dialog.
// ********************************************************************************************************
//<script>

microstrategy.HTMLATTR_SIZES = "SIZES";
microstrategy.HTMLATTR_SIZES_DELIM = ",";
microstrategy.HTMLATTR_DRAG_DISABLED = 0;
microstrategy.HTMLATTR_DRAG_ENABLED = 1;

// properties
mstrDialogImpl.prototype = new mstrBoneImpl();
mstrDialogImpl.prototype.titleBar = null;
mstrDialogImpl.prototype.topPosition = null;
mstrDialogImpl.prototype.leftPosition = null;
mstrDialogImpl.prototype.rect = null;
mstrDialogImpl.prototype.isMidDrag = false;
mstrDialogImpl.prototype.closeAfterDrag = false;
mstrDialogImpl.prototype.afterresize = null;
mstrDialogImpl.prototype.errorMessage = null;
mstrDialogImpl.prototype.resizeHorizontally = false;
mstrDialogImpl.prototype.resizeVertically = false;
mstrDialogImpl.prototype.focusFieldId = null;
mstrDialogImpl.prototype.onselectstartFn = null;

// events
mstrDialogImpl.prototype.onload = function() {
    //@class=mstrDialogImpl;@method=onload;
    try {
        this.initDialog();
        this.initErrorMessage();
        
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.initDialog = function() {
    //@class=mstrDialogImpl;@method=initDialog;
    try {
        this.initBone();
        this.isDraggable = ((parseInt(this.elem.getAttribute('dg')) & 1) != 0);
        this.initTitleBar();
        this.initBody();
        this.initStatusBar();
        this.addListeners();
        this.setFocus();
	    /*if ( this.errorMessage ) {
			this.renderErrorMessage();
	    }*/
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.addListeners = function() {
	if(typeof(mstr) != 'undefined'){
		this.attachWinListener(this, 'resize', 'onresize');
	}
	else {
		document.onresize = new Function("e", "return microstrategy.bone('" + this.id + "').onresize(e);");
	}
}
mstrDialogImpl.prototype.initErrorMessage = function() {
    //@class=mstrDialogImpl;@method=initErrorMessage;
    try {
	    if ( this.errorMessage ) {
			this.renderErrorMessage();
	    }
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.initResize = function() {
    //@class=mstrDialogImpl;@method=initDialog;
    try {
    	if(this.elem){
    		this.resizeLevel = parseInt(this.elem.getAttribute(microstrategy.HTMLATTR_RESIZE));
    		if (this.resizeLevel && !isNaN(this.resizeLevel)) {
    			if (this.resizeLevel & microstrategy.RESIZE_VERTICAL) this.resizeVertically = true;
    			if (this.resizeLevel & microstrategy.RESIZE_HORIZONTAL) this.resizeHorizontally = true;
    		}
        	if (this.resizeVertically || this.resizeHorizontally) {
            	this.initResizeHandles();
	            this.moveResizeHandles();
    	    }
        }
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.renderErrorMessage = function() {
    //@class=mstrDialogImpl;@method=renderErrorMessage;
    try {
	    showMessage({contents:this.errorMessage, elements:microstrategy.OK_BUTTON, okEval:"microstrategy.bone('" + this.id + "').onCloseErrorMessage()", type:mstrMsgBoxImpl.MSG_ERROR});
	}
    catch(err) {
        microstrategy.errors.log(err);
    }
}

mstrDialogImpl.prototype.onCloseErrorMessage = function() {
    //@class=mstrDialogImpl;@method=onCloseErrorMessage;
    try {
         this.setFocus();
    }
    catch(err) {
        microstrategy.errors.log(err);
    }
}

mstrDialogImpl.prototype.initTitleBar = function() {
    //@class=mstrDialogImpl;@method=initTitleBar;
    try {
        if (this.elem) {
            this.titleBar = microstrategy.subObjectFind(this.elem, ["DIV","TD","TR"], microstrategy.SUBOBJTYPE_TITLEBAR);
            if (this.titleBar) {
                var isDraggable = this.elem.getAttribute(microstrategy.HTMLATTR_DRAG);
                isDraggable = (!isNaN(parseInt(isDraggable))) ? parseInt(isDraggable) : microstrategy.HTMLATTR_DRAG_DISABLED;
                if (isDraggable & microstrategy.HTMLATTR_DRAG_ENABLED) {
                    this.titleBar.onmousedown = new Function("e", "return microstrategy.bone('" + this.id + "').ondragdialogmousedown(e);");
                 
                 	//Issue 353684: This breaks multi select on the Object Browser. So, rolling back the changes.
//                    //enable browser select editor text by default
//                	if (bIsIE6) document.onselectstart = function(){return true;}
                }
            }
        }
        return true;
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.closeDialog = function() {
    //@class=mstrDialogImpl;@method=closeDialog;
    try {
        if (this.isMidDrag) {
            this.closeAfterDrag = true;
            return;
        }
        this.closeAfterDrag = false;
        var start = 2;
        //start = parseInt(this.elem.getAttribute("op"));
        //if (isNaN(start) || start < 1) start = 100; */
        this.fadeOut(start);

    }
    catch(err) {
        microstrategy.errors.log(err);
    }
}

mstrDialogImpl.prototype.fadeOut = function(i) {
    //@class=mstrDialogImpl;@method=fadeOut;
    try {
        i  = i - 2;
    //remove use of style.filter to avoid ActiveX dependency
        //this.elem.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + i + ")";
        //if (i > 0) {
        if (false) {
            window.setTimeout("microstrategy.bone('" + this.id + "').fadeOut(" + i + ")", 0);
        } else {
            this.elem.style.visibility = "hidden";
            togglePulldowns(this.elem, true);
            var end = parseInt(this.elem.getAttribute("op"));
            end = 90;
            if (isNaN(end) || end < 1) end = 100;
            //this.elem.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + end + ")";
        }
    }
    catch(err) {
        microstrategy.errors.log(err);
    }
}

// ************************ //
// ***** DRAG FEATURE ***** //
// ************************ //

mstrDialogImpl.prototype.ondragdialogmousedown = function (e) {
    //@class=mstrDialogImpl;@method=ondragdialogmousedown;
    try{
    	//save here,will restore when mouseup
    	this.onselectstartFn = document.onselectstart;
    	
        if (!e) e = window.event;
        var src = getEventTarget(e);
        if (src.tagName == 'IMG') return false;

    	//#339335 : disable text selection while dragging editor
    	document.onselectstart = function() {return false;}

        this.rect = getElementById(this.id + "_dg");
        if (this.rect == null) {
            var dragNode = document.createElement('div');
            dragNode.id = this.id + "_dg";
            dragNode.className = 'dragRect';
            this.elem.appendChild(dragNode);
            this.rect = dragNode;
        }
        if (typeof(mstr) != 'undefined') {
            this.attachWinListener(this, 'mousemove', 'ondragdialogstart');
            this.attachWinListener(this, 'mouseup', 'onmouseup');

        } else {
            document.onmousemove = new Function("e", "return microstrategy.bone('" + this.id + "').ondragdialogstart(e);");
            document.onmouseup = new Function("e", "return microstrategy.bone('" + this.id + "').onmouseup(e);");
        }

    } catch (err) {
    	this.hideDragVisualCue();
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.ondragdialogstart = function(e) {
    //@class=mstrDialogImpl;@method=ondragdialogstart;
    try {
    	if (!e) e = window.event;
        if (e.e) e = e.e;
        //check it has been initialized properly
        var failed = false;
        if (this.rect) {
		    //set event handlers
            if (typeof(mstr) != 'undefined') {
                this.attachWinListener(this, 'mousemove', 'ondragdialog');
                this.attachWinListener(this, 'mouseup', 'ondragdialogend');
            } else {
              document.onmousemove = new Function("e", "return microstrategy.bone('" + this.id + "').ondragdialog(e);");
		      document.onmouseup = new Function("e", "return microstrategy.bone('" + this.id + "').ondragdialogend(e);");
            }
		    this.isMidDrag = true;
		    this.rect.style.display = 'block';
		    this.rect.style.visibility = 'visible';

	        //notify drag feature for any visual cues
		    getMouse(e);
		    var parent = microstrategy.findAncestor(getEventTarget(e));

	        if (parent != null) {
    	    	this.leftPosition = lMouseX;
	        	this.topPosition = lMouseY;
	        	if (this.rect) {
	        		this.rect.style.width = getObjWidth(this.elem) + 'px';
	        		this.rect.style.height = getObjHeight(this.elem) + 'px';
	        		//this.rect.style.display = 'block';
	        	}
	        	this.ondragdialog(e);
	        } else {
                failed = true;
	        }
        } else {
            failed = true;
        }

        if (failed) {
        	this.hideDragVisualCue();
	        this.isMidDrag = false;
	        this.onmouseup(e);
        }
        return false;
    }
    catch(err) {
		this.hideDragVisualCue();
        this.isMidDrag = false;
        this.onmouseup(e);
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.ondragdialogend = function(e) {
    //@class=mstrDialogImpl;@method=ondragdialogend;
    try {
        this.isMidDrag = false;
        //set event handlers
        if (!e) e = window.event;
        if (e.e) e = e.e;
        this.onmouseup(e);

        getMouse(e);
		// show combo boxes behind old position of dialog
		togglePulldowns(this.elem, true);

		// move dialog
		if (this.rect != null) {
		    var newX = getObjSumLeft(this.rect);
		    var newY = getObjSumTop(this.rect);
		    // minimum accepted values ...
		    if (newX<0) newX=1;
		    if (newY<0) newY=1;

		    this.move(newX, newY);
		    // hide visual cue and combo boxes behind new position of dialog
			this.hideDragVisualCue();
	    }

		if (this.closeAfterDrag) this.closeDialog();
		return false;
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

/**
 * Finds and resizes the popup mask for the given element to match the dimensions and position of the element.
 * @param {HTMLElement} elem The HTMLElement whose mask should be resized.
 */
mstrDialogImpl.prototype.resizePopUp = function resizePopUp(elem) {
	//@class=mstrDialogImpl;@method=resizePopUp;
	try {
		if (elem) {
			var popupMask = elem.getAttribute("popupMask");
			if (popupMask && popupMask.style) {
				var w = getObjWidth(elem);
				w = w ||getObjInnerWidth(elem);

				var h = getObjHeight(elem);
				h = h || getObjInnerHeight(elem);

				popupMask.style.width = w + "px";
				popupMask.style.height = h + "px";
			}
		}
	} catch(err) {
		microstrategy.errors.log(err);
	}
}


mstrDialogImpl.prototype.onresize = function(e) {
	this.resizePopUp(this.elem);
}

mstrDialogImpl.prototype.hideDragVisualCue = function() {
    //@class=mstrDialogImpl;@method=hideDragVisualCue;
    try {
        if (this.rect) {
		    this.rect.style.visibility = "hidden";
		    this.rect.style.display = "none";
        }
        return false;
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.ondragdialog = function(e) {
    //@class=mstrDialogImpl;@method=ondragdialog;
    try {
    	if (!e) e = window.event;
        if (e.e) e = e.e;
        getMouse(e);
        moveObjTo(this.rect, lMouseX - this.leftPosition, lMouseY - this.topPosition);
    }
    catch(err) {
        microstrategy.errors.log(err);
    }
    return false;
}

mstrDialogImpl.prototype.move = function(newX, newY) {
    //@class=mstrDialogImpl;@method=move;
    try {
        if (this.moveTo(newX, newY)) {
            // If move was successful than save new position
            var um = microstrategy.updateManager;
            // For security, do not submit event if the bean path is not available.
            if (um && this.beanPath){
                var ac = [];
                ac.push(
                    um.createActionObject(this.elem, mstrUpdateManager.SET_TOPLEFT_POSITION,
                      this.beanPath,
                      ["73001", "73002"],
                      [getObjTop(this.elem), getObjLeft(this.elem)],
                      []));
                um.add(ac, true);
            }
        }
    } catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.moveTo = function(newX, newY) {
    //@class=mstrDialogImpl;@method=moveTo;
    try {
        newX = Math.floor(newX);
        newY = Math.floor(newY);

        if (newX != getObjLeft(this.elem) || newY != getObjTop(this.elem) || newX == 0 || newY == 0) {
            moveObjTo(this.elem, newX, newY);
        }

        //We need to execute these functions whether or not given
        //editor is moved. Pull-down menus could be displayed in Editor.
        togglePulldowns(this.elem, false);

        return true;

    } catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}
// ************************ //
// **** INIT COMPONENT **** //
// ************************ //

mstrDialogImpl.prototype.initBody = function() {
    //@class=mstrDialogImpl;@method=initBody;
    try {
        if (this.elem)
            this.body = microstrategy.subObjectFind(this.elem, ['DIV','TD'], microstrategy.SUBOBJTYPE_BODY);
        return true;
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.initStatusBar = function() {
    //@class=mstrDialogImpl;@method=initStatusBar;
    try {
        if (this.elem)
            this.statusBar = microstrategy.subObjectFind(this.elem, ['DIV'], microstrategy.SUBOBJTYPE_STATUSBAR);
        return true;
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

//moves the images when the components resize
mstrDialogImpl.prototype.onCellResize = function(){
    this.moveResizeHandles();
}

//add images to the resizable Dialog at the right and bottom borders
mstrDialogImpl.prototype.initResizeHandles= function (){
    //@class=mstrDialogImpl;@method=initResizeHandles;
    try {
    	//create handler image if it is not created
    	if(!this.resizeBottom) {
            this.resizeBottom = document.createElement("img");
            this.resizeBottom.src = microstrategy.FOLDER_IMAGES + "1ptrans.gif";
            this.resizeBottom.style.position = "absolute";

            this.resizeBottom.style.height = "3px";
            this.resizeBottom.style.width = "3px";
    	    if (!bIsIE4 && bIsW3C) {
    	    	this.resizeBottom.style.display = 'none';	//for Netscape 7 repaint issue
    	    }

            if (this.resizeVertically) {
                this.resizeBottom.style.cursor = "n-resize";
                this.resizeBottom.onmousedown = new Function("e", "return microstrategy.bone('" + this.id + "').onDialogResizeDown(e);");
            }
            this.elem.appendChild(this.resizeBottom);
    	}    
        
    	//create handler image if it is not created
    	if(!this.resizeRight) {
            this.resizeRight = this.resizeBottom.cloneNode(true);
            this.resizeRight.style.width = "3px";
            this.resizeRight.style.top = "0px";
            
            if (this.resizeHorizontally) {
                this.resizeRight.style.cursor = "e-resize";
                this.resizeRight.onmousedown = new Function("e", "return microstrategy.bone('" + this.id + "').onDialogResizeDown(e);");
            }
                
            this.elem.appendChild(this.resizeRight);
    	}
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}
mstrDialogImpl.prototype.moveResizeHandles= function (){
    //@class=mstrDialogImpl;@method=moveResizeHandles;
    try {
        if (this.resizeBottom == null) {
            return false;
        }
        var cWidth = (this.elem.style != null && this.elem.style.width != null && this.elem.style.width.length > 0 && parseInt(this.elem.style.width)==getObjWidth(this.elem)) ? parseInt(this.elem.style.width) : getObjWidth(this.elem);
        var cHeight = (this.elem.style != null && this.elem.style.height != null && this.elem.style.height.length > 0 && parseInt(this.elem.style.height)==getObjHeight(this.elem)) ? parseInt(this.elem.style.height) : getObjHeight(this.elem);

        with (this.resizeBottom.style) {
        	width = cWidth + "px";
        	top = (cHeight - 3) + "px";
        	left = "0px";
        }

        with (this.resizeRight.style) {
        	height = cHeight + "px";
        	left = (cWidth - 3) + "px";
            top = "0px";
        }

	    //for Netscape 7 repaint issue
	    if (!bIsIE4 && bIsW3C) {
	        this.resizeBottom.style.display = "block";
	        this.resizeRight.style.display = "block";
	    }
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.onDialogResizeDown= function (e){
    //@class=mstrDialogImpl;@method=onDialogResizeDown;
    try {
        if (!e) e = window.event;
        getMouse(e);
        this.resizeX = lMouseX;
        this.resizeY= lMouseY;
        this.resizeHandler = getEventTarget(e);

        if (typeof(mstr) != 'undefined'){
            this.attachWinListener(this, 'mousemove', 'onDialogResizeStart');
            this.attachWinListener(this, 'mouseup', 'onmouseup');
        } else {
            document.onmousemove = new Function("e", "return microstrategy.bone('" + this.id + "').onDialogResizeStart(e);");
            document.onmouseup = new Function("e", "return microstrategy.bone('" + this.id + "').onmouseup(e);");
        }
        return false;
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.onDialogResizeStart= function (e){
    //@class=mstrDialogImpl;@method=onDialogResizeStart;
    try {
        if (!e) e = window.event;
        if (e.e) e = e.e;
    
        document.body.style.cursor = this.resizeHandler.style.cursor;
        this.resizeRight.onmouseout = null;

        this.tempHandler = document.createElement("img");
        this.tempHandler.src = microstrategy.FOLDER_IMAGES + "1ptrans.gif";
        this.tempHandler.style.position = "absolute";
        this.tempHandler.style.zIndex = 10000;
        this.tempHandler.style.backgroundColor = "#ffff00";

        if (this.resizeHandler.style.cursor.toLowerCase() == "e-resize"){
           //create a img showing with the dragging movement
           this.tempHandler.style.left = getObjSumLeft(this.resizeRight);
           this.tempHandler.style.top = getObjSumTop(this.resizeRight);
           this.tempHandler.style.width = "3px";
           this.tempHandler.style.height = this.resizeRight.style.height;
        }
        else if(this.resizeHandler.style.cursor.toLowerCase() == "n-resize"){//position at the bottom
           this.tempHandler.style.left = getObjSumLeft(this.resizeBottom);
           this.tempHandler.style.top = getObjSumTop(this.resizeBottom);
           this.tempHandler.style.width= this.resizeBottom.style.width;
           this.tempHandler.style.height = "3px";
        }

        document.body.appendChild(this.tempHandler);

        // TODO: ie6 only
        if (this.resizeVertically) {
            this.resizeBottom.style.cursor = "n-resize";
            this.resizeBottom.style.height = "3px";
        }
        if (typeof(mstr) != 'undefined') {
            this.attachWinListener(this, 'mousemove', 'onDialogResize');
            this.attachWinListener(this, 'mouseup', 'onDialogResizeEnd');
        } else {
            document.onmousemove = new Function("e","return microstrategy.bone('" + this.id + "').onDialogResize(e);");
            document.onmouseup = new Function("e", "return microstrategy.bone('" + this.id + "').onDialogResizeEnd(e);");
        }
        this.onDialogResize(e);
        return false;
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.onDialogResize = function(e){
    //@class=mstrDialogImpl;@method=onDialogResize;
    try {
        if (!e) e = window.event;
        if (e.e) e = e.e;
    
        getMouse(e);
        if(this.elem == null)
             return false;
        this.resizeBottom.style.zIndex = -200;
        this.resizeRight.style.zIndex= -200;

        var oLeft = getObjSumLeft(this.elem);
        var oTop = getObjSumTop(this.elem);
        var deltaX = lMouseX-this.resizeX;
        var deltaY = lMouseY-this.resizeY;
        var minSize = 135; //70;

        if (this.resizeHandler.style.cursor.toLowerCase() == "e-resize"){
        	if (lMouseX<(oLeft+minSize)){
                //deltaX = minSize - getObjWidth(this.resizeBottom); //this calculation is wrong...
        		deltaX = minSize - getObjLeft(this.resizeHandler);
                this.resizeBottom.style.width = minSize + "px";
            } else {
            	var w = getObjWidth(this.resizeBottom)+ deltaX;
            	if(w < 0) return false;
                this.resizeBottom.style.width = w;
            }
            moveObjTo(this.resizeHandler, getObjLeft(this.resizeHandler)+deltaX, getObjTop(this.resizeHandler));
            moveObjTo(this.tempHandler, getObjSumLeft(this.resizeHandler)+deltaX, getObjSumTop(this.resizeHandler));

        } else if (this.resizeHandler.style.cursor.toLowerCase() == "n-resize"){
            if(lMouseY < (oTop + minSize)){
                deltaY = minSize-getObjHeight(this.resizeRight);
                this.resizeRight.style.height = minSize + "px";
            } else {
            	var h = getObjHeight(this.resizeRight)+ deltaY;
            	if(h < 0) return false;
                this.resizeRight.style.height = h;
            }
            moveObjTo(this.resizeHandler, getObjLeft(this.resizeHandler), getObjTop(this.resizeHandler)+deltaY);
            moveObjTo(this.tempHandler, getObjSumLeft(this.resizeHandler), getObjSumTop(this.resizeHandler)+deltaY);
        }

        this.resizeX = lMouseX;
        this.resizeY = lMouseY;

        return false;
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.onDialogResizeEnd = function(e){
    //@class=mstrDialogImpl;@method=onDialogResizeEnd;
    try {
        if (!e) e = window.event;
        if (e && e.e) e = e.e;  
        this.onmouseup(e);

        this.elem.style.width = (getObjLeft(this.resizeRight)+2) + 'px';	//added 'px', for Netscape & Firefox support
        this.resizeRight.style.zIndex= 1;
        if (this.resizeVertically) {
	        if (this.elem.style.height!=(getObjHeight(this.elem)+'px')) {
	            this.elem.style.height = (getObjTop(this.resizeBottom)-SCROLLBAR_SIZE) + 'px';
	        }
	        else {
	            this.elem.style.height = (getObjTop(this.resizeBottom)+2) + 'px';	//added 'px', for Netscape & Firefox support
	        }
        }
        this.resizeBottom.style.zIndex = 1;
        if (this.mask) this.mask.onmaskedobjectresize();
        this.resizeHandler.style.backgroundColor = "";
        //store the value at the user's preference
        var updateManager = this.updateManager;
        var actionCollection = [];
        var DialogName = this.id;
        var DialogWidth = getObjWidth(this.elem);
//        var DialogHeight = getObjHeight(this.elem);
        var DialogHeight = this.elem.style.height;

        document.body.style.cursor = "auto";
        document.body.removeChild(this.tempHandler);

        microstrategy.eventManager.ondialogresize();
        if (this.afterresize) this.afterresize();
        return false;
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}


mstrDialogImpl.prototype.onmouseup = function(e,path){
    //@class=mstrDialogImpl;@method=onmouseup;
    try {
    	//#378295- enable/restore text selection
    	document.onselectstart = this.onselectstartFn;
    	
        if (typeof(mstr) != 'undefined') {
            this.detachWinListener((path) ? path:this, 'mousemove');
            this.detachWinListener((path) ? path:this, 'mouseup');
        } else {
            document.onmousemove = null;
            document.onmouseup = null;
        }
        return false;
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.onpostload = function() {
    //@class=mstrDialogImpl;@method=onpostload;
    try {
        mstrBoneImpl.prototype.onpostload.call(this);
        this.initResize();
        this.setFocus();
    } catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.setFocus = function() {
    //@class=mstrDialogImpl;@method=setFocus;
    try {
	if ( this.focusFieldId ) {
		if (this.focusTimer) {
			window.clearTimeout(this.focusTimer);
		}
		this.focusTimer = window.setTimeout("microstrategy.bone('" + this.id + "').doSetFocus()", 100);
	}
    } catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

mstrDialogImpl.prototype.doSetFocus = function() {
    //@class=mstrDialogImpl;@method=doSetFocus;
    try {
    
        if ( this.focusFieldId ) {
            var form = this.elem.getElementsByTagName("form")[0];
            if ( form ) {
                var field = form.elements[this.focusFieldId]
                if ( field ) {
                   microstrategy.setCursorToEnd(field);
                }
            }
        }
    }
    catch(err) {
        microstrategy.errors.log(err);
        return false;
    }
}

/**
 * @class The base class for all Dialogs.
 * @param {String} objId The ID of the HTMLElement that visually represents this Dialog.
 * @extends mstrBoneImpl
 */
function mstrDialogImpl(id) {
    this.inherits = mstrBoneImpl;
    this.inherits(id);
    delete this.inherits;

    return this;
}

