// JavaScript Document

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;

var CRLF = "\r\n";

function VideoPlayer() {
  this.slideshowSize = "l";
  this.x264Ready = false;
  this.width = 540;
  this.height = 405;
  this.url = "";
  this.autostart = false;
  this.controlId = "videoplayer";
  this.control = "wmax";
  this.useEmbed = true;

  this.ranWMPDetect = false;	
  this.hasWMInstalled = false;
  this.hasWM64 = false;
  this.hasWM7OrGreater = false;
  this.WMVersion = "";

  this.ranQTDetect = false;
  this.hasQTInstalled = false;
  this.QTVersion = "";

  this.finishedFunction = null;

  return this;
}

VideoPlayer.prototype.playerWidth = function() {
  var retval = 640;
  if (this.slideshowSize == "s") retval = 440;
  if (this.slideshowSize == "m") retval = 540;
  return retval;  
}

VideoPlayer.prototype.playerHeight = function() {
  var retval = 480;
  if (this.slideshowSize == "s") retval = 330;
  if (this.slideshowSize == "m") retval = 405;
  return retval;
}


VideoPlayer.prototype.debugInfo = function(aurl) {
  var di = "";
  this.url = aurl;
  this.determineControl();
  di += "Player Information" + CRLF;
  di += "  player control: " + this.control + CRLF;
  if (this.hasWMInstalled) di += "  Windows Media Player Detected: yes" + CRLF;  else di += "  Windows Media Player Detected: no" + CRLF; 
  di += "  WM Version: " + this.WMVersion + CRLF;
  if (this.hasWM64) di += "  Windows Media Player 6.4: yes" + CRLF;  else di += "  Windows Media Player 6.4: no" + CRLF; 	
  if (this.hasWM7OrGreater) di += "  Windows Media Player 7.0 or greater: yes" + CRLF;  else di += "  Windows Media Player 7.0 or greater: no" + CRLF; 		
  di += CRLF;
	
  if (this.hasQTInstalled) di += "  QuickTime Player Detected: yes" + CRLF;  else di += "  QuickTime Player Detected: no" + CRLF; 	
  di += "  QT Version: " + this.QTVersion + CRLF;
  return(di);
}

VideoPlayer.prototype.canControlViaJScript = function() {
  this.control = this.determineControl();
  var retval = false;
  if (this.control == "wmax") retval = true;
  if (this.control == "qtax") retval = true;
  if (this.control == "x264") retval = true;
  return retval;
}


VideoPlayer.prototype.autoStartToString = function() {
  if (this.autostart) return("true"); else return("false");
}

VideoPlayer.prototype.autoStartToInt = function() {
  if (this.autostart) return("1"); else return("0");
}


