


// START QUICKTIME DETECTION

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));
         }
      }
	}
   
	// 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 = CInt(Hex(obQuicktime.QuickTimeVersion) / 1000000) \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;
}

var quicktimeVersion_DONTKNOW = -1;



var requiredVersion = 6;
var quicktimeVersion = 0;
quicktimeVersion = getQuicktimeVersion();
            
if (quicktimeVersion >= requiredVersion) {

  var bikky = document.cookie; // retrieve cookie string

  function getCookie(name) { // use: getCookie("name");
    var index = bikky.indexOf(name + "=");
    if (index == -1) return null;
    index = bikky.indexOf("=", index) + 1;
    var endstr = bikky.indexOf(";", index);
    if (endstr == -1) endstr = bikky.length;
    return unescape(bikky.substring(index, endstr));
  }

	if (!getCookie("visited")) {

	// AUTOPLAY!	

	movieContent = ('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" height="256" width="320" id="qt"><param name="autoplay" value="true"><param name="cache" value="FALSE"><param name="controller" value="TRUE"><param name="href" value="http://www2.mediathatmattersfest.org/mtm05/film/opening.mov"><param name="pluginspage" value="http://www.apple.com/quicktime/download/indext.html"><param name="src" value="http://www2.mediathatmattersfest.org/mtm05/film/opening.mov"><param name="target" value="myself"><param name="type" value="video/quicktime"><embed src="http://www2.mediathatmattersfest.org/mtm05/film/opening.mov" height="256" width="320" scale="tofit" autoplay="true" controller="true" pluginspage="http://www.apple.com/quicktime/download/" kioskmode="true" name="qt"></embed></object>');

	// SET COOKIE (expires in 28 days)
  var today = new Date();
  var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000); // plus 28 days

  function setCookie(name, value) { // use: setCookie("name", value);
    if (value != null && value != "")
      document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
    bikky = document.cookie; // update bikky
  }

  setCookie ("visited", true);
	
	} else {	

	// else display click to play intro

	movieContent = ('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" height="256" width="320" ID="qt"><param name="autoplay" value="true"><param name="cache" value="FALSE"><param name="controller" value="FALSE"><param name="href" value="http://www2.mediathatmattersfest.org/mtm05/film/opening.mov"><param name="pluginspage" value="http://www.apple.com/quicktime/download/indext.html"><param name="src" value="/mtm05/media/stills/mtm05_trailer.jpg"><param name="target" value="myself"><param name="type" value="video/quicktime"><embed autoplay="TRUE" border="0" cache="FALSE" controller="FALSE" height="256" width="320" href="http://www2.mediathatmattersfest.org/mtm05/film/opening.mov" pluginspage="http://www.apple.com/quicktime/download/index.html" src="/mtm05/media/stills/mtm05_trailer.jpg" type="video/quicktime" TARGET="myself" name="qt"></embed></object>');

	}

}
else if (quicktimeVersion > 0) {
	movieContent = ('<img src="images/movie.gif" height="262" width="400" /><p>You have version  ' + quicktimeVersion + ' of Quicktime installed. This site requires version 6. You can <a href="http://www.apple.com/quicktime/">download the latest version of Quicktime here</a>.</p>');
}
else if (quicktimeVersion == 0) {
	movieContent = ('<img src="images/movie.gif" height="262" width="400" /><p>To view the movies you must have Quicktime installed on your current browser. You can <a href="http://www.apple.com/quicktime/">download the latest version of Quicktime here</a>.</p>');
}
else if (quicktimeVersion == quicktimeVersion_DONTKNOW || quicktimeVersion == null) {
	movieContent = ('<img src="images/movie.gif" height="262" width="400" /><p>This browser does not support Javascript-based Quicktime detection. If you don\'t have Quicktime installed, you can <a href="http://www.apple.com/quicktime/">download the latest version of Quicktime here</a>.</p>');
}




// IE4+
if (document.all)
	playerbox.innerHTML=movieContent;
	
// NS 6 (supports new DOM)
else if (document.getElementById){

pageRange = document.createRange();
pageElement = document.getElementById("playerbox");
pageRange.setStartBefore(pageElement);
htmlFrag = pageRange.createContextualFragment(movieContent);

while (pageElement.hasChildNodes())
	pageElement.removeChild(pageElement.lastChild);
	pageElement.appendChild(htmlFrag);
}

