if(typeof com == "undefined") var com = new Object();
if(typeof com.deconcept == "undefined") com.deconcept = new Object();
if(typeof com.deconcept.util == "undefined") com.deconcept.util = new Object();
if(typeof com.deconcept.WMObjectUtil == "undefined") com.deconcept.WMObjectUtil = new Object();
com.deconcept.WMObject = function(wmv, id, w, h, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
  if (!document.createElement || !document.getElementById) return;
  this.DETECT_KEY = detectKey ? detectKey : 'detectWM';
  this.skipDetect = com.deconcept.util.getRequestParameter(this.DETECT_KEY);
  this.params = new Object();
  this.attributes = new Array();
  this.useExpressInstall = useExpressInstall;

  if(wmv) this.setAttribute('wmv', wmv);
  if(id) this.setAttribute('id', id);
  if(w) this.setAttribute('width', w);
  if(h) this.setAttribute('height', h);
  var q = quality ? quality : 'high';
  this.addParam('quality', q);
  var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
  this.setAttribute('xiRedirectUrl', xir);
  this.setAttribute('redirectUrl', '');
  if(redirectUrl) this.setAttribute('redirectUrl', redirectUrl);
}
com.deconcept.WMObject.prototype = {
  setAttribute: function(name, value){
    this.attributes[name] = value;
  },
  getAttribute: function(name){
    return this.attributes[name];
  },
  addParam: function(name, value){
    this.params[name] = value;
  },
  getParams: function(){
    return this.params;
  },
  createParamTag: function(n, v){
    var p = document.createElement('param');
    p.setAttribute('name', n);
    p.setAttribute('value', v);
    return p;
  },
  getWMHTML: function() {
    var WMNode = "";
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
      WMNode = '<embed type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/" src="'+ this.getAttribute('wmv') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" ';
      WMNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
      var params = this.getParams();
       for(var key in params){ WMNode += [key] +'="'+ params[key] +'" '; }
      WMNode += '/>';
    } else { // PC IE
      WMNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
      WMNode += '<param name="FileName" value="'+ this.getAttribute('wmv') +'" />';
      var params = this.getParams();
      for(var key in params) {
       WMNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
      }
      WMNode += "</object>";
    }
    return WMNode;
  },
  write: function(elementId){
    var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
    n.innerHTML = this.getWMHTML();
  }
}

com.deconcept.util = {
  getRequestParameter: function(param){
    var q = document.location.search || document.location.hash;
    if(q){
      var startIndex = q.indexOf(param +"=");
      var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
      if (q.length > 1 && startIndex > -1) {
        return q.substring(q.indexOf("=", startIndex)+1, endIndex);
      }
    }
    return "";
  }
}


if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}


var getQueryParamValue = com.deconcept.util.getRequestParameter;
var WMObject = com.deconcept.WMObject;

