var dynamicHeaderLoaded = true;
// if g_Domain exists, must be "http://" + <domain name>
var m_Domain = ( (typeof g_Domain) != 'undefined' ) ? g_Domain : '';
var m_Cache = ( (typeof g_Cache) != 'undefined' ) ? g_Cache : 'http://c.ancestry.com';
var m_CachePartner = ( (typeof g_CachePartner) != 'undefined' ) ? g_CachePartner : 'http://c.ancestry.com/p/0';

// page width
var CPAGEWIDTH = "760"
var m_PageWidth = ( (typeof g_PageWidth) != 'undefined' ) ? g_PageWidth : CPAGEWIDTH;

// Tab titles-
var C_HOME = "Home";
var C_MYANCESTRY = "My Ancestry";
var C_SEARCH = "Search";
var C_ADVSEARCH = "Advanced Search";
var C_TREES = "Family Trees";
var C_BOARDS = "Ancestry Community";
var C_LEARN = "Learning Center";
var C_SHOPS = "Store";
var C_HELP = "Help";
var C_EMPTY = "";
var C_CHARTFORM = "Charts and Forms";

// Delete these when we have changed the constants
var CHOME = "Home";
var CSEARCH = "Search Records";
var CTREES = "Family Trees";
var CBOARDS = "Message Boards";
var CLEARN = "Genealogy Help";
var CSHOPS = "Ancestry Shops";
var CHELP = "?";

var CTabHome		= new Array(C_HOME,		m_Domain + "/",				"64",	"Ancestry Home Page",																						"c_home");
var CTabLibHome		= new Array(C_HOME,		m_Domain + "/",				"64",	"Ancestry Library Edition Home Page",																		"c_home");
var CTabMyAncestry	= new Array(C_MYANCESTRY, m_Domain + "/myancestry/","95",	"My Ancestry - Store personal information",																	"c_myancestry");
var CTabSearch		= new Array(C_SEARCH,	m_Domain + "/search/",			"119",	"Genealogy Search - Find Birth Records, Death Records, Marriage Records and US Census Records.",		"c_search");
var CTabAdvSearch	= new Array(C_ADVSEARCH,m_Domain + "/search/",			"119",	"Genealogy Search - Find Birth Records, Death Records, Marriage Records and US Census Records.",		"c_search");
var CTabTrees		= new Array(C_TREES,	m_Domain + "/trees/",			"101",	"Family Trees - Build your family tree using our pedigree files.",										"c_trees");
var CTabChartForm	= new Array(C_CHARTFORM,m_Domain + "/charts/ancchart.aspx",	"119",	"Record the ancestors from whom you directly descend.",											"c_tabChartForm");
var CTabBoards		= new Array(C_BOARDS,	m_Domain + "/community/",		"124",	"Genealogy Message Boards - Find others who are researching your ancestors.",								"c_boards");
var CTabLearn		= new Array(C_LEARN,	m_Domain + "/learn/",		"120",	"Resources to help you research your family history, including books, articles, and genealogy archives.",	"c_learn");
var CTabShops		= new Array(C_SHOPS,	m_Domain + "/rx/shops.asp?lfl=m",		"59",	"Discover, preserve, and celebrate your heritage with unique products.",						"c_shops");
var CTabEmpty		= new Array(C_EMPTY,	m_Domain + "",							"75",	"",																								"c_empty");


function IsStarterExperience()
{
 return false;
}

if (typeof CTabs == 'undefined' )
	var CTabs = new Array(CTabHome, CTabMyAncestry,CTabSearch, CTabBoards, CTabLearn, CTabShops);

if (typeof CNoShopsTabs == 'undefined' )
	var CNoShopsTabs = new Array(CTabHome, CTabMyAncestry, CTabSearch, CTabBoards, CTabLearn);

if (typeof CFooterLinks == 'undefined' )
{
	var CFooterLinks = new Array("Corporate Info", "http://www.myfamilyinc.com",
															 "Affiliate Program", m_Domain + "/home/partner/main.htm",
															 "PRIVACY STATEMENT", m_Domain + "/legal/privacy.aspx",
															 "Contact Us", "http://ancestryhelp.custhelp.com/cgi-bin/ancestryhelp.cfg/php/enduser/ask.php",
															 "Terms and Conditions", m_Domain + "/legal/terms.aspx");

	var p = m_CachePartner.substring(m_CachePartner.lastIndexOf("/")+1);
	if (p == "0")
		CFooterLinks[7] = "http://ancestry.custhelp.com/cgi-bin/ancestry.cfg/php/enduser/ask.php";
	else if (p == "4300")
		CFooterLinks[7] = "http://ancestryaol.custhelp.com/cgi-bin/ancestryaol.cfg/php/enduser/ask.php";
}

//var crumb=null;

var bDebug = false;

