
// JavaScript Document
<!-- Original:  Kurt Grigg (kurt.grigg@virgin.net) -->
<!-- Web Site:  http://website.lineone.net/~kurt.grigg/javascript -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

var n4=(document.layers);
var n6=(document.getElementById&&!document.all);
var ie=(document.all);
var o6=(navigator.appName.indexOf("Opera") != -1)?true:false;

<!-- Begin
Image0 = new Image();
//Image0.src = "../bluebub2.gif";
Image0.src = "bubblack.gif";
//Amount = 20; 
var Amount = 10; 
var nTimerFreq = 20;
var AmountCtr=Amount;
var nOpacity = 50;
var Ymouse = -50;
var Xmouse = -50;
var orig_Ymouse = Ymouse;
var orig_Xmouse = Xmouse;
Ypos = new Array();
Xpos = new Array();
Speed = new Array();
rate = new Array();
grow = new Array();
Step = new Array();
Cstep = new Array();
nsSize = new Array();
ns = (n4)?1:0;
(n4||(n6))?window.captureEvents(Event.MOUSEMOVE):0;
function mouse(evnt) {
	var orig_Ymouse = Ymouse;
	var orig_Xmouse = Xmouse;
	Ymouse=(n4||(n6))?evnt.pageY-20-window.pageYOffset:event.y-20;
	Xmouse=(n4||(n6))?evnt.pageX:event.x;
//	Ymouse=mouseY(evnt);
//	Xmouse=mouseX(evnt);
	// Added to so bubbles will only display on mousemove
	if(AmountCtr<1){
		if(Ymouse != orig_Ymouse || Xmouse != orig_Xmouse){
			// Added to so bubbles will only display on mousemove
			AmountCtr=Amount;
			resetBubbles();
		}
	}
}
(n4)?window.onMouseMove=mouse:document.onmousemove=mouse;
//(document.layers)?window.onMouseDown=Mouse:document.onmousedown=Mouse;
for (i = 0; i < Amount; i++) {
	Ypos[i] = Ymouse;
	Xpos[i] = Xmouse;
	Speed[i] = Math.random()*4+1;
	Cstep[i] = 0;
	Step[i] = Math.random()*0.1+0.05;
//	grow[i] = 8;
	grow[i] = 2;	// controls growth rate
	nsSize[i] = Math.random()*15+5;
	rate[i] = Math.random()*0.5+0.1;
}
if (n4) {
	for (i = 0; i < Amount; i++) {
		document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+Image0.src+" name='N' width="+nsSize[i]+" height="+nsSize[i]+" \/><\/LAYER>");
   }
}
else {
	document.write('<div style="position:absolute;top:0px;left:0px">');
	for (i = 0; i < Amount; i++) {
		if (n6){
//			document.write('<img id="si" name="si" src="'+Image0.src+'" style="position:absolute;top:0px;left:0px;z-index:2;filter:alpha(opacity=90)" \/>');	
		} 
		else {
			document.write('<img id="si" name="si" src="'+Image0.src+'" style="position:relative;top:0px;left:0px;z-index:2;filter:alpha(opacity='+nOpacity.toString()+')" \/>');
		}
	//	document.write('<img id="si" src="'+Image0.src+'" style="position:absolute;top:0px;left:0px;filter:alpha(opacity=90)">');
	}
document.write('<\/div>');
}

function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX) return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
else return null;
}

function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY) return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
else return null;
}

function resetBubbles(){
	for (var i=0; i<Amount; i++){
		// if it was invisible, then we want to start it out 
		// at the cursor, otherwise keep going
		if(ns){
		}else{
		try{
			if(si[i].style.visibility == "hidden"){
				Ypos[i] = -50;
			}
			si[i].style.visibility = "visible";
			}
			catch(e){
			}
		}
	}
}
function MouseBubbles() {
//	if(document.layers) return;
	var hscrll = (n4)?window.pageYOffset:document.body.scrollTop;
	var wscrll = (n4)?window.pageXOffset:document.body.scrollLeft;
	var isAnyVisible = 0;
	for (i = 0; i < Amount; i++){
		sy = Speed[i] * Math.sin(270 * Math.PI / 180);
		sx = Speed[i] * Math.cos(Cstep[i] * 4);
		Ypos[i] += sy;
		Xpos[i] += sx; 
		// added to only release bubble-set on mousemove
		try{
		var sVisible = (n4)?document.layers['sn'+i].visibility:si[i].style.visibility;
		} 
		catch(e){
		sVisible = "hidden";
		}
//		var sVisible = (document.layers)?document.layers['sn'+i].visibility:si[i].style.visibility
		
		if((sVisible) == "visible"){
			isAnyVisible = 1;
			// If off-screen then re-create from mouse position
			if (Ypos[i] < -40) {
				// added to only release bubble-set on mousemove
				if(--AmountCtr < 1) {
					if (n4) {
						document.layers['sn'+i].visibility = "visible";
					}
					else {
						si[i].style.visibility = "hidden";	// turn uff the bubble
					}
				}
				// end
				Ypos[i] = Ymouse + hscrll;
				Xpos[i] = Xmouse + wscrll;
				Speed[i] = Math.random() * 6 + 4;
//			   grow[i] = 8;
				grow[i] = 3;
				nsSize[i] = Math.random() * 15 + 5;
			}
			if (n4) {
				document.layers['sn'+i].left = Xpos[i] + wscrll;
				document.layers['sn'+i].top = Ypos[i] + hscrll;
			}
			else {
				si[i].style.pixelLeft = Xpos[i] + wscrll;
				si[i].style.pixelTop = Ypos[i] + hscrll;
				si[i].style.width = grow[i];
				si[i].style.height = grow[i]; 
			}
		}
		grow[i] += rate[i]; 
		Cstep[i] += Step[i];
		if (grow[i] > (i%2?14:24)) grow[i] = (i%2?15:25);	// Maximum size of bubble (in pixels)
//		if (grow[i] > 19) grow[i] = 20;
	}
	// turn-off timer if no bubbles currently playing
	(isAnyVisible)?setTimeout('MouseBubbles()', nTimerFreq):setTimeout('MouseBubbles()', 0);
}
//  End -->