VideoPlayer.prototype.toString = function() {
		this.control = this.determineControl();	

		var html = "";
		
		var tips = '';
		tips += '<div style="position:relative; top:-50px">';
		tips += '<a class="bluelink" href="' + this.url + '">Click here to download and play video</a><BR>if it does not start playing within this window.' + CRLF;
		tips += '<BR><BR>Or<BR><BR>' + CRLF;
		tips += '<a class="bluelink" href="javascript:videoPlayerTips(\'' + this.control + '\')">Click here</a> for tips on configuring your browser<BR>to play video within this window.' + CRLF;											
		tips += '</div>';
		//tips += '<a class="bluelink" href="javascript:videoPlayerTips(\'' + this.control + '\')">Click here</a> for tips on configuring your browser<BR>to play video within this window.' + CRLF;									
		
		var playlink = '<table align=center border=0>\r\n  <tr>\r\n    <td class=slidecaption>Click <a class=slidebtmlink target=new href="' + this.url + '">here</a> to download video if it does not start playing above.</td>\r\n  </tr>';
                if ((useragent.isfirefox) && (useragent.iswindows) && (this.control == "wmobj") && (!hasWMPFixPlugin())) {
                  playlink += '<tr><td class=slidecaption>If your video looks distorted when playing, please download and install this <a class=slidebtmlink href="http://port25.technet.com/videos/downloads/wmpfirefoxplugin.exe ">plugin</a>.<BR><BR></td></tr>';
                }
                playlink += '\r\n</table>';		

    if (this.control == "x264") {
      var so = new SWFObject("/ftweb/scripts/jw_player/player-licensed.swf", this.controlId, this.playerWidth() + "px", this.playerHeight() + "px", "9", "#000000");
      so.addVariable("file", this.url);
      if ((this.slideshowSize == "l") || (this.slideshowSize == "o")) {      
        so.addVariable("stretching", "none");
      } else {
        so.addVariable("stretching", "uniform");      
      }
      so.addVariable("smoothing", "true");
      so.addVariable("quality", "true");
      so.addVariable("bufferlength", "4");      
      so.addParam("allowfullscreen", "true");
      so.addParam("wmode", "opaque");
      so.addParam("allowscriptaccess", "always");
      //so.setAttribute("style", "z-index:5000");
      html = so.getSWFHTML();
      this.x264Ready = false;
      return html;    
    }
		
		if (this.control == "wmax") {
			if (this.hasWMInstalled) {
				html += '<object';
				if (this.hasWM7OrGreater) html += ' classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"'; else html += ' classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"';
				html += ' id="' + this.controlId + '"';
				//html += ' data="' + this.url + '"';
				html += ' width="' + this.width + '"';
				html += ' height="' + this.height + '"'
				html += '>';
				//html += '<param name="src" value="' + this.url + '" />';
				html += '<param name="autostart" value="' + this.autoStartToString() + '" />';
				html += '<param name="controller" value="true" />' + CRLF;
				//html += tips + CRLF;
				html += '</object>';
				html += this.playerEventsHtml();				
				html += playlink;
			} else { 
			  html += tips;
			}
		}

		if (this.control == "wmobj") {

      if (useragent.isfirefox) {
				html += '<object';
				html += ' type="video/x-ms-wmp" id="' + this.controlId + '" data="' + this.url + '"';
				html += ' width="' + this.width + '" height="' + this.height + '">';
				html += '<param name="autostart" value="' + this.autoStartToInt() + '" />';
				html += '<param name="controller" value="true" />' + CRLF;
				//html += tips + CRLF;
				html += '</object>';
				html += playlink;		
        return html;
      }

    
			if (this.hasWMInstalled) {
				if (this.useEmbed) {
					html += '<embed';
					html += ' type="application/x-mplayer2" id="' + this.controlId + '" src="' + this.url + '"';
					html += ' width="' + this.width + '" height="' + this.height + '"';
					html += ' AutoStart="' + this.autoStartToInt() + '"';
					html += ' Showcontroller="1"';
					html += ' enablejavascript="true"';
					html += '>' + CRLF;
					//html += tips + CRLF;
					html += '</embed>';
  				html += playlink;		
				} else {
					html += '<object';
					html += ' type="video/x-ms-wmv" id="' + this.controlId + '" data="' + this.url + '"';
					html += ' width="' + this.width + '" height="' + this.height + '">';
					html += '<param name="autostart" value="' + this.autoStartToInt() + '" />';
					html += '<param name="controller" value="true" />' + CRLF;
					html += tips + CRLF;
					html += '</object>';
				  html += playlink;					
				}
			} else {
				html += tips;
			}
		}
		
		if (this.control == "qtax") {
	  	if (this.hasQTInstalled) {
	      html += '<table name=qttable id=qttable bgcolor=white border=0 cellspacing=0 cellpadding=0 width=540 height=405>' + CRLF;
				html += '  <tr>' + CRLF;
				html += '    <td width=540 height=405 bgcolor=white valign=middle align=center>' + CRLF;
				html += '      <OBJECT id="' + this.controlId + '" CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
				html += ' width="' + this.width + '" height="' + this.height + '"';
				html += ' CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">';
				html += '        <PARAM NAME="src" VALUE="' + this.url + '">';
				html += '        <PARAM NAME="autoplay" VALUE="' + this.autoStartToString() + '">';
				html += '        <PARAM NAME="Controller" VALUE="True">';
				//-html += '        <PARAM NAME="ShowController" VALUE="True">' + CRLF;						
				html += '        <PARAM NAME="Scale" VALUE="Aspect">';
				html += '        <PARAM NAME="EnableJavaScript" VALUE="True">';
				//html += tips + CRLF;
				html += '      </OBJECT>';
				html += '    </td>' + CRLF;
				html += '  </tr>' + CRLF;
				html += '</table>' + CRLF;
				html += playlink;				
			} else {
				html += tips;
			}
		}

		if (this.control == "qtobj") {
			if (this.useEmbed == true) {
				if (this.hasQTInstalled) {
					html += '<embed id="' + this.controlId + '" type="video/quicktime"';
					html += ' width="' + this.width + '" height="' + this.height + '"';
					html += ' src="' + this.url + '">' + CRLF;
					//html += '  <param name="enablejavascript" value="true">' + CRLF;
					html += '  <param name="autoplay" value="' + this.autoStartToString() + '">' + CRLF;
					html += '  <param name="controller" value="true">' + CRLF;		
				  html += '  <param name="EnableJavaScript" value="true">' + CRLF;									
					if (useragent.issafari) html += '  <param name="src" value="' + this.url + '" />' + CRLF;			
					html += ' </embed>' + CRLF;	
  				html += playlink;					
				} else {
					html += tips;
				}
			} else {			
				html += '<object id="' + this.controlId + '" type="video/quicktime"';
				html += ' width="' + this.width + '" height="' + this.height + '"';
				html += ' data="' + this.url + '">' + CRLF;
				//html += '  <param name="enablejavascript" value="true">' + CRLF;
				html += '  <param name="autoplay" value="' + this.autoStartToString() + '">' + CRLF;
				html += '  <param name="controller" value="true">' + CRLF;		
				if (useragent.issafari) html += '  <param name="src" value="' + this.url + '" />' + CRLF;			
				html += tips + CRLF;
				html += ' </object>' + CRLF;			
				html += playlink;				
			}
		}

    //alert(this.toJSONString());
    //alert(html);
		return html; 
}


