var dontKnow = false;
var quicktimeVersion = 0;

quicktimeVersion_DONTKNOW = -1;

// Retrieve quicktime cookie
var cookieStart = document.cookie.indexOf('quicktime');
if (cookieStart != -1) {
	var cookieEnd = document.cookie.indexOf(';', cookieStart);
	if (cookieEnd == -1) cookieEnd = document.cookie.length;
	quicktimeVersion = document.cookie.substring(cookieStart + 10, cookieEnd); 
}

// If the cookie doesn't exist...
	else {
	
	// use quicktime_detect.js to return the Quicktime version
	quicktimeVersion = getQuicktimeVersion();
	
	// write the version information to a cookie
	document.cookie = 'quicktime=' + quicktimeVersion;
}

// For the situation where we can't detect, set the values of the reference variables
if (quicktimeVersion == quicktimeVersion_DONTKNOW) {
	quicktimeVersion = 0;
	dontKnow = true;
}

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;
}

/* http version as at 7/5/04 */

function buildEmbed(){
	var htmltext="";
	var tapeNo=location.href.substring(location.href.indexOf(".html")-1, location.href.indexOf(".html"));
	if (getQuicktimeVersion() >= 4){
		htmltext += '<object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="120" height="106" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">';
		htmltext += '<param name="src" value="http://australianbiography.s3.amazonaws.com/' + id +'/' + id + '_poster.mov">';
		htmltext += '<param name="href" value="http://australianbiography.s3.amazonaws.com/' + id + '/rushes_nh/' + id + tapeNo + '.mov">';
		htmltext += '<param name="autoplay" value="true">';
		htmltext += '<param name="loop" value="false">';
		htmltext += '<param name="controller" value="true">';
		htmltext += '<embed src="http://australianbiography.s3.amazonaws.com/' + id +'/' + id + '_poster.mov" width="120" height="106" ';
		htmltext += 'href="http://australianbiography.s3.amazonaws.com/' + id + '/rushes_nh/' + id;
		htmltext += tapeNo + '.mov" TARGET="myself" targetcache="true" autoplay="false" ';
		htmltext += 'name="movie1" enablejavascript="true" align="right" ';
		htmltext += 'controller="false" bgcolor="#000000"></embed></object>';
	} else {
		htmltext += '<p class="legal">To view video of this interview you require the latest ';
		htmltext += '<a href="http://www.apple.com/quicktime/download/" target="_blank">QuickTime plug-in</a>.';
	}
	return htmltext;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


// Setting movie time --------------------------


var embed;
var $video_message;
var seek_timeout;
var time_sought;

function clear_seek_timeout() {
    clearTimeout(seek_timeout);
}

// Cross-platform event listener registration
// Inspired from http://developer.apple.com/documentation/QuickTime/Conceptual/QTScripting_JavaScript/bQTScripting_JavaScri_Document/chapter_1000_section_6.html
function myAddListener(obj, evt, handler, captures){
    if ( document.addEventListener )
        obj.addEventListener(evt, handler, captures);
    else
        // IE
        obj.attachEvent('on' + evt, handler);
}


if (window['$'] != undefined) { // Since Jquery is not included in every page but this script is, we want to check that jquery is loaded first.
    $(document).ready(function() {
        embed = $('#rush').children()[0];
        $video_message = $('#video_message');
    
        // Stop the auto seeking if one of the control clicked
        myAddListener(embed, 'qt_pause', clear_seek_timeout, false);
        myAddListener(embed, 'qt_play', clear_seek_timeout, false);
        myAddListener(embed, 'qt_timechanged', clear_seek_timeout, false);
    });
}

// Function that sets the time of the movie. If that time in the movie is
// not loaded yet, that function calls itself a few milliseconds later to
// try again, until the video is loaded.
function setMovieTime() {
	if (embed.GetMaxTimeLoaded() < time_sought) {
        if (!$video_message.html())
            $video_message.html('Movie still loading.<br/>Please wait...');
        seek_timeout = setTimeout("setMovieTime()",700);
    }
    else {
        embed.SetTime(time_sought);
        $video_message.html('');
        embed.Play();
    }
}

function seek(seconds){
    clear_seek_timeout();
    embed.Stop();
    time_sought = seconds * 600
    setMovieTime();
    
}


// ------------------------------

function seek_old(seconds){
	var ua = navigator.userAgent.toLowerCase(); 
	var isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1));
	if (document.all && navigator.platform.indexOf("Mac") != -1){
		var windowProps="height=540,width=326,left=100,top=100";
		var newWin=window.open("../support/maciewarning.html","warning",windowProps);
		newWin.moveTo(100,100);
		newWin.resizeTo(540,326);
	} else {
		with(document.movie1){
			if(GetURL().indexOf("poster.mov") != -1){
				SetURL(GetHREF());
			}
			Stop();
			SetTime(seconds * 600);
			Play();
		}
	}
}

