/* 
	ac-quicktime-and-helpers.js
	=================================================================	
	QuickTime detection and helper functions
	Based on swfobject-helpers.js
	-----------------------------------------------------------------
*/

/* 
	AC_QuickTime.js
	---------------------------------------------------------------	
	Apple's QuickTime embedding
	=================================================================		
	Abstract: This file contains functions to generate OBJECT and EMBED tags for QuickTime content.
	
	Version: <1.1>
	
	Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
	Computer, Inc. ("Apple") in consideration of your agreement to the
	following terms, and your use, installation, modification or
	redistribution of this Apple software constitutes acceptance of these
	terms.  If you do not agree with these terms, please do not use,
	install, modify or redistribute this Apple software.
	
	In consideration of your agreement to abide by the following terms, and
	subject to these terms, Apple grants you a personal, non-exclusive
	license, under Apple's copyrights in this original Apple software (the
	"Apple Software"), to use, reproduce, modify and redistribute the Apple
	Software, with or without modifications, in source and/or binary forms;
	provided that if you redistribute the Apple Software in its entirety and
	without modifications, you must retain this notice and the following
	text and disclaimers in all such redistributions of the Apple Software. 
	Neither the name, trademarks, service marks or logos of Apple Computer,
	Inc. may be used to endorse or promote products derived from the Apple
	Software without specific prior written permission from Apple.  Except
	as expressly stated in this notice, no other rights or licenses, express
	or implied, are granted by Apple herein, including but not limited to
	any patent rights that may be infringed by your derivative works or by
	other works in which the Apple Software may be incorporated.
	
	The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
	MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
	THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
	FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
	OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
	
	IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
	MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
	AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
	STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
	
	Copyright 2006 Apple Computer, Inc., All Rights Reserved
	-----------------------------------------------------------------		
*/ 
	
	/*
	 * This file contains functions to generate OBJECT and EMBED tags for QuickTime content. 
	 */
	
	/************** LOCALIZABLE GLOBAL VARIABLES ****************/
	
	var gArgCountErr =	'The "%%" function requires an even number of arguments.'
					+	'\nArguments should be in the form "atttributeName", "attributeValue", ...';
	
	/******************** END LOCALIZABLE **********************/
	
	var gTagAttrs				= null;
	var gQTGeneratorVersion		= 1.0;
	
	function AC_QuickTimeVersion()	{ return gQTGeneratorVersion; }
	
	function _QTComplain(callingFcnName, errMsg)
	{
			errMsg = errMsg.replace("%%", callingFcnName);
		alert(errMsg);
	}
	
	function _QTAddAttribute(prefix, slotName, tagName)
	{
		var		value;
	
		value = gTagAttrs[prefix + slotName];
		if ( null == value )
			value = gTagAttrs[slotName];
	
		if ( null != value )
		{
			if ( 0 == slotName.indexOf(prefix) && (null == tagName) )
				tagName = slotName.substring(prefix.length); 
			if ( null == tagName ) 
				tagName = slotName;
			return '' + tagName + '="' + value + '"';
		}
		else
			return "";
	}
	
	function _QTAddObjectAttr(slotName, tagName)
	{
		// don't bother if it is only for the embed tag
		if ( 0 == slotName.indexOf("emb#") )
			return "";
	
		if ( 0 == slotName.indexOf("obj#") && (null == tagName) )
			tagName = slotName.substring(4); 
	
		return _QTAddAttribute("obj#", slotName, tagName);
	}
	
	function _QTAddEmbedAttr(slotName, tagName)
	{
		// don't bother if it is only for the object tag
		if ( 0 == slotName.indexOf("obj#") )
			return "";
	
		if ( 0 == slotName.indexOf("emb#") && (null == tagName) )
			tagName = slotName.substring(4); 
	
		return _QTAddAttribute("emb#", slotName, tagName);
	}
	
	
	function _QTAddObjectParam(slotName, generateXHTML)
	{
		var		paramValue;
		var		paramStr = "";
		var		endTagChar = (generateXHTML) ? ' />' : '>';
	
		if ( -1 == slotName.indexOf("emb#") )
		{
			// look for the OBJECT-only param first. if there is none, look for a generic one
			paramValue = gTagAttrs["obj#" + slotName];
			if ( null == paramValue )
				paramValue = gTagAttrs[slotName];
	
			if ( 0 == slotName.indexOf("obj#") )
				slotName = slotName.substring(4); 
		
			if ( null != paramValue )
				paramStr = '<param name="' + slotName + '" value="' + paramValue + '"' + endTagChar;
		}
	
		return paramStr;
	}
	
	function _QTDeleteTagAttrs()
	{
		for ( var ndx = 0; ndx < arguments.length; ndx++ )
		{
			var attrName = arguments[ndx];
			delete gTagAttrs[attrName];
			delete gTagAttrs["emb#" + attrName];
			delete gTagAttrs["obj#" + attrName];
		}
	}
	
			
	
	// generate an embed and object tag, return as a string
	function _QTGenerate(callingFcnName, generateXHTML, args)
	{
		// is the number of optional arguments even?
		if ( args.length < 4 || (0 != (args.length % 2)) )
		{
			_QTComplain(callingFcnName, gArgCountErr);
			return "";
		}
		
		// allocate an array, fill in the required attributes with fixed place params and defaults
		gTagAttrs = new Object();
		gTagAttrs["src"] = args[0];
		gTagAttrs["width"] = args[1];
		gTagAttrs["height"] = args[2];
		gTagAttrs["classid"] = "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
			//Impportant note: It is recommended that you use this exact classid in order to ensure a seamless experience for all viewers
		gTagAttrs["pluginspage"] = "http://www.apple.com/quicktime/download/";
	
		// set up codebase attribute with specified or default version before parsing args so
		//  anything passed in will override
		var activexVers = args[3]
		if ( (null == activexVers) || ("" == activexVers) )
			activexVers = "6,0,2,0";
		gTagAttrs["codebase"] = "http://www.apple.com/qtactivex/qtplugin.cab#version=" + activexVers;
	
		var	attrName,
			attrValue;
	
		// add all of the optional attributes to the array
		for ( var ndx = 4; ndx < args.length; ndx += 2)
		{
			attrName = args[ndx].toLowerCase();
			attrValue = args[ndx + 1];
	
			// "name" and "id" should have the same value, the former goes in the embed and the later goes in
			//  the object. use one array slot 
			if ( "name" == attrName || "id" == attrName )
				gTagAttrs["name"] = attrValue;
	
			else 
				gTagAttrs[attrName] = attrValue;
		}
	
		// init both tags with the required and "special" attributes
		var objTag =  '<object '
						+ _QTAddObjectAttr("classid")
						+ _QTAddObjectAttr("width")
						+ _QTAddObjectAttr("height")
						+ _QTAddObjectAttr("codebase")
						+ _QTAddObjectAttr("name", "id")
						+ _QTAddObjectAttr("tabindex")
						+ _QTAddObjectAttr("hspace")
						+ _QTAddObjectAttr("vspace")
						+ _QTAddObjectAttr("border")
						+ _QTAddObjectAttr("align")
						+ _QTAddObjectAttr("class")
						+ _QTAddObjectAttr("title")
						+ _QTAddObjectAttr("accesskey")
						+ _QTAddObjectAttr("noexternaldata")
						+ '>'
						+ _QTAddObjectParam("src", generateXHTML);
		var embedTag = '<embed '
						+ _QTAddEmbedAttr("src")
						+ _QTAddEmbedAttr("width")
						+ _QTAddEmbedAttr("height")
						+ _QTAddEmbedAttr("pluginspage")
						+ _QTAddEmbedAttr("name")
						+ _QTAddEmbedAttr("align")
						+ _QTAddEmbedAttr("tabindex");
	
		// delete the attributes/params we have already added
		_QTDeleteTagAttrs("src","width","height","pluginspage","classid","codebase","name","tabindex",
						"hspace","vspace","border","align","noexternaldata","class","title","accesskey");
	
		// and finally, add all of the remaining attributes to the embed and object
		for ( var attrName in gTagAttrs )
		{
			attrValue = gTagAttrs[attrName];
			if ( null != attrValue )
			{
				embedTag += _QTAddEmbedAttr(attrName);
				objTag += _QTAddObjectParam(attrName, generateXHTML);
			}
		} 
	
		// end both tags, we're done
		return objTag + embedTag + '></em' + 'bed></ob' + 'ject' + '>';
	}
	
	// return the object/embed as a string
	function QT_GenerateOBJECTText()
	{
		return _QTGenerate("QT_GenerateOBJECTText", false, arguments);
	}
	
	function QT_GenerateOBJECTText_XHTML()
	{
		return _QTGenerate("QT_GenerateOBJECTText_XHTML", true, arguments);
	}
	
	function QT_WriteOBJECT()
	{
		document.writeln(_QTGenerate("QT_WriteOBJECT", false, arguments));
	}
	
	function QT_WriteOBJECT_XHTML()
	{
		document.writeln(_QTGenerate("QT_WriteOBJECT_XHTML", true, arguments));
	}
	
