if(typeof KIDS == "undefined" || !KIDS) var KIDS = {};

KIDS.namespace("reporting");

KIDS.reporting.config;
KIDS.reporting.dispatcher;
KIDS.reporting.qs;

Configuration.prototype.initialize = function(){
	this.init();
	this.setting["name"]="vianickjr";
	this.setting["dynamicAccountSelection"] = true;
	this.setting["dynamicAccountList"] = "devvianickjr=nickjr-d.mtvi.com,nickjr-q.mtvi.com";
	this.setting["linkInternalFilters"] = "javascript:,nickjr.com";
	this.setting["trackExternalLinks"] = true;
	this.setting["trackDownloadLinks"] = true;
	this.setting["trackInlineStats"] = true;
	if(!this.isLink()){
		if(KIDS.get("reportingKey").length>0) this.setting.pageName = KIDS.get("reportingKey");
		else if(KIDS.get("categoryPath").length>0) this.setting.pageName = KIDS.get("categoryPath");
		this.setting.pageName = this.setting.pageName.replace(/\/2009-Redesign/,"");
		if(this.setting.pageName.indexOf(".")<0){
			if(this.setting.pageName.lastIndexOf("/")!=this.setting.pageName.length-1) this.setting.pageName+="/";	
			this.setting.hier2 = this.setting.pageName.substr(1) + "index";
		}else this.setting.hier2 = this.setting.pageName.substr(1, this.setting.pageName.lastIndexOf(".")-1);
		this.setting.channel = this.setting.hier2.substr(0,this.setting.hier2.indexOf("/"));		
		this.setting.prop3 = location.search;
		this.setting.prop10 = KIDS.get("showId");
		this.setting.events = "event16";
		
		var xid = com.mtvi.config.qs.xid?com.mtvi.config.qs.xid:"";
		if(xid.length>0){ 
			var exdate = new Date();
			exdate.setDate(exdate.getDate()+30);	
			document.cookie="NICKJR.xid=" +xid+ ";expires="+exdate.toGMTString();
		}
		xid=KIDS.utils.getCookie("NICKJR.xid");
		xid=(xid==null)?"":xid; 
		this.setting.prop6 = xid;
		this.setting.eVar7 = xid; 
		this.setting.campaign = xid;
		if(xid.length>0)this.setting.events += ",event2"; 	
		this.setting.prop42 = this.setting.campaign;
	}
}
KIDS.reporting.init = function(){
	com.mtvi.config.qs=com.mtvi.util.queryStringToHash(window.location.search);
	KIDS.reporting.qs = com.mtvi.config.qs;
	KIDS.reporting.config = new Configuration();
	KIDS.reporting.config.initialize();
	
	if(location.pathname.indexOf("/kids/")>-1||location.pathname.indexOf("/kids-games/")>-1||location.pathname.indexOf("/kids-videos/")>-1){
		com.mtvi.reporting.Account={
			name:'vianickjr',
			dynamicAccountSelection:true,
			dynamicAccountList:'devvianickjr=nickjr-d.mtvi.com,nickjr-q.mtvi.com',
			linkInternalFilters:'javascript:,nickjr.com',
			trackInlineStats : true,
			trackExternalLinks: true,
			trackDownloadLinks: true
		};
		KIDS.reporting.config.setting["name"]="vianickjr";
		KIDS.reporting.config.setProp(11, "kids");
	}else{
		com.mtvi.reporting.Account={
			name:'vianickjr,vianickjrparents',
			dynamicAccountSelection:true,
			dynamicAccountList:'devvianickjr=nickjr-d.mtvi.com,nickjr-q.mtvi.com',
			linkInternalFilters:'javascript:,nickjr.com',
			trackInlineStats : true,
			trackExternalLinks: true,
			trackDownloadLinks: true
		};
		KIDS.reporting.config.setting["name"]="vianickjr,vianickjrparents";
		KIDS.reporting.config.setProp(11, "grownups");
	}

	KIDS.reporting.dispatcher = new com.mtvi.reporting.Dispatcher();
	KIDS.reporting.dispatcher.setDefaultData();	
	
	KIDS.reporting.config.setProp(9,KIDS.reporting.qs.partner);
	KIDS.reporting.config.setEVar(2,com.mtvi.config.qs.searchterm?com.mtvi.config.qs.searchterm:"");
	KIDS.reporting.config.setEVar(3,com.mtvi.config.qs.searchtype?com.mtvi.config.qs.searchtype:"");
	KIDS.reporting.config.setProp(17,KIDS.reporting.config.getEVar(2));	
}
KIDS.reporting.firePageLoad = function(){
	if(location.href.indexOf("ad-entry")<0)KIDS.reporting.omnifunctions.sendReportingCall();
}
