// JavaScript Document

function trackVideo() {
//alert("starting omniture call");
	//printStatus("playVideo.args.length "+playVideo.arguments.length);
	//var previousVideoEvent = videoEvent;
	previousVideoEvent = "";

	var args = trackVideo.arguments;

	//alert ("Vidtypename = " + args[0].vidtypename + "\nVidtype = " + args[0].vidtype);

	/*for (i in args[0])
	{ alert(i + "= " + args[0][i])}
	alert(args[0]);*/
	//videoEvent = appManager.makeVideoObject(args[0],previousVideoEvent);
	//eval("videoEvent = appManager.makeVideoObject(" + args[0] + ",previousVideoEvent);");
	//alert("videoEvent = " + videoEvent);

	//preBuffEvent = appManager.makeVideoObject(args[1]);
	s_dc(s_account);  // necessary for dynamic reporting.

	s_channel = ""; // filter out player.jhtml from site sections report
   	//REPORTING.makeCall('video_play', args[0]);
	reporting_manager.reportPlayVideo(args[0],"");
   	s_channel = "mtv.ca broadband";

	/*
	// THIS HBX HANDLER CODE IS NOW VOID - DO NOT USE
	// INSTEAD USE THE hbxTrackVideo() FUNCTION!
	// ==================================================================================================================
   	// HBX Implementation
   	// for Flash Video tracking - by apuga - July 19, 2007

	// Initialize the content category string by determining what kind of video is playing
	var contentCatPath = '/-Top-Path-Not-Set!';
	var contentCatPathDepth = 0;

	//if (String(args[0].vidtype) == "1")
	if (String(args[0].vidtypename) == "music_video")
	{
		contentCatPath = '/MTV/flvTrack/MusicVideo';

		// First, assign each argument to an array for easier manipulation
		var levels = new Array(
						String(args[0].label),
						String(args[0].artistName),
						String(args[0].title),
						String(args[0].id)
			);

		contentCatPathDepth = 3;

	// c2 is a "Custom Metric" gateway variable for HBX for tracking Music Videos only
	// c2 has two "dimensions": Title and Artist, the pipe delimits the dimensions
   	_hbSet ("c2", args[0].title + "|" + args[0].artistName);

	}

	//else if (String(args[0].vidtypename) == "exclusive_audio_track")
	//{
	//}

	else
	{
		contentCatPath = '/MTV/flvTrack/ShowClip';

		// First, assign each argument to an array for easier manipulation
		var levels = new Array(
						String(args[0].content['type']),
						String(args[0].content['title']),
						String(args[0].title),
						String(args[0].id)
			);

		contentCatPathDepth = 3;
	}

	// Then, clean the spaces out of the arguments and assign to the content category string
   	for (var x = 0; (x <= (contentCatPathDepth - 1)); x++)
   	{
   		levels[x] = String (levels[x]);
		levels[x] = levels[x].replace (/%20/gi,"+");
		levels[x] = levels[x].replace (/ /gi,"+");
		contentCatPath = String (contentCatPath + '/' + levels[x]);
   	}

   	// vcon sets the multi-level content category (overrides hbx.mlc)
   	_hbSet ("vcon", contentCatPath);

   	// override the page name variable (hbx.pn) to be the video ID
   	_hbSet ("n", levels[3]);
   	_hbSend();

   	// End HBX Implementation
   	// ==================================================================================================================

   	*/
}

function hbxTrackVideo (reportObj)
{
	// New HBX Media Streaming Tracking Implementation
	// by apuga - August 24, 2007

	//alert ("Inside!");

	// Initialize the content category string by determining what kind of video is playing
	var contentCatPath = '/-Top-Path-Not-Set!';
	var contentCatPathDepth = 0;

	//if (String(args[0].vidtype) == "1")
	if (String(reportObj.mediaObj.vidtypename) == "music_video")
	{
		contentCatPath = '/MTV/flvTrack/MusicVideo';

		// First, assign each argument to an array for easier manipulation
		var levels = new Array(
						String(reportObj.mediaObj.label),
						String(reportObj.mediaObj.artistName),
						String(reportObj.mediaObj.title),
						String(reportObj.mediaObj.id)
			);

		contentCatPathDepth = 4;

		if (reportObj.s == 'play')
		{
			// c2 is a "Custom Metric" gateway variable for HBX for tracking Music Videos only
			// c2 has two "dimensions": Title and Artist, the pipe delimits the dimensions
			_hbSet ("c2", reportObj.mediaObj.title + "|" + reportObj.mediaObj.artistName);
		}

	}
	/*
	else if (String(reportObj.mediaObj.vidtypename) == "exclusive_audio_track")
	{
	}
	*/
	else
	{
		contentCatPath = '/MTV/flvTrack/ShowClip';

		// First, assign each argument to an array for easier manipulation
		var levels = new Array(
						String(reportObj.mediaObj.content['type']),
						String(reportObj.mediaObj.content['title']),
						String(reportObj.mediaObj.title),
						String(reportObj.mediaObj.id)
			);

		contentCatPathDepth = 4;

		if (reportObj.s == 'play')
		{
			// c1: Custom Metric for Show Clips
			_hbSet ("c1", reportObj.mediaObj.content['title'] + "|" + reportObj.mediaObj.title);
		}
	}

	// Then, clean the spaces out of the arguments and assign to the content category string
   	for (var x = 0; (x <= (contentCatPathDepth - 1)); x++)
   	{
   		levels[x] = String (levels[x]);
		levels[x] = levels[x].replace (/%20/gi,"+");
		levels[x] = levels[x].replace (/ /gi,"+");
		contentCatPath = String (contentCatPath + '/' + levels[x]);
   	}

	_hbSet ("m.f", contentCatPath);

	_hbSet ("m.cl", reportObj.cl);
	_hbSet ("m.cv", reportObj.cv);
	_hbSet ("m.s", reportObj.s);
	_hbSet ("m.cp", reportObj.cp);
	_hbSet ("m.ep", reportObj.ep);

	_hbSend ();
}