﻿function IsNumeric(sText) 
{ 
   if (sText=="") return false;
   
   var ValidChars = "0123456789."; 
   var Char;
   for (i = 0; i < sText.length; i++) 
   {
       Char = sText.charAt(i);
       if (ValidChars.indexOf(Char) == -1) 
       {
          return false;
       }
    }
   return true;
}

function OpenWindow(url, width, height, topmost)
{
    var winResult=null;
    if(!window.ActiveXObject)
    {
        if (topmost)
        {
            winResult=window.open(url,'','width='+width+',height='+height+', scrollbars=no,alwaysRaised'); 
        }
        else
        {
            winResult=window.open(url,'','width='+width+',height='+height+', scrollbars=no');
        }
    }
    else
    {
        if (topmost)
        {
            winResult=showModelessDialog(url, window, 'center:1;help:0;resizable:1;status:0;dialogWidth:'+width+'px;dialogHeight:'+height+'px');
        }
        else
        {
            winResult=window.open(url,'','width='+width+',height='+height+', scrollbars=0');
        }
    }
    return winResult;
}

function AnimController()
{
    this.fpsAnim=30;
    this.idTimerAnim=null;
    this.animProgress=0;
    this.animTimeStep=20;
    var oThis=null;
    this.isAnimating=false;
    
    this.Init=function()
    {
        oThis=this;
    }
        
    this.Start=function(handler)
    {
        if (oThis.isAnimating)
        {
            oThis.Stop();
        }
        
        oThis.AnimHandler=handler;
        oThis.isAnimating = true;
        this.idTimerAnim = setInterval(Animate,1000/oThis.fpsAnim);
    }
    
    function Animate()
    {
        if ( (++oThis.animProgress) > oThis.animTimeStep )
        {
            oThis.Stop();
            return;
        }
        setTimeout(oThis.AnimHandler,1);
    }

    this.Stop=function()
    {
        clearInterval(oThis.idTimerAnim);
        oThis.animProgress=0;
        oThis.idTimerAnim=null;
        oThis.isAnimating=false;
    }
}
AnimController.prototype.AnimHandler = function () {};
