//Used in conjunction with the ISAPI filter.  Not directly applied in the source of the project.

/****************** Global utility functions ****************************************/
function getCookieVal (offset) 
{
	//gets value within a cookie
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
		
	return unescape(document.cookie.substring(offset, endstr));
}
			
function GetCookie(name) 
{
	//gets full cookie
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;

	while (i < clen) 
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)  
		{ 
			return (getCookieVal(j));
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
/**********************************************************************************/


/****************** iVillage Partnership Tracking *********************************/
if(iv_javascript == null)
{
	var iv_javascript = true;
	
	if(GetCookie('Partner') == '6')
	{	
		iv_hideTacoda = true;
		document.write("<script type='text/javascript' src='http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/includes/iv_header.js'></script>");
		document.write("<script type='text/javascript' src='http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/includes/iv_footer.js'></script>");
	}
}
/**********************************************************************************/


/****************** Remove outdated cookies *********************************/
function TK_GetCookie(name) 
{
	var start = document.cookie.indexOf(name + "=");
	var len = start + name.length + 1;
	if ((!start) && (name != document.cookie.substring(0, name.length)))
	{
		return null;
	}
	if (start == -1) 
		return null;
	var end = document.cookie.indexOf(";", len);
	if (end == -1) 
		end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
	
function TK_DeleteCookie(name, path, domain) 
{
	if (TK_GetCookie(name)) 
		document.cookie = name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}	

TK_DeleteCookie('membernote', '/', window.location.hostname);
TK_DeleteCookie('__qca', '/', '.theknot.com');
TK_DeleteCookie('__qcb', '/', '.theknot.com');
TK_DeleteCookie('__qca', '/', '.thenest.com');
TK_DeleteCookie('__qcb', '/', '.thenest.com');
TK_DeleteCookie('dateshown', '/', window.location.hostname);

TK_DeleteCookie('__utmc', '/', 'talk.theknot.com');
TK_DeleteCookie('__utmz', '/', 'talk.theknot.com');
TK_DeleteCookie('__utma', '/', 'talk.theknot.com');
TK_DeleteCookie('__utmb', '/', 'talk.theknot.com');

TK_DeleteCookie('__utmc', '/', 'boards.thenest.com');
TK_DeleteCookie('__utmz', '/', 'boards.thenest.com');
TK_DeleteCookie('__utma', '/', 'boards.thenest.com');
TK_DeleteCookie('__utmb', '/', 'boards.thenest.com');