VideoPlayer.prototype.playerEventsHtml = function() {
  var html = "";
  if (this.control == "wmax") {		
    html += '<script language="javascript" for="videoplayer" Event="PlayStateChange(newstate)"> ' + CRLF;
    html += '  if (newstate == 8) vplayer.videoFinished(); ' + CRLF;
    html += '</script> 		  ' + CRLF;
  }
  return html;
}


VideoPlayer.prototype.videoFinished = function() {
  if (this.finishedFunction != null) this.finishedFunction();
}


VideoPlayer.prototype.detectQuickTime = function() {
  // don't need to do this multiple times
  if (this.ranQTDetect) return;
  this.ranQTDetect = true;
	
  this.hasQTInstalled = false;
  qtObj = false;
  if (navigator.plugins && navigator.plugins.length) {
    for (var i=0; i < navigator.plugins.length; i++ ) {
      var plugin = navigator.plugins[i];
      if (plugin.name.indexOf("QuickTime") > -1) this.hasQTInstalled = true;
    } // end for
  } else {
    execScript('on error resume next: qtObj = IsObject(CreateObject("QuickTimeCheckObject.QuickTimeCheck.1"))','VBScript');
    this.hasQTInstalled = qtObj;
  }
}


VideoPlayer.prototype.detectMediaPlayer = function() {
  // don't need to do this multiple times
  if (this.ranWMPDetect) return;
  this.ranWMPDetect = true;
	
  this.hasWMInstalled = false;
  this.WMVersion = "";
  if (navigator.plugins && navigator.plugins.length) {
    for (var i=0; i < navigator.plugins.length; i++ ) {
      var plugin = navigator.plugins[i];
      if (plugin.name.indexOf("Windows Media") > -1) {
        this.hasWMInstalled = true;
        this.WMVersion = "cannot determine from plugin";
      }
    }
  } else {	

    var objMediaPlayer;

    try {
      objMediaPlayer = new ActiveXObject("MediaPlayer.MediaPlayer.1");
      this.hasWMInstalled = true;
      this.hasWM64 = true;
      this.WMVersion = "6.4";
    } catch(objError) {
      this.hasWMInstalled = false;
      this.hasWM64 = false;
    }

    if (this.hasWMInstalled) {
      try {
        objMediaPlayer = new ActiveXObject("WMPlayer.OCX");
	this.hasWM7OrGreater = true;
	this.WMVersion = objMediaPlayer.versionInfo;
      } catch(objError) {
	this.hasWM7OrGreater = false;
      }
    }
		
		
    // testing
    //this.hasWMInstalled = true;
    //this.hasWM64 = true;		
    //this.hasWM7OrGreater = false;
	
  }
}


