﻿var Message = {

	ShowMessage : function (title,string,precallback,postcallback,hideOK) {
	     //document.body.scroll='no';
	     //document.body.style.overflow='hidden';
	    if(precallback!=undefined) this.precallback=precallback;
	    if(postcallback!=undefined) this.postcallback=postcallback;
	    this.hideOK = (hideOK!=undefined);
	    if(window.hidePDF!=null)
	        window.hidePDF();
	        
		return this._ShowMessage(title,string);
		
	},
	
	    


	HideMessage : function () {
	     //document.body.scroll='yes';
	     //document.body.style.overflow='auto';
	     if(window.showPDF!=null)
	        window.showPDF();
        return this._HideMessage();		
	},
	
	_ShowMessage : function (title,string) {
	    
        if(this.precallback!=undefined)
            this.precallback();
        var _height = document.documentElement.clientHeight;
        var _width = document.documentElement.clientWidth;
        
        var div = document.createElement('div');
        div.id='ConfirmMainDiv';
        div.className='transparent';
        div.style.width = _width + "px";
        div.style.height = _height + "px";
        div.style.position = 'absolute';
        div.style.left = '0px';
        
        var ScrollTop = document.body.scrollTop;
        if (ScrollTop == 0)
        {
            if (window.pageYOffset)
                ScrollTop = window.pageYOffset;
            else
                ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
        }
        
        
        div.style.top =ScrollTop + 'px';
        div.style.backgroundColor = '#CCCCCC';
        div.style.zIndex = 9999;

        var div1 = document.createElement('div');
        div1.id='ConfirmSubDiv';
        div1.style.border = 'solid 1px Maroon';
        div1.style.position = 'absolute';
        div1.style.width = (_width/4) + "px";
        div1.style.height = (_height/4) + "px";
        div1.style.left = ((_width - (_width/4))/2)+'px';
        div1.style.top = (((_height - (_height/4))/2)+ScrollTop)+'px';
        div1.style.backgroundColor = '#ffffe0';
        
        div1.style.zIndex = 9999+1;

        
        var TableText = '<table cellpadding="0" cellspacing="0"  width="100%">';
        TableText += '<tr><td>';
        TableText += '<table cellpadding="2" cellspacing="2" style="height:100%" width="100%">';
        TableText += '<tr><td id="tdDrag" colspan="2" style="cursor:move;background-color:#f4a62b;color:white;font-weight:bold;">' + title +'</td></tr>';
        TableText += '<tr><td colspan="2" style="height:5px;"></td>';
        TableText += '<tr><td width="30px" align="center" valign="top">' +((!this.hideOK)? '<img height="25" width="25" src="images/alert.gif"/>' : '')+ '</td><td align="' + ((!this.hideOK)? "left" : "center") + '" valign="'+ ((!this.hideOK)? "top" : "middle") +'" style="color:red;background-color:#ffffe0;height:' + ((_height/4)-65) + 'px">' + string + ((!this.hideOK)? "" : "<br><img src='images/loader.gif' />") +'</td></tr>';
        TableText += '</td><tr>';
        if(!this.hideOK)
        {
            TableText += '<tr><td colspan="2" align="center">';
            TableText += '<a class="linkStyle" href="javascript:Message.HideMessage();">OK</a>';
            TableText += '</td></tr>';
        }
        TableText += '</table>';
        
        div1.innerHTML=TableText;
        
        
        document.body.appendChild(div);
    	document.body.appendChild(div1);
    	Drag.init(document.getElementById("tdDrag"),document.getElementById("ConfirmSubDiv"));
	},

	
	_HideMessage : function () {
	        if(this.postcallback!=undefined)
	            this.postcallback();
            $('#ConfirmSubDiv').fadeOut("slow",function(){
            document.body.removeChild(document.getElementById('ConfirmMainDiv'));
            document.body.removeChild(document.getElementById('ConfirmSubDiv'));}
	        );
	}

}
