
var currentTrackedNames = "";

function nameTrackerInit() {
	NameLab.init();
	
	if ( fV >= 8 )
		ff = "popgraph.swf";
	else
		ff = "popgraph7.swf";
	ff += "?svroot=/servlet2/";
	ff += "&vv=0.94";
	
	var initialNames = "";
	if ( window.location.search.length > 0 )
		initialNames = window.location.search.substr( 1 );
	else {
		var storedNames = NameLab.getCookieValue( "nametracker" );
		if ( storedNames && storedNames.length > 0 )
			initialNames = storedNames;
	}
	
	if (initialNames == 'detoured=1')
			initialNames = "";

	if ( initialNames.length > 0 )
		ff += "&initialNames=" + initialNames;
	var fe = new FlashEmbed( ff, fV, "534", "420", "#ffffff", "popgraph" );
	fe.create( 'popgraph' );
}

function setTargetHash( inHash ) {
	currentTrackedNames = inHash;
	document.cookie = "nametracker=" + inHash + ";PATH=/";
}

function gotoNameDetail( name ) {
	document.location = "http://baby-names.familyeducation.com/name-meaning/" + name;
}

function emailThisGraph() {
	var url = "http://" + window.location.host + window.location.pathname;
	if ( currentTrackedNames.length > 0 )
		url += "?" + currentTrackedNames;
	NameLab.emailThis( url );
	return false;
}

YAHOO.util.Event.addListener(window, "load", nameTrackerInit, window, false);