/*	
	@	qt_browser()
	---------------------------------------------------------------		
	qt helper function
	---------------------------------------------------------------				
	
	Cut down version of browserdetect.js, for portability.	
	_______________________________________________________________
*/	

	var qt_browser;
	
	function qt_browser()
	{
		var ua = navigator.userAgent.toLowerCase(); 
	
		this.isIE = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1)); 		
		this.isNS = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );		
		this.isOpera = (ua.indexOf('opera') != -1);		
		this.isSafari = (ua.indexOf('safari') != - 1);	
		this.isChrome = (ua.indexOf('chrome') != - 1); // Google Chrome
		
		this.isWin = (ua.indexOf('win') != -1);		
		this.isMac = (ua.indexOf('mac') != -1);		
		
		this.versionMinor = parseFloat(navigator.appVersion); 	
		
		if (this.isGecko && !this.isMozilla) 
		{
		  this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
		}
		else if (this.isMozilla) 
		{
		  this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
		}		
		else if (this.isIE && this.versionMinor >= 4) 
		{
		  this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
		}		
		else if (this.isSafari) 
		{
		  this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
		}
		else if (this.isOpera) 
		{
		  this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
		}		
		
		this.versionMajor = parseInt(this.versionMinor); 
		
		/*
			browsers that fail the qt detection test:
		*/			
	
		if (
				(this.isIE && this.versionMajor <= 4) || 		
				(this.isMac && this.isIE && this.versionMajor == 5) ||	
				(this.isNS && this.versionMajor <= 4) 		
				)
		{
			this.supports_QTdetect = false;		
		}
		else
		{
			this.supports_QTdetect = true;		
		}			
	}

	qt_browser = new qt_browser();			

