var callers_adr = "";  
var home_base = this_type;
var in_str = window.location.search;

// example: ../pennsylvania-radon/index.htm?usapg=../index.htm&STN=US
// example: ../radonpittsburgh/index.htm?state=../pennsylvania-radon/index.htm&STN=PA
// ?state means the home base is a state & don't home past the state
// ?local=adr means we're local and home is adr; adr only used for local
// &STN=PA means the state is PA for certifications
if( in_str == "" )
{
	// here from direct entry so defaults are already set
}
else
{
	//alert(in_str);
	// get base if any
	if(in_str.substring(0,7) == "?usapg=")
		SetBase("usapg");
	else if(in_str.substring(0,7) == "?state=")
		SetBase("state");
	else if(in_str.substring(0,7) == "?local=")
		SetBase("local");
	else		
	{
		// bogus data so assume this is the home page
		SetBase("state");
	}
	if( this_type == "common" )
		ret_here = callers_adr;  // if jumping from common, pass along the ret adr
}

function SetBase( h_base )
{
	home_base = h_base;
	// get address if any
	callers_adr = "";
	// get state if any
	var amp_index = in_str.indexOf("&");
	if( amp_index < 0 )
	{
		callers_adr = in_str.substring(7);		
		// leave st_abbrev set at default
	}
	else
	{
		// expecting &STN=PA
		callers_adr = in_str.substring(7,amp_index);		
		if( this_type != "state" && this_type != "usapg" )
			st_abbrev = in_str.substr(amp_index+5,2);
	}

}

function go_home()
{
	//alert("go_home: type="+this_type+", home_base="+home_base+", adr="+callers_adr);
	if( this_type == "state" && home_base == "usapg" )
		document.location="../index.htm"; // no nav supported at main level
	else if( this_type == "local" && (home_base == "state" || home_base == "usapg") )
		document.location= my_state+in_str;
	else if( this_type == "common")
		document.location=callers_adr+in_str;
}

function page_jump( str_goto )
{
	// only jumps to common, etc need this_page, but do it generically for all pages
	document.location=str_goto + "?" + home_base + "=" + ret_here + "&" + "STN=" + st_abbrev;
}

// for common type to show local contact info
function contact_us_jump()
{
	page_jump("../common/contact_us.htm");
}
function contact_us_jump_save()
{
	// from ../pennsylvania-radon/index.htm 
	// to   ../pennsylvania-radon/contact_us.htm 
	var jump_adr;
	var idx = callers_adr.indexOf("index.htm");
	if( idx < 0 || this_type != "common" )
	{
		document.location = "contact_us.htm"; // just use local one
	}
	else
	{
		jump_adr = callers_adr.substr(0,idx) + "contact_us.htm"; // up to start of index.htm
		document.location = jump_adr;
	}
}
