function getCookie(sName) {   
    var sRE = "(?:; )?" + sName + "=([^;]*);?";
    var oRE = new RegExp(sRE);
    if (oRE.test(document.cookie)) {
        return decodeURIComponent(RegExp["$1"]);
    } else {
        return null;
    }
}

function setCookie(sName, sValue, oExpires, sPath, sDomain, bSecure) {
    var sCookie = sName + "=" + encodeURIComponent(sValue);
    if (oExpires) {
        sCookie += "; expires=" + oExpires.toGMTString();
    }
    if (sPath) {
        sCookie += "; path=" + sPath;
    }
    if (sDomain) {
        sCookie += "; domain=" + sDomain;
    }
    if (bSecure) {
        sCookie += "; secure";
    }
    document.cookie = sCookie;
}

function GetUrlArg(strArg, strUrl) {
	var _url;
	if(typeof(strUrl)=='undefined')
		_url = location.href + '&';
	else
		_url = strUrl + '&';
	var regex = new RegExp('(\\?|\\&)' + strArg + '=([^\\&\\?]*)\\&', 'gi');
	if (! regex.test(_url)) return '';
	var arr = regex.exec(_url);
	return (RegExp.$2);
}

var cookieName='wan17cp';
var cp=getCookie(cookieName);
if(cp==null||cp==''){
	cp=GetUrlArg('cp');
	if(cp==null||cp==''){
		cp='com';
	}
	if(cp.substr(0,2)!='gh'&&cp.substr(0,2)!='mt'&&cp.substr(0,2)!='lh'&&cp!='170022'){
	    cp = cp + '_' + clock();
	}
	d = new Date();
	d = new Date(d.getTime() + 30 * 24 * 3600 * 1000);
	setCookie(cookieName, cp, d, "/", "", null);
}

function clock()
{
	var   xmlhttp   =   new   ActiveXObject("Msxml2.XMLHTTP")   ;
  	xmlhttp.open("GET",   "http://www.wan17.com",   false)   ;
  	xmlhttp.setRequestHeader("Range",   "bytes=-1")   ;
  	xmlhttp.send()   ;
	time = new   Date(xmlhttp.getResponseHeader("Date"));
	year=time.getYear();
	month=time.getMonth()+1;
	date=time.getDate();
	dateStr=year;
	if(month<10)
		dateStr+="0"+month;
	else dateStr+=""+month;
	if(date<10)
		dateStr+="0"+date;
	else dateStr+=""+date;
	return dateStr;
}


