/* Functions and methods that interact with and/or supplement Flash applications */


// Change background color in synchrony with Flash background color changes.

function insertPlaceholder(placeholderBannerPath) {
  if(!document.getElementById('flashcontent')) return;

  var flashcontent = document.getElementById('flashcontent');
  var placeholder = document.createElement('img');
  placeholder.className = 'noflash_banner';
  placeholder.src = placeholderBannerPath;
  flashcontent.insertBefore(placeholder, flashcontent.firstChild);
}

function replaceBanner(noFlashBannerPath) {
  if(!document.getElementById('flashcontent')) return;

  var flashcontent = document.getElementById('flashcontent');
  if(flashcontent.getElementsByTagName('embed')[0] || flashcontent.getElementsByTagName('object')[0]) return;

  flashcontent.innerHTML = '<img id="home_failover_flashUpgrade" src="' + noFlashBannerPath + '" alt="Get Adobe Flash Player" usemap="#upgrade_flash" class="noflash_banner" /><map name="upgrade_flash" id="upgrade_flash"><area shape="rect" alt="Download Flash Player" title="Get Adobe Flash Player" coords="321,176,725,266" href="http://www.adobe.com/shockwave/download/download.cgi" target="_blank" /></map>';
}

function initializeSWFObject(noFlashBannerPath) {
  var so = new SWFObject('/flash/index_loader.swf', 'home_globe', '980', '306', '8', '#869193', true);
  so.addParam('base', '/flash');
  so.setAttribute('useExpressInstall', 'true');
  so.write('flashcontent')

  replaceBanner(noFlashBannerPath);
}

function changeBgColor(sRGB) {
  document.getElementsByTagName('body')[0].style.backgroundColor = sRGB;
}
