//--------------------------------------------------------------------------------
var popLeft = 100;  // default, incase only
var popTop  = 100; 

var pDiv = null;    //need to be global variable:
var mDiv = null; 
var isShowing = false; 
//--------------------------------------------------------------------------------
function InsID(obj){ //Insert obj to RecordID 
    document.getElementById('RecordID').value = obj; 
}
function GreySetup(){ //initialize the references to the two divs 
    pDiv = document.getElementById('RecordID').value; 
    mDiv = document.getElementById('M'); 
}
//--------------------------------------------------------------------------------
function GreyShowPop(obj,rcdID){ 
    pDiv = document.getElementById(rcdID);
	mDiv = document.getElementById('M'); 
   //pDiv.style.display = mDiv.style.display = ( obj ? 'block' : 'none');
   if (obj==true) {
	   pDiv.style.display ='block'
	   mDiv.style.display ='block'
   }
   else {
	   pDiv.style.display ='none'
	   mDiv.style.display ='none'	   
   }
    isShowing = obj; 
} 
//--------------------------------------------------------------------------------
function GreyShowPopSubmit(obj,rcdID){ 
    pDiv = document.getElementById(rcdID);
	
   // document.getElementById(rcdID).style.display = ( obj ? 'block' : 'none');
   // document.getElementById('M').style.display = ( obj ? 'block' : 'none'); 
	
   if (obj==true) {
	   document.getElementById(rcdID).style.display ='block'
	   document.getElementById('M').style.display ='block'
   }
   else {
	   document.getElementById(rcdID).style.display ='none'
	   document.getElementById('M').style.display ='none'	   
   }
	
	
	
    isShowing = obj; 
} 
//--------------------------------------------------------------------------------
function GreyTrackBody(){ 
    mDiv.style.top  = document.body.scrollTop; 
    mDiv.style.left = document.body.scrollLeft; 
} 
//--------------------------------------------------------------------------------
function GreyRectrPop(){        //recenter the popup
   // pDiv = document.getElementById('RecordID').valu;
    if (!isShowing) return;     //do nothing if popup isn't showing
    var popLeft = parseInt((document.body.clientWidth -pDiv.clientWidth)/2); 
    var popTop  = parseInt((document.body.clientHeight-pDiv.clientHeight)/2); 
    pDiv.style.left = (document.body.scrollLeft + popLeft) + "px"; 
    pDiv.style.top  = (document.body.scrollTop  + popTop) + "px"; 

    GreyTrackBody(); // ensure the mask is in sync, too. 
} 
//--------------------------------------------------------------------------------
function TrackBody() 
{ 
    var mask = document.getElementById("M"); 
    mask.style.top = document.body.scrollTop; 
    mask.style.left = document.body.scrollLeft; 
} 

function PopClose(rcdID) 
{ 
    document.getElementById('M').style.display = 'none'; 
	document.getElementById(rcdID).style.display = 'none'
	isShowing = false;
    //window.close(); 
} 


//--------------------------------------------------------------------------------
