if(typeof MTVi!="undefined"){if(typeof MTVi.reporting=="undefined"){MTVi.reporting={};}}
MTVi.reporting.Dispatcher=new function(){
	this.version="2.0";
	try{this.widget=MTVi.reporting.Widget;}catch(e){}
	this.send=function(){
		try{
			if(MTVi.util.isDefined(this.widget.un)){this.widget.t();}
		}catch(e){try{MTVi.logger.JsError(e);}catch(e){}}
	};
	this.setAccountVars=function(o){
		try{
			this.widget.setAccount(o.account);
			this.widget.setAttribute("dynamicAccountSelection",o.dynamic);
			this.widget.setAttribute("dynamicAccountList",o.list);
			this.widget.setAttribute("linkInternalFilters",o.filters);
		}catch(e){}
	};
	this.setValues=function(o){
		try{
			for(var i in o){this.widget.setAttribute(i,o[i]);}
		}catch(e){}
	};
	this.config=function(){//when call should not be automatic
		try{this.setAccountVars(MTVi.reporting.Config);}catch(e){}
		try{this.setValues(MTVi.reporting.Map());}catch(e){}
	};
	this.sendCall=function(){
		try{
			this.setAccountVars(MTVi.reporting.Config);
			this.setValues(MTVi.reporting.Map());
			this.setValues(MTVi.config.SectionSetup);
			this.send();
		}catch(e){try{MTVi.logger.JsError(e);}catch(e){}}
	};
	this.setThirdPartyData=function(){
		try{
			var pn="/"+MTVi.config.Get.channel+location.href.replace(/^.*www\.(.*)\.com/g,"");
			this.widget.setAttribute("pageName",pn);
			this.widget.setAttribute("hier1",pn.replace(/^\//,""));
			this.widget.setAttribute("channel",MTVi.config.Get.channel);
		}catch(e){try{MTVi.logger.JsError(e);}catch(e){}}
	};
	this.sendThirdPartyCall=function(){
		try{
			this.setAccountVars(MTVi.config.Get);
			this.setThirdPartyData();
			try{this.setValues(MTVi.reporting.Map());}catch(e){}
			this.send();
		}catch(e){try{MTVi.logger.JsError(e);}catch(e){}}
	};
	this.sendLinkEvent=function(name){
		try{
			this.config();
			var hier2=this.widget.getAttribute("hier2");
			this.setValues({linkType:"o",lnk:true,linkName:name,hier2:""});
			this.send();
			this.widget.setAttribute("hier2",hier2);
		}catch(e){try{MTVi.logger.JsError(e);}catch(e){}}
	};
	this.getBaseUrl=function(){
		try{
			this.config();
			var vendorUrl=".112.2o7.net/b/ss/"; // hardcoded in h_code
			return("http"+(this.widget.ssl?'s':'')+"://"+this.widget.un+vendorUrl+this.widget.un+"/1/");
		}catch(e){try{MTVi.logger.JsError(e);}catch(e){}}
	};
	this.sendFailedSearch=function(v){
		try{
			if(MTVi.util.isDefined(v)){
				var aImg=document.createElement('img');
				aImg.src=this.getBaseUrl()+"EMAIL?pageName=FAILED+SEARCH&v4="+v;
				aImg.id="failedSearchCall";
				document.getElementsByTagName('body')[0].appendChild(aImg);
			}
		}catch(e){try{MTVi.logger.JsError(e);}catch(e){}}
	};
	this.setAttribute=function(k,v){this.widget.setAttribute(k,v);};
	this.getAttribute=function(k){this.widget.getAttribute(k);};
	try{if(MTVi.util.isDefined(MTVi.config.Get.remote)){this.sendThirdPartyCall();}}catch(e){}
	try{if(MTVi.util.isDefined(MTVi.config.sendReportingCall)){this.sendCall();}}catch(e){}
};
