var theBalloon;
var yPos = 0;
var xPos = 100;
var xOff=0;
var dSign = 1;
var winwidth=600;
var winheight=400;
var xoffset=0;
var rnd = Math.random();
var firstdelay=0;

function doFloatingBalloon()
{
    if ( document.getElementById )
        theBalloon = document.getElementById("FloatBalloon");
    else if ( document.layers )
        theBalloon = document.layers["FloatBalloon"];
    else if ( document.all )
        theBalloon = document.all.item("FloatBalloon");

   if (Math.random()<0.75)
    if ( theBalloon )
    {
   // need to find netscrape width, height 
   if (document.layers)
   {
   winwidth=window.innerWidth;
   winheight=window.innerHeight;
   }
   else
   {
   winwidth=document.body.clientWidth;
   winheight=document.body.clientHeight;
   }

    setTimeout( "doBottomToTop()", (Math.random()*10000)  );
      
//    doBottomToTop();
    }
}

function moveObjTo( obj, x, y )
{
    if ( ! obj.style )
    {
        obj.top = y;
        obj.left = x;
    }
    else
    {
        obj.style.top = y + "px";
        obj.style.left = x + "px";
    }
}


function moveHoriz()
{

	var dec=(Math.sin(xOff)*30);
	xOff+=0.18;
	if (xOff==180) xOff==0;
	
   xPos = xoffset+dec;
}

function doBottomToTop()
{
	firstdelay=0;
   yPos = winheight+30;
   xPos=0;
   xoffset=(700-280)*rnd; // rnd pix right from maintable edge
	if (winwidth>770) xoffset+=((winwidth-770)/2);

   dSign = 1;
   moveObjTo( theBalloon, xPos, yPos );
	moveHoriz();
	moveVert();
    unhideObj(theBalloon);
}

function moveVert()
{
	moveHoriz();
	
    var dec = 8;
    yPos -= dec;
    if ( yPos > -200 )
    {
        moveObjTo( theBalloon, xPos , yPos * dSign );
//        if (firstdelay==0)
//        setTimeout( "moveVert()", (Math.random()*10000)  );
//		else
        setTimeout( "moveVert()", 40 );
    }
    else
    {
    hideObj(theBalloon)
    }
	firstdelay=1;
}

function hideObj( obj )
{
    if ( ! obj.style )
        obj.visibility = "hidden";
    else
        obj.style.visibility = "hidden";
}

 function unhideObj( obj )
{
    if ( ! obj.style )
        obj.visibility = "visible";
    else
        obj.style.visibility = "visible";
}