// Includes
document.write('<\link rel="stylesheet" href="' + m_Cache + '/s/0/css/global.css" type="text/css">');
document.write('<\script language="JavaScript" src="' + m_Cache + '/js/global.js"><\/script>');
document.write('<\script language="JavaScript" src="' + m_Cache + '/js/security_shared.js"><\/script>');
document.write('<\script language="JavaScript" src="' + m_Cache + '/js/utility.js"><\/script>');
document.write('<\script language="JavaScript" src="' + m_Cache + '/js/AB.js"><\/script>');
// By including the brand.js file the cobrand header will also be drawn
document.write('<\script language="JavaScript" src="' + m_CachePartner + '/js/brand.js"><\/script>');

// Masks for controlling which parts of the header are shown
var CSHOW_NONE					= 0x00000000;
var CSHOW_ALL 					= 0xFFFFFFFF;
var CSHOW_MASTHEAD				= 0x00000001;
var CSHOW_LARGE_LOGO			= 0x00000002;
var CSHOW_SMALL_LOGO			= 0x00000004;
var CSHOW_LOGIN					= 0x00000008;
var CSHOW_LINE					= 0x00000010;
var CSHOW_TABS					= 0x00000020;
var CSHOW_SUBNAV				= 0x00000040;
var CSHOW_BREADCRUMB			= 0x00000080;
var CSHOW_HELP					= 0x00000100;
var CSHOW_BANNERS				= 0x00000200;
var CSHOW_TOP_WHITESPACE		= 0x00000400;
var CSHOW_BOTTOM_WHITESPACE		= 0x00000800;
var CSHOW_UPGRADE_PROMPT		= 0x00001000;
var CENCLOSING_TABLE			= 0x00002000;
var CSHOW_FOOTER_HR				= 0x00004000;
var CSHOW_COPYRIGHT				= 0x00008000;
var CSHOW_CENTERED				= 0x00010000;
var CSHOW_MYACCOUNT				= 0x00020000;
var CSHOW_WELCOMEUSER			= 0x00040000;
var CSHOW_BRAND_ONLY			= 0x00080000;

var CSTANDARD_HEADER			= CSHOW_ALL;
var CSTANDARD_SMALL_HEADER		= CSHOW_ALL ^ CSHOW_LARGE_LOGO;
var CSHOW_ALL_BUT_BANNERS		= CSHOW_ALL ^ CSHOW_BANNERS ^ CSHOW_TOP_WHITESPACE;
var CSHOW_CUSTOMERINFO			= CSHOW_LOGIN | CSHOW_HELP | CSHOW_MYACCOUNT | CSHOW_WELCOMEUSER;

//"javascript:myaccount(\'' + strLink + '/myaccount/account_fs.htm\'

// Used internally to pass parameters between the included files
var g_hdPageWidth = m_PageWidth;			// The width to constrain the header to, e.g. "750" or "100%"
var g_hdStrActiveTab = C_HOME;				// The title of the currently selected tab
var g_hdStrDomain;							// The domain to prepend to links
var g_hdATabs;								// Array of tab titles and links in the form "Title", "Link"
var g_hdACrumbs;							// Array of breadcrumbs in form Crumb::Link
var g_hdStrHelpLink;						// Link to associate with the help link, null if help should not appear
var g_hdStrCampaign;						// The campaign to associate with the ad banner or "" if no campaign
var g_hdShowFlags = CSHOW_ALL;				// Bit flags indicating which parts of the header to show


var g_ftPageWidth;		// The width to constrain the footer to, e.g. "750" or "100%"
var g_ftStrDomain;		// The width to constrain the footer to, e.g. "750" or "100%"
var g_ftALinks;			// Array of label followed by its associated link
var g_ftLegalLink;		// Link associated with "subject to license"
var g_ftStrCampaign;	// The campaign to associate with the ad banner or "" if no campaign
var g_ftShowFlags;		// Bit flags indicating which parts of the footer to show
var g_ftNeedTrack=true;	// Need Omniture tracking in footer

var g_bEnclosingTableUsed = false;			// Used for the footer to know if it needs to close the table or not.

					 
//mouseover, out and click
function mOvr(evt,src,theClass)
{
	if (!evt)
		evt=window.event;

	if (evt.fromElement && !src.contains(evt.fromElement))
	{
		src.style.cursor = 'hand'; 
		src.className = theClass;
	}
}

//-------
function mClk(evt,i)
{
	if (!evt)
		evt=window.event;

	if(evt.srcElement && evt.srcElement.tagName=='TD')
	{
		document.all.TabLinkID[i].click();
	}
}

//-------
function mOut(evt,src,theClass)
{
	if (!evt)
		evt=window.event;

	if (evt.toElement && !src.contains(evt.toElement))
	{
		src.style.cursor = 'default';
		src.className = theClass;
	}
}


