// Quicktime Detection  v1.0
// documentation: http://www.dithered.com/javascript/quicktime_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)


var quicktimeVersion = 0;
function getQuicktimeVersion() {
	var agent = navigator.userAgent.toLowerCase(); 
	
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Quicktime plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
      for (i=0; i < navigator.plugins.length; i++ ) {
         var plugin =navigator.plugins[i];
         if (plugin.name.indexOf("QuickTime") > -1) {
            quicktimeVersion = parseFloat(plugin.name.substring(18));
			quicktimeVersion = quicktimeVersion * 1000000 ;
			
         }
      }
	}
   
	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	  document.write('<scr' + 'ipt language="VBScript"\> \n');
		document.write('on error resume next \n');
		document.write('dim obQuicktime \n');
		document.write('set obQuicktime = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1") \n');
		document.write('if IsObject(obQuicktime) then \n');
		document.write('   if obQuicktime.IsQuickTimeAvailable(0) then \n');
		document.write('      quicktimeVersion = Hex(obQuicktime.QuickTimeVersion)  \n');
		document.write('   end if \n');
		document.write('end if \n');
		document.write('</scr' + 'ipt\> \n');
		
  }

	// Can't detect in all other cases
	else {
		quicktimeVersion = quicktimeVersion_DONTKNOW;
	}

	return quicktimeVersion;
}

quicktimeVersion_DONTKNOW = -1;


// Flash Version Detector  v1.2.1
// documentation: http://www.dithered.com/javascript/flash_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
// with VBScript code from Alastair Hamilton (now somewhat modified)


function isDefined(property) {
  return (typeof property != 'undefined');
}

var flashVersion = 0;
function getFlashVersion() {
	var latestFlashVersion = 8;
   var agent = navigator.userAgent.toLowerCase(); 
	
   // NS3 needs flashVersion to be a local variable
   if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
      flashVersion = 0;
   }
   
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			for (var i = latestFlashVersion; i >= 3; i--) {
            if (flashPlugin.description.indexOf(i + '.') != -1) {
               flashVersion = i;
               break;
            }
         }
		}
	}

	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	   var doc = '<scr' + 'ipt language="VBScript"\> \n';
      doc += 'On Error Resume Next \n';
      doc += 'Dim obFlash \n';
      doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
      doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
      doc += '   If IsObject(obFlash) Then \n';
      doc += '      flashVersion = i \n';
      doc += '      Exit For \n';
      doc += '   End If \n';
      doc += 'Next \n';
      doc += '</scr' + 'ipt\> \n';
      document.write(doc);
   }
		
	// WebTV 2.5 supports flash 3
	else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

	// older WebTV supports flash 2
	else if (agent.indexOf("webtv") != -1) flashVersion = 2;

	// Can't detect in all other cases
	else {
		flashVersion = flashVersion_DONTKNOW;
	}

	return flashVersion;
}

flashVersion_DONTKNOW = -1;



// ChoiceWay Print Commands
function printFlash( file , x , y) {

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"');
	document.write(' width="' + x + '" height="' + y + '" id="" align="middle"><param name="base" value="http\://www.choicewaymedia.com/v/" /><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="http\://www.choicewaymedia.com/v/' + file + '"');
	document.write(' /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><embed src="http\://www.choicewaymedia.com/v/' + file + '" base="http\://www.choicewaymedia.com/v/" quality="high" bgcolor="#000000" width="' + x + '"');
	document.write(' height="' + y + '" name="cw_0106_home1a" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"');
	document.write(' pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}
function printQT( file , x , y) {

	//document.write('<a href="http://www.apple.com/quicktime/download/" target="_blank">Download Quicktime 7</a> or <a href="index2.htm">View Quicktime 6 Video</a><br>');
	document.write('<EMBED SRC="http\:/');
	document.write('/www.choicewaymedia.com/v/' + file + '" WIDTH=' + x + ' HEIGHT=' + y + ' AUTOPLAY=true CONTROLLER=true LOOP=false PLUGINSPAGE="http:/');
	document.write('/www.apple.com/quicktime/"></EMBED>\n');
	
}
function printVError() {

	document.write('<br><br>No suitable video players were found. Our samples require at least Flash 7 or Quicktime 6.<br>'); 
	document.write('For best results please install <a href="http://www.macromedia.com/go/getflashplayer">Flash 8</a> or <a href="http://www.apple.com/quicktime/">QuickTime 7</a><br><br>');

}

