function findPosX(obj)
      {
        var curleft = 0;
        if(obj.offsetParent)
            while(1) 
            {
              curleft += obj.offsetLeft;
              if(!obj.offsetParent)
                break;
              obj = obj.offsetParent;
            }
        else if(obj.x)
            curleft += obj.x;
        return curleft;
      }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
  
  var maskInfoCol = Array();
        
    function Fade( maskPos ) 
    {  
        maskInfo  = maskInfoCol[maskPos];
        maskInfo.CurOpacity = maskInfo.CurOpacity + 0.02;
        maskInfo.Mask.style.opacity = maskInfo.CurOpacity;
        
        if(maskInfo.Creator.window.document != null) {
        
        if( maskInfo.Mask.style.filter != null  ) 
        {
            maskInfo.Mask.style.filter = "alpha(opacity:" + ( maskInfo.CurOpacity * 100 ) + ")";  
        }
        else if(  maskInfo.Mask.style.opacity != null )
            maskInfo.Mask.style.opacity = maskInfo.CurOpacity;          
        
        if( maskInfo.CurOpacity < maskInfo.MaxOpacity )
            setTimeout( "Fade(" + maskPos + ")", 50 );
            
            if(maskInfo.OnMaskClickFunction)
                    maskInfo.OnMaskClickFunction();
       } 
       else {
            maskInfo.Mask.style.display = "none";
       }
    }
  
   function lockWindow( theWindow1, theWindow2, OnMaskClickFunction, maskColour, opacity, creator ) 
    {
        this.UnLock = UnLock;
        this.Lock = Lock;
        this.RemoveMask = RemoveMask;
        this.AddMask = AddMask;
        this.GetMaskInfo = GetMaskInfo;
        var _modalMask1;         
        var _modalMask2;         
        var maskInfo = new Object();
        maskInfo.MaxOpacity = opacity;
        maskInfo.OnMaskClickFunction = OnMaskClickFunction;
        maskInfo.MasksWindow1 = theWindow1;
        maskInfo.MasksWindow2 = theWindow2;
        maskInfo.Creator = creator;
    
           
               
              
        _modalMask1 = AddMask(_modalMask1,theWindow1);        
        _modalMask2 = AddMask(_modalMask2,theWindow2);         
        
        function GetMaskInfo() {
        return maskInfo;
        }
        
        function AddMask(modalMask, theWindow) 
        {
            winInf = GetWindowInfo(theWindow);
            modalMask=theWindow.document.createElement('div');
            modalMask.style.width=winInf.ContentWidth + "px";
            modalMask.style.height=winInf.ContentHeight + "px";
            modalMask.style.left="0px";
            modalMask.style.top="0px";
            modalMask.style.position='absolute';
            //modalMask.style.background=maskColour;
            //modalMask.style.zIndex=99;
            modalMask.className = "cms_lockLayer";
            
            
            try {
            if(  modalMask.style.filter != null  )
                modalMask.style.filter = "alpha(opacity:" + ( maskInfo.MaxOpacity * 100)+ ")";
            else if(  modalMask.style.opacity != null )
                modalMask.style.opacity = maskInfo.MaxOpacity;
             } 
             catch ( exp ){
                alert( exp );
             }
            
            
            theWindow.document.body.appendChild(modalMask );   
            modalMask.style.display="none";
            modalMask.onclick = function() 
            {
                try {
                if(maskInfo.Creator.window.document != null) {
                    if(maskInfo.OnMaskClickFunction)
                        maskInfo.OnMaskClickFunction();
                }
                else {
                    RemoveMask();
                }
                } catch (exp) {
                    RemoveMask();                    
                }
            }
            return modalMask;
        }
        
        function RemoveMask() 
        {
        try {
            if( theWindow1 != null )
                theWindow1.document.body.removeChild(_modalMask1) ;
            if( theWindow2 != null )
                theWindow2.document.body.removeChild(_modalMask2) ;
                } catch (exp ) {}
        }
        
        function Lock(  ) 
        { 
            _modalMask1.style.display="block"; 
            _modalMask2.style.display="block";       
        }
        
        function UnLock() 
        {
            _modalMask1.style.display="none";
            _modalMask2.style.display="none";
        }       
             
    }



function GetWindowInfo( theWindow )
{var scrollX=0,scrollY=0,width=0,height=0,contentWidth=0,contentHeight=0;if(typeof(theWindow.pageXOffset)=='number')
{scrollX=theWindow.pageXOffset;scrollY=theWindow.pageYOffset;}
else if(theWindow.document.body&&(theWindow.document.body.scrollLeft||theWindow.document.body.scrollTop))
{scrollX=theWindow.document.body.scrollLeft;scrollY=theWindow.document.body.scrollTop;}
else if(theWindow.document.documentElement&&(theWindow.document.documentElement.scrollLeft||theWindow.document.documentElement.scrollTop))
{scrollX=theWindow.document.documentElement.scrollLeft;scrollY=theWindow.document.documentElement.scrollTop;}
if(typeof(theWindow.innerWidth)=='number')
{width=theWindow.innerWidth;height=theWindow.innerHeight;}
else if(theWindow.document.documentElement&&(theWindow.document.documentElement.clientWidth||theWindow.document.documentElement.clientHeight))
{width=theWindow.document.documentElement.clientWidth;height=theWindow.document.documentElement.clientHeight;}
else if(theWindow.document.body&&(theWindow.document.body.clientWidth||theWindow.document.body.clientHeight))
{width=theWindow.document.body.clientWidth;height=theWindow.document.body.clientHeight;}
if(theWindow.document.documentElement&&(theWindow.document.documentElement.scrollHeight||theWindow.document.documentElement.offsetHeight))
{if(theWindow.document.documentElement.scrollHeight>theWindow.document.documentElement.offsetHeight)
{contentWidth=theWindow.document.documentElement.scrollWidth;contentHeight=theWindow.document.documentElement.scrollHeight;}
else
{contentWidth=theWindow.document.documentElement.offsetWidth;contentHeight=theWindow.document.documentElement.offsetHeight;}}
else if(theWindow.document.body&&(theWindow.document.body.scrollHeight||theWindow.document.body.offsetHeight))
{if(theWindow.document.body.scrollHeight>theWindow.document.body.offsetHeight)
{contentWidth=theWindow.document.body.scrollWidth;contentHeight=theWindow.document.body.scrollHeight;}
else
{contentWidth=theWindow.document.body.offsetWidth;contentHeight=theWindow.document.body.offsetHeight;}}
else
{contentWidth=width;contentHeight=height;}
if(height>contentHeight)
height=contentHeight;if(width>contentWidth)
width=contentWidth;var rect=new Object();rect.ScrollX=scrollX;rect.ScrollY=scrollY;rect.Width=width;rect.Height=height;rect.ContentWidth=contentWidth;rect.ContentHeight=contentHeight;return rect;}
























