/* Code executed when page is loaded */
var href = location.href;
var host = location.host;
var path = location.pathname;

// Constant portions of image path. 
var image_path_prefix = "http://www.realcities.com/images/logos/site/";
var image_path_suffix = "/site_logo_150x25.gif";
// Initialize hash maps containing domain-specific portion of image path
initImagePaths();
// Construct full image path and set HBX account code variables.
var imagePath = getImagePath(getDomain(host));
// Image paths 
function initImagePaths() {
  imgPath = new Array();
  imgPath['aberdeennews']='aberdeennews/aberdeennews';
  imgPath['belleville']='belleville/belleville';
  imgPath['bradenton']='bradenton/bradenton';
  imgPath['centredaily']='centredaily/centredaily';
  imgPath['charlotte']='charlotte/charlotte';
  imgPath['contracostatimes']='contracostatimes/cctimes';
  imgPath['dfw']='dfw/dfw';
  imgPath['fortwayne']='fortwayne/fortwayne';
  imgPath['kansas']='kansas/kansas';
  imgPath['kansascity']='kansascity/kansascity';
  imgPath['kentucky']='kentucky/kentucky';
  imgPath['ledger-enquirer']='ledgerenquirer/ledgerenquirer';
  imgPath['macon']='macon/macon';
  imgPath['mercurynews']='mercurynews/mercurynews';
  imgPath['miami']='miami/miamiherald';
  imgPath['montereyherald']='montereyherald/montereyherald';
  imgPath['myrtlebeachonline']='myrtlebeachonline/myrtlebeachonline';
  imgPath['ohio']='ohio/ohio';
  imgPath['philly']='philly/philly';
  imgPath['realcities']='realcities/krwashington';  
  imgPath['sanluisobispo']='sanluisobispo/sanluisobispo';
  imgPath['siliconvalley']='siliconvalley/siliconvalley';
  imgPath['sunherald']='sunherald/sunherald';
  imgPath['thatsracin']='thatsracin/thatsracin';
  imgPath['thestate']='thestate/thestate';
  imgPath['timesleader']='timesleader/timesleader';
  imgPath['twincities']='twincities/twincities';
}

//parse the url to retrieve the domain
function getDomain(host) {
	var domains = host.split(".");
	var primary_domain = domains.length - 2;
	return domains[primary_domain];
}

function getImagePath(site) {
	//alert(image_path_prefix + imgPath[site] + image_path_suffix);
	return image_path_prefix + imgPath[site] + image_path_suffix;
}
//write the image tag into the dom...
function createSiteLogoImage(imagePath,pubId) {
	var pubDiv = document.getElementById(pubId);
	//alert(pubDiv);
	if (pubDiv != null) {
		//alert("img path: " + imagePath);
		pubDiv.innerHTML = '<img width="150" height="25" border="0" src="' + imagePath + '"/>'
	}
}
//make sure the body is loaded before executing commands that affect the DOM.
function init()
{
	createSiteLogoImage(imagePath,'publication')
}
window.onload = init;