
var brOK=false;
var mie=false;
var aver=parseInt(navigator.appVersion.substring(0,1));
var aname=navigator.appName;


var vmin=2;         	// velocity min
var vmax=5;
var vr=1.5;		//average speed
var timer1;
var flag1=false;


var chip1;		//will be bird object

//quote array initialisation
function makeQArray()
{
this[0] = "We are what we think. All that we are arises with our thoughts. With our thoughts we make the world.";
this[1] = "Life is not a matter of holding good cards but of playing your hand well. ";
this[2] = "The mind is it's own place, and in itself can choose to make a hell of heaven or a heaven of hell."
this[3] = "A happy person is not a person in a certain set of circumstances but rather a person with a certain set of attitudes.";
this[4] = "We must walk in balance upon the earth - a foot in spirit and a foot in the physical.";
this[5] = "Your life is like a tapestry being woven on an enchanted loom. Every bobble of the shuttle has meaning, every thread is important.";
this[6] = "Life is a mirror and will reflect back to the thinker what he thinks into it.";
this[7] = "Life is not a problem to be solved but a reality to be experienced.";

this.length = 8;
}

var QArray = new makeQArray();

// Functions start here


function pagestart()	//called by body tag
{checkbrOK(); 		//validates browser is java enabled
 chip1=new Chip("chip1",90,150);		//(chipname, width, height)



 if(brOK) 
   {movechip("chip1")}    // call the functions that moves the bird
    								// with a delay

}



function no_frames (url) {
  
  if (parent.frames.length != 0)
    parent.location.href = (url);
  }



function checkbrOK()					// check browser
{if(aname.indexOf("Internet Explorer")!=-1)
   {if(aver>=4) brOK=navigator.javaEnabled();
    mie=true;
   }
 if(aname.indexOf("Netscape")!=-1)  
   {if(aver>=4) brOK=navigator.javaEnabled();}
}



function Chip(chipname,width,height)	//constructs swan objects
{this.named=chipname;			// this.named ie swan1 passed to doc.all.named
 this.vx=vmin+vmax*Math.random();	//x velocity
 this.vy=vmin+vmax*Math.random();	//y velocity
 this.w=width;				
 this.h=height;
 /*if(!mie)
      {this.yy = document.chip1.top;
       this.xx = document.chip1.left;
      } 
   else
      {this.yy = document.all.chip1.style.pixelLeft + this.w;
       this.xx = document.all.chip1.style.pixelTop - this.h; 
      }
  */
 this.xx=800
 this.yy=50;
 this.timer1=null;
 
}

function movechip(chipname)
{
 if(brOK)
  {eval("chip="+chipname);
   if(!mie)
    {pageX=window.pageXOffset;
     pageW=window.innerWidth;
     pageY=window.pageYOffset;
     pageH=window.innerHeight;
    }
   else
    {pageX=window.document.body.scrollLeft;
     pageW=window.document.body.offsetWidth-8;
     pageY=window.document.body.scrollTop;
     pageH=window.document.body.offsetHeight;
    } 
   
   if(flag1)
   {
   chip.xx=chip.xx+chip.vx;
   chip.yy=chip.yy+chip.vy;
   }   

   chip.vx+=vr*(Math.random()-1);
   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.w))
     {chip.xx=pageX + (pageW * 0.85);
     // chip.vx=vmin+vmax*(Math.random() - 1);
     }
   if(chip.xx>=pageX+pageW-chip.w)
     {chip.xx=pageX+pageW-chip.w;
      chip.vx=-vmin-vmax*Math.random();
     }
   if(chip.yy<=pageY)
     {chip.yy=pageY;
      chip.vy=vmin+vmax*Math.random();
     }
   if(chip.yy>=pageY+pageH-chip.h)
     {chip.yy=pageY+pageH-chip.h;
      chip.vy=-vmin-vmax*Math.random();
     }

   if(!mie)
      {eval('document.'+chip.named+'.top ='+chip.yy);
       eval('document.'+chip.named+'.left='+chip.xx);
      } 
   else
      {eval('document.all.'+chip.named+'.style.pixelLeft='+chip.xx);
       eval('document.all.'+chip.named+'.style.pixelTop ='+chip.yy); 
      }
   if(flag1)
      {
     chip.timer1=setTimeout("movechip('"+chip.named+"')",100);
      }
   else	//long first delay
     {chip.timer1=setTimeout("movechip('"+chip.named+"')",3000);
     }
  flag1=true;		// movechip has been called at least once

   }
}

function stopme(chipname)
{if(brOK)
  {//alert(chipname)
   eval("chip="+chipname);
   if(chip.timer1!=null)
    {clearTimeout(chip.timer1)}
  }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