VideoPlayer.prototype.determineControl = function() {
  var uurl = this.url.toUpperCase();
  var iswmv = uurl.indexOf(".WMV") > 0;
  var isqt = ((uurl.indexOf(".MOV") > 0) || (uurl.indexOf(".MP4") > 0));
  var isx264 = uurl.indexOf("_X264.MP4") > 0;

  if (isx264) return("x264");

  this.detectQuickTime();
  this.detectMediaPlayer();

  if (iswmv) {
    if (useragent.supportsActiveX) return("wmax");
    return("wmobj");
  }

  if (isqt) {
    if (useragent.supportsActiveX) return("qtax");
    return("qtobj");
  }

  if (useragent.supportsActiveX) return("wmax");
  if (useragent.iswindows) return("wmobj");
  if (useragent.ismac) return("qtobj");
  return("wmobj");
}



function videoPlayerTips(playertype) {
  var msg = "";
	var caption = "Tips for playing video with the ";
	if (playertype == "wmax") {
		caption += "Windows Media Player";
		msg = 'Make sure that you have the latest version of the Windows Media Player installed on your system.  You can download it from Microsoft here:<BR><BR>';
		msg += '<a target=_blank class=bluelink href="http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx?displang=en&qstechnology=">http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx?displang=en&qstechnology=</a>';				
	}
	if (playertype == "wmobj") {
		caption += "Windows Media Player";	
		if (useragent.isIntelMac) {
  		msg = 'To play WindowsMedia videos, you need to install the Flip4Mac video<BR>components for QuickTime provided by Microsoft.<BR><BR>';
	  	msg += '<a target=_blank class=bluelink href="http://www.microsoft.com/downloads/details.aspx?FamilyId=915D874D-D747-4180-A400-5F06B1B5E559&displaylang=en">Download WindowsMedia Support for MacOSX</a>';						
			msg += '<BR><BR>Be sure to restart your browser after installing Flip4Mac.';
		} else {
  		msg = 'Make sure that you have the latest version of the Windows Media Player installed on your system.  You can download it from Microsoft here:<BR><BR>';
	  	msg += '<a target=_blank class=bluelink href="http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx?displang=en&qstechnology=">http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx?displang=en&qstechnology=</a>';						
		  if (useragent.iswindows) {
  		  msg += '<BR><BR>If you are using Mozilla, FireFox, Opera, or any other browser compatible with plugins, you may need to download the necessary plugins below.  Extract the contents of this zip file and put them in your browser\'s plugins folder.<BR><BR>';
  	  	msg += '<a target=_blank class=bluelink href="http://www.fototime.com/shared/plugins.zip">http://www.fototime.com/shared/plugins.zip</a>';		
	  	}		
		}
	}
	if (playertype == "qtax") {
		caption += "QuickTime Player";		
		msg = 'Make sure that you have the latest version of the QuickTime player installed on your system.  You can download it from Apple here:<BR><BR>';
		msg += '<a target=_blank class=bluelink href="http://www.apple.com/quicktime/download">http://www.apple.com/quicktime/download</a>';		
	}
	if (playertype == "qtobj") {
		caption += "QuickTime Player";		
		msg = 'Make sure that you have the latest version of the QuickTime player installed on your system.  You can download it from Apple here:<BR><BR>';
		msg += '<a target=_blank class=bluelink href="http://www.apple.com/quicktime/download">http://www.apple.com/quicktime/download</a>';
		if (useragent.iswindows) {
  		msg += '<BR><BR>If you are using Mozilla, FireFox, Opera, or any other browser compatible with plugins, you may need to download the necessary plugins below.  Extract the contents of this zip file and put them in your browser\'s plugins folder.<BR><BR>';
	  	msg += '<a target=_blank class=bluelink href="http://www.fototime.com/shared/plugins.zip">http://www.fototime.com/shared/plugins.zip</a>';		
		}
	}
	showMessageDialog(caption, msg);
}


