// May 09, 2010
// FMR
// PalauLive.com
//
// Random images to display
//  
      var randnum = randomIMG(13);
      var path = "/fla/";
      var fname= "";
      var pathAndFile = path;
      
      if(parseInt(getCookie("randnum")) >=0)
        var randCookie = getCookie("randnum");
      else
        var randCookie = 0;

      var prev = parseInt(randCookie);
      
      // return selected media file from the array.
      function getMedia(mediaid)
      {
        var arraymedia = new Array("BoatSkyBeach3.swf","BoatSkyBeach2.swf","BoatSkyBeach4.swf",
                                   "BoatSkyBeach.swf","LookUpCocos.swf","CoralSand.swf",
                                   "ComboFlowers.swf","CocoTreeFlower.swf","CoconutTree.swf",
                                   "CoconutFeeder2.swf","GoodCoco.swf","CoconutFeeder.swf",
                                   "CoconutYellow.swf","ButterFly.swf"
                                  );
        
        fname = arraymedia[mediaid];
                
        //alert('json: '+path+fname);
                
        return fname;
      }
      
      // this function actually 
      function selectMedia()
      {  
        if(randnum!=prev && randnum<=13)
        {
          getMedia(randnum);          
        }
        else
        {
          if(randnum>=0 && randnum <13) 
          {
            randnum++;
          }
          else
          {
            randnum--;
          }
          getMedia(randnum); // get different media from previous
        }
        
        //return pathAndFile; 
      }
       
      selectMedia(); // call function selectMedia to select a media, different from previous.

      pathAndFile+= fname;      // combine path and file name to one string. 

      // set cookie 
      setCookie("randnum",randnum,exp);   
      
      // do pre-load swf here.
      //if(window.document.movie)
        //alert(movie.PercentLoaded());
      
      // reder the media to webpage.   
      document.write('<EMBED src="' + pathAndFile +'"' + ' NAME="movie" quality="high" wmode="transparent" bgcolor="#FFFFFF"  WIDTH="100%" HEIGHT="150px" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>');       
      
      /* 
      if(movie.PercentLoaded() > 0)
        alert('if: '+ movie.PercentLoaded());
      else
        alert('else: ' + movie.PercentLoaded());
      */
      //alert(movie.TotalFrames()); 
      //movie.Zoom(50);
      //if(OnProgress(0))
      // alert('loading...');   
   
      // testing to see which media name and the previous media id.
      //alert('pathAndFile: '+pathAndFile+',  prev:'+prev); // for testing.
    