﻿/// <reference name="MicrosoftAjax.debug.js" />

Type.registerNamespace("CliqueSite.Core.Video");

CliqueSite.Core.Video.QuickTimePackager = function() {
		CliqueSite.Core.Video.QuickTimePackager.initializeBase(this);
		this._Id = null;
		this._TargetElement = null;
		this._FileUrl = null;
		this._PosterImage = null;
		this._holder = null;
}

CliqueSite.Core.Video.QuickTimePackager.prototype = {
	initialize: function() {
		CliqueSite.Core.Video.QuickTimePackager.callBaseMethod(this, "initialize");
		$addHandlers(this.get_TargetElement(), { "click":this._make }, this);
		this._holder = document.createElement("div");
		this._holder.setAttribute("id", this.get_Id());
		document.body.appendChild(this._holder);
	},
	
	_make : function(e) {
		var o = document.createElement("object");
		o.setAttribute("codebase", "http://www.apple.com/qtactivex/qtplugin.cab#version=7,3,0,0");
		o.setAttribute("height", "1");
		o.setAttribute("width", "1");
		o.setAttribute("id", "outobject");
		this._createParam(o, "src", this.get_PosterImage());
		var i = document.createElement("object");
		i.setAttribute("data", this.get_PosterImage());
		i.setAttribute("type", "video/quicktime");
		i.setAttribute("height", "1");
		i.setAttribute("width", "1");
		i.setAttribute("id", "inobject");
		this._createParam(i, "href", this.get_FileUrl());
		this._createParam(i, "target", "QuickTimePlayer");
		this._createParam(i, "controller", "false");
		this._createParam(i, "autohref", "true");
		this._createParam(o, "href", this.get_FileUrl());
		this._createParam(o, "target", "QuickTimePlayer");
		this._createParam(o, "controller", "false");
		this._createParam(o, "autohref", "true");
		o.setAttribute("classid", "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B");
		this._holder.appendChild(o);
		if (navigator.userAgent.indexOf("MSIE") == -1 || navigator.userAgent.indexOf("Opera") != -1)
			o.appendChild(i);
	},
	
	_createParam : function(parent, name, value) {
		var param = document.createElement("param");
		param.setAttribute("name", name);
		param.setAttribute("value", value);
		parent.appendChild(param);
	},

	dispose : function() {
		CliqueSite.Core.Video.QuickTimePackager.callBaseMethod(this, "dispose");
	},
	
	get_Id : function() {
		return this._Id;
	},
	set_Id : function(value) {
		this._Id = value;
	},
	
	get_TargetElement : function() {
		return this._TargetElement;
	},
	set_TargetElement : function(value) {
		this._TargetElement = value;
	},
	
	get_FileUrl : function() {
		return this._FileUrl;
	},
	set_FileUrl : function(value) {
		this._FileUrl = value;
	},
	
	get_PosterImage : function() {
		return this._PosterImage;
	},
	set_PosterImage : function(value) {
		this._PosterImage = value;
	}
}

CliqueSite.Core.Video.QuickTimePackager.registerClass("CliqueSite.Core.Video.QuickTimePackager", Sys.Component);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();