chooseindia.com
flowers flowers flowers flowers flowers flowers flowers
Software Jobs Hindi Movies Starworld Indian Recipes Travel and Tourism
 

Back          JavaScript / DHTML          chooseindia.com

 
 
 

Flying Butterfly 

<!-- Paste this code into the HEAD of your HTML document -->

<script language="Javascript1.2">

var butterflypath="butterfly.gif" 
var speed=200; 

var change=800; 
var xmax=15; 
var ymax=15; 
var isNS=(navigator.appName=="Netscape");
var _all='all.';
var _style='.style';
var _visible='visible';
var w_x, w_y, x, y, tx, ty, xo, yo, img1;
var incrx=2;
var incry=8;
var xdir=true;
var ydir=true;
if(isNS){
_all='';
_style='';
_visible='show';
}

function init(){
img1=eval('document.'+_all+'img1'+_style);
resize();
moveimg(w_x/2,w_y/2);
img1.visibility=_visible;
animate();
changedirs();
regenerate2();
}

function resize(){
if(isNS){
w_x=window.innerWidth-document.img1.document.width;
w_y=window.innerHeight-document.img1.document.height;
}else{
w_x=document.body.clientWidth-document.image1.width;
w_y=document.body.clientHeight-document.image1.height;
}}

function changedirs(){
xdir=(Math.floor(Math.random()*2)==0);
ydir=(Math.floor(Math.random()*2)==0);
incrx=Math.floor(Math.random()*xmax);
incry=Math.floor(Math.random()*ymax);
setTimeout('changedirs()',change);
}

function animate(){
if(isNS){
tx=img1.left;
ty=img1.top;
xo=pageXOffset;
yo=pageYOffset;
}else{
tx=img1.pixelLeft;
ty=img1.pixelTop;
xo=document.body.scrollLeft;
yo=document.body.scrollTop;
}
if(ydir){
if((ty+incry)>(w_y+yo)){ ydir=false; moveimg(0,-incry); }else{ moveimg(0,incry); }
}else{
if((ty-incry)<yo){ ydir=true; moveimg(0,incry); }else{ moveimg(0,-incry); }
}
if(xdir){
if((tx+incrx)>(w_x+xo)){ xdir=false; moveimg(-incrx,0); }else{ moveimg(incrx,0); }
}else{
if((tx-incrx)<xo){ xdir=true; moveimg(incrx,0); }else{ moveimg(-incrx,0); }
}
setTimeout('animate()',speed);
}

function moveimg(dx,dy){
if(isNS){
img1.moveBy(dx,dy);
}else{
img1.pixelTop+=dy;
img1.pixelLeft+=dx;
}}

function hidebutterfly(){
if (document.all)
document.all.img1.style.visibility="hidden"
else if (document.layers)
document.img1.visibility="hide"
}

function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers)
setTimeout("window.onresize=regenerate",400)
}

if (document.all)
window.onresize=resize
window.onload=init
</script>

<!-- Paste this code into the BODY of your HTML document -->

<div id="img1" style="position:absolute; top:0px; left:0px; visibility:hidden; z-index:10">
<script language="JavaScript1.2">
if (document.all||document.layers)
document.write('<a href="javascript:hidebutterfly()"><img src="'+butterflypath+'" border=0" name="image1" border=0></a>')
</script>
</div>

<--Save image (fly.gif) in your web site directory. -->

 
 
 
 
 
 
Alternative Therapy
Engineering
Software Jobs
Tourism
Starworld
Indian Recipes
 
cool flash sites
Javascript / DHTML
Jokes
Software Jobs | Starworld | Recipe |
Copyright © 1996-2000, ChooseIndia.com All rights reserved.