//-------
function popupHelp(helpURL)
{
	var leftPos
	var helpHeight=400;
	var helpWidth=400;
	if (screen)
	{
		helpHeight=screen.height-105;
		helpWidth=Math.max(screen.width/2,600);
		leftPos = screen.width-helpWidth-12;
	}
	self.name="ancmain";
	helpWin = window.open(helpURL,"anchelp","toolbar=1,location=0,status=0,menubar=0,scrollbars=1,resizable=1,top=0,left="+leftPos+",width="+helpWidth+",height="+helpHeight);
	if (helpWin){helpWin.focus()};
}
//-----
function legalFooterOnly()
{
	document.write('<table width="' + g_hdPageWidth + '" border="0" cellspacing="0" cellpadding="0">');
	document.write('	<tr>');
	document.write('		<td height="4" colspan="2" class="lbg"><spacer type="block" height=1></td>');
	document.write('	</tr>');
	document.write('	<tr valign="bottom">');
	document.write('		<td height="15" class="copyright">');
	document.write('<a href="http://www.myfamilyinc.com">Corporate Info</a> | <a href="http://www.ancestry.com/home/partner/main.htm">Affiliate Program</a> | <a href="http://www.ancestry.com/legal/privacy.aspx">PRIVACY STATEMENT</a> | <a href="http://ancestryhelp.custhelp.com/cgi-bin/ancestryhelp.cfg/php/enduser/ask.php">Contact Us</a>');
	document.write('		</td>');
	document.write('		<td align="right" class="copyright">Copyright &copy; 1998-' + new Date().getFullYear() + ', MyFamily.com Inc. &#150; <a href="http://www.ancestry.com/legal/terms.aspx">Terms and Conditions</a>');	
	document.write('		&nbsp;</td>');
	document.write('	</tr>');
	document.write('</table>');
}

//-------
function doTab(aTabs, tIndex, tHeight, bActive, strDomain)
{
	document.write('<a href="'+ prependDomain(strDomain, aTabs[tIndex][1]) + '" id="' + aTabs[tIndex][4].toLowerCase() + '" ' + (bActive ? 'class="g_activeNav"' : '') + ' title="' + aTabs[tIndex][3] + '">' + aTabs[tIndex][0] + '</a>');
}

//-------
function doSpace(sWidth)
{
// Space between tabs
	document.write('		<td' + ((parseInt(sWidth) != 0) ? (' width="' + sWidth + '"') : '') + ' valign="bottom">');
	document.write('			<table width="100%" height="1" border="0" cellspacing="0" cellpadding="0">');
	document.write('				<tr height="1">');
	document.write('					<td class="sTabBorder" height="1"><img src=' + m_Cache + '/i/pixel.gif height="1" width="1"></td>');
	document.write('				</tr>');
	document.write('			</table>');
	document.write('		</td>');
}

//-------
function getWinWidth()
{
  var bw = m_PageWidth;
  if(typeof(window.innerWidth) == 'number')
    bw = window.innerWidth;	//Non-IE
	else
    if(document.documentElement && document.documentElement.clientWidth)
      bw = document.documentElement.clientWidth;	//IE 6+ in 'standards compliant mode'
		else
      if(document.body && document.body.clientWidth)
        bw = document.body.clientWidth;	//IE 4 compatible
	return bw;
}

//-------
function WriteTabs(pageWidth, strActiveTab, strDomain, aTabs)
{
	var tabsWidth = 0;
	var bNetScrape = false;
	for (i=0; i < aTabs.length; i++)
	{
		tabsWidth += parseInt(aTabs[i][2]) + 2;
	}
	tabsWidth -= 2;

	if ((pageWidth.indexOf("%") != -1) && (navigator.appName == "Navigator") && (parseInt(navigator.appVersion) < 5))
	{
		pageWidth = getWinWidth() * (100 / parseInt(pageWidth)) - 16;	// Determine the width of the window
		bNetScrape = true;
	}

	document.write('<div class="g_nav">');

	var bActive = false;
	
	if (aTabs != null)
	{
		for (i=0; i < aTabs.length; i++)
		{
			bActive = (aTabs[i][0] == strActiveTab);
			if (bActive)
				currentNav = aTabs[i][4];
			
			doTab(aTabs, i, (bActive ? 20 : 17), bActive, strDomain);
		}
	}

	document.write('</div>');
}

//-------
function WriteSubNav()
{
	if (bDebug)
		alert('WriteSubNav \ng_hdACrumbs: ' + g_hdACrumbs);
	var bShowCrumb = (((g_hdShowFlags & CSHOW_BREADCRUMB) != 0) && (g_hdACrumbs != null));

	// If there is anything in the sub nav
	if (bShowCrumb  || (IsLoggedIn() && g_hdStrActiveTab == C_BOARDS))
	{
		if (IsLoggedIn() && g_hdStrActiveTab == C_BOARDS && !IsInstitutionalAccount()) 
		{
			document.write('<div class="g_tools"><a href="' + g_hdStrDomain + '/rx/mb.asp?urlscheme=1&url=' + escape ('htx=myprofile&onok=' + escape (document.URL)) + '">My&nbsp;Profile</a> | ');
			document.write('<a href="' + g_hdStrDomain + '/rx/mb.asp?urlscheme=1&url=' + escape ('htx=myfavorites&onok=' + escape (document.URL)) + '">My&nbsp;Favorites</a> | ');
			document.write('<a href="' + g_hdStrDomain + '/rx/mb.asp?urlscheme=1&url=' + escape ('htx=mysubscriptions&onok=' + escape (document.URL)) + '">My Notifications</a></div>');
		}
		
		document.write('<div class="g_crumbs">');

		if (bShowCrumb)
			WriteBreadcrumb(g_hdACrumbs);
		
		document.write('</div>');
		
		
	}
}
//-------
function WriteBreadcrumb(aCrumbs)
{
	if (bDebug)
		alert('WriteBreadcrumb \naCrumbs: ' + aCrumbs);

	// If the breadcrumb is defined
	if (aCrumbs != null)
	{
		document.write('You are here: ');
		// Write each element of the breadcrumb
		for (i = 0; i < aCrumbs.length; i ++)
		{
			if (i < (aCrumbs.length - 1))
			{
				document.write('<a href="' + aCrumbs[i].split("::")[1] + '">' + aCrumbs[i].split("::")[0] + '</a> &gt; ');
			}
			else
			{
				document.write('<b>' + aCrumbs[i].split("::")[0] + '</b>');
			}
		}
	}
}

