var TrackingClass = new Class({
	initialize : function () {
		this.currVideoTrackingId  = '';
		this.currPageType         = '';
		this.currPageName         = '';
	},
	
	setPageType : function (videoOrSerenade) {
		this.currPageType = videoOrSerenade;
		this.currPageName = (videoOrSerenade == 'serenades') ? 'Send_A_Personalized_Serenade' : 'Watch_Music_Videos';
	},
	
	setVideoId : function (videoId) {
		if (this.currPageType == 'serenades') {
			this.currVideoTrackingId = this.getSerenadesTrackingId(videoId);
		} else {
			this.currVideoTrackingId = this.getVideosTrackingId(videoId);
		}
		
		this.play();
	},
	
	getSerenadesTrackingId : function (videoId) {
		var i;
		
		for (i = 0; i < serenadesData.length; i++ ) {
			if ( serenadesData[i].videoId == videoId ) {
				return serenadesData[i].trackingid;
			}
		}
		
		return '';
	},
	
	getVideosTrackingId : function (videoId) {
		var i;
		
		for (i = 0; i < musicVideos.length; i++ ) {
			if ( musicVideos[i].videoId == videoId ) {
				return musicVideos[i].trackingid;
			}
		}
		
		return '';
		
	},
	
	track : function (action, label, count) {
		
		//pageTracker._trackEvent('_trackEvent', this.currPageName, action, label, count.toString());
		
		var pageName = this.currPageName + '/' + action;
		
		if (label != null) {
			pageName += '/' + label;
		}
		
		if (count != null) {
			pageName += '/' + count.toString();
		}
		
		var ev = ['_trackPageview', pageName];
		_gaq.push(ev);
		
		//console.log(ev);
		//_gaq.push(ev);
		
	},
	
	// This is essentially a landing on a video
	play : function () {
		this.track(this.currVideoTrackingId);
	},
	
	shareFB : function () {
		this.track(this.currVideoTrackingId, "Share_Facebook");
	},
	
	shareTW : function () {
		this.track(this.currVideoTrackingId, "Share_Twitter");
	},
	
	shareEmail : function () {
		this.track(this.currVideoTrackingId, "Share_Email");
	},
	
	viewAll : function () {
		this.track(this.currVideoTrackingId, "View_All");
	},
	
	sendSerenade : function () {
		this.track(this.currVideoTrackingId, "Play/Send_This_Serenade");
	},

	sendFB : function (sendCount) {
		this.track(this.currVideoTrackingId, "Play/Send_This_Serenade/Facebook", sendCount);
	},
	
	sendTW : function (sendCount) {
		this.track(this.currVideoTrackingId, "Play/Send_This_Serenade/Twitter", sendCount);
	},
	
	sendEmail : function () {
		this.track(this.currVideoTrackingId, "Play/Send_This_Serenade/Email");
	},
	
	showRandomizer : function () {
		this.track("Try_The_Juicy_Secret_Serenadizer");
	},
	
	reshuffleRandomizer : function () {
		this.track("Try_The_Juicy_Secret_Serenadizer", "Reshuffle");
	},
	
	sendRandomizer : function () {
		this.track("Try_The_Juicy_Secret_Serenadizer", "Send_This_Serenade");
	},
	
	banner : function () {
		this.track("Gotta_Have_Sweet_Gotta_Have_Juicy_Fruit");
	},
	
	linkFB : function () {
		this.track("Visit_Us_On_Facebook");
	},
	
	linkYT : function () {
		this.track("Visit_Youtube_Channel");
	},
	
	linkDL : function () {
		this.track("Download_Occasion_Serenades_For_Free_On_Itunes");
	}

	
});

