
function getMyCookie(cookieName) 
{
  // 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 find a cookie by that name, set its value to NO.
  if (pos !=-1) {
     document.cookie = cookieName+"NO"
     cookieValue="NO";
     }
  
  else {
     document.cookie = cookieName + "YES";
     cookieValue="YES";
     }
    
  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='40' height='40' 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='#000000' /> ");
   document.write("<embed src=" + "'" + PlayerFileName + "' " + "quality='high' bgcolor='#000000' width='40' height='40' name='BAPPLAYER' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'/> ");
   document.write("</object>");
}


// the functioning of the BAP Player relies on the use of the temporary cookie named "FirstTime"
// this temporary cookie should be for exclusively used in the control of the BAP Player	
var firstVisit = getMyCookie("FirstTime=");

//document.write ("Cookie FirstTime = " + firstVisit);
//document.write("<BR>"+"HERE!" + "<BR>");

var PlayerFileName = " ";
if (firstVisit=="YES") {
    PlayerFileName = "http://www.businessaudioproductions.com/webaudio/671179/flash/671179-01a.swf";
    }
else {
    PlayerFileName = "http://www.businessaudioproductions.com/webaudio/671179/flash/671179-01b.swf";
    }

var OK = writePlayer(PlayerFileName);
