function sendAnalyticsEvent(str){ 
	try{
		if(typeof dispatcher!="undefined"){
			ns=com.mtvi.reporting.Account.name;
			if(str!=null&&str!=="") ns+=","+str;
			com.mtvi.reporting.Account.name=ns;
			dispatcher.sendCall();
		}
	}catch(e){}
}

function sendLinkEvent(str,lnkname){
	try{
		if(typeof dispatcher!="undefined"){
			ns=com.mtvi.reporting.Account.name;
			if(str!=null&&str!=="") ns+=","+str;
			com.mtvi.reporting.Account.name=ns;
			dispatcher.setAttribute("linkType","o");
			dispatcher.setAttribute("lnk",true);
			dispatcher.setAttribute("linkName",lnkname);
			dispatcher.setAttribute("prop11","");
			dispatcher.setAttribute("prop13","");
			dispatcher.sendCall();
		}
	}catch(e){}
}

function sendReportingCall(ro){
	if(ro){
		if(ro.setOverrides)	omniSetOverrides(ro.setOverrides);
	} sendAnalyticsEvent("");
}

function sendLinkCall(linkName, ro){
	var lnkName = unescape(linkName);
	if(ro){
		if(ro.setOverrides)	omniSetOverrides(ro.setOverrides);
	} void(sendLinkEvent("", lnkName));
}

function omniSetOverrides(or){
	for(var i in or){
		try{
			if(typeof dispatcher!="undefined"){
				var omniParam=i.replace(/s_/,"");
				com.mtvi.config.SectionSetup[omniParam]=or[i];
				dispatcher.setAttribute(omniParam,or[i]);
			}
		}catch(e){}
	}
}

function sendReportingCallTN2(ro){
	if(ro){
		if(ro.setOverrides)	omniSetOverrides(ro.setOverrides);
	} void(sendAnalyticsEvent("vianickvision"));
}

function sendInitCall(e1,e2,e3){
	elementString=e1+"-"+e2+"-"+e3;
	linkName="/init_click_tracking/"+elementString;
	sendLinkEvent("",linkName);
}
//Nick JR Link tracking function
function TrackLinkNickJr(e1,e2,e3)
{
	//alert("1-TrackLinkNickJr,"+e1+","+e2+","+e3);
	linkName="/init_click_tracking/"+e1+"-"+e2+"-"+e3;
	dispatcher.setAccountVars({
		name:'vianickjr',
		dynamicAccountSelection:'true',
		linkInternalFilters:'javascript:,nickjr.com',
		trackExternalLinks: true,
		trackDownloadLinks: true,
		pageName:'',
		hier1:'',
		hier2:'',
		channel:'',
		prop1:'',
		prop2:'',
		prop3:'',
		prop4:'',
		prop5:'',
		prop6:'',
		prop10:'',		
		prop11:'',
		prop13:'',
		linkType:'o',
		lnk: true,
		linkName: linkName
	});
	//alert("2-TrackLinkNickJr,"+e1+","+e2+","+e3);
	dispatcher.sendCall();
	//alert("3-TrackLinkNickJr,"+e1+","+e2+","+e3);
}
function pageNameReset(newPagename){
		pagevalue=dispatcher.getAttribute("pageName");
		dispatcher.setAttribute("pageName",newPagename);
		dispatcher.setAttribute("hier2",hier2);
		dispatcher.setAttribute("channel",channel);
		dispatcher.setAttribute("prop11",prop11);		
		dispatcher.send();
		dispatcher.setAttribute("pageName",pagevalue);
		dispatcher.setAttribute("hier2",hier2);
		dispatcher.setAttribute("channel",channel);
}

function pageNameAppend(newPagename){
		pagevalue=pageName;
		dispatcher.setAttribute("pageName",pagevalue+"-"+newPagename);
		dispatcher.setAttribute("hier2",hier2);
		dispatcher.setAttribute("channel",channel);
		dispatcher.setAttribute("prop11",prop11);
		if (newPagename!="games"){
			dispatcher.setAttribute("prop5",newPagename);
		}
		dispatcher.send();
		dispatcher.setAttribute("pageName",pagevalue);
		dispatcher.setAttribute("hier2",hier2);
		dispatcher.setAttribute("channel",channel);
		dispatcher.setAttribute("prop5","");
}

var _nrtrackingcode="";
var NRcall="";

