/*
 * FlashObject embed
 * http://blog.deconcept.com/2004/10/14/web-standards-compliant-javascript-flash-detect-and-embed/
 *
 * by Geoff Stearns (geoff@deconcept.com, http://www.deconcept.com/)
 *
 * v1.0.7 - 11-17-2004
 *
 * Create and write a flash movie to the page, includes detection
 *
 * Usage:
 *
 *	myFlash = new FlashObject("path/to/swf.swf", "swfid", "width", "height", flashversion, "backgroundcolor");
 *	myFlash.altTxt = "Upgrade your Flash Player!";                // optional
 *	myFlash.addParam("wmode", "transparent");                     // optional
 *	myFlash.addVariable("varname1", "varvalue");                  // optional
 *	myFlash.addVariable("varname2", getQueryParamValue("myvar")); // optional
 *	myFlash.write();
 *
 */

MovieObject = function(movie, id, w, h, mime) {
  this.movie = movie;
  this.id = id;
  this.width = w;
  this.height = h;
  this.mime = mime;
  this.align = "middle"; // default to middle
  this.altTxt = 'You do not appear to have an appropriate plugin. Please visit <a href="http://www.quicktime.com">www.quicktime.com</a> to download one for free.';
}

MovieObject.prototype.getHTML = function() {
  var qtHTML = "";
  if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // PC IE
    qtHTML += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
    qtHTML += '<param name="src" value="' + this.movie + '" />';
    qtHTML += '<param name="scale" value="aspect" />';
    qtHTML += '<param name="autostart" value="true" />';
    qtHTML += '<param name="controller" value="true" />';
    qtHTML += '<param name="bgcolor" value="#ffffff" />';
    qtHTML += '<object type="' + this.mime + '" width="' + this.width + '" height="' + this.height + '" align="center" data="/adchallenge/av/' + this.movie + '" id="nonIE">';
    qtHTML += '<param name="scale" value="aspect" />';
    qtHTML += '<param name="autostart" value="true" />';
    qtHTML += '<param name="controller" value="true" />';
    qtHTML += '<param name="bgcolor" value="#ffffff" />';
    qtHTML += this.altTxt;
    qtHTML += '</object>';
    qtHTML += '</object>';
  } else { // Everyone else
    qtHTML += '<embed type="'+this.mime+'" src="' + this.movie + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '" scale="aspect" autostart="true" controller="true" bgcolor="#ffffff"></embed>';
  }
  return qtHTML;	
}


MovieObject.prototype.write = function(elementId) {
  if (elementId) {
    document.getElementById(elementId).innerHTML = this.getHTML();
  } else {
    document.write(this.getHTML());
  }
}

/* add Array.push if needed */
if(Array.prototype.push == null){
	Array.prototype.push = function(item){
		this[this.length] = item;
		return this.length;
	}
}