function getSiteZone() {
	// Provide a hook so that the user can override the default site/zone mechanism
	// if necessary.
	try {
		returnValue = overrideSiteZone()
	}
	catch (e) {
		returnValue = {'site': null, 'zone': null}
	}

	if (returnValue.site && returnValue.zone) {
		return returnValue
	}

	metaArray = document.getElementsByTagName("meta");
	for (metaArrayIndex = 0; metaArrayIndex < metaArray.length; metaArrayIndex++) {
		if (!returnValue.site && metaArray[metaArrayIndex].name == "site" && metaArray[metaArrayIndex].content) {
			returnValue.site = metaArray[metaArrayIndex].content;
		}
		if (!returnValue.zone && metaArray[metaArrayIndex].name == "zone" && metaArray[metaArrayIndex].content) {
			returnValue.zone = metaArray[metaArrayIndex].content;
		}
	}

	if (returnValue.site == null || returnValue.site == '') {
		returnValue.site = 'Uncategorized'
	}
	if (returnValue.zone == null || returnValue.zone == '') {
		returnValue.zone = 'Uncategorized'
	}
	return returnValue
}

var USN = {
	version: '1.0 (from homepage.js)',
	base: 'http://www.usnews.com/usnews/v3/scripts/', /* note: this attibute if FINAL. If you must change, change outside the USN class!*/
	load: function(libName) {
		var includes = {
			ads: "ads",
			printing: "print",
			socialBookmarking: "shareLinks",
			striping: "stripe",
			tabs: "tabs",
			slider: "slide",
			effects: "effects",
			analytics: "analytics", 
			analyticsExtensions: "analyticsCustom",
			windows: "window",
			technorati: "technorati",
			gallery: 'ibox'
		}
		if (includes[libName]) {
			document.write('<script type="text/javascript" src="'+this.base+includes[libName]+'.js"></script>');
		}
	}
}

sitezone = getSiteZone()
USN.site = sitezone.site
USN.zone = sitezone.zone

//USN.load('windows');
USN.load('ads');
USN.load('analytics');
USN.load('analyticsExtensions');
USN.load('tabs');
USN.load('striping');

var newwindow = "";

function openWindow(url,width,height) {
	// derived from PPK, http://www.quirksmode.org/js/croswin.html
	if (!newwindow.closed && newwindow.location) {
		//alert('newwindow is closed or already has a location');
		newwindow.location.href = url;
	}
	else {
		params = (arguments[3])?','+arguemnts[3]:',resizable=yes,scrollbars=no,status=no,toolbar=no';
		var windowOptionsString = [
			'height=',
			height,
			',width=',
			width,
			params
		];
		var windowOptionsString = windowOptionsString.join('');
		newwindow=window.open(url,'window',windowOptionsString);
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus();}
	if (this != window) {
		return false;
	}
}
function openWindowTMP(url,width,height) {
	// derived from PPK, http://www.quirksmode.org/js/croswin.html
	if (!newwindow.closed && newwindow.location) {
		//alert('newwindow is closed or already has a location');
		newwindow.location.href = url;
	}
	else {
		params = (arguments[3])?','+arguemnts[3]:',resizable=yes,scrollbars=no,status=no,toolbar=no';
		var windowOptionsString = [
			'height=',
			height,
			',width=',
			width,
			params
		];
		var windowOptionsString = windowOptionsString.join('');
		newwindow=window.open(url,'window',windowOptionsString);
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus();}
	if (this != window) {
		return false;
	}
}

Event.observe(window, 'load', init, false);

function init() {
	if ($('tab_interface')) {
		mostPopular = new tabInterface('tab_interface');
		Element.addClassName($('most_viewed'), 'active');
		stripe('most_popular_items');
	}
	if (!$('slide-list')) return false;
	l = new shifter($('slide-list'));
	if (l.check) {
		m = new PeriodicalExecuter(function() { l.advance() },5);
		leftButton = $('leftbutton')
		pauseButton = $('pausebutton') 
		rightButton = $('rightbutton')
		leftButton.onclick= function(){l.leftClick(); return false}
		pauseButton.onclick= function(){l.toggle(); return false}
		rightButton.onclick= function(){l.rightClick(); return false}
	}
}
function jumpToMenu() {
	var menu = document.getElementById('jumpMenu');
	if (menu.selectedIndex > 1) {
		top.location.href = menu.options[menu.selectedIndex].value;
	}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
