function getUpdate(typ,pr1,pr2,swf) {
  if(typ == 'size') {
    var frames = 15;
    var currentHeight = PCMPlayer.playerHeights[swf];
    
    if(pr1 != 0 && pr2 != 0) {
      var newHeight = pr2 * document.getElementById(swf).offsetWidth / pr1;
    } else {
      newHeight = 20; //sound only
    }
    
    PCMPlayer.positionFeedsWindow(swf.substr(swf.lastIndexOf('_') + 1));
    
    PCMPlayer.playerHeights[swf] = newHeight;
    
    animateHeight(swf, currentHeight, newHeight, frames, transitionSpring);
  } else if(typ == 'item') {
    PCMPlayer.positionFeedsWindow(swf.substr(swf.lastIndexOf('_') + 1));
  }
}

function animateHeight(element, from, to, frames, transitionFunction) {
  //alert(transitionFunction);
  var difference = to - from;
  for(i=1;i<=frames;i++){
    var dividend = 1 / frames * i;
    if(transitionFunction != null) {
      dividend = transitionFunction(dividend);
    }
    var newHeight = from + (difference*dividend);
    if(newHeight > 0) {
      var cmd = "document.getElementById('" + element + "').height = '" + newHeight + "px'; "
      cmd += "document.getElementById('" + element + "').style.height = '" + newHeight + "px'; "
      if(from == 0 && i == 1) {
        cmd += "document.getElementById('" + element + "').style.display = 'block';"        
      }
    } else {
      var cmd = "document.getElementById('" + element + "').style.display = 'none';"
    }
    if(from == 0) {
      cmd += "document.getElementById('" + element + "').style.opacity = " + (i / frames) + ";"        
    } else if(to == 0) {
      cmd += "document.getElementById('" + element + "').style.opacity = " + (1 - (i / frames)) + ";"        
    }
    setTimeout(cmd, 500 * i / frames);
  }
}

function transitionSpring(pos) {
  return 1 - (Math.cos(pos * 1.5 * Math.PI) * Math.exp(-pos * 6)); //spring
}

function transitionSinodial(pos) {
  return (-Math.cos(pos*Math.PI)/2) + 0.5; //sinodial
}

function isdefined( variable) {
  return (typeof(window[variable]) == "undefined")?  false: true;
} 

function toFlashColor(c){
  return "0x"+c.replace('#','');
}

if(!isdefined('PCM_width')) PCM_width = 640;
if(!isdefined('PCM_columns')) PCM_columns = Math.max(Math.floor(PCM_width / 300), 1);

if(!isdefined('PCM_background_color')) PCM_background_color = '#111111';
if(!isdefined('PCM_border_color')) PCM_border_color = '#202020';

//if(!isdefined('PCM_episode_border_color')) PCM_episode_border_color = '#303030';
if(!isdefined('PCM_episode_background_color')) PCM_episode_background_color = '#202020';
if(!isdefined('PCM_selected_episode_background_color')) PCM_selected_episode_background_color = '#252525';
if(!isdefined('PCM_episode_text_color')) PCM_episode_text_color = '#C0C0C0';

if(!isdefined('PCM_control_background_color')) PCM_control_background_color = '#000000';
if(!isdefined('PCM_control_front_color')) PCM_control_front_color = '#999999';
if(!isdefined('PCM_control_light_color')) PCM_control_light_color = '#DDDDDD';

if(!isdefined('PCM_autostart')) PCM_autostart = false;
if(!isdefined('PCM_number_of_episodes_shown')) PCM_number_of_episodes_shown = 999999999;
if(!isdefined('PCM_show_episode_list')) PCM_show_episode_list = (PCM_number_of_episodes_shown > 1);
if(!isdefined('PCM_show_download_links')) PCM_show_download_links = true;
if(!isdefined('PCM_show_subscribe_links')) PCM_show_subscribe_links = true;
if(!isdefined('PCM_show_embed_code')) PCM_show_embed_code = true;

