(function(){ 
var 
	_G= GEL,  
	_C= _G.config, 
	_I= _G.thepage.initializer,
	_W= window, 
	_U= _W.location.host,
	_C= _G.config,
	_LURL= ['http://', _W['gnt_cobrand'] , ".gannettdigital.com/localvars.js"].join(""),
	
	_P= _G.namespace("config.bus.providers")
;

_G.thepage.pageinfo={ 
	title: document.title, 
	ssts: { 
		section: "search",
		subsection: null,
		topic: null,
		subtopic: null
	}
};
var _Type = _W['pd_search_type'].split(" ")[0].toLowerCase();

switch(_Type) {
	case "events": _G.thepage.pageinfo.adpagetype="events.htm";break;
	case "movies": _G.thepage.pageinfo.adpagetype="movies.htm";break;
	case "theater": _G.thepage.pageinfo.adpagetype="movies.htm";break;
	case "classifieds": _G.thepage.pageinfo.adpagetype="classifieds.htm";break;
	case "recipes": _G.thepage.pageinfo.adpagetype="recipes.htm";break;
	default: _G.thepage.pageinfo.adpagetype="index.htm";break;
}

_P.sitecat= 100; _P.bt= 100; _P.comscore= 100;
if(_G.thepage.pageinfo.type == 'frontpage') 
	_P.checkm8= 200; 

(function(){ 
	var _CFG= GEL.namespace("config.comscore"); 
	_CFG.comscoreenable= "on";
	_CFG.c1= 2;
	_CFG.c4= GEL.namespace("thepage.pageinfo").articleinturl || '';
	_P.comscore= 100;
})();

/*_G.register("localconfig", {path: _LURL, base: "relative"}); */
_G.register("localconfig", {path: _LURL});
_G.register("com.Omniture", {path: "vendor/omniture/sitecatalyst.js"}); 
_G.util.importer.require("localconfig").write(); 
_G.util.importer.require("com.Omniture").write(); 
_I.add({ 
	name: "banner", 
	namespace: ["widget.AdBanner"], 
	priority: 25, 
	callback: loadBanners	
}); 
_I.add({ 
	name: "analytics", 
	namespace: ["analytics"], 
	priority: 100, 
	callback: loadAnalytics 
}); 
_I.add({ 
	name: "ur", 
	namespace: ["legacy.GDN"],
	priority: 150, 
	callback: function(){ GDN.UR.Page.Intercept= new Function(); GDN.UR.Page.Load(); }
}); 
_G.thepage.on("ready", function(){ _I.init(); }); 

function loadAnalytics(){
	setBusConfig(); 
	var 
	_V= _G.thepage.viewTracker || (function(){ 
		_G.thepage.viewTracker= new GEL.bus.PageTrack(); 
		return _G.thepage.viewTracker; 
	})();

	for(var _p in _P)
		_V.init(_p) ;
	_V.trackView(); 
}


function loadBanners(){ 
	setAdConfig(); 
	var 
		_t= new _G.util.benchmark.Timer("Banners").start(), 
		_bl= _G.thepage.bannerLoader= 
			new _G.widget.AdBanner.Locator(), 
		_bm= null 
	; 	
	_bl.findBanners(); 
	_bm= _bl.loadBanners(
		function(){ 
			if(this.marker.getAttribute("url")){ 
				this.config.url= this.marker.getAttribute("url"); 
				GEL.log("set url to " + this.config.url ); 
			}
			return this.config.loadOnInit;
		}, 
		null, 
		false
	);
	_bm.on("ready", _t.getStop()); 
	this.addElement(_bm); 

}

function setAdConfig(){ 
	var 
		_C= _G.namespace("config"),
		_T= _G.namespace("thepage.pageinfo"),
		_S= _T.ssts
	;
	_C.AdPage= _C.adDomain;
	
	if(_S.section)
		_C.AdPage+="/" + _S.section;
	
	if(_S.subsection)
		_C.AdPage+="/" + _S.subsection;
	
	if(_S.topic)
		_C.AdPage+="/" + _S.topic;
	
	
	_C.AdPage+= "/" + _T.adpagetype;
	
	_C.AdNetworkId= 5111.1; 
	_C.AdServer= "gannett.gcion.com";
}
function setBusConfig(){ 
var 
	_W=window,
	_obj= { 
		channel: '',
		currencyCode: "USD",
		trackDownloadLinks: true,
		trackExternalLinks: false,
		trackInlineStats: true,
		linkDownloadFileTypes: "exe,zip,wav,mp3,mp4,m4v,mov,mpg,avi,wmv,doc,pdf,xls",
		linkInternalFilters: "javascript:apartments,careerbuilder,cars,customcoupon,customwire.ap.org,eharmony,gannett,gbahn,highschoolsports,homefinder,homescape,infi,job,legacy,network,newsbank,newslibrary,pictopia,salary,topix,ur.gcion.com,usatoday,traffic,planetdiscover,metromix,mom",
		linkLeaveQueryString: false,
		linkTrackVars: "None",
		usePlugins: true, 
		linkTrackEvents: "None"
	},
	_C= _G.namespace("config"), 
	_A= _G.namespace("config.bus.properties"),
	_O= _G.namespace("config.omniture")
	;
	for(var p in _obj){ 
		if(!(p in _O)) 
			_O[p]= _obj[p]; 
	}
	_G.config.bus.properties= { 
		channel: "search",
		server: "planetdiscover",
		custom7: "site_search",
		custom8: "planet discover",
		pageName: "PD - " + _W['pd_search_type'], 
		contenttype: "search",
		location: _W.location.href.split("?")[0],
		syndication: _W.location.href.split("?")[1],
		marketname: _W['g_affilSstatId']
	};

}
})(); 
