//Flying planes - by John Ely
//Modified from: Autumn leaves script- by Kurt Grigg (kurt.grigg@virgin.net)
//Modified by Dynamic Drive for NS6 functionality
//visit http://www.dynamicdrive.com for this script

//Pre-load your image below!
//CHANGE 5 to the number of images listed below
grphcs=new Array(4) 

//PRELOAD the involved images (extend or contract variables according to # of images used)
Image0=new Image();
Image0.src=grphcs[0]="/wp-content/themes/PaL/images/theme/cloud1.png"
Image1=new Image();
Image1.src=grphcs[1]="/wp-content/themes/PaL/images/theme/cloud2.png"
Image2=new Image();
Image2.src=grphcs[2]="/wp-content/themes/PaL/images/theme/cloud3.png"
Image3=new Image();
Image3.src=grphcs[3]="/wp-content/themes/PaL/images/theme/cloud4.png"

//SPECIFY number of images to randomly display concurrently from list above. Less the more efficient
Amount=4; 
Ypos=new Array();
Xpos=new Array();
Speed=new Array();
ns=(document.layers)?1:0;
ns6=(document.getElementById&&!document.all)?1:0;
ie=document.all

if (ns){
for (i = 0; i < Amount; i++){
var P=Math.floor(Math.random()*grphcs.length);
rndPic=grphcs[P];
document.write("<LAYER NAME='fly_sn"+i+"' LEFT=-100 TOP=-100><img src="+rndPic+"></LAYER>");
}
}
else{
document.write('<div style="position:absolute;top:-100px;left:-100px"><div style="position:relative">');
for (i = 0; i < Amount; i++){
var P=Math.floor(Math.random()*grphcs.length);
rndPic=grphcs[P];
document.write('<img id="fly_si'+i+'" src="'+rndPic+'" style="position:absolute;top:-100px;left:-100px">');
}
document.write('</div></div>');
}
WinHeight=(ns||ns6)?window.innerHeight-100:window.document.documentElement.clientHeight-100;
WinWidth=(ns||ns6)?window.innerWidth-200:window.document.documentElement.clientWidth-200;
for (i=0; i < Amount; i++){                                                                
 Ypos[i] = Math.round(Math.random()*WinHeight);
 Xpos[i] = Math.round(Math.random()*WinWidth);
 Speed[i]= Math.random()+1;
}
function fly(){
var WinHeight=(ns||ns6)?window.innerHeight-100:window.document.documentElement.clientHeight-100;
var WinWidth=(ns||ns6)?window.innerWidth-200:window.document.documentElement.clientWidth-200;

for (i=0; i < Amount; i++){
sx = Speed[i]*0.3;
Xpos[i]+=sx; 
if (Xpos[i] > WinWidth){
Ypos[i]=Math.max(80,Math.round(Math.random()*WinHeight));
Xpos[i]=-200;
Speed[i]=Math.random()+1;
}

if (ns){
document.layers['fly_sn'+i].left=Xpos[i];
document.layers['fly_sn'+i].top=Ypos[i];
}

else if (ns6){
document.getElementById("fly_si"+i).style.left=Xpos[i]+'px';
document.getElementById("fly_si"+i).style.top=Math.min(WinHeight,Ypos[i])+'px';
}

else{
eval("document.all.fly_si"+i).style.left=Xpos[i];
eval("document.all.fly_si"+i).style.top=Ypos[i];
} 
}
setTimeout('fly()',20);
}

if (ie||ns||ns6)
window.onload=fly