function videoReportingCall(){
	dispatcher.setAccountVars({name:'vianickvision',dynamicAccountSelection:'false',linkInternalFilters:'javascript:,nickjr.com',trackExternalLinks: true,trackDownloadLinks: true});
if (videoManager.currentElement.typeGroup == "bumper")
	{
		//Ad Sequence Reporting Call
		dispatcher.setAttribute("hier2",configManager.suite+"/"+configManager.displayMode+"/ad_sequence");
		dispatcher.setAttribute("pageName","/"+configManager.suite+"/"+configManager.displayMode+"/ad_sequence");
		dispatcher.setAttribute("prop1","");
		dispatcher.setAttribute("prop2","");
		dispatcher.setAttribute("prop4","");
		dispatcher.setAttribute("prop5","");
		dispatcher.setAttribute("prop6","");
		dispatcher.setAttribute("prop7","");
		dispatcher.setAttribute("prop8","");
		dispatcher.setAttribute("prop9",videoManager.currentElement.averageBitRate);
		dispatcher.setAttribute("prop11",videoManager.nickSkin);
		dispatcher.setAttribute("prop16",configManager.suite+"/"+configManager.displayMode);
		dispatcher.setAttribute("channel",configManager.suite);
		dispatcher.setAttribute("Account","vianickvision");
		dispatcher.send();
		}
		else if(videoManager.currentElement.id=="44466"){
		}
		else if(videoManager.currentElement.id=="44146"){
		}
		else if (videoManager.currentElement.showid=="false")
		{
		//Empty showid override
		dispatcher.setAttribute("hier2",configManager.suite+"/"+configManager.displayMode+"/gateway-"+videoManager.currentElement.gateway+"/playlist-"+videoManager.currentElement.playlistId+"/"+videoManager.currentElement.form+"-"+videoManager.currentElement.typeGroup+"-"+videoManager.currentElement.id+"-"+videoManager.currentElement.shortTitle);
		dispatcher.setAttribute("pageName","/"+configManager.suite+"/"+configManager.displayMode+"/"+videoManager.currentElement.gateway+"/"+videoManager.currentElement.form+"-"+videoManager.currentElement.typeGroup+"-"+videoManager.currentElement.id+"-"+videoManager.currentElement.shortTitle);
		dispatcher.setAttribute("prop1",configManager.suite+"-"+videoManager.currentElement.form+"-"+videoManager.currentElement.typeGroup+"-"+videoManager.currentElement.id+"-"+videoManager.currentElement.shortTitle);
		dispatcher.setAttribute("prop2",configManager.suite);
		dispatcher.setAttribute("prop4",configManager.suite+configManager.sec);
		dispatcher.setAttribute("prop5",configManager.suite+"_"+videoManager.currentElement.form+"form");
		dispatcher.setAttribute("prop6",configManager.suite+"_"+configManager.displayMode+"_"+videoManager.currentElement.duration+"_seconds_long");
		dispatcher.setAttribute("prop7",configManager.suite+"_"+configManager.displayMode+"_"+videoManager.currentElement.timeViewed+"_seconds_viewed");
		dispatcher.setAttribute("prop8",configManager.suite+"_"+configManager.displayMode+"_"+videoManager.currentElement.percentViewed+"_percent_viewed");
		dispatcher.setAttribute("prop9",videoManager.currentElement.averageBitRate);
		dispatcher.setAttribute("prop10","No_Show_Association");
		dispatcher.setAttribute("prop11",videoManager.nickSkin);
		dispatcher.setAttribute("prop13",configManager.suite+"/"+configManager.displayMode);
		dispatcher.setAttribute("prop16",configManager.suite+"/"+configManager.displayMode);
		dispatcher.setAttribute("prop17",videoManager.currentElement.id);
		dispatcher.setAttribute("channel",configManager.suite);
		dispatcher.sendCall();	
		resetParamsToDefault();	

		_nrtrackingcode = "http://secure-us.imrworldwide.com/cgi-bin/m?ci=us-viacom&cg="+ "playtimetv" +"&si=http%3A%2F%2Fwww.nickjr.com%2F"+ id + "&tl=dav0-"+ id +"&c0=pa,Viacom%20Digital&c1=br,Nickelodeon%20Network&c2=ch,NickJR&cc=1";
		NRcall = document.createElement('img');
		NRcall.setAttribute('src',_nrtrackingcode);	
	}else{
		//Standard Reporting Call
		dispatcher.setAttribute("hier2",configManager.suite+"/"+configManager.displayMode+"/gateway-"+videoManager.currentElement.gateway+"/playlist-"+videoManager.currentElement.playlistId+"/"+videoManager.currentElement.form+"-"+videoManager.currentElement.typeGroup+"-"+videoManager.currentElement.id+"-"+videoManager.currentElement.showid+"-"+videoManager.currentElement.shortTitle);
		dispatcher.setAttribute("pageName","/"+configManager.suite+"/"+configManager.displayMode+"/"+videoManager.currentElement.gateway+"/"+videoManager.currentElement.form+"-"+videoManager.currentElement.typeGroup+"-"+videoManager.currentElement.id+"-"+videoManager.currentElement.showid+"-"+videoManager.currentElement.shortTitle);
		dispatcher.setAttribute("prop1",configManager.suite+"-"+videoManager.currentElement.form+"-"+videoManager.currentElement.typeGroup+"-"+videoManager.currentElement.id+"-"+videoManager.currentElement.shortTitle);
		dispatcher.setAttribute("prop2",configManager.suite);
		dispatcher.setAttribute("prop4",configManager.suite+configManager.sec);
		dispatcher.setAttribute("prop5",configManager.suite+"_"+videoManager.currentElement.form+"form");
		dispatcher.setAttribute("prop6",configManager.suite+"_"+configManager.displayMode+"_"+videoManager.currentElement.duration+"_seconds_long");
		dispatcher.setAttribute("prop7",configManager.suite+"_"+configManager.displayMode+"_"+videoManager.currentElement.timeViewed+"_seconds_viewed");
		dispatcher.setAttribute("prop8",configManager.suite+"_"+configManager.displayMode+"_"+videoManager.currentElement.percentViewed+"_percent_viewed");
		dispatcher.setAttribute("prop9",videoManager.currentElement.averageBitRate);
		dispatcher.setAttribute("prop10",configManager.suite+"_"+videoManager.currentElement.showid);
		dispatcher.setAttribute("prop11",videoManager.nickSkin);
		dispatcher.setAttribute("prop13",configManager.suite+"/"+configManager.displayMode);
		dispatcher.setAttribute("prop16",configManager.suite+"/"+configManager.displayMode);
		dispatcher.setAttribute("prop17",videoManager.currentElement.id);
		dispatcher.setAttribute("channel",configManager.suite);
		dispatcher.sendCall();
		resetParamsToDefault();	

		_nrtrackingcode = "http://secure-us.imrworldwide.com/cgi-bin/m?ci=us-viacom&cg="+ "playtimetv" +"&si=http%3A%2F%2Fwww.nickjr.com%2F"+ id + "&tl=dav0-"+ id +"&c0=pa,Viacom%20Digital&c1=br,Nickelodeon%20Network&c2=ch,NickJR&cc=1";
		NRcall = document.createElement('img');
		NRcall.setAttribute('src',_nrtrackingcode);
	}
}
function trackKidsGamePlay(gameName){
	try{
		if(com.mtvi.util.isDefined(gameName)){
			if(com.mtvi.util.isDefined(dispatcher)){
				if(com.mtvi.util.isDefined(com.mtvi.reporting.Account)){ 					
					pName = document.URL;
					var ro={};
					com.mtvi.reporting.Account.name = "viakidsgameplay";
					ro.name = com.mtvi.reporting.Account.name;
					ro.dynamicAccountSelection = false;
					ro.dynamicAccountList = "nickviadev=nick-d.mtvi.com,nick-q.mtvi.com";
					ro.linkInternalFilters = "javascript:,nick.com";
					ro.trackExternalLinks = true;
					ro.trackDownloadLinks = true;
					ro.pageName = pName;
					dispatcher.setAccountVars(ro);
					var site = fetchGamePlaySite(pName);
					dispatcher.setAttribute("channel",site);
					dispatcher.setAttribute("hier1",site+"/"+gameName);
					dispatcher.setAttribute("hier2","");
					dispatcher.setAttribute("prop1",site+"/"+gameName);
					dispatcher.setAttribute("prop2",gameName);
					dispatcher.setAttribute("prop3",site);					
					for(var i=4; i<41; i++){
						dispatcher.setAttribute("prop"+i, "");	
					}					
					dispatcher.sendCall();
					resetParamsToDefault();
				}
			}
		}
	}catch(e){}
}
function fetchGamePlaySite(locStr){
	var pattern = new RegExp("(nick)(?:-[dq].mtvi)?.com","gi");
	var result = pattern.exec(locStr);
	if(result){//has nick
		pattern = new RegExp("/(turbonick|nicktropolis)/","gi");
		var result2 = pattern.exec(locStr);
		if(result2){//has turbonick or nicktrolopis
			return(result2[1]);
		}
		return(result[1]);
	}else{
		pattern = new RegExp("(nickjr)(?:-[dq].mtvi)?.com","gi");
		result = pattern.exec(locStr);
		if(result){//has nickjr
			if(locStr.indexOf("/playtime/")>0) return("playtime");
			return(result[1]);
		}else{
			pattern = new RegExp("(noggin)(?:-[dq].mtvi)?.com","gi");
			result = pattern.exec(locStr);
			if(result){//has noggin
				return(result[1]);
			}else{
				pattern = new RegExp("(shockwave|addictinggames|the-n).*.com","gi");
				result = pattern.exec(locStr);
				if(result) return(result[1]);
				else return(null);
			}
		}
	}
}
function resetParamsToDefault(){
	try {
		if(com.mtvi.util.isDefined(dispatcher)){
			if(rollup=="grownups"){
				dispatcher.setAccountVars({
					name:'vianickjr,vianickjrparents',
					dynamicAccountSelection:'false',
					dynamicAccountList:'devvianickjr=nickjr-d',
					linkInternalFilters:'javascript:,nickjr.com',
					trackExternalLinks: true,
					trackDownloadLinks: true
				});
			}else {
				dispatcher.setAccountVars({
					name:'vianickjr',
					dynamicAccountSelection:'false',
					dynamicAccountList:'devvianickjr=nickjr-d',
					linkInternalFilters:'javascript:,nickjr.com',
					trackExternalLinks: true,
					trackDownloadLinks: true
				});
			}
			dispatcher.setAttribute("pageName", pageName);
			dispatcher.setAttribute("hier1", hier1);
			dispatcher.setAttribute("hier2", hier2);
			dispatcher.setAttribute("channel", channel);
			dispatcher.setAttribute("prop1", prop1);
			dispatcher.setAttribute("prop2", prop2);
			dispatcher.setAttribute("prop3", prop3);
			dispatcher.setAttribute("prop4", prop4);
			dispatcher.setAttribute("prop5", prop5);
			dispatcher.setAttribute("prop7", prop7);
			dispatcher.setAttribute("prop8", prop8);
			dispatcher.setAttribute("prop9", prop9);
			dispatcher.setAttribute("prop10", prop10);
			dispatcher.setAttribute("prop11", prop11);
			dispatcher.setAttribute("prop12", prop12);
			dispatcher.setAttribute("prop13", prop13);
			dispatcher.setAttribute("prop14", prop14);
			dispatcher.setAttribute("prop15", prop15);
			dispatcher.setAttribute("prop16", prop16);
			dispatcher.setAttribute("prop18", prop18);
			dispatcher.setAttribute("prop19", prop19);
			dispatcher.setAttribute("prop20", prop20);
			dispatcher.setAttribute("prop21", prop21);
			dispatcher.setAttribute("prop22", prop22);
			dispatcher.setAttribute("prop23", prop23);
			dispatcher.setAttribute("prop24", prop24);
			dispatcher.setAttribute("prop25", prop25);
			dispatcher.setAttribute("prop26", prop26);
			dispatcher.setAttribute("prop27", prop27);
			dispatcher.setAttribute("prop28", prop28);
			dispatcher.setAttribute("prop36", prop36);
			dispatcher.setAttribute("prop41", prop41);
			dispatcher.setAttribute("prop42", prop42);
			dispatcher.setAttribute("prop45", prop45);
			dispatcher.setAttribute("prop46", prop46);
			dispatcher.setAttribute("prop47", prop47);
			dispatcher.setAttribute("prop48", prop48);
			dispatcher.setAttribute("prop49", prop49);
			dispatcher.setAttribute("prop50", prop50);
		}
	} catch(e){}
}
function flashReport(category){
	try{
		if(pagevalue) pageNameReset(pagevalue.replace("index.jhtml",category));
	}catch(e){}
}

