AC.ViewMaster.Tracker = Class.create();
Object.extend(AC.ViewMaster.Tracker.prototype, Event.Listener);
Object.extend(AC.ViewMaster.Tracker.prototype, {
	count: 0,
	type: "",
	isReplay: false,
	ccTime: 0,
	mediaType: "",
	geoCode: "",
	movieType: "",
	overlay: false,
	interactionCount: 0,
	initialize: function (c, a) {
		this.type = c;
		this.options = a || {};
		this.qtEventSource = document.getElementsByTagName("body")[0];
		var b = window.location.pathname;
		var d = window.location.hostname;
		if (d.match(/apple.com.cn/)) {
			this.geoCode = " (CN)"
		} else {
			if (!b.match(/^\/(ws|pr|g5|go|ta|wm)\//)) {
				if (b.match(/^\/(\w{2}|befr|benl|chfr|chde|asia|lae)(?=\/)/)) {
					b = b.split("/");
					this.geoCode = " (" + b[1].toUpperCase() + ")"
				}
			}
		}
		if (this.geoCode == "") {
			this.geoCode = " (US)"
		}
		this.listenForEvent(AC.ViewMaster, "ViewMasterDidShowNotification", false, this.sectionDidChange);
	},
	setDelegate: function (a) {
		this.delegate = a
	},
	pageName: function (a) {
		this._id = "";
		if (a) {
			this._id = this.trackingNameForSection(a)
		} else {
			if (this.viewMaster.currentSection) {
				this._id = this.trackingNameForSection(this.viewMaster.currentSection)
			}
		}
		/*this._pageName = AC.Tracking.pageName() + " - " + this._id;
		if (typeof this._pageName === "string") {
			this._pageName = this._pageName.replace(/[\'\'\"]/g, "")
		}*/
	},
	trackingNameForSection: function (a) {
		var b = a.id.replace("MASKED-", "");
		if (this.delegate && typeof(this.delegate.trackingNameForSection) === "function") {
			b = this.delegate.trackingNameForSection(this, b, a)
		}
		return b
	},
	isSnowLeopardControllerAvailable: function () {
		return (typeof(Media) != "undefined")
	},
	sectionDidChange: function (b) {
		this.viewMaster = b.event_data.data.sender;
		var a = b.event_data.data.incomingView;
		if (a && !a.content.hasClassName("sneaky") && (typeof(b.event_data.data.trigger) != "undefined" || window.location.toString().match(a.id) || a.mediaType().match(/video/))) {
			var c = {};
			this.pageName(a);
			if (this._id) {
				c.pageName = this._pageName + this.geoCode;
				this.mediaType = "";
				if (this.delegate && typeof(this.delegate.sectionDidChange) == "function") {
					c = this.delegate.sectionDidChange(this, this.viewMaster, a, this._id, c)
				}
				if (this.interactionCount == 0 && this.mediaType == "") {
					c.eVar16 = c.prop16 = "Gallery Interaction";
					c.events = "event1"
				}
				if (this.type == "click") {
					/*c.prop3 = c.pageName.replace(/\s*\((\w{2}|befr|benl|chfr|chde|asia|lae)\)/g, "");
					c.pageName = AC.Tracking.pageName() + this.geoCode;
					AC.Tracking.trackClick(c, this.viewMaster, "o", c.prop3)*/
				} else {
					AC.Tracking.trackPage(c)
				}
				this.count++;
				this.interactionCount++
			}
		}
	}
});