PCMPlayer = {
  BASE_URL: isdefined('PCM_base_url') ? PCM_base_url : 'http://feed.podcastmachine.com',
  STYLESHEET: "/stylesheets/player.css",
  CONTROLLER: 'podcasts',
  ACTION: 'player',
  ROOT: 'pcm_player',
  playerHeights: new Array(),

  hasClassName: function(element, className) {
    if (element == null) return;
    var elementClassName = element.className;
    return (elementClassName.length > 0 && (elementClassName == className ||
      new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
  },

  addClassName: function(element, className) {
    if (element == null) return;
    if (!this.hasClassName(element, className))
      element.className += (element.className ? ' ' : '') + className;
    return element;
  },

  removeClassName: function(element, className) {
    if (element == null) return;
    element.className = element.className.replace(
      new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').replace(/^\s+/, '').replace(/\s+$/, '');
    return element;
  },

  requestStylesheet: function() {
    stylesheet = document.createElement("link");
    stylesheet.rel = "stylesheet";
    stylesheet.type = "text/css";
    stylesheet.href = this.BASE_URL + this.STYLESHEET;
    stylesheet.media = "all";
    document.lastChild.firstChild.appendChild(stylesheet);
  },

  requestContent: function() {
    if (isdefined('PCM_podcast_id')){
      var script = document.createElement('script');
      script.src = this.BASE_URL +'/' +this.CONTROLLER+'/'+PCM_podcast_id +'/'+this.ACTION+'?';
      if (isdefined('PCM_sorting')){
        script.src += '&sort='+PCM_sorting;
      }

      if (isdefined('PCM_episode_id') && PCM_episode_id != null){
        script.src += '&episode_id='+PCM_episode_id;
        script.src += '&episodes=1';
      } else {
        script.src += '&episodes='+PCM_number_of_episodes_shown;
      }

      document.getElementsByTagName('head')[0].appendChild(script);
    }
  },

  serverResponse: function(data) {
    if (!data) return;
    this.podcast = data;
    this.renderStacked();
  },
  
  renderStacked: function() {
    var div = document.getElementById(this.ROOT);
    var html = "";
    var columns = Math.min(PCM_columns, this.podcast.episodes.length);
    var videoFieldWidth = (PCM_width - (4 * (columns - 1))) / columns - 116;
    var audioFieldWidth = (PCM_width - (4 * (columns - 1))) / columns - 9;
    var fieldWidth;
        
    var title_ids = [];
    
    var podcastPlayerStyle = 'width: ' + (PCM_width + 8) + 'px; background-color:' + PCM_background_color + '; border: 1px solid '+PCM_border_color+';';
    if (PCM_show_episode_list){
      podcastPlayerStyle += ' padding-bottom: 0px;';
    }
    
    var tdStyle = 'background: '+PCM_episode_background_color+'; color: '+PCM_episode_text_color+';';
    var actionPanelStyle = tdStyle;
    if(isdefined('PCM_episode_border_color')) {
      tdStyle += ' border: 1px solid '+PCM_episode_border_color+';';
    }
    
    if (this.podcast.episodes.length==0){
      html+='\n<div class="podcast_player" style="' + podcastPlayerStyle + '">';
      html+='\n  <div id="player_'+this.podcast.id+'" class="player">';
      html+='\n    This podcast has no playable episodes';
      html+='\n  </div>';
      html+='\n</div>';
    } else {
      html+='\n<div class="podcast_player" style="' + podcastPlayerStyle + '">';
      html+='\n  <div id="player_'+this.podcast.id+'" class="player">';
      html+='\n    <a href="http://www.macromedia.com/go/getflashplayer">Get Flash</a> to see this player.';
      html+='\n  </div>';
      
      if(PCM_show_subscribe_links || PCM_show_download_links || PCM_show_embed_code) {
        html+='\n  <div id="subscribe_window_' + this.podcast.id + '" class="action_panel" style="'+actionPanelStyle+' display: none; width: ' + (PCM_width - 16) + 'px">';
        if(PCM_show_subscribe_links) {
          html+='\n    Subscribe: ';        
          if(this.podcast.feeds.ipodvideolarge || this.podcast.feeds.aac || this.podcast.feeds.mp3) {
            html+='\n    <a href="itpc' + (this.podcast.feeds.ipodvideolarge || this.podcast.feeds.aac || this.podcast.feeds.mp3).url + '" onclick="PCMPlayer.togglePanel('+this.podcast.id+', \'subscribe\')" style="color: '+PCM_episode_text_color+'">';
            html+='\n      <img src="' + this.BASE_URL + '/images/media_players/itunes_24.png"/>';
            html+='\n      Subscribe with iTunes';
            html+='\n    </a>';
          }
          if(this.podcast.feeds.miro) {
            html+='\n    <a href="http://subscribe.getmiro.com/?url1=http' + this.podcast.feeds.miro.url + '?torrent" onclick="PCMPlayer.togglePanel('+this.podcast.id+', \'subscribe\')" style="color: '+PCM_episode_text_color+'">';
            html+='\n      <img src="' + this.BASE_URL + '/images/media_players/miro_24.png"/>';
            html+='\n      Subscribe with Miro';
            html+='\n    </a>';
          }
          html+='\n    <a onclick="PCMPlayer.togglePanel('+this.podcast.id+', \'subscribe\'); document.getElementById(\'feeds_window_' + this.podcast.id + '\').style.display = \'block\';" style="color: '+PCM_episode_text_color+'">';
          html+='\n      <img src="' + this.BASE_URL + '/images/media_players/podcast_24.png"/>';
          html+='\n      RSS feeds';
          html+='\n    </a>';
        }
        html+='\n  </div>';

        html+='\n  <div id="download_window_' + this.podcast.id + '" class="action_panel" style="'+actionPanelStyle+' display: none; width: ' + (PCM_width - 16) + 'px">';
        if(PCM_show_download_links) {
          var currentContentForDownloadWindow = this.contentForDownloadWindow(this.podcast.episodes[0]);
          html+=currentContentForDownloadWindow;
        }
        html+='\n  </div>';

        html+='\n  <div id="embed_window_' + this.podcast.id + '" class="action_panel" style="'+actionPanelStyle+' display: none; width: ' + (PCM_width - 16) + 'px">';
        if(PCM_show_embed_code) {
          html+='\n    Embed code: <input type="text" value="' + this.embedCode().replace(/\n/g,'').replace(/\"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;') + '"/>';
        }
        html+='\n  </div>';

        html+='\n  <div class="action_bar">';
        if(PCM_show_embed_code) {
          html+='\n    <a onclick="PCMPlayer.togglePanel('+this.podcast.id+', \'embed\');" style="'+actionPanelStyle+'" onmouseover="PCMPlayer.mouseOverEpisode(this)" onmouseout="PCMPlayer.mouseOutEpisode(this)">embed</a>';
        }
        if(PCM_show_download_links && currentContentForDownloadWindow.length > 0) {
          html+='\n    <a onclick="PCMPlayer.togglePanel('+this.podcast.id+', \'download\');" style="'+actionPanelStyle+'" onmouseover="PCMPlayer.mouseOverEpisode(this)" onmouseout="PCMPlayer.mouseOutEpisode(this)">download</a>';
        }
        if(PCM_show_subscribe_links) {
          html+='\n    <a onclick="PCMPlayer.togglePanel('+this.podcast.id+', \'subscribe\');" style="'+actionPanelStyle+'" onmouseover="PCMPlayer.mouseOverEpisode(this)" onmouseout="PCMPlayer.mouseOutEpisode(this)">subscribe</a>';
        }
        html+='\n  </div>';

        html+='\n  <dl id="feeds_window_' + this.podcast.id + '" class="feeds_window" style="display: none; ' + tdStyle + '">';
        html+='\n    <a onclick="document.getElementById(\'feeds_window_' + this.podcast.id + '\').style.display = \'none\'">close</a>';
        for (var feed in this.podcast.feeds) {
          html+='\n    <dt>' + this.podcast.feeds[feed].name + '</dt>';
          html+='\n    <dd>http' + this.podcast.feeds[feed].url + '</dd>';
          html+='\n    <dt>' + this.podcast.feeds[feed].name + ' Torrents</dt>';
          html+='\n    <dd>http' + this.podcast.feeds[feed].url + '?torrent</dd>';
        }
        html+='\n  </dl>';
      }
      
      if (PCM_show_episode_list && this.podcast.episodes.length > 0 && PCM_number_of_episodes_shown > 0) {
        html+='\n  <table class="player_episode_list" cellspacing="4">';
        var episode;
        for (var i = 0; i < this.podcast.episodes.length; i++) {
          episode = this.podcast.episodes[i];
          if(i % columns == 0) {
            html+='\n    <tr>';
          }

          fieldWidth = (episode.thumbnail != undefined) ? videoFieldWidth : audioFieldWidth;
          title_ids[title_ids.length] = 'episode_title_' + episode.id;

          html+='\n    <td id="episode_' + episode.id + '" class="' + (episode.image == undefined ? 'audio' : 'video') + '" style="'+tdStyle+'" onmouseover="PCMPlayer.mouseOverEpisode(this)" onmouseout="PCMPlayer.mouseOutEpisode(this)" onclick="PCMPlayer.mediaplayer('+this.podcast.id + ', ' + i + ', true)">';
          if(episode.thumbnail != undefined) {
            html+='\n      <div class="poster" style="background-image: url(' + episode.thumbnail + ')">';
            html+='\n        <span>' + episode.duration + '</span>';
            html+='\n      </div>';
          }
          html+='\n      <div class="title" style="width: ' + fieldWidth + 'px; color: '+PCM_episode_text_color+';" id="' + title_ids[title_ids.length - 1] + '">' + episode.title + '</div>';
          html+='\n      <div class="description" style="width: ' + fieldWidth + 'px; color: '+PCM_episode_text_color+';">' + episode.desc + '</div>';
          html+='\n    </td>';
          if(i % columns == (columns - 1)) {
            html+='    </tr>';
          }
        }
        if(i % columns == 0) {
          html+='\n    </tr>';
        }
        html+='\n  </table>';
      }
      html+='\n</div>';
      
      div.innerHTML = html;
    } 
    if (this.podcast.episodes.length>0) {
      if(this.podcast.episodes[0].video) {
        this.playerHeights['podcast_player_'+this.podcast.id] = PCM_width * this.podcast.episodes[0].height / this.podcast.episodes[0].width;
      }
      this.mediaplayer(this.podcast.id, 0, PCM_autostart);
    }

    div.style.display = 'block'; // make element visible
    div.style.visibility = 'visible'; // make element visible

    for(var i = 0; i < title_ids.length; i++) {
      this.setTitleSize(document.getElementById(title_ids[i]), 11, 15);
    }
  },
  
  setTitleSize: function(titleElement, size, max) {
    titleElement.style.fontSize = size + 'px';
    if(titleElement.offsetHeight <= 21 && size <= max) {
      this.setTitleSize(titleElement, size + 1, max);
    } else {
      titleElement.style.fontSize = (size - 1) + 'px';
      titleElement.style.height = '21px';
    }
  },
  
  panelNames: ['download', 'subscribe', 'embed'],
  
  togglePanel: function(podcast_id, panel_name) {
    document.getElementById('feeds_window_' + podcast_id).style.display = 'none';
    var this_window = document.getElementById(panel_name + '_window_' + podcast_id);
    
    var other_window = null;
    for(var i = 0; i < this.panelNames.length; i++) {
      if(this.panelNames[i] != panel_name) {
        other_window = document.getElementById(this.panelNames[i] + '_window_' + podcast_id);
        if(other_window.style.display == 'block') {
          break;
        }
      }
    }
    
    if(this_window.style.display == 'block') {
      animateHeight(this_window.id, 24, 0, 10, transitionSinodial);
    } else if(other_window != null && other_window.style.display == 'block') {
      other_window.style.display = 'none';
      this_window.height = '24px';
      this_window.style.height = '24px';
      this_window.style.opacity = 1;
      this_window.style.display = 'block';
    } else {
      animateHeight(this_window.id, 0, 24, 10, transitionSinodial);
    }
    return true;
  },

  cumulativeOffset: function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      element = element.offsetParent;
    } while (element);
    return [valueL, valueT];
  },
  
  positionFeedsWindow: function(podcastId) {
    var embedElement = document.getElementById("podcast_player_" + podcastId);
    var feedsWindow = document.getElementById("feeds_window_" + podcastId);
    var embedElementPosition = PCMPlayer.cumulativeOffset(embedElement);
    
    feedsWindow.style.left = (embedElementPosition[0] - 1 + embedElement.offsetWidth / 20) + 'px';
    feedsWindow.style.top = (embedElementPosition[1] - 1 + embedElement.offsetHeight / 20) + 'px';
    feedsWindow.style.minWidth = (embedElement.offsetWidth - 22 - embedElement.offsetWidth / 10) + 'px';
    //feedsWindow.style.height = (embedElement.offsetHeight - 22 - embedElement.offsetHeight / 10) + 'px';
  },
  
  contentForDownloadWindow: function(episode) {
    var html = "";
    if(episode.downloads.h264) {
      html+='\n    <img src="' + this.BASE_URL + '/images/media_players/quicktime_24.png"/>';
      if(episode.downloads.h264.large) {
        html+='\n    <a href="' + episode.downloads.h264.large + '" style="color: '+PCM_episode_text_color+'">large</a>';
      }
      if(episode.downloads.h264.medium) {
        html+='\n    <a href="' + episode.downloads.h264.medium + '" style="color: '+PCM_episode_text_color+'">medium</a>';
      }
      if(episode.downloads.h264.small) {
        html+='\n    <a href="' + episode.downloads.h264.small + '" style="color: '+PCM_episode_text_color+'">small</a>';
      }
    }
    if(episode.downloads.wmv) {
      html+='\n    <img src="' + this.BASE_URL + '/images/media_players/windowsmedia_24.png"/>';
      if(episode.downloads.wmv.large) {
        html+='\n    <a href="' + episode.downloads.wmv.large + '" style="color: '+PCM_episode_text_color+'">large</a>';
      }
      if(episode.downloads.wmv.medium) {
        html+='\n    <a href="' + episode.downloads.wmv.medium + '" style="color: '+PCM_episode_text_color+'">medium</a>';
      }
      if(episode.downloads.wmv.small) {
        html+='\n    <a href="' + episode.downloads.wmv.small + '" style="color: '+PCM_episode_text_color+'">small</a>';
      }
    }
    if(episode.downloads.aac) {
      html+='\n    <a href="' + episode.downloads.aac + '" style="color: '+PCM_episode_text_color+'"><img src="' + this.BASE_URL + '/images/media_players/sound_24.png"/> AAC</a>';
    }
    if(episode.downloads.mp3) {
      html+='\n    <a href="' + episode.downloads.mp3 + '" style="color: '+PCM_episode_text_color+'"><img src="' + this.BASE_URL + '/images/media_players/sound_24.png"/> MP3</a>';
    }
    if(episode.downloads.ogg) {
      html+='\n    <a href="' + episode.downloads.ogg + '" style="color: '+PCM_episode_text_color+'"><img src="' + this.BASE_URL + '/images/media_players/sound_24.png"/> OGG</a>';
    }
    
    if(html.length > 0) {
      html = "Download: " + html;
    }
    return html;
  },
  
  mouseOverEpisode: function(episodeElement) {
    if(episodeElement != null) {
      episodeElement.style.backgroundColor = PCM_selected_episode_background_color;
    }
  },
  
  mouseOutEpisode: function(episodeElement) {
    if(episodeElement != null) {
      if(!this.hasClassName(episodeElement, 'selected')) {
        episodeElement.style.backgroundColor = PCM_episode_background_color;
      }
    }
  },
  
  mediaplayer: function(podcast_id,episode_index,autostart){
    var episode = this.podcast.episodes[episode_index]

    var selectedEpisodeElement = document.getElementById('episode_' + this.episode_id);
    if(selectedEpisodeElement != null) {
      PCMPlayer.removeClassName(selectedEpisodeElement, 'selected');
      PCMPlayer.mouseOutEpisode(selectedEpisodeElement);
    }

    var selectedEpisodeElement = document.getElementById('episode_' + episode.id);
    PCMPlayer.addClassName(selectedEpisodeElement, 'selected');
    PCMPlayer.mouseOverEpisode(selectedEpisodeElement);

    PCMPlayer.episode_id = episode.id;
    var id = 'podcast_player_'+podcast_id;

    if (this.playerHeights[id]==null){
      this.playerHeights[id] = 128;
    }

    if(!episode.video && (episode.image == undefined || episode.image == null || episode.image.length == 0)) {
      this.playerHeights[id] = 20;
    }

    var so = new SWFObject(this.BASE_URL + '/swf/mediaplayer.swf',id,PCM_width,this.playerHeights[id],'8', PCM_background_color);
    so.useExpressInstall(this.BASE_URL + '/swf/expressinstall.swf');
    so.addParam("allowscriptaccess","always");
    so.addParam("allowfullscreen","true");
    so.addParam("wmode","opaque");
    so.addVariable('javascriptid','podcast_player_'+podcast_id);
    so.addVariable('enablejs','true');
    so.addVariable("file", episode.url);
    if(episode.fallback_url != undefined && episode.fallback_url != null && episode.fallback_url.length > 0) {
      so.addVariable("fallback", episode.fallback_url);
    }
    if(episode.image != undefined && episode.image != null && episode.image.length > 0) {
      so.addVariable("image", episode.image);
    }
    if(episode.video) {
      so.addVariable("displayheight",this.playerHeights[id]);    
    } else {
      so.addVariable("displayheight",this.playerHeights[id] - 20);
      so.addVariable("showicons", 'false');
    }
    so.addVariable("screencolor", toFlashColor(PCM_background_color));
    so.addVariable("backcolor", toFlashColor(PCM_control_background_color));
    so.addVariable("frontcolor", toFlashColor(PCM_control_front_color));
    so.addVariable("lightcolor", toFlashColor(PCM_control_light_color));
    so.addVariable("width", PCM_width);
    so.addVariable("height", this.playerHeights[id]);
    if (autostart){
      so.addVariable("autostart", "true");
    }
    so.write('player_'+podcast_id);
    
    download_window = document.getElementById("download_window_" + podcast_id);
    if(download_window) {
      download_window.innerHTML = this.contentForDownloadWindow(episode);
    }
  },
  
  embedCode: function() {
    return "<script type=\"text/javascript\">\n" +
           "  PCM_podcast_id = " + PCM_podcast_id + ";\n" +
           "  PCM_base_url = '" + this.BASE_URL + "';\n" +
           //"  PCM_sorting='" + PCM_sorting + "';\n" +
           "  PCM_number_of_episodes_shown = " + PCM_number_of_episodes_shown + ";\n" +
           "  PCM_episode_id = " + (isdefined('PCM_episode_id') ? PCM_episode_id : null)+ ";\n" +
           "  PCM_show_episode_list = " + PCM_show_episode_list + ";\n" +
           "  PCM_show_download_links = " + PCM_show_download_links + ";\n" +
           "  PCM_show_subscribe_links = " + PCM_show_subscribe_links + ";\n" +
           "  PCM_show_embed_code = " + PCM_show_embed_code + ";\n" +
           "  PCM_autostart = " + PCM_autostart + ";\n" +
           
           "  PCM_width = " + PCM_width + ";\n" +
           "  PCM_columns = " + PCM_columns + ";\n" +
           
           "  PCM_background_color = '" + PCM_background_color + "';\n" +
           "  PCM_border_color = '" + PCM_border_color + "';\n" +
           
           "  PCM_episode_background_color = '" + PCM_episode_background_color + "';\n" +
           "  PCM_selected_episode_background_color = '" + PCM_selected_episode_background_color + "';\n" +
           (isdefined('PCM_episode_border_color') ? "  PCM_episode_border_color = '" + PCM_episode_border_color + "';\n" : "") +
           "  PCM_episode_text_color = '" + PCM_episode_text_color + "';\n" +
           
           "  PCM_control_background_color = '" + PCM_control_background_color + "';\n" +
           "  PCM_control_front_color = '" + PCM_control_front_color + "';\n" +
           "  PCM_control_light_color = '" + PCM_control_light_color + "';\n" +
           "</script>\n" +
           "<script type=\"text/javascript\" src=\"" + this.BASE_URL + "/javascripts/player.js\"></script>";
  },
  
  init: function() {
    this.requestStylesheet();
    this.requestContent();
    var no_script = document.getElementById('no_script');
    if (no_script) { no_script.style.display = 'none'; }
  }
}

document.write("<div id='" + PCMPlayer.ROOT + "' style='display: none'></div>");
PCMPlayer.init();

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
