// requires previous inclusion of:
//	1.) /include/utility.js

if ( 'undefined' == (typeof tspacer_included) )
{
	if ( 'string' != typeof(document.location.protocol) || 0 != document.location.protocol.toLowerCase().indexOf('https') )
		document.write('<script language="JavaScript" src="http://c.mfcreative.com/js/tspacer.js"></script>');
	else
		document.write('<script language="JavaScript" src="https://a248.e.akamai.net/7/248/7051/v001/origin.c.ancestry.com/js/tspacer.js"></script>');
}

function getLoginName()
{
	var	loginName = getVars2Cookie('loginname');
	return ( null == loginName ) ? '' : loginName;
}

function getSubscriptionAll()
{
	return getSubscriptionAllEx(0x0409);
}

function getSubscriptionAllEx(locale)
{	// mimics SUBSCRIPTION_ALL in security_shared.asp

	var	SUBSCRIPTION_ALL = (0x0409 == locale) ? 0x1E17 : 0x0004;
	return SUBSCRIPTION_ALL;
}

function getUserRights()
{
	var iUR	= parseInt(getVarsCookie('UR'));
	if ( isNaN(iUR) )
	{
		iUR = 0;
	}
	return iUR;
}

function IsLoggedIn()
{
	var ATT = getCookie('ATT');
	return ( null != ATT && ATT.length > 1 );
}

function IsInstitutionalAccount()
{	// ParAZT cookie is dropped on session start

	var ParentAccount = getVars2Cookie('ParAZT');
	return ( null != ParentAccount && ParentAccount.length > 1 );
}

function IsRemembered()
{
	var recallUser = getCookie('rMeATT');
	return ( null != recallUser && recallUser.length > 1 );
}

function IsSNSLogin()
{
	var SNS = getVars2Cookie('sns');
	return ( IsLoggedIn() && '1' == SNS );
}

function touchCcrPixel(att,usid,siteId,rootPage)
{
	var domain		= ( (typeof m_Domain) != 'undefined' && null != m_Domain ) ? m_Domain : '';
	var touchUrl	= domain + rootPage + '?from=header.js&uatt=' + escape(att) + '&usid=' + escape(usid) + '&sid=' + escape(siteId);

	document.write('<img width="1" height="1" src="' + touchUrl + '">');
}

function touchCcr(rootRelTouchPage,siteId)
{
	if ( IsLoggedIn() )
	{
		// get value of timer cookie

		var ccrt = getCookie('CCRT');

		if ( null == ccrt || 0 >= ccrt.length )
		{
			// timer cookie expired, so set another to expire in two minutes...

			var exp = new Date();
			exp.setTime(exp.getTime() + 120000);
			document.cookie = 'CCRT=1; path=/; expires=' + exp.toGMTString();

			// create image pixel for concurrency update AFTER timer cookie set...

			var att			= getCookie('ATT'); if ( null == att ) { att = ''; }
			var sessionId	= getVarsCookie('USID'); if ( null == sessionId ) { sessionId = ''; }

			touchCcrPixel(att,sessionId,siteId,rootRelTouchPage);
		}
		else if ( -1 < ccrt.toLowerCase().indexOf('.aspx') )
		{
			// if timer cookie has .NET page in it, clear cookie and go to page

			var exp = new Date();
			exp.setTime(exp.getTime() - 120000);
			document.cookie = 'CCRT=1; path=/; expires=' + exp.toGMTString();

			document.location = ccrt;
		}
	}
}

function hasBouncedEmail()
{	
	if ( IsLoggedIn() && !IsInstitutionalAccount() ) 
	{
		var acctStat = getVars2Cookie('ACCTSTAT');
		return ( 1 == (1 & acctStat) );
	}
}




function isReferringDomainSite(domainName)
{

	var rdn = getDictionaryCookie('SOURCES','RDN');
	if(rdn != null)
	{
	rdn = rdn.toLowerCase();

	if(rdn.indexOf(domainName.toLowerCase(),0) >= 0)
		return true;
	else
		return false;
	}
	else
	{
		return false;
	}	

}

