bubbleboxes=new Array();
bubblevelocities=new Array();
bubbleposx=new Array();
bubbleposy=new Array();
bubbleangle=new Array();

function makeitso()
{
    initbubbles();
	initrb();
}

function initbubbles()
{
	var winW = 630, winH = 460;
    if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName.indexOf("Microsoft")!=-1)
		{
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
		else
		{
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
    }

    var links=document.getElementsByTagName("a");
    for (var i=links.length-1; i>-1; i--)
    {
        box=document.createElement("div");
        box.className="bubblebox";
        node=links[i];
        node.parentNode.removeChild(node);
        box.innerHTML=node.innerHTML;
		box.id=node.href;
		box.onmousedown=function() {window.location=this.id;};
		box.style.zIndex=10;
        document.body.appendChild(box);
        bubbleboxes.push(box);
        bubblevelocities.push(Math.random()*3+0.5);
        bubbleposx.push(Math.floor(Math.random()*(winW-100)));
		bubbleposy.push(winH+20);
		bubbleangle.push(Math.floor(Math.random()*180));
    }
    floatbubbles();
}

function floatbubbles()
{
    var winW = 630, winH = 460;
    if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName.indexOf("Microsoft")!=-1)
		{
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
		else
		{
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
    }
	
	for (var i=0; i<bubbleboxes.length; i++)
	{
		bubbleposy[i]-=bubblevelocities[i];
		if (bubbleposy[i]<-100)
		{
			bubbleposy[i]=winH+20;
			bubbleposx[i]=Math.floor(Math.random()*(winW-100));
			bubblevelocities[i]=Math.random()*3+0.5;
		}
		bubbleangle[i]=(bubbleangle[i]+4)%360;
		bubbleboxes[i].style.left=bubbleposx[i]+bubblevelocities[i]*5*Math.cos(Math.PI*bubbleangle[i]/180.0);
		bubbleboxes[i].style.top=bubbleposy[i];
	}
	
    setTimeout(floatbubbles,10);
}

function initrb()
{
	/*var imb=document.createElement("img");
	imb.id="rbbox";
	imb.style.position="absolute";
	imb.style.top="0px";
	imb.style.left="0px";
	imb.style.zIndex=5;
	document.body.appendChild(imb);*/
	refreshbackground();
}

function refreshbackground()
{
	document.body.style.backgroundPosition="center center";
	document.body.style.backgroundImage='url("cam/shot.jpg?b='+(new Date()).getTime()+'")';
	/*var winW = 630, winH = 460;
    if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName.indexOf("Microsoft")!=-1)
		{
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
		else
		{
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
    }
	var imb=document.getElementById("rbbox")
	imb.width=winW;
	imb.height=winH;
	imb.src="cam/shot.jpg?b="+(new Date()).getTime();*/
	setTimeout(refreshbackground,30000);
}