// =======================================================
// HTML & Script: Gerard Ferrandez - Ge-1-doot - Jul 2001
// news://news.leibowitz.org/nzn.fr.html
// http://www.dhteumeuleu.com
// =======================================================
//
//window.onerror = new Function("return true");



var object = new Array();
// --------
nbfm   = 7;
// --------
var xm = 0;
var ym = 9999;
var nx = 0;
var ny = 0;

var x1 = 100;
var y1 = 90;


function movbulb(){
        with (this) {	
                if(ec < 20){
                        if(Math.abs(x0 - xm) < 100 && Math.abs(y0 - ym) < 100){
                                xx = (xm - x0) / 8;
                                yy = (ym - y0) / 8;
                                ec++;
                        }
                }

                xx *= 0.99;
                yy *= 0.99;

                x0 = Math.round(x0 + Math.cos(y0 / 15) * p) + xx;
                y0+= yy - v;

                if(y0 < -h * 2 || x0 < -w * 2 || x0 > nx + w * 2){
                        y0 = ny + N + h * 2;
                        x0 = nx/2-200 + Math.random() * 100;
                        ec = 0;
                }
				
			
				if(y0 < 5 ){ y0 = 5; x0 = x0 - 30 }
				
//				if(y0 < 5 && x0 < 80){ y0 = 5; x0 = x0 - 2 }				
				
				if(y0 > 120 ){ y0 = 80; x0 = 100 }
				
//				if(x0 < 30 ){ y0 = 130;  }
//				if(x0 > 220 ){ x0 = 30; y0 = 130  }
				

				if(y0 > 50 && x0 < 30 ){ x0 = 218; }

				if(x0 > 50 && x0 < 120 && y0 < 35  ){ y0 = 50; }

				if(y0 < 30 && y0 > 20 && x0 > 200 ){ x0 = 31; }

				
                obj.style.top  = (y0 - h) + "px";
                obj.style.left = (x0 - w) + "px";
                
        }
}

var zind = 1;

function CObj(N,img,w,h){
        this.obj = document.createElement("img");
        this.obj.src = img.src;
        this.obj.style.position = "absolute";
        this.obj.style.left = "-1000px";
        this.obj.style.zIndex = zind;
       
        zind++
        document.body.appendChild(this.obj);

        this.N  = N;
        this.x0 = 0;
        this.y0 = -1000;
        this.v  = 1 + Math.round((80 / h) * Math.random());
        this.p  = 1 + Math.round((w / 8) * Math.random());
        this.xx = 0;
        this.yy = 0;
        this.ec = 0;
        this.w  = w;
        this.h  = h;
        this.movbulb = movbulb;
        
}
function resize(){
        nx = 750;
        ny = 100;
}
onresize = resize;
/*
document.onmousemove = function(e){
        if (window.event) e = window.event;
        xm = document.body.scrollLeft+(e.x || e.clientX);
        ym = document.body.scrollTop+(e.y || e.clientY);
}
*/

        xm = parseInt(Math.random() * 10);
        ym = parseInt(Math.random() * 10);


function run(){
        for(i in object)object[i].movbulb();
        setTimeout("run();",160);
}

function initAnim() {
        PIC = document.getElementById("bubbles").getElementsByTagName("img");
        resize();
        
        for(nbf=0;nbf<nbfm;nbf++){
                sf = PIC[nbf%PIC.length];
                object[nbf] = new CObj(nbf,sf,sf.width/2,sf.height/2);
        }
        run();
}


