        
function FilterMouseOverLeaveEvent (evt)
{   

    var parentFromId = "";
    var parentToId = "";
    
    var fromElement = evt.fromElement;
    if (! fromElement) fromElement = evt.currentTarget;
    
    var toElement = evt.toElement;
    if (! toElement) toElement = evt.relatedTarget;    
    
    if (fromElement != null && fromElement.parentElement != null)
    {
        parentFromId = fromElement.parentElement.id;
    }
    if (fromElement != null && fromElement.parentNode != null)
    {
        parentFromId = fromElement.parentNode.id;
    }
    
    if (toElement != null && toElement.parentElement  != null)
    {
        parentToId = toElement.parentElement.id;
    }
    if (toElement != null && toElement.parentNode  != null)
    {
        parentToId = toElement.parentNode.id;
    }
    
    if (parentFromId != "" && parentFromId == toElement.id) 
    {
        return true;
    }
    if (parentToId != "" && parentToId == fromElement.id) 
    {
        return true;
    }
    
    if (parentToId != "" && parentToId == parentFromId) 
    {
        return true;
    }
    
    if (fromElement.id != "" && fromElement.id == toElement.id) 
    {
        return true;
    }    
    
    return false;
}

function HasParent (obj, parentID)
{
    for (;obj != null;)
    {
        if (obj.id == parentID)
        {
            return true;
        }        
        
        obj = GetParent(obj);        
    }
    return false;
}

function GetParent (obj)
{
    if (obj != null && obj.parentElement != null)
    {
        return obj.parentElement;
    }
    if (obj != null && obj.parentNode != null)
    {
        return obj.parentNode;
    }
    return null;
}

function FilterMouseOverLeaveEvent (evt, commonParentID)
{   
    var fromElement = evt.fromElement;
    if (! fromElement) fromElement = evt.currentTarget;
    
    var toElement = evt.toElement;
    if (! toElement) toElement = evt.relatedTarget;    
    
    if (HasParent (fromElement, commonParentID) && HasParent (toElement, commonParentID))
    {   
        return true;
    }
    
    return false;
    
}
       

function textLinkMouseHandler(evt, objID, arrowID,from,to,imgFrom,imgTo,count,delay)
{        
    ChangeWidth(objID,arrowID,from,to,imgFrom,imgTo,count*1.0,delay)
    //ChangeWidth (objID, arrowID, 0, 100, -3, 0, 10.0, 10);    
}

function ChangeWidth(objID,arrowID,from,to,imgFrom,imgTo,count,delay)
{
    var obj = document.getElementById(objID);
    var img = document.getElementById(arrowID);
    var delta=(to-from)/(count * 1.0);
    var newfrom=from+delta;
    var newcount=count-1;

    var imgDelta=(imgTo-imgFrom)/count;
    var newImgFrom=imgFrom+imgDelta;

    obj.style.width=from + "%";
    img.style.left=imgFrom + "px";

    if (count==0)
    {
        return;
    }

    var command="ChangeWidth('"+objID+"','"+arrowID+"',"+newfrom+","+to+","+newImgFrom+","+imgTo+","+newcount+","+ delay+")";
    window.setTimeout(command, delay);
    
}

function imgLinkFrameMouseEnter(evt, parentWidth, parentHeight, topID, bottomID, leftID, rightID, width, offset, count, delay) 
{
    var top=document.getElementById(topID); 
    var parent = GetParent(top);
    if (null != parent)
    {
        if (FilterMouseOverLeaveEvent (evt, parent.id)) return;
    }     
    
    var bottom=document.getElementById(bottomID);
    var left=document.getElementById(leftID);
    var right=document.getElementById(rightID);    

    top.style.display='block';
    bottom.style.display='block';
    left.style.display='block';
    right.style.display='block';

    ChangeFrameWidth(parentWidth, parentHeight, topID, bottomID, leftID, rightID,width,offset + width,offset, count*1.0, delay);
}

function imgLinkFrameMouseLeave(evt, topID, bottomID, leftID, rightID) 
{
    var top=document.getElementById(topID); 
    var parent = GetParent(top);
    if (null != parent)
    {
        if (FilterMouseOverLeaveEvent (evt, parent.id)) return;
    }
    
    var bottom=document.getElementById(bottomID);
    var left=document.getElementById(leftID);
    var right=document.getElementById(rightID);   
    top.style.display='none';
    bottom.style.display='none';
    left.style.display='none';
    right.style.display='none';
}

