var mi=(typeof mi=='undefined')?{'media_domain':''}:mi;mi.getArgs=function(){if(typeof mi.args=='undefined'){mi.args={};var query=location.search.substring(1);var pairs=query.split('&');for(var i=pairs.length-1;i>=0;i--){var pos=pairs[i].indexOf('=');if(pos==-1){continue;}
mi.args[pairs[i].substring(0,pos)]=unescape(pairs[i].substring(pos+1));}}
return mi.args;};mi._console=function(s){mi._console.log=(mi._console.log&&mi._console.log.length>0)?mi._console.log+'\n---------------------------------------------------\n'+s:s;};mi.fixConsole=function(){if(typeof window.console!="object"){window.console={};}
if(window.console.is_fixed){}
else{var firebugMethods=["log","debug","info","warn","error","assert","dir","dirxml","trace","group","groupEnd","time","timeEnd","profile","profileEnd","count"];var methodCount=firebugMethods.length;var args=mi.getArgs();var view=(args.viewlog&&args.viewlog=='1');for(var i=0;i<methodCount;i++){var methodName=firebugMethods[i];if(typeof window.console[methodName]!="function"){switch(methodName){case'log':if(view){window.console.log=mi._console;if(window.addEventListener){window.addEventListener("load",function(){alert(mi._console.log);},false);}else if(window.attachEvent){window.attachEvent("onload",function(){alert(mi._console.log);});}
}else{window.console.log=function(){};}
break;default:eval("window.console[methodName] = function(s){window.console.log('"+methodName.toUpperCase()+": '+ s)};");}}}}
window.console.is_fixed=true;};mi.fixConsole();mi.cloneObject=function(sourceObj){for(i in sourceObj){if(typeof sourceObj[i]=='object'){this[i]=new mi.cloneObject(sourceObj[i]);}else{this[i]=sourceObj[i];}}};mi.App=function(){var _configs={};this._manageConf=function(prop,val){return val;};this.setConf=function(){switch(arguments.length){case 1:for(var prop in arguments[0]){_configs[prop]=this._manageConf(prop,arguments[0][prop]);}
break;case 2:_configs[arguments[0]]=this._manageConf(arguments[0],arguments[1]);break;}};this.getConf=function(prop){return _configs[prop];};this.viewConfs=function(){console.dir(_configs);};this.cache={};switch(arguments.length){case 1:this.setConf(arguments[0]);break;case 2:this.setConf(arguments[0],arguments[1]);break;}};mi.getEventSrc=function(e){if(!e){e=window.event;}
if(e.target){return e.target;}else if(e.srcElement){return e.srcElement;}};mi.templateVarPattern=/\@([^\@]+)\@/g;mi.templateParser=function(data,template){return template.replace(mi.templateVarPattern,function(){return data[arguments[1]];})};mi.makeHash=function(sourceData,firstDelimiter,secondDelimiter){if(sourceData&&firstDelimiter&&secondDelimiter){var hash={};var pairs=sourceData.split(firstDelimiter);var pos;for(var i=pairs.length-1;i>=0;i--){if(typeof(pairs[i+1])!='undefined'){pos=pairs[i].indexOf(secondDelimiter);if(pos==-1){continue;}
hash[pairs[i].substring(0,pos)]=pairs[i].substring(pos+1);}}
return hash;}
else{console.log('sourceData, firstDelimiter, & secondDelimiter must be defined. There are no default values.');}};mi.Search=function(){mi.App.apply(this,arguments);mi.getArgs();this.kill;};mi.Search.prototype.submitForm=function(){this.kill="false";switch(this.getConf("searchSelectorType")){case"option":var searchType=document.miSearchForm.aff.value;break;case"radio":var searchType=$('input:radio[name=aff]:checked').val();break;}
var searchText=encodeURIComponent(document.miSearchForm.keywords.value);if(searchType==parseInt(searchType)){return;}
else{this.searchParamConfig(searchType,searchText);this.buildForm(searchType);}
if(this.kill=="false"){document.miSearchForm.submit();}
else{return false;}};mi.Search.prototype.buildForm=function(search_type){var self=this;var searchInputContainer_div=document.getElementById("searchInputContainer").innerHTML;if(searchInputContainer_div){$("#searchInputContainer > input[type='hidden']").each(function(){$(this).remove();});}
try{jQuery.each(self.getConf("query_fields"),function(paramName,paramValue){paramName=paramName.replace(/(.*)_mihyphen_(.*)/,"$1-$2");$("<input type='hidden' name='"+paramName+"' value='"+paramValue+"' />").appendTo("#searchInputContainer");});}
catch(e){console.error("Script Caught Error - "+e);}
document.miSearchForm.action=self.getConf("form_action");};mi.Search.prototype.checkOption=function(){var self=this;if(typeof mi.args.collection!="undefined"){switch(self.getConf("searchSelectorType")){case"option":if(mi.args.collection=="WEB"){$("select#search_select option[value='web_search']").attr("selected",1);}else if(mi.args.collection=="ARCHIVES"){$("select#search_select option[value='archives']").attr("selected",1);}else{$("select#search_select option[value='h_archives']").attr("selected",1);}
break;case"radio":if(mi.args.collection=="WEB"){$("#search_web").attr("checked",1);}else if(mi.args.collection=="ARCHIVES"){$("#search_archives").attr("checked",1);}else{$("#search_history").attr("checked",1);}
break;}}};mi.Search.prototype.configErrorReporter=function(){this.kill="true";alert("Option doesn't exist in your configuration. Please review your browsers error console.");console.error("Option doesn't exist in your configuration. Please submit a ticket to MI Support for assistance.");return false;}
mi.Search.prototype.searchParamConfig=function(search_type,search_text){this.setConf("searchSelectorType","radio");if(search_type){switch(search_type){case"web_search":this.setConf("form_action","http://search2.tri-cityherald.com/search-bin/search.pl.cgi");this.setConf("query_fields",{sf_Keywords:search_text,product:"Yahoo,Overture",collection:"WEB",live_template:"http://www.tri-cityherald.com/searchresults/v-ysr/index.html",error_template:"http://www.tri-cityherald.com/searchresults/v-yerr/index.html",preview_template:"http://preview.tri-cityherald.com/searchresults/v-ysr/index.html",results_per_page:"10",preview:"0",prop_related:"1",prop_dym:"1"});break;default:this.configErrorReporter();}}};