
//*** This JS include file potentially called twice (if in frame) - frame version or HTML by itself, uses same code block, checks done in code to determine where it is (frame or not)

//   *****************************************************************************************************
//  *** Template JS File                                                                                ***
//  ***   - Rename file "Player_Template_JS.asp" to ATA_1968_07_20_1_Player.js   (i.e. FDR_1941_12_07_1_Player.asp) ***
//  ***   - Global change "ATA_1968_07_20_1" to strATA_1968_07_20_1  (i.e. "FDR_1941_12_07_1")                       ***
//   *****************************************************************************************************

   fframes = "Y"
   if (parent.location.href == self.location.href) {
      fframes = "N"
      }

   function PlayAudio() {
     //null
     }

   function thisMovie(movieName) {
       var isIE = navigator.appName.indexOf("Microsoft") != -1;
       return (isIE) ? window[movieName] : document[movieName];
       }

   function makeCall(sstr) {
     aarg = sstr.split(",")
     str     = aarg[0]
     imgname = aarg[1]

     if (fframes == "Y") {
        ll = parent.transcript_content.document.images.length;
        }
     else {
        ll = document.images.length;
        }

     soundOff = new Image()
     soundOff.src = "../Images/AAT_Speaker_30x19.jpg"
     soundOn = new Image()
     soundOn.src = "../Images/PP2_Play_30x19.jpg"
     soundPlay = new Image()
     soundPlay.src = "../Images/PP2_Play_30x19.jpg"
     soundPause = new Image()
     soundPause.src = "../Images/PP2_Pause_30x19.jpg"

     // *** search for and switch speaker symbol to Play - Pause symbol
     found_playpoint = "N";
     if (fframes == "Y") {
        for (var j=0; j<ll; j++) {
            nname = parent.transcript_content.document.images[j].name;
            if (nname == imgname) {    //*** means found image at link clicked
               ssource = parent.transcript_content.document.images[j].src;
               wwhere = ssource.indexOf("PP2_Play",0)
               wwherePause = ssource.indexOf("PP2_Pause",0)

               if (wwhere != -1 ) {
                  // *** reset previous Green Arrow on (if any)
                  for (var k=0; k<ll; k++) {
                      nname = parent.transcript_content.document.images[k].name;
                      if (nname.substring(0,3) == "img") {    //*** means found speaker symbol image, so image source to speaker (if it happend to be a green arrow)
                         parent.transcript_content.document.images[k].src = soundOff.src
                         }
                      }  // *** end For loop
                  //*** end reset green arrows (if any)

                  //*** Start Pause code
                  parent.transcript_content.document.images[j].src = soundPause.src
                  str = "pauseHere"
                  //*** End   Pause code
                  }    //*** end image was Play-Pause symbol


               if (wwherePause != -1 ) {
                  // *** reset previous Green Arrow on (if any)
                  //alert("Found Pause")
                  for (var k=0; k<ll; k++) {
                      nname = parent.transcript_content.document.images[k].name;
                      if (nname.substring(0,3) == "img") {    //*** means found speaker symbol image, so image source to speaker (if it happend to be a green arrow)
                         parent.transcript_content.document.images[k].src = soundOff.src
                         }
                      }  // *** end For loop
                  //*** end reset green arrows (if any)

                  //*** Start Play-Pause code
                  parent.transcript_content.document.images[j].src = soundPlay.src
                  str = "playHere"
                  //*** End   Play-Pause code
                  }    //*** if end image was Play-Pause symbol


               }       //*** end found image at link
            }          //*** end For Loop
        }              //*** end if frames = Y
     else {
        for (var j=0; j<ll; j++) {
            nname = document.images[j].name;
            if (nname == imgname) {    //*** means found image at link clicked
               ssource = document.images[j].src;
               wwhere = ssource.indexOf("PP2_Play",0)
               wwherePause = ssource.indexOf("PP2_Pause",0)

               if (wwhere != -1 ) {
                  // *** reset previous Green Arrow on (if any)
                  for (var k=0; k<ll; k++) {
                      nname = document.images[k].name;
                      if (nname.substring(0,3) == "img") {    //*** means found speaker symbol image, so image source to speaker (if it happend to be a green arrow)
                         document.images[k].src = soundOff.src
                         }
                      }  // *** end For loop
                  //*** end reset green arrows (if any)

                  //*** Start Pause code
                  document.images[j].src = soundPause.src
                  str = "pauseHere"
                  //*** End   Pause code
                  }    //*** end image was Play-Pause symbol


               if (wwherePause != -1 ) {
                  // *** reset previous Green Arrow on (if any)
                  //alert("Found Pause")
                  for (var k=0; k<ll; k++) {
                      nname = document.images[k].name;
                      if (nname.substring(0,3) == "img") {    //*** means found speaker symbol image, so image source to speaker (if it happend to be a green arrow)
                         document.images[k].src = soundOff.src
                         }
                      }  // *** end For loop
                  //*** end reset green arrows (if any)

                  //*** Start Play-Pause code
                  document.images[j].src = soundPlay.src
                  str = "playHere"
                  //*** End   Play-Pause code
                  }    //*** if end image was Play-Pause symbol


               }       //*** end found image at link
            }          //*** end For Loop
        }              //*** end if frames = Y


       if (fframes == "Y") {
          parent.AAT_Player.thisMovie("audioPlayer").asFunc(str);
          }
       else {
          thisMovie("audioPlayer").asFunc(str);
          }
       }

   function jsFunc(str) {
       //confirm("Audio and Text Player Help \n\nTo play the audio, click on the Play button in the Audio Player, or click on any Speaker Symbol along the right side of the text area.  \n\n --- More Helpful Instructions to be added later --- \n\n\nFor company information and additional help, please visit our website at \n www.AudioAndText.com - a division of New Media Dynamics - www.NewMediaDynamics.com")
       window.open('../AAT_Player_Help.html','mywindow','width=500,height=400,scrollbars=yes,resizable=yes')
       }
   function ddbug(str) {
       alert("Debug: "+str)
       }

   function myTestFunction(str) {
       document.inForm.inField.value = str;
       }



  //*** function Play Point **********************************
  function PlayPoint(theNumber) {
     tmpPP = theNumber.split("_")
     PP = tmpPP[1]

     soundOff = new Image()
     soundOff.src = "../Images/AAT_Speaker_30x19.jpg"
     soundOn = new Image()
     soundOn.src = "../Images/PP2_Play_30x19.jpg"
     soundPlay = new Image()
     soundPlay.src = "../Images/PP2_Play_30x19.jpg"
     soundPause = new Image()
     soundPause.src = "../Images/PP2_Pause_30x19.jpg"

     // *** sample JS Transcript notation for use with frames -  ll = parent.transcript_content.document.images.length;
     if (fframes == "Y") {
        ll = parent.transcript_content.document.images.length;
        }
     else {
        ll = document.images.length;
        }

     found_playpoint = "N";
     k = 0;

     // *** reset previous Green Arrow on (if any)
     if (fframes == "Y") {
        for (var j=0; j<ll; j++) {
            nname = parent.transcript_content.document.images[j].name;
            if (nname.substring(0,3) == "img") {    //*** means found speaker symbol image, so image source to speaker (if it happend to be a green arrow)
               parent.transcript_content.document.images[j].src = soundOff.src
               }
            }  // *** end For loop
        }  //*** end fframes = Y
     else {
        for (var j=0; j<ll; j++) {
            nname = document.images[j].name;
            if (nname.substring(0,3) == "img") {    //*** means found speaker symbol image, so image source to speaker (if it happend to be a green arrow)
               document.images[j].src = soundOff.src
               }
            }  // *** end For loop
        }  //*** end fframes = N



     // *** search for and switch speaker symbol to Green Arrow
     found_playpoint = "N";
     if (fframes == "Y") {
        for (var j=0; j<ll; j++) {
            nname = parent.transcript_content.document.images[j].name;
            if (nname.substring(0,3) == "img") {    //*** means found speaker symbol image, so image source to speaker (if it happend to be a green arrow)
               if (PP == k) {
                  parent.transcript_content.document.images[j].src = soundOn.src
                  found_playpoint = "Y";
                  }
               else {
                  k++;
                  }
               }
            if (found_playpoint == "Y") {
               break;
               }
            }  // *** end For loop
        }
     else {
        for (var j=0; j<ll; j++) {
            nname = document.images[j].name;
            if (nname.substring(0,3) == "img") {    //*** means found speaker symbol image, so image source to speaker (if it happend to be a green arrow)
               if (PP == k) {
                  document.images[j].src = soundOn.src
                  found_playpoint = "Y";
                  }
               else {
                  k++;
                  }
               }
            if (found_playpoint == "Y") {
               break;
               }
            }  // *** end For loop
        }
  }  // end function PlayPoint

  // Check to see if the player is in the parent.AAT_Player frame, otherwise player will not write when inside player frame
  player_location = "N"
  if (fframes == "Y") {
     if (parent.AAT_Player.location.href == self.location.href) {
        player_location = "Y"
        }
     }

  var browser=navigator.appName

  if (fframes == "N" || player_location == "Y" ) {
     // **** AudioAndText_Player - Automatic Control Activiation in IE
     document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="321" height="25" id="audioPlayer" align="middle">')
     document.write('<param name="allowScriptAccess" value="sameDomain" />')
     document.write('<param name="movie" value="../AAT_Player_Green_Arrow.swf" />')
     document.write('<param name="quality" value="high" />')
     document.write('<param name="bgcolor" value="#eeeeee" />')
     document.write('<param name=FlashVars value="location=../Audio_Files/ATA_1968_07_20_1/&baseName=ATA_1968_07_20_1&Segments=15&dummyVar=1">')
     document.write('<embed src="../AAT_Player_Green_Arrow.swf" FlashVars="location=../Audio_Files/ATA_1968_07_20_1/&baseName=ATA_1968_07_20_1&Segments=15&dummyVar=1" quality="high" bgcolor="#eeeeee" width="321" height="25" name="audioPlayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />')
     document.write('</object>')
     }
  else {    // *** After Transcript is loaded, then load appropiate Player JS
     // Code called from multiple places, determine the correct location of player code based on calling URL of transcript
     ll = document.location.href
     var hhere=ll.indexOf("?",0) + 1
     if (hhere==0) {
        //*** called from List Index
        parent.AAT_Player.location.replace("ATA_1968_07_20_1_Player.asp")
        //*** hide the Search Result Navigation buttons unless showing Search Results
        parent.SRhide()
        }
     else {
        //*** called from Search Results
        //*** Checking for IE browser and specifing different URLs because running into browser specific problems
        if (browser=="Microsoft Internet Explorer") {
           parent.AAT_Player.location.replace("transcripts/ATA_1968_07_20_1_Player.asp")
           //*** hide the Search Result Navigation buttons unless showing Search Results
           parent.SRshow()
           }
        else {
           parent.AAT_Player.location.replace("ATA_1968_07_20_1_Player.asp")
           //*** hide the Search Result Navigation buttons unless showing Search Results
           parent.SRshow()
           }        //** end type of browser
        }
     }