//-------
function WriteMasthead(showFlags, pageWidth, strActiveTab, strDomain)
{
	if (bDebug)
		alert('writeMasthead \nshowFlags: ' + showFlags + '\npageWidth: ' + pageWidth + '\nstrActiveTab: ' + strActiveTab + '\nstrDomain: ' + strDomain);

	
	document.write('<div class="g_masthead">');		
	
	if ((g_hdShowFlags & CSHOW_CUSTOMERINFO) != 0)
		WriteCustomerInfo (strDomain);
		
	if ( IsLoggedIn() )
		document.write('	<img alt="Search Genealogy Records" src="' + m_CachePartner + '/i/logo.gif" alt="" border="0" style="height:38px;width:175px;" />');
	else
		document.write('	<img alt="Search Genealogy Records" src="' + m_CachePartner + '/i/logo.gif" alt="" border="0" style="height:38px;width:175px; margin-top:14px;" />');
	document.write('</div>');
}

//-------
function WriteCustomerInfo(strDomain)
{
 	var name = getLoginName();
	var p = m_CachePartner.substring(m_CachePartner.lastIndexOf("/")+1);
 	if ( null == name || "" == name ) 
 	{ 
 		name = "Welcome"; 
 	}
 	else 
 	{ 
 		name = 'Welcome, <strong>' + name +'</strong> '; 
 	}
				
 	if ( !IsInstitutionalAccount() && ((g_hdShowFlags & CSHOW_LOGIN) != 0))
 	{
 		if ( IsLoggedIn() )
 		{
 			document.write('<div class="g_customerinfo">');
 			document.write(name);
			document.write('<a href="' + strDomain + '/security/loginredir.aspx?logout=true&home=true">Log Out</a>');
			document.write('<a href="' + strDomain + '/myancestry/myaccount/default.aspx">Upgrade</a>');

			if ((g_hdShowFlags & CSHOW_MYACCOUNT) != 0)
			{
				document.write('<a href="' + strDomain + '/myancestry/myaccount/default.aspx">My Account</a>');
			}
			document.write('<a href="' + strDomain + '/rx/help.asp">Help</a>');
			document.write('</div>');
 		}
 		else
 		{
 			var secureDomain = "";
 			if (strDomain == "http://www.ancestrydev.com")
 				secureDomain = "https://secure.ancestrydev.com";
 			else if	(strDomain == "http://www.ancestrystage.com")
 				secureDomain = "https://secure.ancestrystage.com";
 			else if (strDomain == "http://www.ancstage2.com")
 				secureDomain = "https://secure.ancstage2.com";
 			else
 				secureDomain = "https://secure.ancestry.com";
 			
 			document.write('<div class="g_customerinfo" style="margin-top: 42px;">');
			document.write('	<a href="' + strDomain + '/subscribe/subscribeplanstx.asp">Subscribe</a>');
			document.write('	<a href="' + strDomain + '/rx/help.asp">Help</a>');	
			document.write('</div>');
 			document.write('<div class="g_headLogin">');
			document.write('<table border="0" cellpadding="0" cellspacing="0">');
			document.write('<form action="' +  secureDomain + '/security/passwordlogin.aspx" method="post">');
			document.write('	<tr>');
			document.write('		<td colspan="3" style="padding-bottom: 4px;"><strong>Member Login</strong></td>');
			document.write('	</tr>');
			document.write('	<tr>');
			document.write('		<td><input name="username" type="text" class="data" /></td>');
			document.write('		<td><input name="password" type="password" class="data" /></td>');
			document.write('		<td><input type="submit" value="Login" class="g_btnSmall"/></td>');
			document.write('	</tr>');
			document.write('	<tr style="padding-top: 3px;">');
			document.write('		<td>Username</td>');
			document.write('		<td>Password  (<a href="' + strDomain + '/default.aspx?rlin=1">Forgot?</a>)</td>');
			document.write('		<td>&nbsp;</td>');
			document.write('	</tr>');
			document.write('<input type="hidden" name="ti" value="' + p + '">');
			document.write('<input type="hidden" name="kurl" value="' + document.URL + '">');
			document.write('</form>');
			document.write('</table>');
			document.write('</div>');
 			//document.write('<img align="middle" src="' + m_Cache + '/i/home/arrow16.gif" alt="" border="0" style="height:16px;width:16px;" />');
 			//document.write('<a href="' + strDomain + '/security/loginredir.aspx">Already a member? Login</a>')

			//if ((g_hdShowFlags & CSHOW_UPGRADE_PROMPT) != 0)
			//	document.write('<a href="' + strDomain + '/subscribe/subscribeplanstx.asp">Subscribe</a>');
 		}
 	}
	
}