/*	
	@	PluginDetectQT.js
	---------------------------------------------------------------		
	qtobject helper function
	---------------------------------------------------------------				
	PluginDetect v0.5.0 [ QT ] by Eric Gerds 
	www.pinlady.net/PluginDetect 	
	
	Detects for presence of QuickTime plugin + supports IE7 :)
	_______________________________________________________________
*/	

/* PluginDetect v0.5.0 [ QT ] by Eric Gerds www.pinlady.net/PluginDetect */ if(!PluginDetect){var PluginDetect={getNum:function(A,_2){if(!this.num(A)){return null}var m;if(typeof _2=="undefined"){m=/[\d][\d\.\_,-]*/.exec(A)}else{m=(new RegExp(_2)).exec(A)}return m?m[0].replace(/[\.\_-]/g,","):null},hasMimeType:function(_4){if(PluginDetect.isIE){return null}var s,t,z,M=_4.constructor==String?[_4]:_4;for(z=0;z<M.length;z++){s=navigator.mimeTypes[M[z]];if(s&&s.enabledPlugin){t=s.enabledPlugin;if(t.name||t.description){return s}}}return null},findNavPlugin:function(N,_7){var _8=N.constructor==String?N:N.join(".*"),numS=_7===false?"":"\\d";var i,re=new RegExp(_8+".*"+numS+"|"+numS+".*"+_8,"i");var _a=navigator.plugins;for(i=0;i<_a.length;i++){if(re.test(_a[i].description)||re.test(_a[i].name)){return _a[i]}}return null},getAXO:function(_b){var _c,e;try{_c=new ActiveXObject(_b);return _c}catch(e){}return null},num:function(A){return (typeof A!="string"?false:(/\d/).test(A))},compareNums:function(_e,_f){if(!this.num(_e)||!this.num(_f)){return 0}if(this.plugin&&this.plugin.compareNums){return this.plugin.compareNums(_e,_f)}var m1=_e.split(","),m2=_f.split(","),x,p=parseInt;for(x=0;x<Math.min(m1.length,m2.length);x++){if(p(m1[x],10)>p(m2[x],10)){return 1}if(p(m1[x],10)<p(m2[x],10)){return -1}}return 0},formatNum:function(num){if(!this.num(num)){return null}var x,n=num.replace(/\s/g,"").replace(/[\.\_]/g,",").split(",").concat(["0","0","0","0"]);for(x=0;x<4;x++){if(/^(0+)(.+)$/.test(n[x])){n[x]=RegExp.$2}}return n[0]+","+n[1]+","+n[2]+","+n[3]},initScript:function(){var $=this,IE;$.isIE=/*@cc_on!@*/false;$.IEver=-1;$.ActiveXEnabled=false;if($.isIE){IE=(/msie\s*\d\.{0,1}\d*/i).exec(navigator.userAgent);if(IE){$.IEver=parseFloat((/\d.{0,1}\d*/i).exec(IE[0]),10)}var _14,x;_14=["ShockwaveFlash.ShockwaveFlash","Msxml2.XMLHTTP","Microsoft.XMLDOM","Msxml2.DOMDocument","TDCCtl.TDCCtl","Shell.UIHelper","Scripting.Dictionary","wmplayer.ocx"];for(x=0;x<_14.length;x++){if($.getAXO(_14[x])){$.ActiveXEnabled=true;break}}}if($.isIE){$.head=typeof document.getElementsByTagName!="undefined"?document.getElementsByTagName("head")[0]:null}},init:function(_15){if(typeof _15!="string"){return -3}_15=_15.toLowerCase().replace(/\s/g,"");var $=this,IE,p;if(typeof $[_15]=="undefined"){return -3}p=$[_15];$.plugin=p;if(typeof p.installed=="undefined"){p.installed=null;p.version=null;p.getVersionDone=null}$.garbage=false;if($.isIE&&!$.ActiveXEnabled){return -2}return 1},isMinVersion:function(_17,_18,_19){var $=PluginDetect,i=$.init(_17);if(i<0){return i}if(typeof _18=="undefined"||_18==null){_18="0"}if(typeof _18=="number"){_18=_18.toString()}if(!$.num(_18)){return -3}_18=$.formatNum(_18);if(typeof _19=="undefined"){_19=null}var _1b=-1,p=$.plugin;if(p.getVersionDone!=1){p.getVersion(_18,_19);if(p.getVersionDone==null||p.version!=null){p.getVersionDone=1}}if(p.version!=null||p.installed!=null){if(p.installed<=0.5){_1b=p.installed}else{_1b=(p.version==null?0:($.compareNums(p.version,_18)>=0?1:-1))}}$.cleanup();return _1b;return -3},getVersion:function(_1c,_1d){var $=PluginDetect,i=$.init(_1c);if(i<0){return null}var p=$.plugin;if(typeof _1d=="undefined"){_1d=null}if(p.getVersionDone!=1){p.getVersion(null,_1d);if(p.getVersionDone==null||p.version!=null){p.getVersionDone=1}}$.cleanup();return p.version;return null},cleanup:function(){var $=this;if($.garbage&&typeof window.CollectGarbage!="undefined"){window.CollectGarbage()}},isActiveXObject:function(_21){var $=this,result,e,s="<object width=\"1\" height=\"1\" "+"style=\"display:none\" "+$.plugin.getCodeBaseVersion(_21)+">"+$.plugin.HTML+"</object>";if($.head.firstChild){$.head.insertBefore(document.createElement("object"),$.head.firstChild)}else{$.head.appendChild(document.createElement("object"))}$.head.firstChild.outerHTML=s;try{$.head.firstChild.classid=$.plugin.classID}catch(e){}result=false;try{if($.head.firstChild.object){result=true}}catch(e){}try{if(result&&$.head.firstChild.readyState<4){$.garbage=true}}catch(e){}$.head.removeChild($.head.firstChild);return result;},codebaseSearch:function(min){var $=this;if(typeof min!="undefined"){return $.isActiveXObject(min)};var _25=[0,0,0,0],x,y,A=$.plugin.digits,t=function(x,y){var _28=(x==0?y:_25[0])+","+(x==1?y:_25[1])+","+(x==2?y:_25[2])+","+(x==3?y:_25[3]);return $.isActiveXObject(_28)};var _29,tmp;var _2a=false;for(x=0;x<A.length;x++){_29=A[x]*2;_25[x]=0;for(y=0;y<20;y++){if(_29==1&&x>0&&_2a){break}if(_29-_25[x]>1){tmp=Math.round((_29+_25[x])/2);if(t(x,tmp)){_25[x]=tmp;_2a=true}else{_29=tmp}}else{if(_29-_25[x]==1){_29--;if(!_2a&&t(x,_29)){_2a=true}break}else{if(!_2a&&t(x,_29)){_2a=true}break}}}if(!_2a){return null}}return _25.join(",");},dummy1:0}}PluginDetect.initScript();PluginDetect.onJavaDetectionDone=function(f,jar){var $=this,j=$.java,z;if(j.getVersionDone!=1){z=$.isMinVersion("Java","0",jar);if(z==-3){z=$.getVersion("Java",jar)}}if(j.installed!=null&&j.installed!=-0.5&&j.installed!=0.5){if(typeof f=="function"){f()}return}};PluginDetect.onWindowLoaded=function(f){};PluginDetect.quicktime={mimeType:["video/quicktime","application/x-quicktimeplayer","image/x-macpaint","image/x-quicktime"],progID:"QuickTimeCheckObject.QuickTimeCheck.1",progID0:"QuickTime.QuickTime",classID:"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B",minIEver:7,HTML:"<param name=\"src\" value=\"A14999.mov\" /><param name=\"controller\" value=\"false\" />",getCodeBaseVersion:function(v){var r=v.replace(/[\.\_]/g,",").split(","),$=PluginDetect;if($.compareNums(v,"7,5,0,0")>=0){v=r[0]+","+r[1]+r[2]+","+r[3]}return "codebase=\"#version="+v+"\""},digits:[16,16,16,0],clipTo3digits:function(v){if(v==null||typeof v=="undefined"){return null}var t;t=v.split(",");return t[0]+","+t[1]+","+t[2]+",0"},getVersion:function(){var _35=null,p,$=PluginDetect;var _36=true;if(!$.isIE){if(navigator.platform&&(/linux/i).test(navigator.platform)){_36=false}if(_36){p=$.findNavPlugin(["QuickTime","(Plug-in|Plugin)"]);if(p&&p.name&&$.hasMimeType(this.mimeType)){_35=$.getNum(p.name)}}this.installed=_35?1:-1}else{var obj;if($.IEver>=this.minIEver&&$.getAXO(this.progID0)){_35=$.codebaseSearch()}else{obj=$.getAXO(this.progID);if(obj&&obj.QuickTimeVersion){_35=obj.QuickTimeVersion.toString(16);_35=_35.charAt(0)+"."+_35.charAt(1)+"."+_35.charAt(2)}}this.installed=_35?1:($.getAXO(this.progID0)?0:-1)}this.version=this.clipTo3digits($.formatNum(_35))}};	

