var nameIMGa = "images/seagull1.gif";
var nameIMGb = "images/seagull2.gif";
var heightIMG = 15;
var widthIMG = 33;

NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
VERSION4 = (NS4|IE4) ? 1 : 0;

var objIMG = new Array();
var numObjIMG = 6;
var ptrIMG = 0;

var xborneIMG = 50;
var yborneIMG = 30;
var xaqIMG = xborneIMG;
var yaqIMG = yborneIMG;
var xcaqIMG = xborneIMG;
var ycaqIMG = yborneIMG;

var fIMG = 0;

function animObjIMG () {
    if (fIMG == 0) {
        (this.d) ? this.x+=2 : this.x-=2;
        if (this.x >= xborneIMG) {
            this.x = xborneIMG;
	    this.changedir();
	}
	if (this.x <= -xborneIMG) {
	    this.x = -xborneIMG;
	    this.changedir();
	}

	if (Math.round(Math.random()*(this.s+1)*60) == 1) this.changedir ();
    }

    var t = Math.round(Math.random()*(this.s+1)*10);
    if (t==2 && this.y <  yborneIMG) this.y++;
    if (t==1 && this.y > -yborneIMG) this.y--;

    if (NS4) {
        this.layer.left = this.x+xaqIMG;
	this.layer.top = this.y+yaqIMG;
    } else {
	this.layer.style.pixelLeft = this.x+xaqIMG;
	this.layer.style.pixelTop = this.y+yaqIMG;
    }
}

function changedirObjIMG () { 
    if (this.d == 0) {
	this.d = 1;
        this.img.src = nameIMGb;
    }
    else {
	this.d = 0;
        this.img.src = nameIMGa;
    }
}

function defObjIMG(ID) {
    if (NS4) {
        this.layer = new Layer (0);
        this.layer.visibility = "visible";
        this.layer.document.write('<img name=\"imgIMG'+ID+'\" src=\"'+nameIMGa+'\" height=\"'+heightIMG+'\" width=\"'+widthIMG+'\" border=\"0\">');
        this.layer.document.close();
        eval ('this.img   = this.layer.document.images[\'imgIMG'+ID+'\']');
    } else {
        eval ('this.layer = document.all.IMG'+ID);
        eval ('this.img   = document.images[\'imgIMG'+ID+'\']');
    }
    this.d = Math.round(Math.random());
    this.s = Math.round(Math.random());
    this.x = Math.round(Math.random()*2*xborneIMG) - xborneIMG;
    this.y = Math.round(Math.random()*2*yborneIMG) - yborneIMG;

    this.img.src = (this.d ==0) ? nameIMGa : nameIMGb;

    this.anim = animObjIMG;
    this.changedir = changedirObjIMG;
}

function animIMG() {
    var dx = xcaqIMG-xaqIMG;
    if (Math.abs(dx) > 2) {
        var ix = Math.round(dx/10);
	if (Math.abs(ix) < 2 ) ix = dx > 0 ? 2 : -2;
        xaqIMG += ix;
	fIMG = 1;
    }
    else {
	xaqIMG = xcaqIMG;
	fIMG = 0;
    }

    if (ycaqIMG != yaqIMG) yaqIMG += Math.round((ycaqIMG-yaqIMG)/10);

    for(var x=0; x < numObjIMG; x++) {
        if (dx != 0) {
            if (dx < 0 && objIMG[x].d == 1) objIMG[x].changedir();
            if (dx > 0 && objIMG[x].d == 0) objIMG[x].changedir();
	}
        objIMG[x].anim();
    }
}

function mouseEventIMG(e) {
    if (NS4) {
        xcaqIMG = e.pageX ;
        ycaqIMG = e.pageY ;
    } else {
        xcaqIMG = event.clientX + document.body.scrollLeft ;
        ycaqIMG = event.clientY + document.body.scrollTop ;
    }
}

function initIMG() {
    if (VERSION4) {
        for(var x=0; x<numObjIMG; x++) objIMG[x] = new defObjIMG(x) ;

        if (NS4) document.captureEvents(Event.MOUSEMOVE);
        document.onmousemove = mouseEventIMG;

        setInterval("animIMG();",50);
    }
}

if (VERSION4 && ! NS4) {
    for (var x=0; x<numObjIMG; x++) {
        document.write('<div id="IMG'+x+'" style="position: absolute; visibility: visible;">');
        document.write('<img name="imgIMG'+x+'" src="'+nameIMGa+'" height="'+heightIMG+'" width="'+widthIMG+'" border="0"></div>');
        document.write('</div>');
    }
}

if (window.onload) {
    if (window.RegExp) {
        var regstr = '^[^\\{]*\\{((.|\\t|\\n|\\r)*)}[^\\}]*$';
        window.onload.toString().match(regstr);
        window.onload = new Function (RegExp.$1+"; initIMG ();");
    }
}
else window.onload = initIMG;