//-------
function testShowHeaderAd(showFlags)
{
	if (bDebug)
		alert('testShowHeaderAd \nshowFlags: ' + showFlags);

	if ((showFlags & CSHOW_BANNERS) == 0)
		return false;

	if (bDebug)
	{
		alert('ShowAdOnPage(): ' + ShowAdOnPage());
		alert('IsInstitutionalAccount(): ' + IsInstitutionalAccount());
	}

	return (ShowAdOnPage() && !IsInstitutionalAccount());
}

//-------
function prependDomain (strDomain, strLink)
{
	strResult = strLink;
	strCheckURL = strLink.substring(0,6).toLowerCase();

	if (strCheckURL != "http:/"
			&& strCheckURL != "https:"
			&& strCheckURL != "javasc")
		strResult = strDomain + strLink;

	if (bDebug)
		alert('prependDomain\n'
					+ '\nstrDomain: ' + strDomain
					+ '\nstrLink: ' + strLink
					+ '\nstrCheckURL: ' + strCheckURL
					+ '\nstrResult: ' + strResult);

	return strResult;
}

//-------
// Write "invalid/bounced email" message on header
function writeHeaderMessage()
{
	var cachePath = ( 'undefined' == (typeof m_Cache) ) ? "http://c.ancestry.com/i/warning.gif" : m_Cache + "/i/warning.gif";
	var changeMailPath = ( 'undefined' == (typeof m_Domain) ) ? "/myancestry/myaccount/changeemail.aspx" : m_Domain + "/myancestry/myaccount/changeemail.aspx";	
	
	document.write('<div class="g_error" style="margin-bottom: 5px;"> ');
	document.write('	There appears to be a problem with your email address. ');
	document.write('	<a href="' + changeMailPath + '">Click here to verify your email address</a>. ');
	document.write('</div> ');
}

//-------
// Write the brand header first and then write the Ancestry branding and tabs.
function writeHeader(pageWidth,				// The width to constrain the header to, e.g. "750" or "100%"
						strActiveTab,		// The title of the currently selected tab
						strDomain,			// The domain to prepend to links
						aTabs,				// Array of tab titles and links in the form "Title", "Link"
						aCrumbs,			// Array of breadcrumbs in form Crumb::Link
						strHelpLink,		// Link to associate with the help link, null if help should not appear
						strCampaign,		// The campaign to associate with the ad banner or "" if no campaign
						showFlags)			// Bit flags indicating which parts of the header to show
{
	var p = m_CachePartner.substring(m_CachePartner.lastIndexOf("/")+1);

	if ( "5542" == p )
		aTabs = new Array(CTabLibHome, CTabAdvSearch, CTabChartForm);
	else if("5538" == p && !IsInstitutionalAccount())
		aTabs = new Array(CTabHome, CTabMyAncestry, CTabSearch, CTabBoards);
	else if (IsInstitutionalAccount())
		aTabs = new Array(CTabHome, CTabSearch, CTabBoards, CTabLearn);
	else if ( "5543" == p)
		aTabs = new Array(CTabHome, CTabMyAncestry, CTabSearch, CTabBoards);
	else if ( "5544" == p)
		aTabs = new Array(CTabHome, CTabMyAncestry, CTabSearch, CTabBoards);
	else
		aTabs = new Array(CTabHome, CTabMyAncestry, CTabSearch, CTabBoards, CTabLearn, CTabShops);

	if (document.location.href.indexOf("debug=1") != -1)
	{
		bDebug = true;
		document.write('<table border="1" bgcolor="#FFFFFF"><tr><td colspan="2" align="center"><b>writeHeader</b></td></tr><tr><td>m_PageWidth:</td><td>' + m_PageWidth + '</td></tr><tr><td>pageWidth:</td><td>' + pageWidth + '</td></tr><tr><td>strActiveTab:</td><td>' + strActiveTab + '</td></tr><tr><td>strDomain:</td><td>' + strDomain + '</td></tr><tr><td>aTabs:</td><td>' + aTabs + '</td></tr><tr><td>aCrumbs:</td><td>' + aCrumbs + '</td></tr><tr><td>strHelpLink:</td><td>' + strHelpLink + '</td></tr><tr><td>strCampaign:</td><td>' + strCampaign + '</td></tr>');
		document.write('<tr><td>showFlags:</td><td>');
		writeDebugFlags(showFlags);
		document.write('</td></tr><tr><td>writeHeader.arguments.length:</td><td>' + writeHeader.arguments.length + '</td></tr><tr><td>writeHeader.arguments:</td><td>');
		for(i=0;i < writeHeader.arguments.length;i++)
		{
			document.write('writeHeader.arguments[' + i + ']: ' + writeHeader.arguments[i] + '<br>');
		}
		document.write('</td></tr></table>');
	}

	// Load the parameters into global variables for passing
	g_hdPageWidth = pageWidth;	
	g_hdStrActiveTab = strActiveTab;
	g_hdStrDomain = strDomain;
	g_hdACrumbs = aCrumbs;
	g_hdATabs = aTabs;
	g_hdStrHelpLink = strHelpLink;
	g_hdStrCampaign = strCampaign;
	g_hdShowFlags = showFlags;

	if ( CSHOW_NONE != showFlags )
	{
		// writeBrandHeader is define in Brand.js
		writeBrandHeader(strDomain);		
		
		// Variable is defined in brand.js file if .js files are used to display the brand header
		var m_bUsesJSFile = ( (typeof g_bUsesJSFile) != 'undefined' ) ? g_bUsesJSFile : false;
		if (m_bUsesJSFile == true)
		{
			// Call writeCommonHeader from an included .js file
			// This is done this way so that brand headers that are done with .js files will display in the proper position.
			document.writeln ('<\script LANGUAGE="JavaScript1.1" SRC="' + m_CachePartner + '/js/writeheader.js"><\/script>');
		}
		else
		{
			writeCommonHeader();
		}
	}
	
	// identify the user as still active... (see sharedheader.ascx for .NET implementation.)
	if ( 'undefined' != (typeof touchCcr) ) touchCcr('/security/concurrencyupdate.aspx','ancestry');
}