/*	
	@	qt_oldBrowserWarning()
	---------------------------------------------------------------		
	qtobject helper function
	---------------------------------------------------------------				
	
	A simple document.write for old browsers.
	
	This may be customised on a per-project basis, but don't forget
	to update the HTML old-browser and noscript warnings to
	match the tone/syntax of this message.
	_______________________________________________________________
*/		

	function qt_oldBrowserWarning(container, el)
	{	
		if (container == 'summary')
		{
			document.write('<' + el + ' class="upgrade"><span class="warning-header">Please wait, Video Player is loading..<\/span><\/' + el + '>');	
		}
		else if (container == 'detail')
		{			
				document.write('<' + el + '><span class="warning-detail">If the Video player does not appear after 10 seconds (depending on your connection speed), then it is likely that your browser is not supported. Please upgrade to a standards compliant browser such as <a href="http://www.firefox.com/">Firefox<\/a> and then refresh this page. <\/span><\/' + el + '>');
		}			
	}				
	
/*	
	@	qt_oldQTWarning()
	---------------------------------------------------------------			
	qtobject helper function
	---------------------------------------------------------------		
	
	Arguments:
	1 x qt_containerId
	OR
	1 x qt_warningContainerId
	
	Change the qt_oldBrowserWarning() to an old-QT warning.	
	
	This is for newer browsers so it uses correct DOM manipulation
	of elements, rather than el.innerHTML or document.write()
	
	Note: div.warning needs to wrap the warning message
	_______________________________________________________________
*/		
	
	function qt_oldQTWarning(qt_containerId)
	{				
		if (!document.getElementById(qt_containerId))
		{
			return;
		}	
		
		// warning header
		warning_header = document.createElement('span');
		warning_header.className = 'warning-header';			
		warning_header_text = document.createTextNode('Please upgrade your QuickTime player');
		
		warning_header.appendChild(warning_header_text);				
				
		// warning detail						
		warning_detail = document.createElement('span');
		warning_detail.className = 'warning-detail';			
		warning_detail_text1 = document.createTextNode('You\'re seeing this notice because you\'re using an old version of the QuickTime Player. Please upgrade to the latest ');		
		warning_detail_link = document.createElement('a');
		warning_detail_link.setAttribute('href', 'http://www.apple.com/quicktime/download/ ');
		warning_detail_link_text = document.createTextNode('Quicktime Player');
		warning_detail_text2 = document.createTextNode(' and then refresh this page. ');												
			

		warning_detail_link.appendChild(warning_detail_link_text);	
		warning_detail.appendChild(warning_detail_text1);	
		warning_detail.appendChild(warning_detail_link);			
		warning_detail.appendChild(warning_detail_text2);		
								
		// check that there is in fact a warning to upgrade				
		var divs = document.getElementById(qt_containerId).getElementsByTagName('div');	
		
		for (var i=0; i<divs.length; i++)
		{				
			if (divs[i].className == 'warning')
			{
				// search thru all warning elements and replace the ones that match						
				var els = document.getElementById(qt_containerId).getElementsByTagName('*'); // BPA p39				
				
				for (var i=0; i<els.length; i++)
				{			
					if (els[i].className == 'warning-header')
					{
						els[i].parentNode.replaceChild(warning_header, els[i]);
					}				
					else if (els[i].className == 'warning-detail')
					{
						els[i].parentNode.replaceChild(warning_detail, els[i]);
					}					
				}
			}	
		}				
	}	
	
