﻿var curDomain='.titleboxing.com';

var ck = getCookie('__b4');
if(ck){
	// has cookie
	// hide the first time visitor content
	if(document.styleSheets[0].insertRule && ! (/Apple/.test(navigator.vendor))){
		document.styleSheets[0].insertRule('p.optp { display: none; }',document.styleSheets[0].cssRules.length );
		document.styleSheets[0].insertRule('#hpcpy h2 { display: none; }',document.styleSheets[0].cssRules.length );
	}
	else{
		document.styleSheets[0].addRule('p.optp', 'display:none');
		document.styleSheets[0].addRule('#hpcpy h2', 'display:none');
	}
} else {
	// need to set cookie
	setb4cookie('__b4',"1");
}

function setb4cookie( cname, cval )
{
	var xtm = new Date();
	xtm.setTime (xtm.getTime() + 36000000); // Adjust the expiration as needed
	setCookie(cname,cval,xtm,"/",curDomain);
}

function getCookie(name)
{
	var arg = name + "=";
	var argLen = arg.length;
	var cookieLen = document.cookie.length;
	var i = 0;
	while (i < cookieLen)
	{
		var j = i + argLen;
		if (document.cookie.substring(i, j) == arg)
		{
			return getCookieVal(j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
		{
			break;
		}
	}

	return null;
}
function setCookie(name, value)
{
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = 	name + "=" + escape(value) +
				((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
				((path == null) ? "" : ("; path=" + path)) +
				((domain == null) ? "" : ("; domain=" + domain)) +
				((secure == true) ? "; secure" : "");
}
// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function getCookieVal(offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	{
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}
