var newfrom;
function checkChannel(){
	findfrom();setCookiefrom();
}
function getCookie(A){
	var $=new RegExp(A+"=([^;]+)"),B=$.exec(document.cookie),C="";
	if(B!=null){
		try{
			C=decodeURI(B[1])
		}catch(_){
		}
	}
	return C
}
function setCookie(D,$,E,C,B,A){
	var _=D+"="+encodeURI($)+((E)?"; expires="+E.toGMTString():"")+((C)?"; path="+C:"")+((B)?"; domain="+B:"")+((A)?"; secure":"");
	document.cookie=_
}
function GetQueryString($){
	var A=new RegExp("(^|&)"+$+"=([^&]*)(&|$)"),_=window.location.search.substr(1).match(A);
	if(_!=null)
	return unescape(_[2]);return null
}
function findfrom(){
	var _=getCookie("channel_from"),$=GetQueryString("from"),A=getReffrom();
	if(!(A>0)&&!($>0)&&(_>0))return true;
	if(($>0)&&(_!=$)){
		newfrom=$;return true
	}
	if(!($>0)&&(A>0)&&(_!=A)){
		newfrom=A;return true
	}
}

function setCookiefrom(){
	if(newfrom!=""&&newfrom!="null"&&newfrom!=null&&(newfrom>0)){
		var $=new Date((new Date()).getTime()+12*60*60*1000);
		setCookie("channel_from",newfrom,$,"/")
	}
}

function getReffrom(){
	var _=document.referrer,A=new RegExp("(^|&?)from=([^&]*)(&|$)"),D=_.substr(1).match(A);
	if(D!=null)
		return unescape(D[2]);
	/*var $=new RegExp("://([^/]*)/"),B=_.substr(1).match($);
	if(B!=null){
		dm=unescape(B[1]);
		var C=checkCoopD(dm);
		return C
	}return null*/
}
/*function checkCoopD(C){
	var $=sis[C];
	if($>0)
		return $;
	else{
		var _=new RegExp(".([^.]*){1}.(com.cn|net.cn|org.cn|com|net|org|cn)"),D=C.substr(1).match(_),B="*."+D[1]+"."+D[2],A=sis[B];
		if(A>0)return A
	}
	return null
}*/
checkChannel();