/*	
	@	qt_removeWarning()
	---------------------------------------------------------------			
	swfobject helper function
	---------------------------------------------------------------				
	
	Arguments:
	1 x qt_warningContainerId		
	
	Remove the warning container.		
	_______________________________________________________________
*/		

	function qt_removeWarning(qt_warningContainerId)
	{
		if (!document.getElementById(qt_warningContainerId))
		{
			return;
		}
		
		qt_warningContainer = document.getElementById(qt_warningContainerId);		
		qt_warningContainer.parentNode.removeChild(qt_warningContainer);
	}	
	
/*	
	@	qt_object_properties_to_param_string()
	---------------------------------------------------------------			
	swfobject helper function
	---------------------------------------------------------------				
	
	Arguments:
	1 x object name			
	1 x separator string		
	_______________________________________________________________
*/	

	function qt_object_properties_to_param_string(object_name, separator_str)
	{
		var str = '';
		var p = 0;
		
		for (var i in object_name)
		{
			// FOR/IN : http://www.quirksmode.org/js/associative.html: 
			// loop through all properties of the object (in no particular disorder)
			
			if (p > 0)
			{
				str += ', ';
			}		
			
			// add each object property/value to the parameters string
			str += ('"' + i.toUpperCase() + '", "' + object_name[i] + '"');									
		
			p++;
		}		
		return str;
	}

