﻿var _faithtech_stat_scriptfile_id = "_faithtech_stat_scriptfile_id";
var _sid = document.getElementById(_faithtech_stat_scriptfile_id);
if( _sid ) _sid = _sid.getAttribute("data");
if (_sid) {
    (function () {
        var plocation = window.location;
        var preferrer = document.referrer;
        var tlocation = "", treferrer = "";
        try {
            tlocation = window.parent.location;
        }
        catch (e)
        { }
        try {
            treferrer = window.parent.document.referrer;
        }
        catch (e)
        { }
        if (tlocation != "") plocation = tlocation;
        if (treferrer != "") preferrer = treferrer;

        var pcolor; //色彩
        if (navigator.appName == "Netscape") {
            pcolor = screen.pixelDepth;
        }

        else {
            pcolor = screen.colorDepth;
        }

        //一次性浏览页面数,来访次数,以一小时无动静为一次
        var vpagescookie = "FaithTech_Stat_Pages", vtimescookie = "FaithTech_Stat_Times", maccookie = "FaithTech_Stat_Mac";
        var vpages, vtimes, mac;
        try {
            vpages = document.cookie.match(new RegExp("(^| )" + vpagescookie + "=([^;]*)(;|$)"));
            vpages = (vpages == null) ? 1 : (parseInt(unescape((vpages)[2])) + 1);
            var _vp_t = new Date();
            _vp_t.setTime(_vp_t.getTime() + 60 * 60 * 1000);
            document.cookie = vpagescookie + " = " + vpages + ";path = /;expires = " + _vp_t.toGMTString();

            vtimes = document.cookie.match(new RegExp("(^| )" + vtimescookie + "=([^;]*)(;|$)"));
            if (vtimes == null) {
                vtimes = 1;
            } else {
                vtimes = parseInt(unescape((vtimes)[2]));
                vtimes = (vpages == 1) ? vtimes + 1 : vtimes;
            }
            _vp_t.setTime(_vp_t.getTime() + 365 * 24 * 60 * 60 * 1000);
            document.cookie = vtimescookie + " = " + vtimes + ";path = /;expires = " + _vp_t.toGMTString();

            var t = new Date();
            mac = document.cookie.match(new RegExp("(^| )" + maccookie + "=([^;]*)(;|$)"));
            mac = (mac == null) ? null : (mac)[2];
            if (mac == null) {
                mac = "Mac" + t.getYear() + t.getMonth() + t.getDay() + t.getHours() + t.getMinutes() + t.getSeconds() + t.getMilliseconds() +
                   Math.floor(Math.random() * 1000000);

                t.setTime(t.getTime() + 7200 * 60 * 60 * 1000);
                document.cookie = maccookie + " = " + mac + ";path = /;expires = " + t.toGMTString();
            }
        } catch (e)
        { }


        var query = "id=" + _sid + "&vpages=" + vpages + "&vtimes=" + vtimes + "&url=" + escape(plocation) + "&re=" + escape(preferrer)
            + "&color=" + pcolor + "&size=" + screen.width + "*" + screen.height + "&mac=" + mac;

        document.write("<img src='http://s.faithtech.com.cn/stat/?" + query + "' style='width:0px;height:0px;' />");

    })();
}
