// Moving Objects Script
// By Virtual_Max
// 
// Permission to use, copy, modify, and distribute this software and its documentation 
// for NON-COMMERCIAL purposes and  without fee is hereby granted provided that this 
// notice appears in all copies. 
//
// VIRTUAL MAX MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE 
// SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 
// NON-INFRINGEMENT. VIRTUAL MAX SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY 
// LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR 
// ITS DERIVATIVES.




function BrowserCheck()
{
return (navigator.javaEnabled() && (browser_id=="IE" || (browser_id=="OP" && browser_version>5) || (browser_id=="FF" && browser_version>=2)))
}



if (BrowserCheck())
{


var vmin=12; //2
var vmax=15; //5
var vr=2;
var timer1;




function iecompattest()
{
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function Chip(chipname,width,height){
 this.named=chipname;
 this.vx=vmin+vmax*Math.random();
 this.vy=vmin+vmax*Math.random();
 this.w=width;
 this.h=height;
 this.xx=0;
 this.yy=0;
 this.timer1=null;
}



function movechip( id)
{
var spin;
var chip;

if (document.getElementById)
{
    eval("chip = chip"+id);
    spin = "spin"+id;

    if (window.innerWidth || window.opera)
    {
	pageX = window.pageXOffset;
	pageW = window.innerWidth-20; //size pic
	pageY = window.pageYOffset;
	pageH = window.innerHeight-20;
    }
    else if (document.body)
    {
	pageX = iecompattest().scrollLeft;
	pageW = iecompattest().offsetWidth-20; // size pic
	pageY = iecompattest().scrollTop;
	pageH = iecompattest().offsetHeight-20;
    } 

    if (document.all[spin].src!=sp.src) document.all[spin].src=sp.src;

    if (Math.floor(Math.random()*6) != 0) chip.xx = chip.xx+chip.vx; //silly walk
    chip.yy=chip.yy+chip.vy;
    chip.vx+=vr*(Math.random()-0.5);
    chip.vy+=vr*(Math.random()-0.5);

    if (chip.vx>(vmax+vmin))  chip.vx=(vmax+vmin)*2-chip.vx;
    if (chip.vx<(-vmax-vmin)) chip.vx=(-vmax-vmin)*2-chip.vx;
    if (chip.vy>(vmax+vmin))  chip.vy=(vmax+vmin)*2-chip.vy;
    if (chip.vy<(-vmax-vmin)) chip.vy=(-vmax-vmin)*2-chip.vy;


    if (chip.xx<=pageX)
    {
        chip.xx=pageX;
        chip.vx=vmin+vmax*Math.random();
    }
    else if (chip.xx>=pageX+pageW-chip.w)
    {
        chip.xx=pageX+pageW-chip.w;
        chip.vx=-vmin-vmax*Math.random();
    }
    else if (chip.yy<=pageY)
    {
        chip.yy=pageY;
        chip.vy=vmin+vmax*Math.random();
    }
    else if (chip.yy>=pageY+pageH-chip.h)
    {
        chip.yy=pageY+pageH-chip.h;
        chip.vy=-vmin-vmax*Math.random();
    }

    document.getElementById(chip.named).style.left=chip.xx+"px";
    document.getElementById(chip.named).style.top=chip.yy+"px";
//document.getElementById(chip.named).style.left=chip.xx+"px";
//document.getElementById(chip.named).style.top=chip.yy+"px";
//document.getElementById(chip.named).style.position="absolute"; //
    //spin = "spin1";//chip.named;
    //document.all[spin].src=sp.src;
    //document.getElementById(spin).src=sp.src;


    chip.timer1=setTimeout("movechip('"+id+"')",100);
}
}





function stopme(id,visibility)
{
chipname="chip"+id; 
spin="spin"+id;
   
    if (visibility==0)
    {
        //if (document.layers)
        //{
        //    eval('document.'+chip+'.visibility="hide"');
       // }
        //else
        //{
            eval('document.all.'+chipname+'.style.visibility="hidden"');
        //}
    }



    if (chipname=="chip1") {spin="spin1";lid = 1;}
    if (chipname=="chip2") {spin="spin2";lid = 2;} 
    if (chipname=="chip3") {spin="spin3";lid = 3;} 
    if (chipname=="chip4") {spin="spin4";lid = 4;} 

    
    document.all[spin].src=sp2.src;
    //eval('document.layers['+lid+'].document.'+spin+'.src=sp2.src'); // NS
      
    eval("chip=chip"+id);

    if (chip.timer1!=null)
    {
       clearTimeout(chip.timer1);
    }

}





}
/*
Floating image script
By Virtual_Max (http://www.geocities.com/siliconvalley/lakes/8620)
Permission granted to Dynamicdrive.com to feature it in it's archive
For 100's of FREE DHTML scripts and components,
Visit http://dynamicdrive.com
*/

function BrowserCheck()
{
return true; //(navigator.javaEnabled() && (browser_id=="IE" || (browser_id=="OP" && browser_version>5) || (browser_id=="FF" && browser_version>=2)))
}

var chip1;
var chip2;
var chip3;
//var chip4;
//var chip5;

var slowdownstart; 

//add or delete more variables, depending on how many images you're using

function pagestart()
{
if (BrowserCheck())
{
chip1=new Chip("chip1",10,10);
chip2=new Chip("chip2",10,10);
chip3=new Chip("chip3",10,10);
}
}

function Reload( id)
{
if (BrowserCheck())
{
millisec = 1000*(Math.floor(Math.random()*10)+2);
setTimeout("movechip('"+id+"');",150*slowdownstart);
setTimeout("stopme('"+id+"',1);",millisec);
setTimeout("stopme('"+id+"',1);",millisec+1000);
}
}