//-------
// Output the common part of the header
function writeCommonHeader()
{
	if ((g_hdShowFlags & CENCLOSING_TABLE) != 0)
	{
		document.write('<style type="text/css">');
		if(g_hdPageWidth != 760) document.write('body {width:' + g_hdPageWidth + ' !important; max-width:' + g_hdPageWidth + ' !important; padding: 0 !important;}');
		document.write('.g_body{background-color:#ffffff; width: ' + g_hdPageWidth + '} ');
		document.write('</style>');
		document.write('<div class="g_body"><table class="g_bodytable" width="' + g_hdPageWidth + '"><tr><td>');// opening div and table for new header
		g_bEnclosingTableUsed = true;
	}
	// write "bounced email" message on header (User has a bad email)
	if ( hasBouncedEmail() ) //found on cache/js/security_shared.js
		writeHeaderMessage();
			
	// Masthead
//	if ((g_hdShowFlags & CSHOW_MASTHEAD) != 0)
	WriteMasthead(g_hdShowFlags, g_hdPageWidth, g_hdStrActiveTab, g_hdStrDomain);

	// Tabs
	if ((g_hdShowFlags & CSHOW_TABS) != 0)
		WriteTabs(g_hdPageWidth, g_hdStrActiveTab, g_hdStrDomain, g_hdATabs);

	// SubNav & Breadcrumb
	if ((g_hdShowFlags & CSHOW_SUBNAV) != 0)
		WriteSubNav();

	// Ad Banner
	if (testShowHeaderAd(g_hdShowFlags))
	{
		DisplayAdBanner("Top", 468, 60, g_hdStrCampaign);
	}

	// Bottom whitespace
	//if ((g_hdShowFlags & CSHOW_BOTTOM_WHITESPACE) != 0)
	//	writeVerticalSpace(8);

	// Enclosing table
	//if ((g_hdShowFlags & CENCLOSING_TABLE) != 0)
	//{
	//	document.write('<table width="' + g_hdPageWidth + '" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top">');
	//	g_bEnclosingTableUsed = true;
	//}
	document.close();
}

