function reloadParent(url)
{
	// replace invalid chars
	url = url.replace('?','/');
	url = url.replace('&','/');
	url = url.replace('=','.');
	url = url + '/';

	windowVar = window.open(url);
}

// Track when video is loaded
// [Video ID|Video Title]);
function TrackVidLoad(vidPlayerType, videoID, videoTitle, videoDuration, pageTitle, pageURL) {
	var videoPlayerTracker = lrgVideoPlayerTracker;

	//alert("vidPlayerType = "+vidPlayerType);
	//alert("videoID = "+videoID);
	//alert("videoTitle = "+videoTitle);
	//alert("pageTitle = "+pageTitle);
	//alert("pageURL = "+pageURL);

	// Get Video Player Type
	if (vidPlayerType != '') {
		if (vidPlayerType == "LRG") {
			videoPlayerTracker = lrgVideoPlayerTracker;
		}
		else if (vidPlayerType == "MED") {
			videoPlayerTracker = medVideoPlayerTracker;
		}
		else if (vidPlayerType == "SML") {
			videoPlayerTracker = smlVideoPlayerTracker;
		}
	}

	// Set tracking label
	var trackingLabel = videoTitle + ' - ';
	var trackingLabel = trackingLabel + videoDuration + ' - ';
	var trackingLabel = trackingLabel + pageTitle + ' - ';
	var trackingLabel = trackingLabel + pageURL + ' - ';
	var trackingLabel = trackingLabel + videoID;

	// alert('TrackVidLoad - ' + trackingLabel);
	
	// Capture Event
	videoPlayerTracker._trackEvent('VideoLoaded', trackingLabel);
	
	// alert('TrackVidLoad - data captured');
}


// Track Duration of active video when new video is requested or when active video is finished playing
// eg. TPB([LRG|MED|SML], [Video ID|Video Title]);
function TrackVidDuration(vidPlayerType, videoID, videoTitle, playTime, videoDuration, pageTitle, pageURL) {
	var playtime_in_seconds;
	var videoduration_in_seconds;
	var percentage_watched;
	var videoPlayerTracker = lrgVideoPlayerTracker;
	
	// alert("track video Duration");
	// alert("vidPlayerType = "+vidPlayerType);
	// alert("videoID = "+videoID);
	// alert("videoTitle = "+videoTitle);
	// alert("playTime = "+playTime);
	// alert("videoDuration = "+videoDuration);
	// alert("pageTitle = "+pageTitle);
	// alert("pageURL = "+pageURL);

	// Get Video Player Type
	if (vidPlayerType != '') {
		if (vidPlayerType == "LRG") {
			videoPlayerTracker = lrgVideoPlayerTracker;
		}
		else if (vidPlayerType == "MED") {
			videoPlayerTracker = medVideoPlayerTracker;
		}
		else if (vidPlayerType == "SML") {
			videoPlayerTracker = smlVideoPlayerTracker;
		}
	}
	
	if (playTime != undefined && videoDuration != undefined)
	{
		// convert playTime to seconds
		playtime_in_seconds = ConvertToSeconds(playTime);
	
		// convert videoDuration to seconds
		videoduration_in_seconds = ConvertToSeconds(videoDuration);

		// Calculate percentage watched
		percentage_watched = parseInt(playtime_in_seconds/videoduration_in_seconds * 100)
	}
	else {
		percentage_watched = 0;
	}
	
	// alert("percentage_watched = "+percentage_watched);

	// Set tracking label
	var trackingLabel = videoTitle + ' - ';
	var trackingLabel = trackingLabel + videoDuration + ' - ';
	var trackingLabel = trackingLabel + pageTitle + ' - ';
	var trackingLabel = trackingLabel + pageURL + ' - ';
	var trackingLabel = trackingLabel + videoID;

	if (percentage_watched > 0)
	{
		// alert('TrackVidDuration - ' + trackingLabel +'-pp-'+ percentage_watched);

		// Capture Event
		videoPlayerTracker._trackEvent('VideoDurationPlayed', trackingLabel, percentage_watched);

		// alert('TrackVidDuration - data captured');
	}
}

function ConvertToSeconds(duration) {
	var mintues;
	var seconds;
	var delim;
	var duration_in_seconds;

	// 1 - See if there is a ':' character
	if (duration != '') {
		delim = duration.indexOf(":");
		if (delim > 0) {
			// get minutes
			minutes = duration.substring(0, delim)

			// get seconds
			seconds = duration.substring(delim+1, duration.length)

			// get Duration in seconds
			duration_in_seconds = (parseInt(minutes) * 60) + parseInt(seconds)
		}
		else {
			// Seconds only
			duration_in_seconds = parseInt(duration);
		}
	}

	return duration_in_seconds;
}

function DisplayAlert(message){
	 alert(message);
}