function printTracker(urlAlias,contentType,showID,numberPages){
					site="nickjr";
					var ro={};
					com.mtvi.reporting.Account.name = "viakfprint";
					ro.name = com.mtvi.reporting.Account.name;
					ro.dynamicAccountSelection = false;
					ro.dynamicAccountList = "nickviadev=nickjr-d.mtvi.com,nickjr-q.mtvi.com";
					ro.linkInternalFilters = "javascript:,nickjr.com";
					ro.trackExternalLinks = true;
					ro.trackDownloadLinks = true;
					dispatcher.setAccountVars(ro);
					dispatcher.setAttribute("pageName",site+"-"+contentType+"-"+showID+"-"+urlAlias);
					dispatcher.setAttribute("channel",site);
					dispatcher.setAttribute("hier1",site+"/"+contentType+"/"+showID+"/"+urlAlias);
					dispatcher.setAttribute("hier2",site+"/"+contentType+"/"+showID+"/"+urlAlias);
					dispatcher.setAttribute("prop1",numberPages);
					dispatcher.setAttribute("prop2",site);
					dispatcher.setAttribute("prop3",contentType);
					dispatcher.setAttribute("prop4",showID);
					dispatcher.setAttribute("prop5",urlAlias);
					dispatcher.sendCall();
					resetParamsToDefault();
}