﻿// JScript File

function animacao()
{    
    // variaveis
    var thisObj = this;
    var clock = 50;
    
    // pulse
    this.pulseX = function(id, comprimento, milseg)
    {
        // vars
        if (typeof(id) == "string") id = document.getElementById(id);
        var d1 = new Date();
        var d2;
        var x = 0;
        var y = 0;
        var w = 0;
        
        // clock
        var t = setInterval(
            function()
            {
               d2 = new Date();
               x = (d2.getTime() - d1.getTime()) / milseg;
               if (x > 1) x = 1;
               y = Math.sin(x * Math.PI);
               w = y * comprimento;
               
               id.style.width = Math.ceil(w) + "px";
                              
               // fim          
               if (x == 1) clearInterval(t);
            },
            clock
        );
    }
    
    // pulse alpha
    this.pulseAlpha = function(id, periodo, milseg)
    {
        // vars
        if (typeof(id) == "string") id = document.getElementById(id);
        var d1 = new Date();
        var d2;
        var x = 0;
        var y = 0;
        
        // clock
        var t = setInterval(
            function()
            {
               d2 = new Date();
               x = (d2.getTime() - d1.getTime()) / milseg;
               if (x > 1) x = 1;
               y = Math.sin(x * Math.PI * 2 * periodo);
               
               changeOpac(id, Math.ceil(y*100));
                              
               // fim          
               if (x == 1) clearInterval(t);
            },
            clock
        );
    }
    
    // pulse
    this.pulse = function(id, escala, periodo, milseg)
    {
        // vars
        if (typeof(id) == "string") id = document.getElementById(id);
        var d1 = new Date();
        var d2;
        var x = 0;
        var y = 0;
        var h = 0;
        var w = 0;
        var altura = id.offsetHeight;
        var comprimento = id.offsetWidth;
        
        // clock
        var t = setInterval(
            function()
            {
               d2 = new Date();
               x = (d2.getTime() - d1.getTime()) / milseg;
               if (x > 1) x = 1;
               y = Math.sin(x * Math.PI * 2 * periodo);
               h = (y * altura * escala) + altura;
               w = (y * comprimento * escala) + comprimento;
               
               id.style.height = Math.ceil(h) + "px";
               id.style.width = Math.ceil(w) + "px";
                              
               // fim          
               if (x == 1) clearInterval(t);
            },
            clock
        );
    }
    
    
    // stretch
    this.stretchX = function(id, comprimento, milseg)
    {
        // vars
        if (typeof(id) == "string") id = document.getElementById(id);
        var d1 = new Date();
        var d2;
        var status = 0;
        
        // clock
        var t = setInterval(
            function()
            {
               d2 = new Date();
               status = (d2.getTime() - d1.getTime()) / milseg;
               if (status > 1) status = 1;
               id.style.width = Math.ceil(status * comprimento) + "px";
                              
               // fim          
               if (status == 1) clearInterval(t);
            },
            clock
        );
        
    }
    
    
    
    // opacity
	function changeOpac (obj, opacity)
	{
		obj.style.opacity = (opacity / 100);
		obj.style.MozOpacity = (opacity / 100);
		obj.style.KhtmlOpacity = (opacity / 100);
		obj.style.filter = "alpha(opacity=" + opacity + ")";
	}
	

}