//-------
function writeFooter(pageWidth,				// The width to constrain the footer to, e.g. "750" or "100%"
					aLinks,					// Array of label followed by its associated link
					legalLink,				// Link associated with "subject to license"
					strCampaign,			// The campaign to associate with the ad banner or "" if no campaign
					showFlags)				// Bit flags indicating which parts of the footer to show
{
	var p = m_CachePartner.substring(m_CachePartner.lastIndexOf("/")+1);

	// Load the parameters into global variables for passing
	if (writeFooter.arguments.length == 5)
	{
		g_ftPageWidth = writeFooter.arguments[0];	
		g_ftALinks = writeFooter.arguments[1];	
		g_ftLegalLink = writeFooter.arguments[2];	
		g_ftStrCampaign = writeFooter.arguments[3];
		g_ftShowFlags = writeFooter.arguments[4];
	}
	else
	{
		g_ftPageWidth = writeFooter.arguments[0];	
		g_ftALinks = writeFooter.arguments[1];	
		g_ftLegalLink = m_Domain + "/legal/terms.aspx";	
		g_ftStrCampaign = writeFooter.arguments[2];
		g_ftShowFlags = writeFooter.arguments[3];
	}

	if ((document.location.href.indexOf("debug=1") != -1)
			|| (document.location.href.indexOf("debugf=1") != -1))
	{
		bDebug = true;
		document.write('<table border="1" bgcolor="#FFFFFF"><tr><td colspan="2" align="center"><b>writeFooter</b></td></tr><tr><td>pageWidth:</td><td>' + g_ftPageWidth + '</td></tr><tr><td>aLinks:</td><td>' + g_ftALinks + '</td></tr><td>legalLink:</td><td>' + g_ftLegalLink + '</td></tr><tr><td>strCampaign:</td><td>' + g_ftStrCampaign + '</td></tr><tr><td>showFlags:</td><td>');
		writeDebugFlags(g_ftShowFlags); 
		document.write('</td></tr><tr><td>writeFooter.arguments.length:</td><td>' +  writeFooter.arguments.length + '</td></tr><tr><td>writeFooter.arguments:</td><td>');
		for(i=0;i < writeFooter.arguments.length;i++)
		{
			document.write('writeFooter.arguments[' + i + ']: ' + writeFooter.arguments[i] + '<br>');
		}
		document.write('</td></tr></table>');
	}

	if ((CSHOW_NONE != g_ftShowFlags))
	{  
		if ( "5542" != p )
		{
			// New Trial Genealogy Footer Links 
			var iRights	= getUserRights();
			if (!IsLoggedIn() || (IsLoggedIn() && (getSubscriptionAll() & iRights) == 0) )
			{	
				var l_Domain = ( (typeof g_Domain) != 'undefined' ) ? g_Domain : '';	
				document.write('<div class="g_footerGenealogy">');
				document.write('	<b style="font-size: 11px;">Genealogy Links:&nbsp;</b>');
				document.write('	<a href="' + l_Domain + '/rd/landing.aspx?html=/family_trees/family_tree.aspx">Family Trees</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="' + l_Domain + '/rd/landing.aspx?html=/census_records/census_records.aspx">Census Records</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="' + l_Domain + '/rd/landing.aspx?html=/immigration/immigration_records.aspx">Immigration Records</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="' + l_Domain + '/rd/landing.aspx?html=/genealogy/genealogy_records.aspx">Genealogy Records</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="' + l_Domain + '/rd/landing.aspx?html=/uk_genealogy/uk_genealogy.aspx">U.K. Records</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="' + l_Domain + '/rd/landing.aspx?html=/newspapers/historical_newspapers.aspx">Historical Newspapers</a>');
				document.write('</div>');
			}
			//End New Trial Footer Links
			document.write('<div class="g_footer">');
			document.write('	<div style="float: left;">');
			if (g_ftALinks != null)
			{
				var i = 0;
				var bHash = false;

				while (i < g_ftALinks.length)
				{
					if (g_ftALinks[i] != "Terms and Conditions")
					{
						if (bHash)
							document.write(' | ');
						document.write('<a href="' + prependDomain(m_Domain, g_ftALinks[i+1]) + '">' + g_ftALinks[i] + '</a>');
						bHash = true;
					}
					i +=2;
				}
			}
			document.write('	</div>');
			document.write('	<div style="float: right;">');
			if ((g_ftShowFlags & CSHOW_COPYRIGHT) != 0)
			{
				document.write('Copyright &copy; 1998-' + new Date().getFullYear() + ', MyFamily.com Inc.');
				document.write(' &#150; <a href="' + g_ftLegalLink + '"><b>Terms and Conditions</b></a>');
			}
			document.write('	</div>');
			document.write('</div>');
		
			writeVerticalSpace(10);

			// Ad Banner
			if (testShowFooterAd(g_ftShowFlags))
			{
				DisplayAdBanner("Bottom", 468, 60, "");
				writeVerticalSpace(10);
			}

			// End enclosing table
			//if ((g_hdShowFlags & CENCLOSING_TABLE) != 0 && g_bEnclosingTableUsed == true)
			//	document.write('</TD></TR></TABLE>');
		}
	}
	if ((g_hdShowFlags & CENCLOSING_TABLE) != 0 && g_bEnclosingTableUsed == true)
		document.write('</td></tr></table></div>'); // closing table and div for new header
	writeOmniture(); // Do before writeBrandFooter
	if ((CSHOW_NONE != g_ftShowFlags))
	{ 
		// Write out the brand portion of the footer
		writeBrandFooter(m_Domain); 
	}
	document.close();
}

//2 lines commented out to eliminate sampling for omniture.
//var s_visitorSampling=10;	// Percent of visitors to sample. 10 means 10%. Can be 0.01 to 100.00.
//var s_visitorSamplingGroup=1; // Sample group "revision" number. Must match value in Util/Tracking.cs and header.js. Change to re-randomize sample group.


