﻿// JScript File

function ShowMsgXY(MsgObj,PosObj,Offset)
{
    var Obj=document.getElementById(MsgObj);
    var Obj2=PosObj;
    //Obj.style.left=event.clientX 
    //Obj.style.top=event.clientY 
    
	var curleft = curtop = 0;
	if (PosObj.offsetParent) {
		curleft = PosObj.offsetLeft;
		curtop = PosObj.offsetTop;
		while (PosObj = PosObj.offsetParent) {
			curleft += PosObj.offsetLeft;
			curtop += PosObj.offsetTop;
		}
	}

	if (Offset=='left'){
		curtop += Obj2.offsetHeight;
	    curleft += (Obj2.offsetWidth-10);
	}else{
	
	}
	
    Obj.style.left=curleft;
    Obj.style.top=curtop;	 
    Obj.style.position="absolute";  
    Obj.style.display="block";
}

function ShowMsg(MsgObj,PosObj)
{
    //var Obj2=document.getElementById(PosObj);
    var Obj2;
    
    var Obj=document.getElementById(MsgObj + '_MainDiv');
    Obj.style.display="block";  
    Obj.style.left=(document.documentElement.scrollWidth / 2) - (GetSizeInt(Obj.currentStyle.width) / 2) + "px";
    Obj.style.top=(document.documentElement.scrollTop + 150) + "px";  
    Obj.style.position="absolute";      
    
    var Obj=document.getElementById(MsgObj + '_MainIFrame');
    Obj.style.background="";
    Obj.style.display="block"; 
    Obj.style.left=(document.documentElement.scrollWidth / 2) - (GetSizeInt(Obj.currentStyle.width) / 2) + "px";
    Obj.style.top=(document.documentElement.scrollTop + 150) + "px";  
    Obj.style.position="absolute";  
    
    var Obj=document.getElementById(MsgObj + '_WaitGif');
    if (Obj != null) {
        Obj.innerHTML = '<img src="' + Obj.getAttribute('src') + '" />';
    }
        
    //If the Obj2 is null then just size up using the document.    
    if (Obj2 != null){            
        var boo=document.getElementById(MsgObj + '_BlackOut');
        if (boo != null) {
            boo.style.display="block";
            boo.style.width = Obj2.offsetWidth + "px"; 
            boo.style.height = Obj2.offsetHeight + "px";
            boo.style.top= Obj2.style.top;
            boo.style.position="absolute"; 
            //boo.style.left= "-" + Obj2.style.borderLeftWidth;  
            boo.style.left= "-" + Obj2.currentStyle.borderLeftWidth;  
        }  
    }else{
       var boo=document.getElementById(MsgObj + '_BlackOut');
        if (boo != null) {
            boo.style.display="block";
            boo.style.width = document.documentElement.scrollWidth + "px"; 
            boo.style.height = document.documentElement.scrollHeight + "px";
            boo.style.top= 0;
            boo.style.left= 0;
            boo.style.position="absolute";  
        }    
    }
}

function HideMsg(MsgObj)
{
    var Obj=document.getElementById(MsgObj + '_MainDiv');
    Obj.style.display="none";
    
    var Obj=document.getElementById(MsgObj + '_MainIFrame');
    Obj.style.display="none";    
}

function MonitorTimeout(MsgObj,PosObj,Time)
{
    setTimeout(function () { ShowMsg(MsgObj,PosObj);}, Time);
}

function GetSizeInt(Value)
{
    return Value.replace('px','')
}
