    function $ID(elemento)

    {

        return document.getElementById(elemento);

    }



    function $Tag(elemento)

    {

        return document.getElementsByTagName(elemento);

    }



    function $Name(elemento)

    {

        return document.getElementsByName(elemento);

    }



    function fadeOutSamba(elemento, tempo)

    {

    	var elemento = $ID(elemento);

        var alpha = 100;

        var timer = (tempo * 1000) / 50;

        var i = setInterval(

                              function()

                              {

                                 if(alpha <= 0)

                                 {

                                    clearInterval(i);

                                 }

                                 setAlphaSamba(elemento, alpha);

                                 alpha -= 2;

                              }, timer

                           );

    }



    function fadeInSamba(elemento, tempo)

    {

        var elemento = $ID(elemento);

        var alpha = 0;

        var timer = (tempo * 1000) / 50;

        var i = setInterval(

                              function()

                              {

                                 if(alpha >= 100)

                                 {

                                    clearInterval(i);

                                 }

                                 setAlphaSamba(elemento, alpha);

                                 alpha += 2;

                              }, timer

                           );

    }

        

    function htmlSamba(elemento, conteudo, fade, tempo)

    {

        if(fade == 'Y')

        {

            if(tempo == undefined || tempo == null || tempo == '')

            {

                fadeOutSamba(elemento, 0.1);

                $ID(elemento).innerHTML = conteudo;

                fadeInSamba(elemento, 0.1);

            }

            else

            {

                fadeOutSamba(elemento, tempo);

                $ID(elemento).innerHTML = conteudo;

                fadeInSamba(elemento, tempo);

            }

        }

        else

        {

			if(tempo == undefined || tempo == null || tempo == '')

            {

	            $ID(elemento).innerHTML = conteudo;

			}

			else

			{

				setTimeout

				(

					function()

					{

						$ID(elemento).innerHTML = conteudo;

					}, tempo

				)

			}

        }

    }





	function sizeSamba(elemento, timer, widthInit, widthFinal, heightInit, heightFinal, pos)

    {

		

    	var elemento = $ID(elemento);   	

		var width = widthInit;

		var height = heightInit;

		var repeticoes = 0;

		var tempo = 1;



		setWidthSamba(elemento, widthInit);

		setHeightSamba(elemento, heightInit);



		elemento.style.display = 'block';

		

		var pctWidth = (widthFinal - widthInit)/timer;

		var pctHeight = (heightFinal - heightInit)/timer;

		

		var j =	setInterval(

			function()

			{

				if (repeticoes >= timer)

				{

					clearInterval(j);

				}



				width += pctWidth;

				height += pctHeight;

				setWidthSamba(elemento, width);

				setHeightSamba(elemento, height);

				

				if (pos == 'c')

				{

					centralizaDiv(elemento, width, height);

				}

				

				repeticoes += 1;

			}, 1

		);

    }

	

    function getPosicaoElemento(elemento)

    {

        var posicaoElemento = $ID(elemento);

        var margemEsquerda = 0;

        var margemTopo     = 0;

        

        margemEsquerda += posicaoElemento.offsetLeft;

        margemTopo     += posicaoElemento.offsetTop;

                

        if(navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != undefined)

        {

            margemEsquerda += document.body.leftMargin;

            margemTopo     += document.body.topMargin;

	    }

        return {left:margemEsquerda, top:margemTopo}; 

    }

    

    function getPosicaoMouse(event)

    {

        var posicaoX, posicaoY;    

        var x = event.clientX;

        var y = event.clientY;

        return {posicaoX:x, posicao:y}

    }

	

	function centralizaDiv(elemento, width, height)

	{

		elemento.style.marginLeft = '-' + (width / 2) + 'px';

		elemento.style.marginTop = '-' + (height / 2) + 'px';	

		elemento.style.left = '50%';

		elemento.style.top = '50%';	

		mostraDivFundo();

	}



    function setAlphaSamba(elemento, alpha)

    {		

		if(alpha > 100)

		{

			 elemento.style.filter = '';

		}

		else

		{

			elemento.style.filter = 'alpha(opacity=' + alpha + ')';

		}

		

        elemento.style.opacity = alpha / 100;

    }

	

	function setWidthSamba(elemento, width)

	{

		//alert('setWidthSamba('+elemento+', '+width+')')

		elemento.style.width = width+'px';

	}

	

	function setHeightSamba(elemento, height)

	{

		//alert('setWidthSamba('+elemento+', '+height+')')

		elemento.style.height = height + 'px';

	}

	

    function hideSamba(elemento, type, tempo)

    {

	 	if(tempo == undefined || tempo == null || tempo == '')

		{

			if(type == 'h')

			{

				$ID(elemento).style.visibility = 'hidden';

			}

			else if(type == 'n')

			{

				$ID(elemento).style.display = 'none';

			}

		}

		else

		{

			var i = setTimeout(function()

				{

					if(type == 'h')

					{

						$ID(elemento).style.visibility = 'hidden';

					}

					else if(type == 'n')

					{

						$ID(elemento).style.display = 'none';

					}	

				}, tempo

			)

		}

    }



    function showSamba(elemento, type, tempo)

    {

		

		if (tempo == undefined || tempo == null || tempo == '')

		{

			if(type == 'v')

			{

				$ID(elemento).style.visibility = 'visible';

			}

			else if(type == 'b')

			{

				$ID(elemento).style.display = 'block';

			}

		}

		else

		{

			var i = setTimeout(function()

				{

					if(type == 'v')

					{

						$ID(elemento).style.visibility = 'visible';

					}

					else if(type == 'b')

					{

						$ID(elemento).style.display = 'block';

					}

				}, tempo

			)

		}

    }

    

    function resetFormSamba(form)

    {

        if(form == '')

        {

            $Tag('form').reset();

        }

        else

        {

            $ID(form).reset();

        }

    }

    

    function $Focus(elemento)

    {

        return $ID(elemento).focus();

    }

    

    function $Selected(elemento)

    {

        return $ID(elemento).selected();

    }

    

    function hideMSG(elemento, tempoP, tempoS)

    {

        if(tempoP == '' || tempoP == undefined)

        {   

            tempoP = 1000

        }

        

        if(tempoS == '' || tempoS == undefined)

        {   

            tempoS = 10000

        }

        

        setTimeout(

                     function()

                     {

                        fadeOutSamba(elemento, 0.1);

                        setTimeout(

                                     function()

                                     {

                                        htmlSamba(elemento, ''); hideSamba(elemento, 'n');

                                     }, tempoP);

                     }, tempoS);

    }

        



    function preloadImagens() 

    {

	   if(document.images) 

	   {

	        if(!document.imageArray)

	        {

	            document.imagemArray = new Array();

	        }

	   

	        var imagemQtd = document.imagemArray.length; 

	        var argumentos = preloadImagens.arguments; 

	   

	        for(var i = 0; i < argumentos.length; i++)

            {

                document.imagemArray[imagemQtd] = new Image;

                document.imagemArray[imagemQtd++].src = argumentos[i];

            }

        }

    }

	

	function zebra(contador, cor1, cor2)

    {

        var cores = [cor1, cor2];

        return (contador % 2 == 0) ? cores[0] : cores[1]

    }

	

	function rolaPagina(id)

	{

		var inicial;

		var finalRoll

		

		if (document.all)

		{

            inicial = document.documentElement.scrollTop;

		}

        else

		{

            inicial = window.scrollY;	

		}

		

		finalRoll = getPosicaoElemento(id).top - 60;

		

		var i = setInterval

		(

			function()

			{

				if (inicial >= finalRoll)

				{

					clearInterval(i)

				}

				else

				{

					window.scrollBy(0, 20)

					inicial += 20;

				}

			},10

		);

	}

	

	function mostraDivFundo()

	{

		var divFundo = 	$ID('divFundoGeral');

		

		if (divFundo != null)

		{

			divFundo.style.display = 'block';

		}

	}

	

	function abreFechaHeight(elemento, classeP, elementoSize, heightFinal, largura)

	{

		//var largura = $ID(elementoSize).clientWidth;

		var altura =  $ID(elementoSize).clientHeight;

		

		/*if(document.all)

		{

		   largura = document.all[elementoSize].clientWidth;

           altura = document.all[elementoSize].clientWidth;  

		}

		else

		{

		   largura = $ID(elementoSize).clientWidth;

		   altura = $ID(elementoSize).clientHeight;

		}*/



		var	elementoEst;

		//alert('Altura :-> ' + altura);

		if(altura == 0)

		{

		//	alert("0 - " + largura);

			sizeSamba(elementoSize, 30, largura, largura, 0, heightFinal, 't');

			elementoEst = 1;

		}

		else

		{

		//	alert("1 - " + largura);			

			sizeSamba(elementoSize, 30, largura, largura, heightFinal, 0, 't');

			elementoEst = 0;

		}

		

		mudaEstado(elemento, classeP, elementoEst);

	}

	

	function mudaEstado(elemento, classeP, estado)

	{

		if(estado == 1)

		{

			$ID(elemento).className = classeP + "Act";

		}

		else

		{

			$ID(elemento).className = classeP + "Pas";

		}	

	}

	

	function getPosicaoElemento(elemento)

	{

		var offsetTrail = $ID(elemento);

		var offsetLeft = 0;

		var offsetTop = 0;

		

		while(offsetTrail)

		{

			offsetLeft += offsetTrail.offsetLeft;

			offsetTop += offsetTrail.offsetTop;

			offsetTrail = offsetTrail.offsetParent;

		}

		

		if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != undefined)

		{

			offsetLeft += document.body.leftMargin;

			offsetTop += document.body.topMargin;

		}

		

		return {left:offsetLeft, top:offsetTop};

	}

	

	function preencheInput(id, mensagem, classe)

	{

		var elemento = $ID(id);

		

		if (elemento.value.length == 0)

		{

			elemento.value = mensagem;

			elemento.setAttribute((document.all) ? 'className' : 'class', classe);

		}

	}

	

	function despreencheInput(id, classe)

	{

		var elemento = $ID(id);

		

		if (elemento.value == 'Digite seu E-mail...')

		{

			elemento.value = '';

			elemento.setAttribute((document.all) ? 'className' : 'class', classe);

		}

	}

	

	function apareceJanelaVideo(funcao)

	{

		var marginLeft = $("#video").width()/2;

		var marginTop = $("#video").height()/2;

		$("#video").css({'margin-left' : '-'+marginLeft+'px', 'margin-top' : '-'+marginTop+'px', 'opacity' : '1'});

		$("#video").show(700, function(){eval(funcao);});

		$("#video").fadeIn(700);

		$("#divFundoGeral").show();

	}

	

	function limpaCaixa()

	{

		$("#totalVideo").html('');

		$("#video").fadeOut(700,function(){ $("#video").hide(); })

		$("#divFundoGeral").hide();

	}
	
	
	