//-------
// This code adds Omniture tracking on some stacks.
// Other stacks include the files via a .NET module or ISAPI filter and should not be tagged here.
// Variables starting with s_ are global Omniture variables.
function writeOmniture()
{
	var p = m_CachePartner.substring(m_CachePartner.lastIndexOf("/")+1);
	
	// Omniture tracking was moved here from s/0/p/*/js/brand.js. This test prevents double tracking during transition:
	if (typeof(g_ftNeedTrack)=='undefined' || g_ftNeedTrack)
	{
		var sEnabledDomains = "::awtc.ancestry.com::awt.ancestry.com::boards.ancestry.com::localhost::"; // Use Ancestry.com format
		var sSimpleHostname = window.document.location.hostname; // Transform to Ancestry.com format

		s_channel = p;	// Set the Omniture variable for Traffic > Segmentation > Most Popular Site Sections

//2 lines commented out to eliminate sampling for omniture.
//		if (sSimpleHostname.indexOf("test")>=0||sSimpleHostname.indexOf("dev")>=0||sSimpleHostname.indexOf("localhost")>=0||sSimpleHostname.indexOf("stage")>=0)
//			s_visitorSampling=""; // Disable sampling in test environments

		if (p == "4300")
		{
			sSimpleHostname = sSimpleHostname.replace("ancestryaol","ancestry").replace(".families.aol.",".").replace("test.",".");
			s_account = "ancestryaolcobrand";	// Report suite ID (assigned by Omniture)
		}
		else if (p == "4317") //Netscape
		{
			sSimpleHostname = sSimpleHostname.replace("netscape.","").replace("ancestryaol","ancestry");
			s_account = "myfamilyancestry";	// Report suite ID (assigned by Omniture)
		}
		else if (p == "5519") //MyFamily
		{
			sSimpleHostname = sSimpleHostname.replace(".myfamily","");
			s_account = "myfamilyancestry";	// Report suite ID (assigned by Omniture)
		}
		else if (p == "5538")
		{
			sSimpleHostname = sSimpleHostname.replace(".co.uk",".com");
			s_account = "ancestryuki";	// Report suite ID (assigned by Omniture)
		}
		else if (p == "5541")
		{
			sSimpleHostname = sSimpleHostname.replace("msn.","");
			s_account = "ancestrymsn";	// Report suite ID (assigned by Omniture)
		}
		else if (p == "5542")
		{
			sSimpleHostname = sSimpleHostname.replace("library.",".");
			s_account = "ancestrylibrary";	// Report suite ID (assigned by Omniture)
		}
		else if (p == "5543")
		{
			sSimpleHostname = sSimpleHostname.replace(".ca",".com");
			s_account = "ancestryca";	// Report suite ID (assigned by Omniture)
		}
		else // if (p == "0")
		{
			s_account = "myfamilyancestry";	// Report suite ID (assigned by Omniture)
		}
		sSimpleHostname = "::"+sSimpleHostname.replace("dev.",".").replace("stage.",".") + "::";
		if (sEnabledDomains.indexOf(sSimpleHostname) > -1)
			document.write('<\script language="JavaScript" src="' + m_Cache + '/js/omniture_base.js"><\/script>');
		g_ftNeedTrack=false;	// Don't repeat in brand.js
	}
}


//-------
function writeVerticalSpace(vSpace)
{
			document.write('<table border="0" cellspacing="0" cellpadding="0"><tr><td height="' + vSpace + '"><spacer type="block" height="1" width="1"></td></tr></table>');
}


//-------
function testShowFooterAd(showFlags)
{
	return (((showFlags & CSHOW_BANNERS) != 0)
					&& ShowAdOnPage()
					&& !IsInstitutionalAccount());
}


//-------
function writeDebugFlags (debugFlags)
{
		document.write('CSHOW_NONE: ' + ((CSHOW_NONE == debugFlags) ? "true<br>":"false<br>"));
		document.write('CSHOW_ALL: ' + (((debugFlags & CSHOW_ALL) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_MASTHEAD: ' + (((debugFlags & CSHOW_MASTHEAD) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_LARGE_LOGO: ' + (((debugFlags & CSHOW_LARGE_LOGO) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_SMALL_LOGO: ' + (((debugFlags & CSHOW_SMALL_LOGO) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_LOGIN: ' + (((debugFlags & CSHOW_LOGIN) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_LINE: ' + (((debugFlags & CSHOW_LINE) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_TABS: ' + (((debugFlags & CSHOW_TABS) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_SUBNAV: ' + (((debugFlags & CSHOW_SUBNAV) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_BREADCRUMB: ' + (((debugFlags & CSHOW_BREADCRUMB) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_HELP: ' + (((debugFlags & CSHOW_HELP) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_BANNERS: ' + (((debugFlags & CSHOW_BANNERS) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_TOP_WHITESPACE: ' + (((debugFlags & CSHOW_TOP_WHITESPACE) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_BOTTOM_WHITESPACE: ' + (((debugFlags & CSHOW_BOTTOM_WHITESPACE) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_UPGRADE_PROMPT: ' + (((debugFlags & CSHOW_UPGRADE_PROMPT) != 0) ? "true<br>":"false<br>"));
		document.write('CENCLOSING_TABLE: ' + (((debugFlags & CENCLOSING_TABLE) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_FOOTER_HR: ' + (((debugFlags & CSHOW_FOOTER_HR) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_COPYRIGHT: ' + (((debugFlags & CSHOW_COPYRIGHT) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_CENTERED: ' + (((debugFlags & CSHOW_CENTERED) != 0) ? "true<br>":"false<br>"));
		document.write('CSHOW_MYACCOUNT: ' + (((debugFlags & CSHOW_MYACCOUNT) != 0) ? "true<br>":"false<br>"));
}


// This is here to eliminate errors on pages where the function is called but no longer included
// Remove this AFTER all calls to dateString are removed
function dateString(date)
{
	return "";
}

