
  // SCRIPT:   Page Shwoop Animation
  // Filename: pageShwoopAnim.js
  // Purpose:  Script to animate an image across the page
  //
  // Author:   Deborah Lee Soltesz, USGS, 4/2002


    // image moves from lower left to upper right
    function animateImageShwoopUL (imageID) {
      if (ns6) {
        imageObject = document.getElementById(imageID) ;

        winW = document.body.offsetWidth ;
        winH = document.body.offsetHeight ;

        loc_w = winW + 1 ;
        loc_h = winH + 1 ;

        imageObject.style.left = loc_w ;
        imageObject.style.top  = loc_h ;

        imageObject.style.visibility = "visible" ;

        moveImageFromLRtoUL (loc_w, loc_h, winW, winH, imageID);
      }
   }



    function moveImageFromLRtoUL (loc_w, loc_h, winW, winH, imageID) {
      if (ns6) {

        // this function is called another function, which should
        // check to make sure ns6 == true
        imageObject = document.getElementById(imageID) ;

        if (loc_h > -150 || loc_w > -150) {

          loc_w -= 2  ;
          loc_h -= 2 * (winH/winW) ;

          imageObject.style.left = loc_w ;
          imageObject.style.top  = loc_h ;

          cmdToRun = "moveImageFromLRtoUL (" + loc_w   + ", "   +
                                               loc_h   + ", "   +
                                               winW    + ","    +
                                               winH    + ", \"" +
                                               imageID + "\")"  ;
          window.setTimeout(cmdToRun, 10) ;
        }
        else {
          imageObject.style.visibility = "hidden" ;
          imageObject.style.left = -200 ;
          imageObject.style.top  = -200 ;
        }
      }
    }








    // image moves in a circle
    function animateImageDance (imageID, radius) {
      if (ns6) {
        // set up image that spins
        imageObject = document.getElementById(imageID) ;
        imageObject.style.visibility = "visible" ;

        winW = document.body.offsetWidth ;
        winH = document.body.offsetHeight ;

        loc_w = winW - radius * 3 ;
        loc_h = radius + 10  ;

        imageObject.style.left = loc_w ;
        imageObject.style.top  = loc_h ;

        moveImageDance(loc_w, loc_h, loc_w, loc_h, radius, 1, imageID);
      }
    }

    // image moves in a circle around another image
    function animateImageOrbit (imageID, imageID2, radius) {
      if (ns6) {
        // set up image that spins
        imageObject = document.getElementById(imageID) ;
        imageObject.style.visibility = "visible" ;

        winW = document.body.offsetWidth ;
        winH = document.body.offsetHeight ;

        loc_w = winW - radius * 2 ;
        loc_h = radius + 10  ;

        imageObject.style.left = loc_w ;
        imageObject.style.top  = loc_h ;

        // setup image that stays static
        imageObject2 = document.getElementById(imageID2) ;
        imageObject2.style.visibility = "visible" ;
        imageObject2.style.left = loc_w - (imageObject2.offsetWidth  / 2.0) + 10 ;
        imageObject2.style.top  = loc_h - (imageObject2.offsetHeight / 2.0) + 10 ;

        //window.status = imageObject2.style.left + ", " + imageObject2.style.top ;


        moveImageDance(loc_w, loc_h, loc_w, loc_h, radius, 1, imageID);
      }
   }



    function moveImageDance (loc_w, loc_h, center_w, center_h, radius, curDegree, imageID) {
      if (ns6) {

        // this function is called another function, which should
        // check to make sure ns6 == true
        imageObject = document.getElementById(imageID) ;

          curDegree++ ;

          loc_w = center_w + (radius * Math.cos(curDegree/57.2957795786 )) ;
          loc_h = center_h + (radius * Math.sin(curDegree/57.2957795786 )) ;

          imageObject.style.left = loc_w ;
          imageObject.style.top  = loc_h ;

          cmdToRun = "moveImageDance (" + loc_w     + ", "   +
                                          loc_h     + ", "   +
                                          center_w  + ", "   +
                                          center_h  + ","    +
                                          radius    + ", " +
                                          curDegree + ", \"" +
                                          imageID + "\")"  ;
          window.setTimeout(cmdToRun, 100) ;
      }
    }






    // image moves from lower left to upper right
    function animateImageWiggleHorizRL (imageID, radius) {
      if (ns6) {
        imageObject = document.getElementById(imageID) ;
        imageObject.style.visibility = "visible" ;

        winW = document.body.offsetWidth ;
        winH = document.body.offsetHeight ;

        loc_w = winW - 30;
        loc_h = radius + 10  ;

        imageObject.style.left = loc_w ;
        imageObject.style.top  = loc_h ;

        moveImageWiggleRL(loc_w, loc_h, loc_w, loc_h, radius, 1, imageID);
      }
   }



    function moveImageWiggleRL (loc_w, loc_h, center_w, center_h, radius, curDegree, imageID) {
      if (ns6) {

        // this function is called another function, which should
        // check to make sure ns6 == true
        imageObject = document.getElementById(imageID) ;

        if (loc_w > -150) {
          curDegree++ ;

          loc_w-- ;
          loc_h = center_h + (radius * Math.sin(curDegree/57.2957795786 )) ;

          imageObject.style.left = loc_w ;
          imageObject.style.top  = loc_h ;

          cmdToRun = "moveImageWiggleRL (" + loc_w     + ", "   +
                                          loc_h     + ", "   +
                                          center_w  + ", "   +
                                          center_h  + ","    +
                                          radius    + ", " +
                                          curDegree + ", \"" +
                                          imageID + "\")"  ;
          window.setTimeout(cmdToRun, 100) ;
        }
        else {
          imageObject.style.visibility = "hidden" ;
        }
      }
    }




