function News_Cookie_Enabled(){
    var cookieEnabled=(navigator.cookieEnabled)? true : false;//判断cookie是否开启
    //如果浏览器不是ie4+或ns6+
    if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){ 
        document.cookie="testcookie"
        cookieEnabled=(document.cookie=="testcookie")? true : false
        document.cookie="" //erase dummy value
    }
    return cookieEnabled;
}

function News_ReadCookie(name){
	var arg=name+"=";
	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 News_WriteCookie(name,value){
	var argv=News_WriteCookie.arguments;
	var argc=News_WriteCookie.arguments.length;
	var expires=(2<argc)?argv[2]:null;
	var path=(3<argc)?argv[3]:null;
	var domain=(4<argc)?argv[4]:null;
	var secure=(5<argc)?argv[5]:null;

	document.cookie=name+"="+escape(value)+((expires == null)?" ":(";expires ="+expires.toGMTString()))+((path == null)?"  ":(";path = "+path))+((domain == null)?" ":(";domain =" +domain)) +((secure==true)?";secure":" ");
}

NewsCe = News_Cookie_Enabled();
if(NewsCe===true){
    if (newsid != ""){
        curviewnewsid = News_ReadCookie("curviewnewsid");
        cookieid      = News_ReadCookie("cookieid");
        if (curviewnewsid!=newsid){
            News_WriteCookie("curviewnewsid",newsid,null,"/",null,false);
            if (cookieid != ""){
                var cookieid = Math.round(Math.random()*2147483647);
                var expdate_news = new Date();
                expdate_news.setTime(expdate_news.getTime()+365*24*60*60);
                News_WriteCookie("cookieid",cookieid,expdate_news,"/",null,false);
            }
            var r = "?newsid="+newsid+"&cookieid="+cookieid;
            var News_CountUrl ='http://stat.house365.com/newscount.php'+ r;
            // document.write("<script src='" + News_CountUrl + "'></script>");
        }
    }
}