if(typeof (AC)=="undefined") {
	AC={};
}

AC.Quicktime = {
 controllers:[],

 packageMovie:function(V,t,E) {
	function D(U,n,H) {
		if(!U) {return ;}
		var F=document.createElement("param");
		F.setAttribute("value",H);
		F.setAttribute("name",n);
		U.appendChild(F);
	}
	
	function R(H,n,U) {
		var r=document.createElement("object");
		
		if(AC.Detector.isiPhone()&&U.posterFrame) {
			D(r,"src",U.posterFrame);
			D(r,"href",n);D(r,"target","myself");
		} else {
			D(r,"src",n);
		}
		
		r.setAttribute("id",H);
		var F="6,0,2,0";
		
		if(null!=U&&""!=U.codebase&&typeof (U.codebase)!="undefined") {
			F=U.codeBase;
		}
		
		r.setAttribute("codebase","http://www.apple.com/qtactivex/qtplugin.cab#version="+F);
		return r;
	}
	
	function X(F,U,H) {
		var n=document.createElement("object");
		n.setAttribute("type","video/quicktime");
		n.setAttribute("data",U);
		n.setAttribute("id",F+"Inner");
		return n;
	}
	
	function N() {
		if(null==E||typeof (E)=="undefined") {
			return false;
		}
		for(var U in E) {
			var n=U.toLowerCase();
			switch(n) {
				case ("type"):
				case ("src"):
				case ("data"):
				case ("classid"):
				case ("name"):
				case ("id"):break;
				case ("class"):Element.addClassName(S,E[U]);break;
				case ("innerId"):if(A){A.setAttribute("id",E[U]);}break;
				case ("width"):
				case ("height"):S.setAttribute(n,E[U]);	if(A){A.setAttribute(n,E[U]);}break;
				default:D(S,n,E[U]);D(A,n,E[U]);break;
			}
		}
	}
	
	if(V==null||t==null) {
		throw new TypeError("Valid Name and File URL are required arguments.");
	}
	
	var S=R(V,t,E);
	if(!AC.Detector.isIEStrict()) {
		var A=X(V,t,E);
		try { 
			S.appendChild(A);
			S.inner=A;
		} catch(f) {}
	} else {
		Event.observe(window,"unload",function() {
			try {
				S.Stop();
			} catch(n) {} 
				S.style.display="none";
				S=null;
			});
	}
	
	N();
	D(S,"saveembedtags",true);
	D(A,"saveembedtags",true);
	S.setAttribute("classid","clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B");
	S.toMarkup = function(){
					if(!S.outerHTML) {
						return ;
					}
					var n="";
					n=S.outerHTML.replace("</OBJECT>","");
					for(var U=0;U<S.childNodes.length;U++) {
						n+=S.childNodes[U].outerHTML;
					}
					n+="</OBJECT>";
					return n;
				};
	return S;
	},
	 
 swapMovie:function(V,A,N) {
		var S=AC.Detector.isIEStrict();
		if(S&&A) {
			A.style.display="none";
		}
		Element.removeAllChildNodes(V);
		var R=null;
		if(!S) {
			V.appendChild(N);
			R=N;
		} else {
			V.innerHTML=N.toMarkup();
			R=V.firstChild;
			R.style.display="block";
		} 
		return R;
	   },
	    
 render:function(S,R,t) { 
	   	    var A=$(R);
	   	    var N=A.innerHTML;
	   	    if(!AC.Detector.isQTInstalled()) {
	   	    	Element.addClassName(A,"static");
	   	    	return ;
	   	    }
	   	    A.innerHTML="";
	   	    Element.addClassName(A,"loading");
	   	    A.appendChild(S);
	   	    var t=t?t:{};
	   	    var f=function() {
	   	    	D.monitorMovie();
	   	    	Element.removeClassName(R,"loading");
	   	    	Element.addClassName(R,"loaded");
	   	    };
	   	    var X=function() {return ;};
	   	    if("finishedState" in t) {
	   	    	var V=function(n,E) {
	   	    		return (function() {
	   	    			D.detachFromMovie();
	   	    			S.style.display="none";
	   	    			S=null;n.innerHTML="";
	   	    			if(typeof (E)=="string") {
	   	    				n.innerHTML=E;
	   	    			} else {
	   	    				n.appendChild(E);
	   	    			}
	   	    		});
	   	    	};
	   	    	X=V(A,t.finishedState);
	   	    }
	   	    var D=new AC.QuicktimeController(S, {onMoviePlayable:f, onMovieFinished:X});
	   	  }
};
	   	 
