
var ReportUrl = "http://" + urgeStage + "/services/radio/reporting/radio_logger.jhtml";

function getCustomerId(){
	var customerId;
	if (CookieManager.exists("MTVN_TUNER_ID")){
		customerId = CookieManager.getRawCookie("MTVN_TUNER_ID");
	} else {
		if (CookieManager.exists("JSESSIONID")){
			customerId = CookieManager.getRawCookie("JSESSIONID");
 			CookieManager.setCookie("MTVN_TUNER_ID",customerId);
		} 
	}
	return customerId;
}

function RadioReporting(){
	this.MTVNTrackId = "";
	this.duration = 0;
	this.songPosition = 0;
	this.songSkipped = false;
	this.sent = false;
	this.entrytype = "";
	this.service = "";
	this.stationId = "";
	this.id = getCustomerId();

}

RadioReporting.prototype.Send = function(skipped){
	if(!this.sent && this.entrytype != "promo" && this.MTVNTrackId != ""){
		var UrlParamStr = ReportUrl + "?";
		UrlParamStr += "MTVNTrackId=" + this.MTVNTrackId;
		UrlParamStr += "&songPosition=" + this.songPosition;
		UrlParamStr += "&duration=" + this.duration;
		UrlParamStr += "&songSkipped=" + skipped;
		UrlParamStr += "&service=" + this.service;
		UrlParamStr += "&stationId=" + this.stationId;
		UrlParamStr += "&id=" + this.id;
		PreloadImg(UrlParamStr);
		WriteToLog("Reporting Call Made: " + UrlParamStr);
		this.sent = true;
	}
}

RadioReporting.prototype.UpdateTrack = function(){
	this.MTVNTrackId = NOWPLAYING.getTrackId();
	this.songPosition = NOWPLAYING.playlistCurrentItemCount();
	this.duration = 0;
	this.sent = false;
	this.entrytype = NOWPLAYING.entrytype();
	this.service = ReportingServiceParam;
	this.stationId = NOWPLAYING.getStationId();
}

var RadioReporting = new RadioReporting();






