function checkRef()
{
	var ref='';
	if(document.referrer.length>0){ref=document.referrer;}
	try{if (ref.length==0&&opener.location.href.length>0){ref=opener.location.href;}}catch(e){}
	var zs=ref;
	var zboo=true;
	if(zs!=""&&zs.length>35){zs=zs.substring(0,35);}
	if(zs==""||zs.indexOf("baihui.com")!=-1)zboo=false;
	if(zboo){try{_addCookie("vistorref",ref,'',"/","baihui.com");}catch(e){}}
}
function _addCookie(name,value,expires,path,domain)
{
	var str=name+"="+escape(value);
	if(expires!=""){
		var date=new Date();
		date.setTime(date.getTime()+expires*24*3600*1000);
		str+=";expires="+date.toGMTString();
	}
	if(path!=""){str+=";path="+path;}
	if(domain!=""){str+=";domain="+domain;}
	document.cookie=str;
}
function _getCookie(n)
{
	var sc = document.cookie;
	var ac = sc.split("; ");
	var a;
	for(var i=0;i<ac.length;i++)
	{
		a = ac[i].split("=");
		if(a[0]==n) return unescape(a[1]);
	}
	return "";
}
checkRef();