function getMyCookie(CookieName) 
{
  //
  // This function retrieves the specified cookie and assigns it a new value
  // based upon its current setting
  //
  // Read the cookie property. This returns all cookies for this document
  var AllCookies = document.cookie;


  // Look for the start of the cookie named in the argument list
  var pos = AllCookies.indexOf(CookieName);

  // If we do NOT find a cookie by that name, set its value to ONE.
  if (pos==-1) {
     document.cookie = CookieName+"ONE";
     CookieValue="ONE";
     }
  
  else {

     // A Cookie was found by that name; locate the first character of the desired cookie	    
     var start = pos+12;  // start position for the cookie's value
    
     // locate last character of the desired cookie
     var end = AllCookies.indexOf(";", start);
     if (end==-1) end = AllCookies.length; 
    
     // get the value of the cookie
     CookieValue=AllCookies.substring(start,end);
     
     // based upon its current value, set the cookie to its new value

     if (CookieValue=="ONE") {
        document.cookie = CookieName+"TWO";
        CookieValue = "TWO";
        }
     else if (CookieValue=="TWO") {
        CookieValue = "ONE";
        document.cookie = CookieName+"ONE";
        }
     else {
        CookieValue = "FINISH"
        document.cookie = CookieName+"FINISH";
        }
     }


  return CookieValue;
}


function writePlayer(PlayerFileName)
{
  //
  // this function writes the BAP Player to the web page using the specified audio file specified
  // in the argument "PlayerFileName
  //
   document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='50' height='50' id='BAPPLAYER' align='middle'> ");
   document.write("<param name='allowScriptAccess' value='sameDomain' /> ");
   document.write("<param name='movie' value="+ "'" + PlayerFileName + "' /> ");
   document.write("<param name='quality' value='high' /> ");
   document.write("<param name='bgcolor' value='#FFFFFF' /> ");
   document.write("<embed src=" + "'" + PlayerFileName + "' " + "quality='high' bgcolor='#FFFFFF' width='50' height='50' name='BAPPLAYER' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'/> ");
   document.write("</object>");
   document.write("<br><b>Audio</b><br>");
}


// the functioning of the BAP Player relies on the use of the temporary cookie named "WhichTime02"
// this temporary cookie should be for exclusively used in the control of the BAP Player	
var WhichVisit = getMyCookie("WhichTime02=");

var PlayerFileName = " ";
if (WhichVisit=="ONE") {
    PlayerFileName = "http://www.businessaudioproductions.com/webaudio/671204/flash/671204-02A.swf";
    }
else if (WhichVisit=="TWO") {
    PlayerFileName = "http://www.businessaudioproductions.com/webaudio/671204/flash/671204-02B.swf";
    }
else {
    
    PlayerFileName = "http://www.businessaudioproductions.com/webaudio/671204/flash/671204-02A.swf";
    }

// debug statement
// document.write("Cookie = " + WhichVisit + "<br>");

// create the appropriate player
var OK = writePlayer(PlayerFileName);