// onload
var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = omniVideoOnLoad;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      omniVideoOnLoad();
    }
  }

function omniVideoOnLoad () {
	s.Media.autoTrack = false;
	s.Media.playerName = "Windows Video Player";
	s.eVar7 = s.pageName;  // sourcepage
	s.Media.trackVars = "events,pageName,eVar6,eVar7";
	s.Media.trackEvents = "event6";
}

// videoMode - corresponds to the mode under which the video was played, i.e. single video, three video list, browse, browse with categories
// mediaName - The name of the media item as it will appear in reports.
// mediaLength - The length of the media item in seconds
// isSilverlight - (optional) method of telling whether or not the player is Silverlight
function videoStart ( mediaName, videoMode, mediaLength, isSilverlight ) {
	s.events = "event5";
	var oldltvars = s.linkTrackVars;
	var oldltevts = s.linkTrackEvents;
	s.linkTrackEvents = "event5";
	s.linkTrackVars = "prop6,prop8,prop9,eVar6,eVar7,eVar8,eVar9,events";
	s.prop6 = mediaName;
	if (isSilverlight || Silverlight.isInstalled("2.0")) {
		s.eVar8 = s.prop8 = "silverlight";  
	}
	else {
		s.eVar8 = s.prop8 = "wmp";  
	}
	s.eVar9 = s.prop9 = videoMode;  
	s.tl( true, "o", "Video Start" ); 
	s.linkTrackEvents = oldltevts;
	s.linkTrackVars = oldltvars;
	
	var seconds = mediaLength;
	if (mediaLength && mediaLength.indexOf(":") > -1)
	{
		var durationParts = mediaLength.split(":");
		seconds = parseInt(durationParts[0] * 60) + parseInt(durationParts[1]);
	}

	try
	{
	    s.Media.open(mediaName, seconds, "DemoVideoPlayer");
	    s.Media.play(mediaName, 0);
	} catch(error) { }
}

// mediaName - The name of the media item as it will appear in reports.
// mediaOffset - The seconds into the media item that play begins. The offset is a zero based number.
function videoPause ( mediaName, mediaOffset ) {
	s.Media.stop( mediaName, mediaOffset );
}

// mediaName - The name of the media item as it will appear in reports.
// mediaOffset - The seconds into the media item that play begins. The offset is a zero based number.
function videoStop ( mediaName, mediaOffset ) {
	s.Media.stop( mediaName, mediaOffset );
}

// mediaName - The name of the media item as it will appear in reports.
function videoCompleted(videoName)
{
    try
	{
	    //s.Media.trackEvents = "event6";

	    var oldltvars = s.linkTrackVars;
	    var oldltevts = s.linkTrackEvents;
	    s.events = "event6";
	    s.Media.close(videoName);
	    s.linkTrackEvents = "event6";
	    // added to better track pathing following completions
	    s.prop6 = s.prop8 = s.prop9 = s.eVar6 = s.eVar8 = s.eVar9 = ""; /*s.events = */
	    s.linkTrackVars = "prop6,prop8,prop9,eVar6,eVar7,eVar8,eVar9,events";
	    s.eVar6 = s.prop6 = videoName;
	    s.eVar8 = s.prop8 = "sl";
	    s.eVar9 = s.prop9 = "sl";
	    var oldPageName = s.pageName;

	    s.tl(true, 'o', 'Video Complete');

	    s.linkTrackEvents = oldltevts;
	    s.linkTrackVars = oldltvars;
	    s.pageName = oldPageName;
	    
	} catch (error) { }
}

// mediaName - The name of the media item as it will appear in reports.
function sendToAFriend ( mediaName ) {
	var oldltvars = s.linkTrackVars;
	s.linkTrackVars = "prop13,prop15,prop16";
	s.prop13 = "Video"; // CM
	s.prop15 = mediaName;  // CE,   use the name of the video here
	s.prop16 = "Video: Send to a Friend";  // HL
	s.tl( true, "o", "Video: Send to a Friend" );
	s.linkTrackVars = oldltvars;
}

// clickEvent - corresponds to the Link Text prefixed with "Video: " (i.e. "Video: Play Video Again")
function otherClickEvent ( clickEvent ) {
	var oldltvars = s.linkTrackVars;
	var oldltevts = s.linkTrackEvents;
	s.linkTrackVars = "prop13,prop16";
	s.prop13 = "Video"; // CM
	s.prop16 = clickEvent;
	s.tl( true, "o", clickEvent );
	s.linkTrackEvents = oldltevts;
	s.linkTrackVars = oldltvars;
}