﻿var intervalId;
var ControlName="";
var OtherControlToBe="";
var defcontrol = "";
var interval = 3;
 var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
var browsern = navigator.userAgent;



function Animate(_ControlName,_OtherControlToBe)
{
   
    ControlName = _ControlName;
    if(_OtherControlToBe!='nully')
    {
        OtherControlToBe = _OtherControlToBe;
    }
    else
    {
        OtherControlToBe = defcontrol;
    }
    
    clearInterval(intervalId);
    
    document.getElementById(ControlName).style.width = document.getElementById(OtherControlToBe).style.width;
    
    if(parseInt(document.getElementById(ControlName).style.left)>parseInt(document.getElementById(OtherControlToBe).style.left))
    {
        
        intervalId=setInterval("BeginAnimationLeft()",1);
        
    }
    else
    {
        intervalId=setInterval("BeginAnimationRight()",1);
    }
    
    
    
}
function BeginAnimationRight()
{
    if(parseInt(document.getElementById(ControlName).style.left)<(parseInt(document.getElementById(OtherControlToBe).style.left)))
    {
        document.getElementById(ControlName).style.left = (parseInt(document.getElementById(ControlName).style.left) + parseInt(interval))+"px";
        
    }
    else
    {
        document.getElementById(ControlName).style.left = document.getElementById(OtherControlToBe).style.left;
        clearInterval(intervalId);
    }
    
}
function BeginAnimationLeft()
{
    if(parseInt(document.getElementById(ControlName).style.left)>(parseInt(document.getElementById(OtherControlToBe).style.left)))
    {
        document.getElementById(ControlName).style.left = (parseInt(document.getElementById(ControlName).style.left) - parseInt(interval))+"px";
        
    }
    else
    {
        document.getElementById(ControlName).style.left = document.getElementById(OtherControlToBe).style.left;
        clearInterval(intervalId);
    }

}