function arrangeImgLinkFrame(parentWidth, parentHeight, top, bottom, left, right, width, offset) 
{
    top.style.top=offset+"px";
    top.style.height=width+"px";
    top.style.width=(parentWidth - 2*offset)+"px";

    bottom.style.top=offset+"px";
    bottom.style.height=width+"px";
    bottom.style.width=(parentWidth - 2*offset)+"px";

    left.style.top=offset+"px";
    left.style.left=offset+"px";
    left.style.width=width+"px";
    left.style.height=(parentHeight - 2*(offset+width))+"px";

    right.style.top=offset+"px";
    right.style.width=width+"px";
    right.style.height=(parentHeight - 2*(offset+width))+"px";
    right.style.left=-offset+"px";
}


function ChangeFrameWidth(parentWidth, parentHeight, topID, bottomID, leftID, rightID,width,from,to,count,delay)
{       
    //alert("to=" + to + " from=" + from);
    var delta=(to-from)/(count * 1.0);
    var newfrom=from+delta;
    var newcount=count-1;
    
    var top=document.getElementById(topID); 
    var bottom=document.getElementById(bottomID);
    var left=document.getElementById(leftID);
    var right=document.getElementById(rightID);   

    arrangeImgLinkFrame(parentWidth, parentHeight, top, bottom, left, right, width, Math.round(from));

    if (count==0)
    {
        arrangeImgLinkFrame(parentWidth, parentHeight, top, bottom, left, right, width, to);
        return;
    }
                                                                                                                           
    var command="ChangeFrameWidth("+parentWidth+","+parentHeight+",'"+topID+"','"+bottomID+"','"+leftID+"','"+rightID+"',"+width+","+newfrom+","+to+","+newcount+","+ delay+")";
    window.setTimeout(command, delay);    
}

function MoveBackgroundNocycle(cellID, width, height, posX, finalPosX, posY, finalPosY, count, delay)
{
    var cell=document.getElementById(cellID); 
    
    var deltaX=(finalPosX-posX);
    posX=posX+(deltaX/(count * 1.0));
        
    var deltaY=(finalPosY-posY);
    posY=posY+(deltaY/(count * 1.0));
    
    var count=count-1;
    cell.style.backgroundPosition = posX + "px " + posY + "px";
    if (count==0)
    {
        cell.style.backgroundPosition = finalPosX + "px " + finalPosY + "px";
        return;
    }
                                                                                                                           
    var command="MoveBackgroundNocycle('"+cellID+"',"+width+","+height+","+posX+","+finalPosX+","+posY+","+finalPosY+","+count+","+delay+")";
    window.setTimeout(command, delay);    
}

function MoveBackground(cellID, width, height, posX, finalPosX, posY, finalPosY, count, delay)
{
    var cell=document.getElementById(cellID); 
    
    var deltaX=(finalPosX-posX);
    if (deltaX <= 0) deltaX += width;
    posX=posX+(deltaX/(count * 1.0));
    if (posX>=width) posX-=width;
    
    var deltaY=(finalPosY-posY);
    if (deltaY <= 0) deltaY += height;    
    posY=posY+(deltaY/(count * 1.0));
    if (posY>=height) posY-=height;    
    
    var count=count-1;
    cell.style.backgroundPosition = posX + "px " + posY + "px";
    if (count==0)
    {
        cell.style.backgroundPosition = finalPosX + "px " + finalPosY + "px";
        return;
    }
                                                                                                                           
    var command="MoveBackground('"+cellID+"',"+width+","+height+","+posX+","+finalPosX+","+posY+","+finalPosY+","+count+","+delay+")";
    window.setTimeout(command, delay);    
}

function ChangeFontSize(objID,from,to,suffix,count,delay)
{
    var obj = document.getElementById(objID);
    
    var delta=(to-from)/(count * 1.0);
    var newfrom=from+delta;
    var newcount=count-1;

    obj.style.fontSize=from + suffix;    

    if (count==0)
    {
        obj.style.fontSize=to + suffix;    
        return;
    }

    var command="ChangeFontSize('"+objID+"',"+newfrom+","+to+",'"+suffix+"',"+newcount+","+ delay+")";
    window.setTimeout(command, delay);    
}