VideoPlayer.prototype.start64ax = function() {
  var player = document.getElementById(this.controlId);
	
  if (player.openState < 6) {
    setTimeout("vplayer.start64ax()",100);			
    return;
  } else {
    player.play();
  }
}


VideoPlayer.prototype.startVideo = function() {
  var player = document.getElementById(this.controlId);

  // make sure flash video player is ready
  if (this.control == "x264") {
    if (this.x264Ready == false) {
      setTimeout("vplayer.startVideo()", 200); 
      return;
    }
  }

  // wait till its ready (ie activeX only)
  if ((this.control == "wmax") || (this.control == "qtax")) {	
    if ((player == null) || (player.readyState != 4)) {
      setTimeout("vplayer.startVideo()", 200); 
      return;					
    }
  }
	
  try {
    if ((this.control == "qtax") || (this.control == "qtobj")) this.QTVersion = player.GetQuickTimeVersion();
  } catch (e) {
    this.QTVersion = "error getting from control";
  }

  try {
    if (this.control == "wmobj") this.WMVersion = player.versionInfo;
  } catch (e) {
    this.WMVersion = "error getting from control";
  }


  try {
    // x264 flash
    if (this.control == "x264") {
      //player.sendEvent("LOAD",this.url);
      player.addModelListener("STATE","stopTrackerX264");
      player.sendEvent("PLAY","true");
    }

    // WM activeX
    if (this.control == "wmax") {
      if (this.hasWM7OrGreater) {
        player.url = this.url;
        player.controls.play();	 	
      } else {
	//player.autostart = true;				
        player.FileName = this.url;
	// wait for video to buffer up
	setTimeout("vplayer.start64ax()",100);			
      }
    }
		
    // QT activeX
    if (this.control == "qtax") {
      var status = player.GetPluginStatus();
      // make sure we are ready to play
      if ((status == "Playable") || (status == "Complete")) {
        // make sure controller is visible
	player.SetControllerVisible(false);
	player.SetControllerVisible(true);
	player.Play();						
	setTimeout("vplayer.checkQTDone()",500);
      } else {
        // if not ready, then come back in a bit
	setTimeout("vplayer.startVideo()", 200);  
      }
    }
		
    if (this.control == "wmobj") {
      // must use autostart with wm object (not in ax mode)
    }		
		
    if (this.control == "qtobj") {
      // must use autostart with qt object (not in ax mode)
    }		
  } catch (e) {
    alert(e.description);
  }
}


VideoPlayer.prototype.checkQTDone = function() {
  var player = document.getElementById(this.controlId);
  var duration = player.GetDuration();
  var time = player.getTime();
  if (time < duration) {
    setTimeout("vplayer.checkQTDone()",500);		
    return;
  }

  vplayer.videoFinished();
}


VideoPlayer.prototype.stopVideo = function() {
  var player = document.getElementById(this.controlId);	
  if (player == null) return;	
  try {

    if (this.control == "x264") {
      player.sendEvent("STOP");
    }

    if (this.control == "wmax") {
      if (this.hasWM7OrGreater) {				
        player.controls.stop();	 	  				
        player.close();	 	  					
      } else {
        player.stop();	 	  				
        player.close();	 	  									
      }
    }	

    if (this.control == "qtax") {
      player.Stop();
      player.Hide();					
    } 

  } catch (e) {
  }

}


function playerReady(obj) {
  if ((obj.id == "videoplayer") || (obj.id == "x264player")) vplayer.x264Ready = true;
}

function stopTrackerX264(obj) {
  var oldstate = obj.oldstate;
  var newstate = obj.newstate;
  if ((oldstate == "PLAYING") && (newstate == "COMPLETED")) {
     vplayer.videoFinished();
  }
}


var vplayer = new VideoPlayer();

