//declare additional variables here if needed
var hierarchy=gameType+"/"+primaryCategory+"/"+gameID;

if(com){
	if(com.mtvi){
		if(com.mtvi.reporting){
			com.mtvi.reporting.Account={
					name:'viashockwave',
				dynamicAccountSelection:true,
				dynamicAccountList:'viashockwavedev=dev,qa,stage,relaunch-d,relaunch-q,localhost,sandbox',
				linkInternalFilters:'javascript:,shockwave.com,facebook.com,digg.com',
				trackExternalLinks: false,
				trackDownloadLinks: false
			};
			var dispatcher=new com.mtvi.reporting.Dispatcher();
			com.mtvi.config.qs=com.mtvi.util.queryStringToHash(window.location.search);
			dispatcher.setDefaultData();
			dispatcher.setAttribute("pageName",location.pathname);
			dispatcher.setAttribute("hier1",hierarchy);
			dispatcher.setAttribute("channel",primaryCategory);
			dispatcher.setAttribute("prop1",gameID);
			dispatcher.setAttribute("prop2",loginState);
			if (gameType=="club"){
				dispatcher.setAttribute("prop4",gameID);
			}else if (gameType=="non-club"){
				dispatcher.setAttribute("prop5",gameID);
			}
			dispatcher.setAttribute("prop6",categoryList);
			dispatcher.setAttribute("prop7",queryString("search_text"));
			if (tokenType=="token"){
				dispatcher.setAttribute("prop8",gameID);
			}else if (tokenType=="non-token"){
				dispatcher.setAttribute("prop9",gameID);
			}
			if (trophyType=="trophy"){
				dispatcher.setAttribute("prop10",gameID);
			}else if (trophyType=="non-trophy"){
				dispatcher.setAttribute("prop11",gameID);
			}	
			dispatcher.setAttribute("campaign",queryString("extcmp"));
			dispatcher.sendCall();
		}
	}
}
function queryString(parameter) { 
var loc = location.search.substring(1, location.search.length);
var param_value = false;
var params = loc.split("&");
for (i=0; i<params.length;i++) {
param_name = params[i].substring(0,params[i].indexOf('='));
if (param_name == parameter) {
param_value = params[i].substring(params[i].indexOf('=')+1)
}
}
if (param_value) {
return param_value;
}
else {
return false; //Here determine return if no parameter is found
}
}

function gameDownload(gameID){
				dispatcher.setAttribute("pageName",location.pathname+"-download");
				dispatcher.setAttribute("prop8",gameID);	
				dispatcher.sendCall();
}
function sendLinkEvent(lnkname){
	sendAnalyticsEvent(null,lnkname);
}
function sendAnalyticsEvent(str,lnkname){
	try {
		if(com.mtvi.util.isDefined(dispatcher)){
			if(com.mtvi.util.isDefined(com.mtvi.reporting.Account)){
				if(com.mtvi.util.isDefined(lnkname)){
					obj = {};
					
					if(com.mtvi.util.isDefined(str)){ 
						obj.name=str;
						omniSetOverrides(obj, "append");
					}else{ 
						obj.name=com.mtvi.reporting.Account.name;
						omniSetOverrides(obj, null);
					}					
					delete obj;
					dispatcher.sendLinkEvent({linkType:"o",lnk:true,linkName:lnkname});
				}else{
					if(com.mtvi.util.isDefined(str))
						omniSetOverrides({name:str}, "append");
					else
						omniSetOverrides({name:com.mtvi.reporting.Account.name}, null);
					dispatcher.sendCall();
				}
			}
		}
	} catch(e){}	
}
function omniSetOverrides(or,acctNameAction){
	try{
		clearDispatcher();
		var ro = {};
		for(i in or){
			var tmpi=i.replace(/s_/,"");
			tmpi=(tmpi=="account")? "name" : tmpi;
			ro[tmpi]=or[i];
			
			if(tmpi=="name"){
				if(acctNameAction){
					if(acctNameAction=="append"){
						var pattern = new RegExp("^"+ro[tmpi]+"$|^"+ro[tmpi]+",|,"+ro[tmpi]+"$|,"+ro[tmpi]+",");
						if(!pattern.test(com.mtvi.reporting.Account.name))
							com.mtvi.reporting.Account.name += ',' + ro[tmpi]; 
					}else if(acctNameAction=="overwrite")
						com.mtvi.reporting.Account.name = ro[tmpi]; 
				}
				ro[tmpi]= com.mtvi.reporting.Account.name;
			}
		}
		ro.dynamicAccountSelection = true;
		dynamicAccountList:'viashockwavedev=dev,qa,stage,relaunch-d,relaunch-q,localhost,sandbox',
		ro.linkInternalFilters = 'javascript:,shockwave.com,facebook.com,digg.com';
		ro.trackExternalLinks = false;
		ro.trackDownloadLinks = false;
		if(com.mtvi.util.isDefined(dispatcher)) dispatcher.setAccountVars(ro);
	}catch(e){}
}
function clearDispatcher(){
	try {
		if(com.mtvi.util.isDefined(dispatcher)){
			com.mtvi.reporting.Account={
				name:'viashockwave',
				dynamicAccountSelection:true,
				dynamicAccountList:'viashockwavedev=dev,qa,stage,relaunch-d,relaunch-q,localhost,sandbox',
				linkInternalFilters:'javascript:,shockwave.com,facebook.com,digg.com',
				trackExternalLinks: false,
				trackDownloadLinks: false
			};
			dispatcher.setAttribute("pageName","");
			dispatcher.setAttribute("channel","");
			dispatcher.setAttribute("hier1","");				
			for(var i=1; i<41; i++){
				dispatcher.setAttribute("prop"+i, "");	
			}	
		}
	} catch(e){}
}

// AdManager setup for QuantCast call
com.mtvi.ads.AdManager.setDartSite('sw.nol');
com.mtvi.ads.AdManager.setPositionThreshold(3);
com.mtvi.ads.AdManager.setKeyValues( 'sec0=' + dartGenre + ';sec1=' + dartKeyword );
// QuantCast
com.mtvi.reporting.QuantCast.sendQuantCastCall({ labels:"MTVN Global Digital Network,MTVN Global Digital Proper,Nickelodeon Kids and Family Global Network,Nickelodeon Kids and Family Proper,Nickelodeon Kids and Family Domestic,Nickelodeon Kids and Family Tribes,ParentsConnect plus Parenting,Nickelodeon Kids Digital,Nickelodeon Parents Digital,Kids and Family Gaming,Kids and Family Paid Products,Shockwave Network,Shockwave Site " });

//ComScore
com.mtvi.reporting.ComScore.sendComScoreCall({ c2:"6059073" });

