﻿var sStep = 16;  
var sTimeout = 15; 

function winOpen(a) 
{ 
    var wObj=a.previousSibling;
    wObj.style.display = 'block';
    wObj.sLeft = 355;
    wObj.sRight = 355;
    
    var parent = a.parentNode.parentNode.parentNode;
    if(wObj.style.marginLeft == "")
    {
        var left = 0;
        var wLeft = 0
        var top = 0;
        var o = wObj;
        while (parent)
        {
            left += parent.offsetLeft;
            top += parent.offsetTop;
            parent = parent.offsetParent;
        }
        while (o)
        {
            wLeft += o.offsetLeft;
            o = o.offsetParent;
        }
        wObj.style.marginLeft = left - wLeft + "px";
        wObj.style.top = top + "px";
    }
    openStep(wObj);
}

function openStep(wObj)
{
    if (wObj.sLeft > 0) 
    { 
        wObj.sRight += sStep;  
        wObj.sLeft -= sStep;          
        var rect = 'rect(auto, '+ wObj.sRight +'px, auto, '+ wObj.sLeft +'px)';        
        wObj.style.clip = rect;      
        setTimeout(function(){ openStep(wObj); }, sTimeout);
    }
}

function winClose(div) 
{
    var wObj = div.parentNode;
    closeStep(wObj);
}

function closeStep(wObj)
{
    if (wObj.sLeft < wObj.sRight) 
    { 
        wObj.sRight -= sStep;  
        wObj.sLeft += sStep;  
        var rect = 'rect(auto, '+ wObj.sRight +'px, auto, '+ wObj.sLeft +'px)'; 
        wObj.style.clip = rect; 
        setTimeout(function(){ closeStep(wObj); }, sTimeout); 
    } 
    else wObj.style.display = 'none';
}