function checkNS(){
    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();
    var is_minor = parseFloat(appVer);
    var is_major = parseInt(is_minor);

    var is_konq = false;
    var kqPos   = agt.indexOf('konqueror');
    if (kqPos !=-1) {                 
       is_konq  = true;
       is_minor = parseFloat(agt.substring(kqPos+10,agt.indexOf(';',kqPos)));
       is_major = parseInt(is_minor);
    }                                 

    var is_getElementById   = (document.getElementById) ? "true" : "false"; // 001121-abk
    var is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false"; // 001127-abk
    var is_documentElement = (document.documentElement) ? "true" : "false"; // 001121-abk

    var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
    var is_khtml  = (is_safari || is_konq);

    var is_gecko = ((!is_khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
    var is_gver  = 0;
    if (is_gecko) is_gver=navigator.productSub;

    var is_moz   = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                    (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                    (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                    (is_gecko) && 
                    ((navigator.vendor=="")||(navigator.vendor=="Mozilla")));
    var is_fb = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                 (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                 (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                 (is_gecko) && (navigator.vendor=="Firebird"));
    if ((is_moz)||(is_fb)) {  // 112403 - dmr
       var is_moz_ver = (navigator.vendorSub)?navigator.vendorSub:0;
       if(!(is_moz_ver)) {
           is_moz_ver = agt.indexOf('rv:');
           is_moz_ver = agt.substring(is_moz_ver+3);
           is_paren   = is_moz_ver.indexOf(')');
           is_moz_ver = is_moz_ver.substring(0,is_paren);
       }
       is_major = parseInt(is_moz_ver);
    }
   var is_fb_ver = is_moz_ver;

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)
                && (!is_khtml) && (!(is_moz)) &&(!is_fb));

    if ((navigator.vendor)&&
        ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&&
        (is_nav)) {
       is_major = parseInt(navigator.vendorSub);
    }

    if(is_nav && (is_major <= 4)){
    	return true;
    } else {
    	return false;
    }
}

function buildJumpMenu(){
	var html = "<form>\r";
	html += "<select name=\"menu1\" onChange=\"MM_jumpMenu('parent',this,0)\" size=\"1\" class=\"legal\">\r";
	if (checkNS()){
		html += "<option value=\"#\" selected>Choose another...</option>";
	} else {
		html += "<option value=\"#\" selected>Choose a biography...</option>";	
	}
    
    
        html += "<option value=\"/subjects/ahtoy/\">Lily Ah Toy</option>";
    
        html += "<option value=\"/subjects/bandler/\">Faith Bandler</option>";
    
        html += "<option value=\"/subjects/belgiorno/\">Franco Belgiorno-Nettis</option>";
    
        html += "<option value=\"/subjects/birch/\">Charles Birch</option>";
    
        html += "<option value=\"/subjects/birdwalton/\">Nancy Bird - Walton</option>";
    
        html += "<option value=\"/subjects/bjelkepetersen/\">Flo Bjelke - Petersen</option>";
    
        html += "<option value=\"/subjects/bonner/\">Neville Bonner</option>";
    
        html += "<option value=\"/subjects/brady/\">Veronica Brady</option>";
    
        html += "<option value=\"/subjects/burrows/\">Eva Burrows</option>";
    
        html += "<option value=\"/subjects/cairns/\">Jim Cairns</option>";
    
        html += "<option value=\"/subjects/churcher/\">Betty Churcher</option>";
    
        html += "<option value=\"/subjects/cilento/\">Diane Cilento</option>";
    
        html += "<option value=\"/subjects/clendinnen/\">Inga Clendinnen</option>";
    
        html += "<option value=\"/subjects/coombs/\">H C &quot;Nugget&quot; Coombs</option>";
    
        html += "<option value=\"/subjects/daprano/\">Zelda D&#39;Aprano</option>";
    
        html += "<option value=\"/subjects/dawe/\">Bruce Dawe</option>";
    
        html += "<option value=\"/subjects/dawson/\">Smoky Dawson</option>";
    
        html += "<option value=\"/subjects/deveson/\">Anne Deveson</option>";
    
        html += "<option value=\"/subjects/durack/\">Elizabeth Durack</option>";
    
        html += "<option value=\"/subjects/fraser/\">Malcolm Fraser</option>";
    
        html += "<option value=\"/subjects/fulton/\">Margaret Fulton</option>";
    
        html += "<option value=\"/subjects/gascoigne/\">Rosalie Gascoigne</option>";
    
        html += "<option value=\"/subjects/gordon/\">Hayes Gordon</option>";
    
        html += "<option value=\"/subjects/hammond/\">Dame Joan Hammond</option>";
    
        html += "<option value=\"/subjects/hazlitt/\">Jack Hazlitt</option>";
    
        html += "<option value=\"/subjects/holborow/\">Barbara Holborow</option>";
    
        html += "<option value=\"/subjects/horne/\">Donald Horne</option>";
    
        html += "<option value=\"/subjects/keneally/\">Thomas Keneally</option>";
    
        html += "<option value=\"/subjects/kunothmonks/\">Rosalie Kunoth-Monks</option>";
    
        html += "<option value=\"/subjects/langford/\">Ruby Langford Ginibi</option>";
    
        html += "<option value=\"/subjects/law/\">Phillip Law</option>";
    
        html += "<option value=\"/subjects/maccallum/\">Mungo MacCallum</option>";
    
        html += "<option value=\"/subjects/mcclelland/\">James McClelland</option>";
    
        html += "<option value=\"/subjects/metcalf/\">Donald Metcalf</option>";
    
        html += "<option value=\"/subjects/mitchell/\">Dame Roma Mitchell</option>";
    
        html += "<option value=\"/subjects/mundey/\">Jack Mundey</option>";
    
        html += "<option value=\"/subjects/odonoghue/\">Lowitja (Lois) O&#39;Donoghue</option>";
    
        html += "<option value=\"/subjects/oliphant/\">Sir Marcus Oliphant</option>";
    
        html += "<option value=\"/subjects/perkins/\">Charles Perkins</option>";
    
        html += "<option value=\"/subjects/riddell/\">Elizabeth Riddell</option>";
    
        html += "<option value=\"/subjects/roycroft/\">Bill Roycroft</option>";
    
        html += "<option value=\"/subjects/santamaria/\">Bob Santamaria</option>";
    
        html += "<option value=\"/subjects/sculthorpe/\">Peter Sculthorpe</option>";
    
        html += "<option value=\"/subjects/smorgon/\">Victor Smorgon</option>";
    
        html += "<option value=\"/subjects/strickland/\">Shirley Strickland de la Hunty</option>";
    
        html += "<option value=\"/subjects/tingwell/\">Charles &quot;Bud&quot; Tingwell</option>";
    
        html += "<option value=\"/subjects/tucker/\">Albert Tucker</option>";
    
        html += "<option value=\"/subjects/uren/\">Tom Uren</option>";
    
        html += "<option value=\"/subjects/whitrod/\">Ray Whitrod</option>";
    
    
    html += "</select>";
    html += "</form>";
    return html;
}

function frontMenu(){
	var html = "<form>\r";
	html += "<select name=\"menu1\" onChange=\"MM_jumpMenu('parent',this,0)\" size=\"1\" class=\"legal\">\r";
	html += "<option value=\"#\" selected>jump to...</option>";   
    
        html += "<option value=\"/subjects/ahtoy/\">Lily Ah Toy</option>";
    
        html += "<option value=\"/subjects/bandler/\">Faith Bandler</option>";
    
        html += "<option value=\"/subjects/belgiorno/\">Franco Belgiorno-Nettis</option>";
    
        html += "<option value=\"/subjects/birch/\">Charles Birch</option>";
    
        html += "<option value=\"/subjects/birdwalton/\">Nancy Bird - Walton</option>";
    
        html += "<option value=\"/subjects/bjelkepetersen/\">Flo Bjelke - Petersen</option>";
    
        html += "<option value=\"/subjects/bonner/\">Neville Bonner</option>";
    
        html += "<option value=\"/subjects/brady/\">Veronica Brady</option>";
    
        html += "<option value=\"/subjects/burrows/\">Eva Burrows</option>";
    
        html += "<option value=\"/subjects/cairns/\">Jim Cairns</option>";
    
        html += "<option value=\"/subjects/churcher/\">Betty Churcher</option>";
    
        html += "<option value=\"/subjects/cilento/\">Diane Cilento</option>";
    
        html += "<option value=\"/subjects/clendinnen/\">Inga Clendinnen</option>";
    
        html += "<option value=\"/subjects/coombs/\">H C &quot;Nugget&quot; Coombs</option>";
    
        html += "<option value=\"/subjects/daprano/\">Zelda D&#39;Aprano</option>";
    
        html += "<option value=\"/subjects/dawe/\">Bruce Dawe</option>";
    
        html += "<option value=\"/subjects/dawson/\">Smoky Dawson</option>";
    
        html += "<option value=\"/subjects/deveson/\">Anne Deveson</option>";
    
        html += "<option value=\"/subjects/durack/\">Elizabeth Durack</option>";
    
        html += "<option value=\"/subjects/fraser/\">Malcolm Fraser</option>";
    
        html += "<option value=\"/subjects/fulton/\">Margaret Fulton</option>";
    
        html += "<option value=\"/subjects/gascoigne/\">Rosalie Gascoigne</option>";
    
        html += "<option value=\"/subjects/gordon/\">Hayes Gordon</option>";
    
        html += "<option value=\"/subjects/hammond/\">Dame Joan Hammond</option>";
    
        html += "<option value=\"/subjects/hazlitt/\">Jack Hazlitt</option>";
    
        html += "<option value=\"/subjects/holborow/\">Barbara Holborow</option>";
    
        html += "<option value=\"/subjects/horne/\">Donald Horne</option>";
    
        html += "<option value=\"/subjects/keneally/\">Thomas Keneally</option>";
    
        html += "<option value=\"/subjects/kunothmonks/\">Rosalie Kunoth-Monks</option>";
    
        html += "<option value=\"/subjects/langford/\">Ruby Langford Ginibi</option>";
    
        html += "<option value=\"/subjects/law/\">Phillip Law</option>";
    
        html += "<option value=\"/subjects/maccallum/\">Mungo MacCallum</option>";
    
        html += "<option value=\"/subjects/mcclelland/\">James McClelland</option>";
    
        html += "<option value=\"/subjects/metcalf/\">Donald Metcalf</option>";
    
        html += "<option value=\"/subjects/mitchell/\">Dame Roma Mitchell</option>";
    
        html += "<option value=\"/subjects/mundey/\">Jack Mundey</option>";
    
        html += "<option value=\"/subjects/odonoghue/\">Lowitja (Lois) O&#39;Donoghue</option>";
    
        html += "<option value=\"/subjects/oliphant/\">Sir Marcus Oliphant</option>";
    
        html += "<option value=\"/subjects/perkins/\">Charles Perkins</option>";
    
        html += "<option value=\"/subjects/riddell/\">Elizabeth Riddell</option>";
    
        html += "<option value=\"/subjects/roycroft/\">Bill Roycroft</option>";
    
        html += "<option value=\"/subjects/santamaria/\">Bob Santamaria</option>";
    
        html += "<option value=\"/subjects/sculthorpe/\">Peter Sculthorpe</option>";
    
        html += "<option value=\"/subjects/smorgon/\">Victor Smorgon</option>";
    
        html += "<option value=\"/subjects/strickland/\">Shirley Strickland de la Hunty</option>";
    
        html += "<option value=\"/subjects/tingwell/\">Charles &quot;Bud&quot; Tingwell</option>";
    
        html += "<option value=\"/subjects/tucker/\">Albert Tucker</option>";
    
        html += "<option value=\"/subjects/uren/\">Tom Uren</option>";
    
        html += "<option value=\"/subjects/whitrod/\">Ray Whitrod</option>";
    
    
    html += "</select>";
    html += "</form>";
    return html;
}

function launch(x,y,width,height,url,name){
	if (document.all){
		var windowProps="height="+(height+3)+",width="+width+",left="+x+",top="+y;
		var newWin=window.open(url,name,windowProps);
		if(navigator.platform.indexOf("Mac") != -1){//Mac bugfix
			newWin.moveTo(x,y);
			newWin.resizeTo(width,height+3);
		}
	} else {
		var windowProps="resizable,height="+(height+3)+",width="+(width)+",screenX="+x+",screenY="+y;	
		var newWin=window.open(url,name,windowProps);
	}
    newWin.focus();
    return newWin;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function replaceText(text){
	while(text.lastIndexOf("&") > 0){
		text = text.replace('&', '[i-Stats]');
	}
	return text;
}