/*	
	@	qt_advancedEmbed()
	---------------------------------------------------------------			
	swfobject helper function	
	---------------------------------------------------------------				
	Embed, for better control of warnings and alternative content
	
	Notes:
	if qt_warningContainer is nested within qt_container, 
	it will automatically be replaced by the QR movie 
	when that is inserted.
	However sometimes the warning is separate from the qt_container, 
	so by calling this function we cover both options
	
	this function is only run if the qt_warningContainerId (still) exists, 
	so if the act of inserting a QT movie deletes 
	the warning container, an error will not be generated. 	
	_______________________________________________________________
*/		

	function qt_advancedEmbed(qt_src, qt_containerId, qt_width, qt_height, qt_reqdVersion, qt_params, qt_custom_args)
	{		
	
		if (qt_browser.supports_QTdetect)
		{
			switch (PluginDetect.isMinVersion('QuickTime', qt_reqdVersion))				
			{ 
				// QuickTime Player version is available:					
				case 1 : 	

					// if a QT movie has been specified, insert the QT movie
					if (qt_src)
					{							
						var qt_params_str = qt_object_properties_to_param_string(qt_params, '", "');
					
						if (qt_params_str.indexOf('"CONTROLLER", "true"') != -1)
						{
							qt_height = ((parseInt(qt_height) + 16) + '');
						}							
					
						// eval function as string, to prevent qt_params_str being passed as a single argument
						qt_embed_code = eval('QT_GenerateOBJECTText("' + qt_src + '", "' + qt_width + '", "' + qt_height + '", "", ' + qt_params_str + ');');				
						
						document.getElementById(qt_containerId).innerHTML = qt_embed_code;									
					}						
					// if a warning exists, remove the warning
					if (qt_custom_args.qt_warningContainerId) 
					{ 
						qt_removeWarning(qt_custom_args.qt_warningContainerId); 
					}		
					
					break;				
				
				// QuickTime Player version is not available:
				case -1 :	
				case -2 :					
					// if a warning exists, change the old-browser warning to an old-QT warning							
					if (qt_custom_args.qt_warningContainerId)
					{
						qt_oldQTWarning(qt_custom_args.qt_warningContainerId); 	
					}															
					break; 				
			}
		}
	}			