AC.QuicktimeController=Class.create();
AC.QuicktimeController.prototype= { 
	   	 	movie:null, 
	   	 	options:null, 
	   	 	movieAttacher:null, 
	   	 	attachDelay:10, 
	   	 	movieWatcher:null, 
	   	 	monitorDelay:400, 
	   	 	currentTime:0, 
	   	 	percentLoaded:0, 
	   	 	movieSize:0, 
	   	 	allowAttach:true, 
	   	 	controllerPanel:null, 
	   	 	currentControl:null, 
	   	 	playControl:null, 
	   	 	pauseControl:null, 
	   	 	slider:null, 
	   	 	track:null, 
	   	 	playHead:null, 
	   	 	loadedProgress:null, 
	   	 	isJogging:false, 
	   	 	hardPaused:false, 
	   	 	duration:0, 
	   	 	finished:false, 
	   	 	playing:false,
	   	 	 
	   	 	initialize:function(V,N) {
		   	 		if(typeof (V)!="undefined"){
		   	 			this.attachToMovie(V,N);
		   	 		} 
		   	 		Event.observe(window,"unload",function(){
		   	 			this.detachFromMovie();
		   	 			this.movie=null;
		   	 		}.bind(this));
		   	 	}, 
		   	 	
		   	 attachToMovie:function(V,S) {
		   	 		this.options=S||{};
		   	 		Event.observe(window,"unload", function() { 
		   	 			this.detachFromMovie();
		   	 		}.bind(this));
		   	 		var N=function(A) {
		   	 			if(!this.allowAttach) {
		   	 				return ;
		   	 			} 
		   	 			var R="";
		   	 			try {
		   	 				this.movie=V;
		   	 				R=this.movie.GetPluginStatus();
		   	 			} catch(X) {
		   	 				try { 
		   	 					this.movie=V.inner;
		   	 					R=this.movie.GetPluginStatus();
		   	 				} catch(X) {
		   	 					this.movie=null;
		   	 				}
		   	 			}
		   	 			if(R=="Playable"||R=="Complete") {
		   	 				clearInterval(this.movieAttacher);
		   	 				if(!this.alreadyRecorded) { 
		   	 					AC.Quicktime.controllers.push(this);
		   	 					this.alreadyRecorded=true;
		   	 				} 
		   	 				if(typeof (A)=="function") {
		   	 					A();
		   	 				}
		   	 			} else {
		   	 				if(R&&R.match(/error/i)) {
		   	 					clearInterval(this.movieAttacher);
		   	 				}
		   	 			}
		   	 		};
		   	 		clearInterval(this.movieAttacher);
		   	 		if(null==document.getElementById(V.id)){
		   	 			throw new ReferenceError("Movie has to be appended to document prior to initializing controller.");
		   	 		}
		   	 		this.movieAttacher=setInterval(N.bind(this,this.options.onMoviePlayable),this.attachDelay);
		   	 	},
		   	 	
		   	 detachFromMovie:function() {
		   	 	this.allowAttach=false;
		   	 	clearInterval(this.movieAttacher);
		   	 	clearTimeout(this.movieWatcher);
		   	 	AC.Quicktime.controllers=AC.Quicktime.controllers.without(this);
		   	 	this.movie=null;
		   	 	this.reset();
		   	 	this.allowAttach=true;
		   	 },
		   	 
		   	 reset:function() { 
		   	 	this.duration=0;
		   	 	this.movieSize=0;
		   	 	this.percentLoaded=0;
		   	 	if(this.slider) {
		   	 		this.slider.setValue(0);
		   	 		this.slider.trackLength=this.slider.maximumOffset()-this.slider.minimumOffset();
		   	 	}
		   	 },
		   	 
		   	 render:function(V) {
		   	 	this.controllerPanel=document.createElement("div");
		   	 	Element.addClassName(this.controllerPanel,"ACQuicktimeController");
		   	 	this.playControl=document.createElement("div");
		   	 	Element.addClassName(this.playControl,"control");
		   	 	Element.addClassName(this.playControl,"play");
		   	 	this.playControl.innerHTML="Play";
		   	 	this.playControl.onclick=this.Play.bind(this);
		   	 	this.pauseControl=document.createElement("div");
		   	 	Element.addClassName(this.pauseControl,"control");
		   	 	Element.addClassName(this.pauseControl,"pause");
		   	 	this.pauseControl.innerHTML="Pause";
		   	 	this.pauseControl.onclick=this.Stop.bind(this);
		   	 	var N=false;
		   	 	if(null!=this.movie) {
		   	 		N=this.GetAutoPlay();
		   	 	}
		   	 	this.currentControl=(N)?this.pauseControl:this.playControl;
		   	 	this.controllerPanel.appendChild(this.currentControl);
		   	 	this.sliderPanel=document.createElement("div");
		   	 	Element.addClassName(this.sliderPanel,"sliderPanel");
		   	 	this.track=document.createElement("div");
		   	 	Element.addClassName(this.track,"track");
		   	 	this.sliderPanel.appendChild(this.track);
		   	 	this.loadedProgress=document.createElement("div");
		   	 	Element.addClassName(this.loadedProgress,"loadedProgress");
		   	 	this.track.appendChild(this.loadedProgress);
		   	 	this.trackProgress=document.createElement("div");
		   	 	Element.addClassName(this.trackProgress,"trackProgress");
		   	 	this.track.appendChild(this.trackProgress);
		   	 	this.playHead=document.createElement("div");
		   	 	Element.addClassName(this.playHead,"playHead");
		   	 	this.track.appendChild(this.playHead);
		   	 	this.controllerPanel.appendChild(this.sliderPanel);
		   	 	if(V) { 
		   	 		$(V).appendChild(this.controllerPanel);
		   	 		if(this.movie) {
		   	 			this.monitorMovie();
		   	 		}
		   	 	}
		   	 	return this.controllerPanel;
		   	 },
		   	 monitorMovie:function() { 
		   	 	function V(S) {
		   	 		return (function() {
		   	 			if(S.controllerPanel!==null) {
		   	 				var D=S.isPlaying()&&(S.currentControl==S.playControl);
		   	 				var f=!S.isPlaying()&&(S.currentControl==S.pauseControl);
		   	 				if(!S.isJogging&&D) {
		   	 					S.controllerPanel.replaceChild(S.pauseControl,S.currentControl);
		   	 					S.currentControl=S.pauseControl;
		   	 				} else {
		   	 					if(!S.isJogging&&f) { 
		   	 						S.controllerPanel.replaceChild(S.playControl,S.currentControl);
		   	 						S.currentControl=S.playControl;
		   	 					}
		   	 				}
		   	 				if(S.percentLoaded<1) { 
		   	 					var R=Element.getDimensions(S.track).width;
		   	 					var X=S.GetMaxBytesLoaded()/S.GetMovieSize();
		   	 					if(!isNaN(X)&&0!==X) { 
		   	 						S.percentLoaded=X;
		   	 					}
		   	 					var A=R*S.percentLoaded;
		   	 					Element.setStyle(S.loadedProgress, {width:A+"px"});
		   	 				}
		   	 				if(S.isPlaying()) {
		   	 					S.slider.setValue(S.GetTime()/S.GetDuration());
		   	 				}
		   	 			}
		   	 			if(S.isPlaying()) {
		   	 				if(!S.playing) {
		   	 					S.playing=true;
		   	 					if(typeof (S.options.onMovieStart)=="function") {
		   	 						S.options.onMovieStart();
		   	 					}
		   	 				}
		   	 			} else {
		   	 				if(S.playing) {
		   	 					S.playing=false;
		   	 					if(typeof (S.options.onMovieStop)=="function") {
		   	 						S.options.onMovieStop();
		   	 					}
		   	 				}
		   	 			} 
		   	 			if(S.isFinished()) {
		   	 				if(!S.finished) {
		   	 					if(typeof (S.options.onMovieFinished)=="function") {
		   	 						S.options.onMovieFinished();
		   	 					}
		   	 					S.finished=true;
		   	 				}
		   	 			} else {
		   	 				S.finished=false;
		   	 			} 
		   	 			if(S.movie!==null) {
		   	 				S.movieWatcher=setTimeout(N,S.monitorDelay);
		   	 			}
		   	 		});
		   	 	}
		   	 	var N=V(this);
		   	 	if(this.controllerPanel!==null) {
		   	 		this.slider=new Control.Slider(this.playHead,this.track,{onSlide:function(S) {
		   	 			if(isNaN(S)) {
		   	 				return ;
		   	 			}
		   	 			this.trackProgress.style.width=this.slider.translateToPx(S);
		   	 			try {
		   	 				this.movie.Stop();
		   	 				this.isJogging=true;
		   	 				this.SetTime(S*this.GetDuration());
		   	 			} catch(R){}
		   	 		}.bind(this),onChange:function(S) {
		   	 			if(isNaN(S)) {
		   	 				return ;
		   	 			}
		   	 			this.trackProgress.style.width=this.slider.translateToPx(S);
		   	 			if(!this.isPlaying()&&!this.hardPaused&&!this.isFinished()) {
		   	 				try { 
		   	 					this.movie.Play();
		   	 				} catch(R){}
		   	 			}
		   	 			this.isJogging=false;
		   	 		}.bind(this)});
		   	 	}
		   	 	this.movieWatcher=setTimeout(N,this.monitorDelay);
		   	 },
		   	 Play:function() {
		   	 	if(null!=this.movie) {
		   	 		this.hardPaused=false;
		   	 		this.movie.Play();
		   	 	}
		   	 },
		   	 Stop:function() {
		   	 	this.hardPaused=true;
		   	 	this.movie.Stop();
		   	 },
		   	 Rewind:function() {
		   	 	if(null!=this.movie) {
		   	 		this.movie.Stop();
		   	 		this.movie.Rewind();
		   	 	}
		   	 },
		   	 Step:function(V) {
		   	 	this.movie.Step(V);
		   	 },
		   	 ShowDefaultView:function() {
		   	 	this.movie.ShowDefaultView();
		   	 },
		   	 GoPreviousNode:function() {
		   	 	this.movie.GoPreviousNode();
		   	 },
		   	 GetQuicktimeVersion:function(){
		   	 	return this.movie.GetQuickTimeVersion();
		   	 },
		   	 GetQuicktimeLanguage:function() {
		   	 	return this.movie.GetQuicktimeLanguage();
		   	 },
		   	 GetQuicktimeConnectionSpeed:function() {
		   	 	return this.movie.GetQuicktimeConnectionSpeed();
		   	 },
		   	 GetIsQuickTimeRegistered:function() {
		   	 	return this.movie.GetIsQuickTimeRegistered();
		   	 },
		   	 GetComponentVersion:function() {
		   	 	return this.movie.GetComponentVersion();
		   	 },
		   	 GetPluginVersion:function() {
		   	 	return this.movie.GetPluginVersion();
		   	 },
		   	 ResetPropertiesOnReload:function() {
		   	 	this.movie.ResetPropertiesOnReload();
		   	 },
		   	 GetPluginStatus:function() {
		   	 	return this.movie.GetPluginStatus();
		   	 }, 
		   	 GetAutoPlay:function() {
		   	 	return this.movie.GetAutoPlay();
		   	 },
		   	 SetAutoPlay:function(V) {
		   	 	this.movie.SetAutoPlay(V);
		   	 },
		   	 GetControllerVisible:function() {
		   	 	return this.movie.GetControllerVisible();
		   	 },
		   	 SetControllerVisible:function(V) {
		   	 	this.movie.SetControllerVisible(V);
		   	 },
		   	 GetRate:function() {
		   	 	return this.movie.GetRate();
		   	 },
		   	 SetRate:function(V) {
		   	 	this.movie.SetRate();
		   	 },
		   	 GetTime:function() {
		   	 	var N=0;
		   	 	try {
		   	 		N=this.movie.GetTime();
		   	 	} catch(V) {}
		   	 	if(0===N) {
		   	 		N=this.currentTime+this.monitorDelay;
		   	 	} else { 
		   	 		this.currentTime=N;
		   	 	} 
		   	 	return N;
		   	 },
		   	 SetTime:function(V) {
		   	 	this.movie.SetTime(V);
		   	 },
		   	 GetVolume:function() {
		   	 	return this.movie.GetVolume();
		   	 },
		   	 SetVolume:function(V) {
		   	 	this.movie.SetVolume(V);
		   	 },
		   	 GetMute:function() {
		   	 	return this.movie.GetMute();
		   	 },
		   	 SetMute:function(V) {
		   	 	this.movie.SetMute();
		   	 },
		   	 GetMovieName:function() {
		   	 	return this.movie.GetMovieName();
		   	 },
		   	 SetMovieName:function(V) {
		   	 	this.movie.SetMovieName(V);
		   	 },
		   	 GetMovieID:function() {
		   	 	return this.movie.GetMovieID();
		   	 }, 
		   	 SetMovieID:function(V) {
		   	 	this.movie.SetMovieID(V);
		   	 },
		   	 GetStartTime:function() {
		   	 	return this.movie.GetStartTime();
		   	 },
		   	 SetStartTime:function(V) {
		   	 	this.movie.SetStartTime(V);
		   	 },
		   	 GetEndTime:function() {
		   	 	return this.movie.GetEndTime();
		   	 },
		   	 SetEndTime:function(V) {
		   	 	this.movie.SetEndTime(V);
		   	 },
		   	 GetBgColor:function() {
		   	 	return this.movie.GetBgColor();
		   	 },
		   	 SetBgColor:function(V) {
		   	 	this.movie.SetBgColor(V);
		   	 },
		   	 GetIsLooping:function() {
		   	 	return this.movie.GetIsLooping();
		   	 },
		   	 SetIsLooping:function(V) {
		   	 	this.movie.SetIsLooping(V);
		   	 }, 
		   	 GetLoopIsPalindrome:function() {
		   	 	return this.movie.GetLoopIsPalindrome();
		   	 },
		   	 SetLoopIsPalindrome:function(V) {
		   	 	this.movie.SetLoopIsPalindrome(V);
		   	 },
		   	 GetPlayEveryFrame:function() {
		   	 	return this.movie.GetPlayEveryFrame();
		   	 },
		   	 SetPlayEveryFrame:function(V) {
		   	 	this.movie.SetPlayEveryFrame(V);
		   	 },
		   	 GetHREF:function() {
		   	 	return this.movie.GetHREF();
		   	 },
		   	 SetHREF:function(V) {
		   	 	this.movie.SetHREF(V);
		   	 },
		   	 GetTarget:function() {
		   	 	return this.movie.GetTarget();
		   	 },
		   	 SetTarget:function(V) {
		   	 	this.movie.SetTarget(V);
		   	 },
		   	 GetQTNEXTUrl:function() {
		   	 	 return this.movie.GetQTNEXTUrl();
		   	 },
		   	 SetQTNEXTUrl:function(N,V) {
		   	 	this.movie.SetQTNEXTUrl(N,V);
		   	 },
		   	 GetURL:function() { 
		   	 	return this.movie.GetURL();
		   	 },
		   	 SetURL:function(V) { 
		   	 	this.movie.SetURL(V);
		   	 	this.reset();
		   	 },
		   	 GetKioskMode:function() { 
		   	 	return this.movie.GetKioskMode();
		   	 },
		   	 SetKioskMode:function(V) {
		   	 	this.movie.SetKioskMode(V);
		   	 }, 
		   	 GetDuration:function() {
		   	 	if(null==this.duration||0===this.duration) {
		   	 		try { 
		   	 			this.duration=this.movie.GetDuration();
		   	 		}catch(V) {
		   	 			this.duration=null;
		   	 		}
		   	 	}
		   	 	return this.duration;
		   	 },
		   	 GetMaxTimeLoaded:function() {
		   	 	return this.movie.GetMaxTimeLoaded();
		   	 }, 
		   	 GetTimeScale:function() {
		   	 	return this.movie.GetTimeScale();
		   	 },
		   	 GetMovieSize:function() {
		   	 	if(0===this.movieSize) {
		   	 		this.movieSize=this.movie.GetMovieSize();
		   	 	}
		   	 	return this.movieSize;
		   	 },
		   	 GetMaxBytesLoaded:function() {
		   	 	return this.movie.GetMaxBytesLoaded();
		   	 },
		   	 GetTrackCount:function() {
		   	 	return this.movie.GetTrackCount();
		   	 },
		   	 GetMatrix:function() {
		   	 	return this.movie.GetMatrix();
		   	 },
		   	 SetMatrix:function(V) {
		   	 	this.movie.SetMatrix(V);
		   	 },
		   	 GetRectangle:function() {
		   	 	return this.movie.GetRectangle();
		   	 },
		   	 SetRectangle:function(V) {
		   	 	this.movie.SetRectangle(V);
		   	 },
		   	 GetLanguage:function() {
		   	 	return this.movie.GetLanguage();
		   	 },
		   	 SetLanguage:function(V) {
		   	 	this.movie.SetLanguage(V);
		   	 },
		   	 GetMIMEType:function() {
		   	 	return this.movie.GetMIMEType();
		   	 },
		   	 GetUserData:function(V) {
		   	 	return this.movie.GetUserData(V);
		   	 },
		   	 GetIsVRMovie:function() {
		   	 	return this.movie.GetIsVRMovie();
		   	 },
		   	 GetHotspotUrl:function(V) {
		   	 	return this.movie.GetHotspotUrl(V);
		   	 },
		   	 SetHotspotUrl:function(V,N) {
		   	 	this.movie.SetHotspotUrl(V,N);
		   	 },
		   	 GetHotspotTarget:function(V) {
		   	 	return this.movie.GetHotspotTarget(V);
		   	 },
		   	 SetHotspotTarget:function(V,N) {
		   	 	this.movie.SetHotspotTarget(V,N);
		   	 },
		   	 GetPanAngle:function() { 
		   	 	return this.movie.GetPanAngle();
		   	 },
		   	 SetPanAngle:function(V) {
		   	 	this.movie.SetPanAngle(V);
		   	 },
		   	 GetTiltAngle:function() {
		   	 	return this.movie.GetTiltAngle();
		   	 },
		   	 SetTiltAngle:function(V) {
		   	 	this.movie.SetTiltAngle(V);
		   	 },
		   	 GetFieldOfView:function() {
		   	 	return this.movie.GetFieldOfView();
		   	 },
		   	 SetFieldOfView:function(V) {
		   	 	this.movie.SetFieldOfView(V);
		   	 },
		   	 GetNodeCount:function() {
		   	 	return this.movie.GetNodeCount();
		   	 },
		   	 SetNodeID:function(V) {
		   	 	this.movie.SetNodeID(V);
		   	 },
		   	 GetTrackName:function(V) {
		   	 	return this.movie.GetTrackName(V);
		   	 }, 
		   	 GetTrackType:function(V) {
		   	 	return this.movie.GetTrackType(V);
		   	 },
		   	 GetTrackEnabled:function(V) {
		   	 	return this.movie.GetTrackEnabled(V);
		   	 },
		   	 SetTrackEnabled:function(N,V) {
		   	 	this.movie.SetTrackEnabled(N,V);
		   	 },
		   	 GetSpriteTrackVariable:function(N,V) {
		   	 	return this.movie.GetSpriteTrackVariable(N,V);
		   	 },
		   	 SetSpriteTrackVariable:function(N,V) {
		   	 	this.movie.SetSpriteTrackVariable(N,V);
		   	 },
		   	 isPlaying:function() {
		   	 	var V=false;
		   	 	try {
		   	 		V=this.movie.GetRate()!==0;
		   	 	} catch(N){}
		   	 	return V;
		   	 },
		   	 isFinished:function() {
		   	 	var S=true;
		   	 	var V=false;
		   	 	try {
		   	 		S=this.movie.GetRate()===0;
		   	 		V=this.movie.GetTime()==this.GetDuration();
		   	 	}catch(N) {
		   	 		return false;
		   	 	}
		   	 	return S&&V;
		   	 },
		   	 toggle:function() {
		   	 	if(this.isPlaying()){
		   	 		this.Stop();
		   	 	}
		   	 	else { 
		   	 		this.Play();
		   	 	}
		   	 }
};
