var isUS = true;
var usReportSuite = "vianicktropoliscom,nickvia";
var ukReportSuite = "vianicktropolisuk,vianickuk";

function setNicktropolisRegion(twoLetterRegion){
	try{
		if(region = twoLetterRegion.toLowerCase()){
			if(region=="uk") isUS = false;
			delete region;
		}
	}catch(e){}
}
function sendReportingCallNicktropolis(ro){
	try{
		if(com.mtvi.util.isDefined(dispatcher)){
			if(obj = ro.setOverrides){
				obj.name	= (isUS) ? usReportSuite : ukReportSuite;		
				//for nicktropolis registered or guest mode
				if(pageName.indexOf("/nicktropolis/")>-1){if(!prop18)obj.prop18="Registered";else obj.prop18="Guest";}
				omniSetOverrides(obj, "overwrite");
			}
			dispatcher.sendCall();
			//adding iframe call for comscore		
			if(typeof jQuery != "undefined"){
				var str = "<iframe id='comscore' src='/common/trigger/coda/index.jhtml' style='overflow:hidden;margin:0px;padding:0px;' scrolling='no' width='1' height='1' frameborder='0'></iframe>";
				if($("#comscore").length) $("#comscore").replaceWith(str);
				else $(str).appendTo("body");
			}
		}
	}catch(e){}
}
function sendChatbotCall(botname){
	linkName="/nicktropolis_chatbot/"+botname;
	sendLinkEvent((isUS)?usReportSuite:ukReportSuite,linkName);
}
function sendNicktropolisStartup(version){
	sendReportingCallNicktropolis({setOverrides:{pageName:"/nicktropolis/game/startup",hier2:"nicktropolis/game/startup",prop12:version,channel:""}});
}
function sendNicktropolisRoom(id,roomtype,franchise,roomURI,roomName){
	if (roomtype!="user")
		sendReportingCallNicktropolis({setOverrides:{pageName:"/nicktropolis/game/"+roomURI+"__"+id+"__"+ roomName,hier2:"nicktropolis/game/"+roomURI+"__"+id+"__"+roomName,prop9:roomURI+"__"+id+"__"+roomName}});
}
function sendNicktropolis(identifier){
	sendReportingCallNicktropolis({setOverrides:{pageName:"/nicktropolis/game/"+identifier,hier2:"nicktropolis/game/"+identifier,prop9:identifier}});
}
function sendNicktropolisGame(game){
	sendReportingCallNicktropolis({setOverrides:{pageName:"/nicktropolis/game/"+game,hier2:"nicktropolis/game/"+game,prop4:game+"_nicktrop",prop9:game}});
}
function sendNicktropolisHFDGame(game,action){
	sendReportingCallNicktropolis({setOverrides:{pageName:"/nicktropolis/game/"+game+"/"+action,hier2:"nicktropolis/game/"+game+"/"+action,prop4:game+"_nicktrop",prop9:game}});
}
function sendNicktropolisObject(id,swapType,location,type,subtype){
	linkName="/nicktropolis_object/"+swapType+"/"+location+"/"+type+"/"+subtype;
	sendLinkEvent((isUS)?"vianicktropoliscom":"vianicktropolisuk",linkName);
}	
function sendNicktropolisChat(type,type2){
	linkName="/nicktropolis_chat/"+type+"/"+type2;
	sendLinkEvent((isUS)?"vianicktropoliscom":"vianicktropolisuk",linkName);
}
function sendNicktropolisError(errorMsg){
	linkName="/nicktropolis_error/"+errorMsg;
	sendLinkEvent((isUS)?"vianicktropoliscom":"vianicktropolisuk",linkName);
}
function sendNicktropolisMashup(MashupID){
	linkName="/nicktropolis_mashup/"+MashupID;
	sendLinkEvent((isUS)?"vianicktropoliscom":"vianicktropolisuk",linkName);
}
function sendNicktropolisAdRoom(id,roomtype,franchise,roomURI,roomName){
	sendReportingCallNicktropolis({setOverrides:{pageName:"/nicktropolis/game/adZone/"+roomURI+"__"+id+"__"+ roomName,hier2:"nicktropolis/game/adZone/"+roomURI+"__"+id+"__"+roomName,prop9:roomURI+"__"+id+"__"+roomName}});
}
function sendNicktropolisAdVideo(id,roomtype,franchise,roomURI,roomName){
	sendReportingCallNicktropolis({setOverrides:{pageName:"/nicktropolis/game/adZone/"+roomURI+"__"+id+"__"+ roomName+"/videoPlayer",hier2:"nicktropolis/game/adZone/"+roomURI+"__"+id+"__"+roomName+"/videoPlayer"}});
}
function sendNicktropolisAdGame(id,roomtype,franchise,roomURI,roomName,gameName){
	sendReportingCallNicktropolis({setOverrides:{	pageName:"/nicktropolis/game/adZone/"+roomURI+"__"+id+"__"+ roomName+"-"+gameName,
							hier2:"nicktropolis/game/adZone/"+roomURI+"__"+id+"__"+roomName+"-"+gameName,
							prop4:"ad-"+roomName+"-"+gameName+"_nicktrop"}});
}
function sendNicktropolisBlocksGame(){
	sendReportingCallNicktropolis({setOverrides:{	pageName:"/nicktropolis/game/BlocksGame",
							hier2:"nicktropolis/game/BlocksGame",
							prop4:"Blocks_nicktrop"}});
}
function sendNicktropolisBlocksStart(type){
	linkName="/nicktropolis_blocksgame/"+type;
	sendLinkEvent((isUS)?"vianicktropoliscom":"vianicktropolisuk",linkName);
}	
function sendNicktropolisBlocksEnd(winLose,time){
	if (winLose=="win"){
		if (time==60){
		timeRange="60";
		}
		else
		var timeRange=((Math.round(time/10))+"0-"+(Math.round(time/10))+"9");
		linkName="/nicktropolis_blocksgame/"+winLose+"/in_"+timeRange+"_seconds";	
		}
	else{
		linkName="/nicktropolis_blocksgame/"+winLose;	
		}
	sendLinkEvent((isUS)?"vianicktropoliscom":"vianicktropolisuk",linkName);
}
function sendNicktropolisHomesite(str){
	if(typeof isUK =="undefined")
		sendReportingCall({setOverrides:{pageName:pageName+"-"+str,account:"nickvia"}});
	else if(isUK==true) 
		sendReportingCall({setOverrides:{pageName:pageName+"-"+str,account:"vianickuk"}});	
	//adding iframe call for comscore		
	/*
	if(typeof jQuery != "undefined"){
		var str = "<iframe id='comscore' src='/common/trigger/coda/index.jhtml' style='overflow:hidden;margin:0px;padding:0px;' scrolling='no' width='1' height='1' frameborder='0'></iframe>";
		if($("#comscore").length) $("#comscore").replaceWith(str);
		else $(str).appendTo("body");
	}
	*/
}
function sendNicktropolisGMGames(gameName){
	var pn = dispatcher.getAttribute("pageName");
	var ind = pn.indexOf("-stamp");
	if(ind>0) pn = pn.substring(0,ind);
	sendReportingCallNicktropolis({setOverrides:{pageName:pn+"-"+gameName}});
}
function sendNicktropolisAdGameEnd(id,roomtype,franchise,roomURI,roomName,gameName){
	sendReportingCallNicktropolis({setOverrides:{	pageName:"/nicktropolis/game/adZone/"+roomURI+"__"+id+"__"+ roomName+"-"+gameName,
							hier2:"nicktropolis/game/adZone/"+roomURI+"__"+id+"__"+roomName+"-"+gameName,
							prop4:"ad-"+roomName+"-"+gameName+"_nicktrop-GameEnd"}});
}	
function sendNicktropolisClothingStore(storeName, numberOfTotalItems){
	linkName="/nicktropolis_clothing_store/"+storeName+"/"+numberOfTotalItems;
	sendLinkEvent((isUS)?"vianicktropoliscom":"vianicktropolisuk",linkName);
}	
function sendNicktropolisKCAStream(){
	sendReportingCall({setOverrides:{name:"viakcastreams",pageName:"KCA Live Cam Stream - Nicktropolis"}});
}