function getCookieVal(offset) {
	var endstr=document.cookie.indexOf(";",offset);
	if (endstr==-1) {
		endstr=document.cookie.length;
	}
	return unescape(document.cookie.substring(offset,endstr));
}
function GetCookie(cname) {
	var arg=cname+"=";
	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;
}
function SaveCookie(cname,cvalue,cdays,cpath) {
	ex = new Date; ex.setTime(ex.getTime() + (cdays*86400000));
	if (cpath == null) { 
		cpath = "/";
	} else { 
		cpath = "; path=" + cpath;
	}
	sitedom=location.hostname.replace(/www\./,"");
	document.cookie=cname + '=' + cvalue + '; expires=' + ex.toGMTString() + cpath + "; domain="+sitedom;
}
var insitecookie="sacbee_user_auth";
if (GetCookie(insitecookie)) {
	document.write('<style type="text/css">#nonmember{display:none;}</style>');
} else {
	document.write('<style type="text/css">#member{display:none;}</style>');
}
var insitecookie="sacbee_user_auth";
var loginpage="http://www.sacbee.com/user_registration/login/?goto=";
var allowsite=0;
var allowArr=["google.com","news10.net","khtk.com","rope.khtk-am.fimc.net"];
//alert(document.referrer);
for (var i = 0; i < allowArr.length; i++) {
	if (document.referrer.indexOf(allowArr[i]) > -1) {
		allowsite=1;
	}
}
if (navigator.userAgent.indexOf("WebTV") > -1) {
	allowsite=1;
}
if (document.referrer == '') {
	allowsite=1;
}
if (!GetCookie(insitecookie) && allowsite == 0) {
	if (location.hostname.indexOf("sacbee.com") > -1) {
		location.replace(loginpage+escape(document.location));
	} else if (location.hostname.indexOf("sacticket.com") > -1) {
		location.replace(loginpage+escape(document.location));
	}
}
if (GetCookie(insitecookie) && !GetCookie("segments")) {
	document.write('<scr' + 'ipt type="text/javascript" src="http://www.sacbee.com/static/secure/daily.js"></scr' + 'ipt>');
}