
var g_from = ""; var g_verify = ""; var g_tm_uid = ""; var g_email = ""; var g_staruser_last_friend = ""; var TEAMBUY = {}; TEAMBUY.CITY = { "init": function () {
    this.iscitylist = false; var self = this; function showCity() {
        var showStatus = $j("#city_list").css("display")
        if (showStatus != "none") { $j("#city_list").hide(); } else { $j("#city_list").show(); self.iscitylist = true; return false; }
    }
    $j("#chg_city").click(showCity); $j(".city_curt").click(showCity); $j("#city_list a").click(function () {
        var city = this.getAttribute("data-id"); var data_type = this.getAttribute("data-type"); var direct = ""; if (g_redirectpage.indexOf("?") > -1)
        { direct = g_redirectpage + "&"; } else if (g_redirectpage.indexOf(".php") > -1)
        { direct = g_redirectpage + "?"; } else
        { direct = g_redirectpage + ".php?"; }
        //window.location.href = g_tmbpath + "/" + direct + "city=" + city; self.iscitylist = false; return false;
        if (city != "quanguo") {
            window.location.href = "http://" + city + ".hao123tuangou.net";
        } else {
            window.location.href = "http://www.hao123tuangou.net";
        }
        self.iscitylist = false; return false;
    }); $j(document).click(function () {
        if (self.iscitylist)
        { $j("#city_list").hide(); self.iscitylist = false; }
    });
}
}; TEAMBUY.JINGPIN = { "init": function (_id) {
    var list_id = _id + "_pop"; var classvalue = "active"; if (_id == "mytuan")
    { classvalue = "hover"; }
    timedMsg(); this.isOverNavfunc = false; this.isOverNavPop = false; this.t = ''; var self = this; $j("#" + _id).mouseover(function () { $j("#" + _id).addClass(classvalue); TEAMBUY.JINGPIN.isOverNavfunc = true; var showStatus = $j("#" + list_id).css("display"); if (showStatus == "none") { $j("#" + _id).addClass(classvalue); $j("#" + list_id).show(); } }); $j("#" + _id).click(function () { $j("#" + _id).addClass(classvalue); TEAMBUY.JINGPIN.isOverNavfunc = true; var showStatus = $j("#" + list_id).css("display"); if (showStatus == "none") { $j("#" + list_id).show(50); } }); $j("#" + _id).mouseout(function () { TEAMBUY.JINGPIN.isOverNavfunc = false; }); $j("#" + list_id).mouseover(function () { TEAMBUY.JINGPIN.isOverNavPop = true; }); $j("#" + list_id).mouseout(function () { TEAMBUY.JINGPIN.isOverNavPop = false; }); $j(document).click(function () {
        if (TEAMBUY.JINGPIN.isOverNavPop == false && TEAMBUY.JINGPIN.isOverNavfunc == false)
        { $j("#" + list_id).hide(); $j("#" + _id).removeClass(classvalue); }
    }); function timedMsg() {
        this.t = setInterval(function () {
            if (TEAMBUY.JINGPIN.isOverNavPop == false && TEAMBUY.JINGPIN.isOverNavfunc == false)
            { $j("#" + list_id).hide(); $j("#" + _id).removeClass(classvalue); }
        }, 200);
    }
}
}; TEAMBUY.SMSSUB = { "sub": function (mobile, city) {
    if (!tm_checkMobile(mobile))
    { alert("您输入的手机号格式有误，请重输！"); document.smsform.mobile.focus(); return false; }
    var uri = g_tmbpath + '/smssub_dlg.php?select_city=' + city + '&mobile=' + mobile; openWindow(uri, 430, 295, '短信订阅'); return false;
}, "sub2": function (mobile, city)
{ var uri = g_tmbpath + '/smssub_dlg.php?select_city=' + city + '&mobile=' + mobile; openWindow(uri, 430, 295, '短信订阅'); return false; }, "unsub": function (mobile, city)
{ var uri = g_tmbpath + '/un_smssub_dlg.php?select_city=' + city + '&mobile=' + mobile; openWindow(uri, 430, 295, '短信退订'); return false; }, "subDirect": function ()
{ var uri = g_tmbpath + '/smssub_dlg.php'; openWindow(uri, 430, 295, '短信订阅'); return false; }
}; TEAMBUY.EMAILSUB = { "a_postoffice": ["163.com", "gmail.com", "qq.com", "126.com", "hotmail.com", "sina.com", "yahoo.com.cn", "sohu.com", "yahoo.cn", "139.com"], "sub": function (mailInput, ajax, elist, select_city, subsysmsg, succcallback) {
    if (elist && elist.html() != "") {
        var v_selectindex = parseInt(elist.attr("selectindex"), 10); if (!isNaN(v_selectindex) && v_selectindex != -1)
        { return false; }
    }
    if (!CheckEmail(mailInput.value))
    { alert("您输入的Email格式有误，请重新输入！"); return false; }
    if (ajax)
    { TEAMBUY.EMAILSUB.t_dealemail(mailInput.value, select_city, subsysmsg, succcallback); return false; } else
    { return true; }
}, "t_dealemail": function (email, city, subsysmsg, succcallback) {
    var subsysmsgPara = (typeof (subsysmsg) != "undefined") ? subsysmsg : 0; $j.ajax({ 'type': 'POST', 'url': g_tmbpath + '/ajax_email_subscription.php', 'data': 'email=' + encodeURIComponent(email) + "&select_city=" + encodeURIComponent(city) + "&subsysmsg=" + encodeURIComponent(subsysmsgPara), 'dataType': "json", 'success': function (b) {
        if (b) {
            if (b.ret == 1) {
                if (typeof (succcallback) == "undefined")
                { openWindow(g_tmbpath + '/emailsucc_dlg.php?select_city=' + city + '&ptype=' + b.ptype, 430, 235, '订阅团购信息'); } else
                { succcallback(); }
            } else
            { alert(b.msg); }
        }
        else
        { alert("订阅失败，请稍后重试！"); }
    }, 'error': function () { alert("网络失败，请稍后重试！"); }
    });
}, "getEmailText": function (v_text, v_selectindex) {
    if (0 <= v_selectindex && v_selectindex < TEAMBUY.EMAILSUB.a_postoffice.length) {
        var v_pos = v_text.indexOf("@"); if (v_pos != -1) {
            var v_postoffice = v_text.substr(v_pos + 1); if (v_postoffice.length) {
                if (TEAMBUY.EMAILSUB.a_postoffice[v_selectindex].substr(0, v_postoffice.length) != v_postoffice)
                { return ""; }
            }
            return v_text.substr(0, v_pos) + "@" + TEAMBUY.EMAILSUB.a_postoffice[v_selectindex];
        }
        return v_text + "@" + TEAMBUY.EMAILSUB.a_postoffice[v_selectindex];
    }
    return v_text;
}, "refreshEmailList": function (v_elist, v_text, v_selectindex, v_position, inputobj) {
    var v_html = ""; if (v_text.length) {
        v_html += '<ul id="sList">'; if (v_position == 0)
        { v_selectindex = 0; }
        var v_previndex = 0; var v_nextindex = 0; var v_lastindex = 0; var v_pos = 0; for (var i = 0; i < TEAMBUY.EMAILSUB.a_postoffice.length; ++i) {
            var v_postoffice = TEAMBUY.EMAILSUB.getEmailText(v_text, i); if (v_postoffice.length) {
                if (v_pos == v_position)
                { v_selectindex = i; }
                if (i == v_selectindex)
                { v_html += '<li id="sWords" class="shover">'; v_html += v_postoffice; v_html += '</li>'; v_previndex = v_lastindex; v_nextindex = v_selectindex; }
                else {
                    v_html += '<li id="sWords">'; v_html += v_postoffice; v_html += '</li>'; if (v_nextindex == v_selectindex)
                    { v_nextindex = i; }
                }
                v_lastindex = i; v_pos++;
            }
        }
        v_html += '</ul>';
    }
    if (v_html == '<ul id="sList"></ul>')
    { v_elist.hide(); v_elist.html(""); }
    else
    { v_elist.attr("selectindex", v_selectindex); v_elist.attr("previndex", v_previndex); v_elist.attr("nextindex", v_nextindex); v_elist.html(v_html); v_elist.show(); }
}, "init": function (input_email) {
    this._input_email = $j("input[id=" + input_email + "]"); var self = this; this._input_email.blur(function () { var elist = $j("#" + $j(this).attr("rellist")); elist.hide(); elist.html(""); }); this._input_email.focus(function () {
        var elist = $j("#" + $j(this).attr("rellist")); var active_input = this; elist.unbind("mousedown"); elist.bind("mousedown", function (e) {
            var v_top = e.clientY + $j(document).scrollTop() - elist.offset().top; var v_position = Math.floor(v_top / 24); if (v_position < 0)
                return; var v_text = $j.trim($j(active_input).attr("value")); var v_selectindex = parseInt(elist.attr("selectindex"), 10); $j(active_input).attr("value", TEAMBUY.EMAILSUB.getEmailText(v_text, v_selectindex)); elist.hide(); elist.html("");
        }); elist.unbind("mousemove"); elist.bind("mousemove", function (e) {
            var v_top = e.clientY + $j(document).scrollTop() - elist.offset().top; var v_position = Math.floor(v_top / 24); if (v_position < 0)
                return; var v_text = $j.trim($j(active_input).attr("value")); TEAMBUY.EMAILSUB.refreshEmailList(elist, v_text, -1, v_position, active_input);
        }); if (elist.html() != "")
        { elist.show(); }
    }); this._input_email.keydown(function (e) {
        var elist = $j("#" + $j(this).attr("rellist")); var v_text = $j.trim($j(this).attr("value")); var v_pos = v_text.indexOf("@"); if (v_pos == -1)
        { elist.hide(); elist.html(""); return; }
        var v_selectindex = parseInt(elist.attr("selectindex"), 10); var v_previndex = parseInt(elist.attr("previndex"), 10); var v_nextindex = parseInt(elist.attr("nextindex"), 10); if (isNaN(v_selectindex))
            v_selectindex = 0; if (isNaN(v_previndex))
            v_previndex = 0; if (isNaN(v_nextindex))
            v_nextindex = 0; if (e.keyCode == 37)
            v_selectindex = 0; else if (e.keyCode == 38)
            v_selectindex = v_previndex; else if (e.keyCode == 40)
            v_selectindex = v_nextindex; else
            return; TEAMBUY.EMAILSUB.refreshEmailList(elist, v_text, v_selectindex, -1, this);
    }); this._input_email.keyup(function (e) {
        var elist = $j("#" + $j(this).attr("rellist")); var v_text = $j.trim($j(this).attr("value")); var v_pos = v_text.indexOf("@"); if (v_pos == -1)
        { elist.hide(); elist.html(""); return; }
        var v_selectindex = parseInt(elist.attr("selectindex"), 10); if (isNaN(v_selectindex))
            v_selectindex = -1; if (e.keyCode == 13) {
            if (elist.html() != "")
            { $j(this).attr("value", TEAMBUY.EMAILSUB.getEmailText(v_text, v_selectindex)); elist.hide(); elist.html(""); }
            return;
        }
        TEAMBUY.EMAILSUB.refreshEmailList(elist, v_text, v_selectindex, -1, this);
    });
}
}; TEAMBUY.COMMENT_NEW = { "init": function (container, iid, ocmttype, homehost, issendnews) {
    this._comment_block = $j("#" + container); this._comment_content_list = this._comment_block.find("#comment"); this._page_block = this._comment_block.find("#comment_pageinfo"); this._comment_container = this._comment_block.find("div.addcomment:first"); this._submit_p = this._comment_container.find("p.tar.mt10:first"); this._submit_button = this._submit_p.children("input[type=button]"); this._is_sharetofrd = this._submit_p.children("input[type=checkbox]"); this._textarea = this._comment_container.find("textarea:first"); this.isactive = false; this._textarea_defaultValue = "请输入评论或提问，客服人员会尽快解答"; this._textarea_defaultValue2 = "请输入评论内容"; this._max_content_len = 1000; this._iid = iid; this._ocmttype = ocmttype; this._homehost = homehost; this._lastaddtime = 0; if (issendnews == "1")
    { $j(this._is_sharetofrd).attr("checked", "checked"); }
    var self = this; this._comment_module = '<div class="commitem" style="display:none">'; this._comment_module += '<div class="commitmein clearfix">'; this._comment_module += '    <a onclick="<_OCMT_UID_CLICK_>" href="http://' + homehost + '/home/?uid=<_OCMT_UID_>" target="_blank" class="c_facearea" ><img alt="<_OCMT_USERNAME_>" class="face50bg" src="<_OCMT_LOGO_URL_>" /></a>'; this._comment_module += '    <div class="commlist">'; this._comment_module += ' <span class="timert"><_OCMT_CTIME_></span>'; this._comment_module += '     <div class="ohz c9"><a onclick="<_OCMT_UID_CLICK_>" href="http://' + homehost + '/home/?uid=<_OCMT_UID_>" target="_blank" class="sl" ><_OCMT_USERNAME_></a>评价道：<_OCMT_FLAG_></div>'; this._comment_module += '        <p class="mt5"><_OCMT_CONTENT_></p>'; this._comment_module += '        <div class="recomm">'; this._comment_module += '        </div>'; this._comment_module += '        <div class="mt10"><a href="#" class="sl replylink">回复</a></div>'; this._comment_module += '        <div class="c_typearea" style="display:none;" id="reply_div_<_OCMT_CID_>">'; this._comment_module += '            <textarea style="width:384px;" cols="" rows=""></textarea>'; this._comment_module += '            <p class="tar mt10"><input type="button" class="btnt2" value="回复" /><input type="button" class="btnt2_g ml10" value="取消" /></p>'; this._comment_module += '        </div>'; this._comment_module += '    </div>'; this._comment_module += '</div>'; this._comment_module += '</div>'; this._reply_module = '<div class="recommitem" style="display:none">'; this._reply_module += '    <span class="timert"><_OCMT_R_CTIME_></span>'; this._reply_module += '    <a onclick="<_OCMT_UID_CLICK_>" href="http://' + homehost + '/home/?uid=<_OCMT_R_UID_>" target="_blank" class="c_facearea" ><img alt="<_OCMT_R_USERNAME_>" class="img_box" height="25" width="25" src="<_OCMT_R_LOGO_URL_>" /></a>'; this._reply_module += '    <div class="c9"><a onclick="<_OCMT_UID_CLICK_>" href="http://' + homehost + '/home/?uid=<_OCMT_R_UID_>" target="_blank" class="sl" ><_OCMT_R_USERNAME_></a>回复道：</div>'; this._reply_module += '    <p class="mt5"><_OCMT_R_CONTENT_></p>'; this._reply_module += '</div>'; $j(document).click(function () { TEAMBUY.COMMENT_NEW.deactive(); }); this._textarea.focus(function () {
        if (!checkLogin())
        { openLoginDlg("addcomment"); return false; }
        var obj = $j(this); if (!this.isactive) {
            if (obj.val() == self._textarea_defaultValue || obj.val() == self._textarea_defaultValue2)
            { obj.val(""); }
            self._submit_p.slideDown(300);
        }
        obj.removeClass('unfocus'); return false;
    }); this._textarea.bind("keyup", function (e) {
        var keycode = e.keyCode; if (keycode == "13" && e.ctrlKey)
        { self._submit_button.click(); }
        var content = self._textarea.val(); var ilen = content.length; if (ilen > self._max_content_len)
        { self._textarea.val(content.substr(0, self._max_content_len)); }
    }); this._textarea.blur(function () { self.isactive = true; }); this._submit_button.click(function () {
        self.isactive = false; var content = self._textarea.val(); if (content.length == 0 || content == self._textarea_defaultValue || content == self._textarea_defaultValue2) {
            if (self._ocmttype == "teambuy1")
            { alert(self._textarea_defaultValue); } else
            { alert(self._textarea_defaultValue2); }
            $j(self._textarea)[0].focus(); return;
        } else if (content.length > self._max_content_len)
        { alert("请把评论或提问控制在" + self._max_content_len + "个字内！"); $j(self._textarea)[0].focus(); return; }
        self.sendcomment(content);
    }); this._is_sharetofrd.click(function ()
    { self.isactive = false; }); this._is_sharetofrd.next().click(function ()
    { self.isactive = false; }); this.bindreplylink();
}, "bindreplylink": function () {
    var self = this; var obj = self._comment_content_list.find(".commlist a.replylink"); obj.unbind("click"); obj.bind("click", function () {
        if (!checkLogin())
        { openLoginDlg("index_addreply"); return false; }
        var a = $j(this).parent().next(); var textarea = a.children("textarea"); var bnt1 = a.children("p").children("input.btnt2"); var bnt2 = a.children("p").children("input.btnt2_g"); if (textarea.is(":visible"))
        { a.slideUp(300); } else
        { a.slideDown(300); $j(textarea)[0].focus(); }
        var cid = a.attr("id").split("_")[2]; bnt1.unbind("click"); bnt1.bind("click", function () {
            var content = textarea.val(); if (content.length == 0)
            { alert("请输入回复内容！"); $j(textarea)[0].focus(); return false; } else if (content.length > self._max_content_len)
            { alert("请把回复内容控制在" + self._max_content_len + "个字内！"); $j(textarea)[0].focus(); return false; }
            if (self.b_strlen(content) < 4)
            { alert("请多写几个字吧"); $j(textarea)[0].focus(); return; }
            if (self.isSpeeding())
            { alert("您说话太快了，休息一下吧：）"); $j(textarea)[0].focus(); return; }
            self.sendreply(cid, content); return false;
        }); bnt2.unbind("click"); bnt2.bind("click", function () { textarea.val(""); a.slideUp(300); return false; }); textarea.unbind("keyup"); textarea.bind("keyup", function (e) {
            var keycode = e.keyCode; if (keycode == "13" && e.ctrlKey)
            { bnt1.click(); return false; }
            var content = textarea.val(); var ilen = content.length; if (ilen > self._max_content_len)
            { textarea.val(content.substr(0, self._max_content_len)); }
        }); return false;
    });
}, "deactive": function () {
    if (this.isactive) {
        this._submit_p.slideUp(300); if (this._textarea.val() == "") {
            if (this._ocmttype == "teambuy1")
            { this._textarea.val(this._textarea_defaultValue); } else
            { this._textarea.val(this._textarea_defaultValue2); }
        }
        this.isactive = false;
    }
    if (this._textarea.val() == this._textarea_defaultValue || this._textarea.val() == this._textarea_defaultValue2)
    { this._textarea.addClass('unfocus'); }
}, "getAddModuleContent": function (r) {
    var tmpstr = this._comment_module; tmpstr = tmpstr.replace(/<_OCMT_CTIME_>/g, r.ctime); tmpstr = tmpstr.replace(/<_OCMT_UID_>/g, r.uid); tmpstr = tmpstr.replace(/<_OCMT_USERNAME_>/g, r.real_name); tmpstr = tmpstr.replace(/<_OCMT_LOGO_URL_>/g, r.icon50); tmpstr = tmpstr.replace(/<_OCMT_CONTENT_>/g, r.content); tmpstr = tmpstr.replace(/<_OCMT_CID_>/g, r.cid); tmpstr = tmpstr.replace(/<_OCMT_UID_CLICK_>/g, r.uidclick); if (r.isused)
    { tmpstr = tmpstr.replace(/<_OCMT_FLAG_>/g, "<i class=\"icon ico_xf\"></i>"); } else if (r.isbuy)
    { tmpstr = tmpstr.replace(/<_OCMT_FLAG_>/g, "<i class=\"icon ico_gm\"></i>"); } else
    { tmpstr = tmpstr.replace(/<_OCMT_FLAG_>/g, ""); }
    return tmpstr;
}, "getReplyModuleContent": function (r)
{ var tmpstr = this._reply_module; tmpstr = tmpstr.replace(/<_OCMT_R_CTIME_>/g, r.ctime); tmpstr = tmpstr.replace(/<_OCMT_R_UID_>/g, r.uid); tmpstr = tmpstr.replace(/<_OCMT_R_USERNAME_>/g, r.real_name); tmpstr = tmpstr.replace(/<_OCMT_R_LOGO_URL_>/g, r.icon25); tmpstr = tmpstr.replace(/<_OCMT_R_CONTENT_>/g, r.content); tmpstr = tmpstr.replace(/<_OCMT_UID_CLICK_>/g, r.uidclick); return tmpstr; }, "addcomment": function (r) {
    var newcontent = this.getAddModuleContent(r); if ($j(this._comment_content_list).html().trim() == "")
    { $j(this._comment_content_list).html(newcontent); } else {
        var firstobj = this._comment_content_list.children(".commitem:first").first(); if (!$j.isEmptyObject(firstobj))
        { firstobj.before(newcontent); }
    }
    if (this._ocmttype == "teambuy1")
    { this._textarea.val(this._textarea_defaultValue); } else
    { this._textarea.val(this._textarea_defaultValue2); }
    this.deactive(); var firstobj = this._comment_content_list.children(".commitem:first").first(); firstobj.slideDown(600); var inobj = firstobj.children(".commitmein:first"); $j(inobj).addClass("hover"); setTimeout(function () { $j(inobj).removeClass("hover"); }, 1000); this.bindreplylink();
}, "addreply": function (r) {
    var pobj = this._comment_content_list.find("#reply_div_" + r.objid); var obj = pobj.prev().prev(); var newcontent = this.getReplyModuleContent(r); pobj.children("textarea").val(""); pobj.slideUp(300); if ($j(obj).html().trim() == "")
    { $j(obj).html(newcontent); } else {
        var firstobj = obj.children(".recommitem").last(); if (typeof (firstobj) != "undefined")
        { firstobj.after(newcontent); }
    }
    var firstobj = obj.children(".recommitem:last").last(); firstobj.slideDown(600); this.bindreplylink();
}, "sendcomment": function (content) {
    var self = this; if (content.length == 0) {
        if (self._ocmttype == "teambuy1")
        { alert(self._textarea_defaultValue); } else
        { alert(self._textarea_defaultValue2); }
        $j(self._textarea)[0].focus(); return;
    }
    if (self.b_strlen(content) < 4)
    { alert("请多写几个字吧"); $j(self._textarea)[0].focus(); return; }
    if (self.isSpeeding())
    { alert("您说话太快了，休息一下吧：）"); $j(self._textarea)[0].focus(); return; }
    $j(self._textarea)[0].blur(); var is_sharetofrd = 0; if ($j(self._is_sharetofrd).attr("checked"))
    { is_sharetofrd = 1; }
    $j.ajax({ 'type': 'POST', 'dataType': 'json', 'url': g_tmbpath + '/ajax_ocmt_send.php', 'data': 'objid=' + self._iid + '&ocmttype=' + self._ocmttype + '&content=' + encodeURIComponent(content) + '&sharetofrd=' + is_sharetofrd + '&t=' + Math.random(), 'success': function (r) {
        if (r && r.ret == 1)
        { self.isactive = true; self.addcomment(r); } else
        { alert("发表失败"); }
    }, 'error': function () { alert("网络出现错误，请稍后再试"); }
    });
}, "sendreply": function (ocmt_id, content) {
    var self = this; if (content.length == 0) {
        if (self._ocmttype == "teambuy1")
        { alert(self._textarea_defaultValue); } else
        { alert(self._textarea_defaultValue2); }
        $j(self._textarea)[0].focus(); return;
    }
    $j.ajax({ 'type': 'POST', 'dataType': 'json', 'url': g_tmbpath + '/ajax_ocmt_send.php', 'data': 'objid=' + self._iid + '&ocmttype=' + self._ocmttype + '&thread_cid=' + ocmt_id + '&content=' + encodeURIComponent(content) + '&t=' + Math.random(), 'success': function (r) {
        if (r && r.ret == 1)
        { self.addreply(r); } else
        { alert("发表失败"); }
    }, 'error': function () { alert("网络出现错误，请稍后再试"); }
    });
}, "goUserHome": function (uid) {
    if (uid == "")
    { return; }
    var url = "http://" + this._homehost + "/home/?uid=" + uid; window.open(url, "");
}, "gotoPage": function (type, objid, start) {
    var self = this; $j.ajax({ 'type': 'POST', 'dataType': 'json', 'url': g_tmbpath + '/ajax_ocmt_getlist.php', 'data': 'objid=' + self._iid + '&ocmttype=' + self._ocmttype + '&start=' + encodeURIComponent(start) + '&t=' + Math.random(), 'success': function (r) {
        if (r && r.ret == 1) {
            if (r.content && r.content != "")
            { $j(self._comment_content_list).html(r.content); self.bindreplylink(); window.location.hash = "comment_ap"; }
            if (r.page && r.page != "")
            { $j(self._page_block).html(r.page); }
        } else
        { return; }
    }, 'error': function () { alert("网络出现错误，请稍后再试"); }
    });
}, "myfocus": function ()
{ $j(this._textarea)[0].focus(); }, "b_strlen": function (fData) {
    var intLength = 0; for (var i = 0; i < fData.length; i++) {
        if ((fData.charCodeAt(i) < 0) || (fData.charCodeAt(i) > 255))
            intLength = intLength + 2; else
            intLength = intLength + 1;
    }
    return intLength;
}, "isSpeeding": function () {
    var d = new Date(); var t = d.getTime(); var lt = getCookie("addcomment_lastaddtime"); lt = lt == "" ? 0 : lt; if (t - lt < 30 * 1000)
    { return true; }
    setCookie("addcomment_lastaddtime", t); return false;
}
}; TEAMBUY.SSO = { "_rcode": "", "_container": "dialog", "_callback": null, "_logouturl": "", "init": function (token, from) { TEAMBUY.SSO._logouturl = g_tmbpath + "/index.php"; g_from = from || ""; KxSso.init(token, "sso_container"); }, "setMode": function (container, callback) { TEAMBUY.SSO._container = container; TEAMBUY.SSO._callback = callback; }, "setLogoutUrl": function (url) { TEAMBUY.SSO._logouturl = g_tmbpath + "/" + url; }, "login": function () { $j(".box-login").hide(); $j(".span-login").hide(); if (TEAMBUY.SSO._checkLogin()) { var act = $j("input[name=act]").val(); var pwd = $j("input[name=pwd]").val(); g_email = act; var params = { "account": act, "password": pwd, "rcode": TEAMBUY.SSO._rcode, "code": $j("input[name=code]").val() }; KxSso.login(params, TEAMBUY.SSO.loadLogin); } }, "logout": function () { KxSso.logout(TEAMBUY.SSO.loadLogout); }, "_showError": function (reason) { $j.ajax({ 'type': 'POST', 'url': g_tmbpath + '/ajax_loginerror.php', 'data': 'account=' + encodeURIComponent(g_email) + '&type=&gtime=' + g_stime + '&genssoip=' + g_tmbip + '&memo=' + encodeURIComponent(reason), 'dataType': "json", 'success': function (b) { }, 'error': function () { } }); switch (reason) { case "accountRequired": $j("#needact").show(300); break; case "accountNotExists": case "accountDeleted": $j("#wrongact").show(300); break; case "accountBanned": $j("#banact").show(300); break; case "passwordRequired": $j("#needpwd").show(300); break; case "passwordWrong": $j("#wrongpwd").show(300); break; case "passwordWrong2": $j("#wrongpwd2").show(300); break; case "captchaRequired": $j("#wrongcap").show(300); TEAMBUY.SSO._loadCaptcha(); break; case "captchaWrong": $j("#wrongcap").show(300); TEAMBUY.SSO._loadCaptcha(); break; case "ipAddressWrong": $j("#banip").show(300); break; default: $j("#unkown").show(300); break; } }, "_showAlertError": function (reason) { switch (reason) { case "accountRequired": alert('请输入账号！'); break; case "accountNotExists": case "accountDeleted": alert('账号不太对吧！重试一次？'); break; case "accountBanned": alert('当前账号暂时无法登录'); break; case "passwordRequired": alert('请输入密码！'); break; case "passwordWrong": alert('密码不对！请检查“Caps Lock”或“Num Lock”键。'); break; case "passwordWrong2": alert('密码错误次数过多，请15分钟后再进行尝试。'); break; case "captchaRequired": alert('请输入验证码！'); TEAMBUY.SSO._loadCaptcha(); break; case "captchaWrong": alert('验证码不对吧！对应繁体汉字也可验证哟！'); TEAMBUY.SSO._loadCaptcha(); break; case "ipAddressWrong": alert('暂时无法从当前IP登录！'); break; default: alert('登录过程发生未知错误！'); break; } }, "_checkLogin": function () {
    var act = $j("input[name=act]"); var dfv = "邮箱/手机号/其他用户名"; if (act.val() == "" || act.val() == dfv) {
        if (TEAMBUY.SSO._container == "page")
            $j("#needact").show(); else
            $j("#needact").show(300); act.focus(); return false;
    }
    var pwd = $j("input[name=pwd]"); if (pwd.val() == "") {
        if (TEAMBUY.SSO._container == "page")
            $j("#needpwd").show(); else
            $j("#needpwd").show(300); pwd.focus(); return false;
    }
    var cod = $j("input[name=code]"); if ("none" != $j("#logincode").css("display") && cod.val() == "") {
        if (TEAMBUY.SSO._container == "page")
            $j("#needcap").show(); else
            $j("#needcap").show(300); cod.focus(); return false;
    }
    return true;
}, "loadLogin": function (data) {
    try {
        if ("undefined" == typeof (data.session)) { if (TEAMBUY.SSO._container == "page") { TEAMBUY.SSO._showAlertError(data.error.reason); } else { TEAMBUY.SSO._showError(data.error.reason); $j("#bnt_submit").attr("readonly", false); } } else {
            g_verify = data.session.verify; if (TEAMBUY.SSO._container == "page" && typeof TEAMBUY.SSO._callback == "function")
            { TEAMBUY.SSO._callback(); } else
            { sso_loginsucc(g_from); new parent.dialog().reset(); }
        }
    } catch (e) { }
}, "_loadCaptcha": function () { TEAMBUY.SSO._rcode = Math.random(); var capurl = KxSso.getCaptcha(TEAMBUY.SSO._rcode); $j("#logincode").show().find("img").attr("src", capurl); }, "loadLogout": function (data) {
    if (data.session)
    { alert("退出失败：" + data.error.reason); } else
    { $j.ajax({ 'type': 'POST', 'url': g_tmbpath + '/logout.php', 'data': '', 'dataType': "json", 'success': function () { top.location.href = TEAMBUY.SSO._logouturl; }, 'error': function () { top.location.href = TEAMBUY.SSO._logouturl; } }); }
}, "getStatus": function () { KxSso.getStatus(TEAMBUY.SSO.getStatusLoad); }, "getStatusLoad": function (data) {
    if (data.session)
    { g_verify = data.session.verify; sso_loginsucc(""); }
}
}; TEAMBUY.REG = { "_rcode": "", "_repchk": true, "_pwdchk": true, "_actchk": true, "_cfmchk": true, "regurl": "", "wizardurl": "", "init": function (token, wizardurl) {
    TEAMBUY.REG.regurl = g_tmbpath + "/reg_dlg.php"; TEAMBUY.REG.wizardurl = g_tmbpath + "/wizard_dlg.php"; KxReg.init(token, "sso_container", function () { TEAMBUY.REG.loadCaptcha(); }); if (wizardurl)
    { TEAMBUY.REG.wizardurl = g_tmbpath + "/" + wizardurl; }
    TEAMBUY.REG._bindCheck();
}, "dialog": function () { openWindow(TEAMBUY.REG.regurl, 525, 415, '注册', 0); }, "loadCaptcha": function () { TEAMBUY.REG._rcode = Math.random(); var capurl = KxReg.getCaptcha(TEAMBUY.REG._rcode); $j("dd.yzm img").attr("src", capurl).show(); }, "doreg": function () { $j("input[type=submit]").attr("disabled", "disabled"); var act = $j("input[name=act]").val(); var pwd = $j("input[name=pwd]").val(); var cod = $j("input[name=code]").val(); var params = { "account": act, "password": pwd, "code": cod, "rcode": TEAMBUY.REG._rcode }; if (TEAMBUY.REG._checkReg()) { TEAMBUY.REG.account = act; KxReg.reg(params, TEAMBUY.REG._loadReg); } else { $j("input[type=submit]").removeAttr("disabled"); } }, "_checkAccount": function () {
    var act = $j("input[name=act]"); $j(".chktip").hide(); if (act.val() == "") { TEAMBUY.REG._actchk = true; return; }
    if (act.val().length < 6) { act.attr("class", "l it3"); $j("#actwarn").show(); $j("#actformat").show(); TEAMBUY.REG._actchk = false; } else { TEAMBUY.REG._actchk = true; KxReg.regcheck("account", { account: act.val() }, function (data) { if ("undefined" != typeof (data.error)) { $j(".chktip").hide(); act.attr("class", "l it3"); $j("#actwarn").show(); TEAMBUY.REG._showError(data.error.reason); TEAMBUY.REG._actchk = false; } else { $j("#actwarn").hide(); $j("#actok").show(); TEAMBUY.REG._actchk = true; } }); }
}, "_checkPassword": function () {
    var pwd = $j("input[name=pwd]"); $j(".chktip").hide(); if (pwd.val() == "") { $j("#pwdwarn").hide(); TEAMBUY.REG._pwdchk = true; return; }
    if (pwd.val().length < 6) { pwd.attr("class", "l it3"); $j("#pwdwarn").show(); $j("#pwdshort").show(); TEAMBUY.REG._pwdchk = false; } else { $j("#pwdwarn").hide(); $j("#pwdok").show(); TEAMBUY.REG._pwdchk = true; }
}, "_checkRepassword": function () {
    var rep = $j("input[name=repwd]"); $j(".chktip").hide(); if (rep.val() == "") { TEAMBUY.REG._repchk = true; $j("#repwdwarn").hide(); return; }
    if (rep.val().length < 6) { rep.attr("class", "l it3"); $j("#repwdwarn").show(); TEAMBUY.REG._repchk = false; } else { $j("#repwdwarn").hide(); TEAMBUY.REG._repchk = true; }
}, "_checkPwdConfirm": function () {
    var pwd = $j("input[name=pwd]"); var rep = $j("input[name=repwd]"); if (rep.val() != "" && rep.val() != pwd.val()) { $j("#repwdwrong").show(); rep.attr("class", "l it3"); TEAMBUY.REG._cfmchk = false; $j("#repwdwarn").show(); $j("#repwdok").hide(); } else {
        if (rep.val() != "" && TEAMBUY.REG._repchk) { pwd.attr("class", "it1"); rep.attr("class", "it1"); $j("#repwdok").show(); }
        TEAMBUY.REG._cfmchk = true;
    }
}, "_bindCheck": function () { var act = $j("input[name=act]"); var pwd = $j("input[name=pwd]"); var rep = $j("input[name=repwd]"); var cod = $j("input[name=code]"); act.unbind().focus(function () { $j("#actwarn").hide(); $j("#actok").hide(); $j("dd.account .chktip").hide(); if (TEAMBUY.REG._pwdchk && TEAMBUY.REG._repchk && TEAMBUY.REG._cfmchk) { $j("#actsug").show(); } }).blur(function () { TEAMBUY.REG._checkAccount(); if (TEAMBUY.REG._actchk) { TEAMBUY.REG._checkRepassword(); TEAMBUY.REG._checkPwdConfirm(); if (TEAMBUY.REG._cfmchk) { TEAMBUY.REG._checkPassword(); } } }); pwd.unbind().focus(function () { $j("#pwdok").hide(); $j("#pwdwarn").hide(); $j("#repwdwrong").hide(); $j("dd.pwd .chktip").hide(); if (TEAMBUY.REG._actchk && TEAMBUY.REG._repchk && TEAMBUY.REG._cfmchk) { $j("#pwdsug").show(); } }).blur(function () { TEAMBUY.REG._checkPassword(); TEAMBUY.REG._checkRepassword(); TEAMBUY.REG._checkPwdConfirm(); if (TEAMBUY.REG._cfmchk) { TEAMBUY.REG._checkPassword(); if (TEAMBUY.REG._pwdchk) { TEAMBUY.REG._checkAccount(); } } }).keyup(function () { TEAMBUY.REG._chkPwdStrength(); }); rep.unbind().focus(function () { $j("#repwdok").hide(); $j("#repwdwarn").hide(); $j("dd.repwd .chktip").hide(); }).blur(function () { TEAMBUY.REG._checkRepassword(); TEAMBUY.REG._checkPwdConfirm(); if (TEAMBUY.REG._cfmchk) { TEAMBUY.REG._checkPassword(); if (TEAMBUY.REG._pwdchk) { TEAMBUY.REG._checkAccount(); } } }); cod.unbind().focus(function () { $j("dd.yzm .chktip").hide(); }); }, "_checkReg": function () {
    $j(".chktip").hide(); var act = $j("input[name=act]"); if (act.val().length < 6) { act.attr("class", "l it3"); $j("#actwarn").show(); $j("#actformat").show(); return false; }
    var pwd = $j("input[name=pwd]"); if (pwd.val().length < 6) { pwd.attr("class", "l it3"); $j("#pwdshort").show(); $j("#pwdwarn").show(); return false; }
    var repwd = $j("input[name=repwd]"); if (repwd.val().length < 6 || repwd.val() != pwd.val()) {
        repwd.attr("class", "l it3"); $j("#repwdwarn").show(); if (repwd.val().length >= 6) { $j("#repwdwrong").show(); }
        return false;
    }
    var cod = $j("input[name=code]"); if (cod.val() == "") { $j("#codeneed").show(); return false; }
    return true;
}, "_loadReg": function (data) {
    if ("undefined" != typeof (data.session)) {
        TEAMBUY.verify = data.session.verify; var param = { "verify": data.session.verify, "name": TEAMBUY.REG.account, "isreg": 1 }; if (parent.TEAMBUY.REG.from && parent.TEAMBUY.REG.invite) { param = { "verify": data.session.verify, "name": TEAMBUY.REG.account, "isreg": 1, "from": parent.TEAMBUY.REG.from, "invite": parent.TEAMBUY.REG.invite }; }
        document.location.href = TEAMBUY.REG.wizardurl;
    } else { $j("input[type=submit]").removeAttr("disabled"); TEAMBUY.REG._showError(data.error.reason); }
}, "_showError": function (reason) {
    switch (reason)
    { case "accountTaken": $j("#actexist").show(); $j("#actwarn").show(); $j("input[name=act]").attr("class", "l it3"); break; case "accountWrong": case "accountRequired": $j("#actformat").show(); $j("#actwarn").show(); $j("input[name=act]").attr("class", "l it3"); break; case "captchaRequired": $j("#codeneed").show(); TEAMBUY.REG.loadCaptcha(); break; case "captchaWrong": $j("#codewrong").show(); TEAMBUY.REG.loadCaptcha(); break; case "passwordRequired": case "passwordTooShort": $j("input[name=pwd]").attr("class", "l it3"); $j("#pwdwarn").show(); $j("#pwdshort").show(); break; case "captchaForbidden": $j("#codeforb").show(); break; case "ipForbidden": $j("#banip").show(); break; default: $j("#unkown").show(); break; }
}, "_chkPwdStrength": function () {
    var rate = 5; var col = "#c00"; var tip = ""; var pwd = $j("input[name=pwd]").val(); if (pwd.search(/[a-z]/g) != -1) { rate -= 1; }
    if (pwd.search(/[A-Z]/g) != -1) { rate -= 1; }
    if (pwd.search(/[0-9]/g) != -1) { rate -= 1; }
    if (pwd.search(/[^0-9A-Za-z]/g) != -1) { rate -= 1; }
    if (pwd.length < 6) { rate = 5; }
    switch (rate) { case 1: col = "#29b520"; tip = "极佳"; break; case 2: col = "#36c"; tip = "强"; break; case 3: col = "#f60"; tip = "一般"; break; case 4: col = "#c00"; tip = "差"; break; }
    $j("#pwdsug img").attr("src", "http://img1.kaixin001.com.cn/i/mmqd_" + rate + ".gif"); $j("#pwdsug b").css("color", col).html(tip);
}
}; TEAMBUY.COUNTDOWN = { "init": function () { this._arrobj = []; var self = this; $j.each($j("span.exptime_tip"), function (i, o) { var d = parseInt($j(o).html()); var next = $j(o).next(); self._arrobj.push({ countDownId: o, endTime: d, next: next }); }); this._total = this._arrobj.length; TEAMBUY.COUNTDOWN.DownCount(); }, "DownCount": function () {
    var now = new Date(); for (var k = 0; k < this._total; k++) {
        var o = this._arrobj[k].countDownId; var d = parseInt(this._arrobj[k].endTime); var next = this._arrobj[k].next; var diff = d - now.getTime() / 1000; if (Math.floor(diff) > 0)
        { next.html(Math.floor(diff / (60 * 60 * 24)) + '天' + Math.floor(diff / (60 * 60)) % 24 + '小时' + Math.floor(diff / (60)) % 60 + '分' + Math.floor(diff) % 60 + '秒'); }
        else
        { next.html('抢购时间已过，谢谢您的关注!'); }
    }
    window.setTimeout("TEAMBUY.COUNTDOWN.DownCount()", 1000);
}
}; TEAMBUY.IMGLOADSYNC = { "init": function () { this._objs = $j(".teambuy_ysjzloadimg"); $j(window).scroll(function () { TEAMBUY.IMGLOADSYNC.imgload(); }); TEAMBUY.IMGLOADSYNC.imgload(); }, "imgload": function () { this._objs.each(function () { typeof $j(this).attr("imgsrc") != "undefined" && $j(this).offset().top < $j(document).scrollTop() + $j(window).height() && $j(this).attr("src", $j(this).attr("imgsrc")).removeAttr("imgsrc"); }) } }
function isCanUseActive()
{ var agt = window.navigator.userAgent.toLowerCase(); if (agt.indexOf("msie") >= 0) return 1; if (agt.indexOf("firefox") >= 0) return 1; return 0; }
function checkLogin()
{ return g_tmbvuid != ""; }
function updateNewsHistory(hash)
{ clickDirect(hash, true); return; }
function sso_login_direct(from) {
    if (from == "") {
        url = top.location.href; if (url.indexOf("index.php") != -1 || url.indexOf("/?") != -1) {
            if (url.indexOf("?") != -1)
            { top.location.href = url + '&t=' + Math.random(); } else
            { top.location.href = url + '?t=' + Math.random(); }
        } else
        { top.location.reload(true); }
    } else if (from == "share_kaixin" || from == "addcomment" || from == "share_msn" || from == "share_sina" || from == "share_tqq") {
        url = top.location.href; if (url.indexOf("?") != -1)
        { top.location.href = url + '&t=' + Math.random() + "#" + from; } else
        { top.location.href = url + '?t=' + Math.random() + "#" + from; }
    } else if (from == "detail_share")
    { updateNewsHistory(from); top.location.reload(true); } else if (from == "mybuy")
    { top.location.href = g_tmbpath + '/mybuy.php'; } else if (from.substr(0, 6) == "djqbuy" && from.length > 3)
    { var tmp = from.substr(6); top.location.href = g_tmbpath + '/buy.php?showdjq=1&iid=' + tmp; } else if (from.substr(0, 11) == "notloginbuy" && from.length > 3)
    { var tmp = from.substr(11); top.location.href = g_tmbpath + '/submit_buy.php?tmpoid=' + tmp; } else if (from == "survey")
    { top.location.href = g_tmbpath + '/survey.php'; } else if (from == "invite")
    { top.location.href = g_tmbpath + '/invite.php'; } else
    { top.location.href = g_tmbpath + '/' + from; }
}
function sso_loginsucc(from)
{ $j.ajax({ 'type': 'POST', 'url': g_tmbpath + '/ajax_nkxuser_setdjq.php', 'data': '', 'dataType': "json", 'success': function (b) { sso_login_direct(from); }, 'error': function () { sso_login_direct(from); } }); }
function openLoginDlg(from)
{ var from = from || ""; openWindow(g_tmbpath + '/login_dlg.php?from=' + from + '&t=' + Math.random(), 525, 415, '', 0); }
function openRegDlg()
{ openWindow(g_tmbpath + '/reg_dlg.php?t=' + Math.random(), 595, 415, '', 0); }
var m_fs_data = []; function sendReveuids() {
    var hash = $H(); for (var i = 0, j = m_fs_data.length; i < j; i++) {
        if (m_fs_data[i].type == "static")
        { hash.set(m_fs_data[i].uid, 1); }
    }
    return hash.keys();
}
function tfs_selectFriend() {
    var len = fs_allfrienddata.length; for (var i = 0; i < len; i++) {
        if ($("checkbox" + i).checked) {
            var obj = fs_allfrienddata[i]; obj.type = "static"; if (!fs_checkCount(true))
            { break; }
            fs_data[fs_data.length] = fs_allfrienddata[i];
        }
    }
    var fs_data2 = []; var j = 0; len = fs_data.length; for (var i = 0; i < len; i++) {
        if (fs_data[i].type == "active")
        { continue; }
        fs_data2[j] = fs_data[i]; j++;
    }
    fs_data = fs_data2; m_fs_data = fs_data2; fs_data = []; fs_data2 = []; fs_dirty = false; $(fs_fsg_nr).style.display = "none"; $(fs_ptrimg).innerHTML = '<img src="http://img1.kaixin001.com.cn/i/xx_xx1.gif" class="cp" onmouseover="this.src=\'http://img1.kaixin001.com.cn/i/xx_xx2.gif\';" onmouseout="this.src=\'http://img1.kaixin001.com.cn/i/xx_xx1.gif\';" alt="选择好友" />';
}
function inviteF()
{ var uids = sendReveuids(); window.open(g_tmbpath + "/invite.php?iid={_IID_}&t={_PAGE_RAND_}&tuid=" + uids, "invite", ""); }
function wordsuggest_selafter(obj)
{ alert("test"); }; function CheckEmail(email) {
    if ((email.length > 128) || (email.length < 6))
    { return false; }
    var format = /^[A-Za-z0-9+]+[A-Za-z0-9\.\_\-+]*@([A-Za-z0-9\-]+\.)+[A-Za-z0-9]+$/; if (!email.trim().match(format))
    { return false; }
    return true;
}
function t_dealmaybuy(content, obj) {
    if (content.trim().length <= 0 || content == "告诉我们你想团的东西吧")
    { alert("请输入想团购的东西！"); return; }
    $j.ajax({ 'type': 'POST', 'url': g_tmbpath + '/ajax_maybuy.php', 'data': 'content=' + content + "&tm_uid=" + g_tm_uid + "&t=" + Math.random(), 'dataType': "json", 'success': function (b) {
        if (b) {
            if (b.ret == 1)
            { obj.val(""); $tmpobj = $j("#id_maybuy_tips"); $tmpobj.show(); setTimeout(function () { $tmpobj.hide(); }, 3000); } else
            { alert(b.msg); }
        }
        else
        { alert("提交失败，请稍后重试！"); }
    }, 'error': function (b) { alert("网络失败，请稍后重试！"); }
    });
}
function OpenSurvey() {
    if (!checkLogin())
    { openLoginDlg('survey'); return; }
    window.open(g_tmbpath + '/survey.php');
}
function OpenInvite() {
    if (!checkLogin())
    { openLoginDlg('invite'); return; }
    window.open(g_tmbpath + '/invite.php');
}
function TabTopItem(index) {
    var url = ""; switch (index)
    { case 2: url = "lastlist.php"; break; case 3: url = "mybuy.php"; break; case 4: url = "navi.php"; break; case 5: url = "help_tutorial.php"; break; default: url = "index.php"; break; }
    if (index == 3 && !checkLogin())
    { openLoginDlg('mybuy'); return; }
    window.location.href = g_tmbpath + "/" + url;
}
function mm_copyToClipboard(txt, title) {
    if (window.clipboardData)
    { window.clipboardData.clearData(); window.clipboardData.setData("Text", title + txt); return true; }
    else if (navigator.userAgent.indexOf("Opera") != -1)
    { return false; }
    else if (window.netscape) {
        try
{ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }
        catch (e)
{ return false; }
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); if (!clip)
            return false; var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); if (!trans)
            return false; trans.addDataFlavor('text/unicode'); var str = new Object(); var len = new Object(); var str = Components.classes['@mozilla.org/supports-string;1'].createInstance(Components.interfaces.nsISupportsString); var copytext = title + txt; str.data = copytext; trans.setTransferData("text/unicode", str, copytext.length * 2); var clipid = Components.interfaces.nsIClipboard; if (!clip)
            return false; clip.setData(trans, null, clipid.kGlobalClipboard); return true;
    }
}
function local_copy_clip(url, title) {
    if (mm_copyToClipboard(url, title))
    { alert("链接已复制，你可以将链接通过MSN/QQ发送给好友，邀请好友来购买！"); } else
    { alert("您使用的浏览器不支持此复制功能，请使用Ctrl+C或鼠标右键手动复制。"); }
}
function showKxDialog(url)
{ var t = $j("#id_showkxdialog_div"); t.html('<iframe src="' + url + '" scrolling="yes"  style="display:none"></iframe>'); }
function clickUrl(id)
{ window.open(g_tmbpath + "/to_third_url.php?id=" + encodeURIComponent(id) + "&tm_uid=" + g_tm_uid); }
TEAMBUY.SEARCH = { "submit": function (form) {
    var v = $j.trim(form.keys.value); if (v == form.keys.title) { form.keys.value = ''; form.keys.focus(); return false; }
    if (v == null || v.length == 0) { form.keys.value = ''; form.keys.focus(); return false; }
    var special_str = "￥#$~!@%^&*();'\"?><[]{}\\|,:/=+—“”‘"; var hasCommonChar = false; for (var i = 0; i < v.length; i++) {
        if (special_str.indexOf(v.charAt(i)) == -1)
        { hasCommonChar = true; continue; }
    }
    if (!hasCommonChar)
    { alert('抱歉，您输入的内容“' + v + '”不在查询范围内。'); form.keys.value = ''; form.keys.focus(); return false; }
    form.keys.value = v; return true;
}
}; TEAMBUY.TIME = { "getLeftTimeStr": function (lefttime) {
    if (lefttime > 0) {
        lefttime = lefttime - 1; var second = Math.floor(lefttime % 60); var minite = Math.floor((lefttime / 60) % 60); var hour = Math.floor((lefttime / 3600) % 24); var day = Math.floor((lefttime / 3600) / 24); var content = ""; if (day > 0)
        { content = day + "天"; }
        if (hour > 0 || content != "")
        { content += hour + "小时"; }
        if (minite > 0 || content != "")
        { content += minite + "分"; }
        content += second + "秒"; return content;
    }
    else
    { return '已经结束'; }
}
}; TEAMBUY.MSG = { "read": function (mid)
{ $j.ajax({ 'type': 'POST', 'dataType': 'json', 'url': g_tmbpath + '/ajax_msg_action.php', 'data': 'mid=' + mid + '&type=read&t=' + Math.random() }); }, "del": function (mid)
{ $j.ajax({ 'type': 'POST', 'dataType': 'json', 'url': g_tmbpath + '/ajax_msg_action.php', 'data': 'mid=' + mid + '&type=del&t=' + Math.random() }); }
}; function resetMainNavStyle()
{ $j('.mainnav li').attr('class', ''); }
var g_dialog_sWordTitle = ''; function openTuanAlert(_sWord, _sButton, _sWidth, _sHeight, _sTitle, _sAction, _sButton2, _sAction2)
{ return _openTuanAlert('', _sWord, _sButton, 'alert', _sWidth, _sHeight, _sTitle, _sAction, "", _sButton2, _sAction2); }
function openTuanNotice(_sWordTitle, _sWord, _sButton, _sWidth, _sHeight, _sTitle, _sAction, _sButton2, _sAction2)
{ return _openTuanAlert(_sWordTitle, _sWord, _sButton, 'notice', _sWidth, _sHeight, _sTitle, _sAction, "", _sButton2, _sAction2); }
function _openTuanAlert(_sWordTitle, _sWord, _sButton, _sType, _sWidth, _sHeight, _sTitle, _sAction, _excss, _sButton2, _sAction2)
{ var oEdit = new dialog(_sWidth, _sHeight, _sTitle); oEdit.init(); oEdit.show(); var framename = "iframe_parent_" + g_iframeno++; g_dialog_sWordTitle = _sWordTitle; g_dialog_sWord = _sWord; g_dialog_sButton = _sButton; g_dialog_sAction = _sAction; g_dialog_excss = _excss; g_dialog_sButton2 = _sButton2; g_dialog_sAction2 = _sAction2; var openIframe = "<iframe width='100%' height='100%' name='" + framename + "' id='" + framename + "' src='" + g_tmbpath + "/blank_dlg.php' frameborder='0' scrolling='no' onload=\"javascript:_openTuanAlert_write('" + framename + "','" + _sType + "')\"></iframe>"; myInnerHTML('dialogBody', openIframe); }
function _openTuanAlert_write(framename, stype) {
    var _sTitle = g_dialog_sWordTitle; var _sWord = g_dialog_sWord; var _sButton = g_dialog_sButton; var _sAction = g_dialog_sAction; var _sButton2 = g_dialog_sButton2; var _sAction2 = g_dialog_sAction2; var _excss = g_dialog_excss; var iframe = window.frames[framename]; if (_excss && _excss.length) {
        try
{ iframe.document.getElementsByTagName('head').item(0).innerHTML += '<style>' + _excss + '</style>'; }
        catch (exc)
{ var ss = iframe.document.createElement('style'); ss.type = "text/css"; ss.styleSheet.cssText = _excss; iframe.document.getElementsByTagName('head').item(0).appendChild(ss); }
    }
    if (_sAction == undefined)
    { _sAction = "new parent.dialog().reset();"; }
    if ('notice' == stype)
    { iframe.document.body.innerHTML = alertNoticeHtml(_sTitle, _sWord, _sButton, _sAction, _sButton2, _sAction2); } else
    { iframe.document.body.innerHTML = alertTuanHtml(_sWord, _sButton, _sAction, _sButton2, _sAction2); }
}
function alertNoticeHtml(_sTitle, _sWord, _sButton, _sAction, _sButton2, _sAction2) {
    var html = '<div class="success_box" style="width: 250px; margin-top: 40px;">\
     <span class="icon ico_succ fl"></span>\
     <p style="margin-bottom: 5px;"><strong class="f14">' + _sTitle + '</strong></p>\
     <p>' + _sWord + '</p>\
    </div>\
    <div style="margin-top: 20px;" class="tac">\
     <span class="btn_yes"><input type="button" style="width: 50px;" onclick="javascript:' + _sAction + '" onmouseout="this.className=\'\'" onmouseover="this.className=\'hover\'" value="' + _sButton + '" class=""></span>\
    </div>'; return html;
}
function alertTuanHtml(_sWord, _sButton, _sAction, _sButton2, _sAction2) {
    var html = '<div class="framebox">\
   <div class="noticebox" style=" width:270px; margin-top:40px;">\
    <p style="padding-top:5px;">' + _sWord + '</p>\
   </div>\
   <div class="btnarea">\
    <span class="btn_cancel"><input type="button"  onclick="javascript:' + _sAction + '"  value="' + _sButton + '" onmouseover="this.className=\'hover\'" onmouseout="this.className=\'\'" style="width:70px" /></span>\
   </div>\
  </div>'; return html;
}
function tm_checkMobile(mobile) {
    if (mobile == "")
    { return false; }
    else if (mobile.length != 11)
    { return false; }
    else if (isNaN(mobile))
    { return false; }
    else if (-1 != mobile.indexOf("."))
    { return false; }
    else if (mobile.substr(0, 1) != 1)
    { return false; }
    return true;
}
function tm_checkPostCode(postcode) {
    if (postcode == '')
    { return false; }
    else if (postcode.length != 6)
    { return false; }
    else if (isNaN(postcode))
    { return false; }
    for (var i = 0; i < postcode.length; i++) {
        var codestr = postcode.charAt(i); if (isNaN(parseInt(codestr)))
        { return false; }
    }
    return true;
}
function add_starfriends(uid, fkey) {
    if (!checkLogin())
    { $j('.follow #add_notice').hide(); openLoginDlg(''); return; }
    if (g_staruser_last_friend) {
        if (g_staruser_last_friend == uid)
        { return; }
    }
    g_staruser_last_friend = uid; $j.ajax({ 'type': 'POST', 'url': g_tmbpath + '/addfan.php', 'data': 'touid=' + fkey + "&fkey=" + fkey + "&quick=1&fans_from=fans_from_tuan&fromuid=" + uid + "&r=" + Math.random(), 'dataType': "json", 'success': function (b) {
        if (b) {
            if (b.succ == 1)
            { $j('.follow #add_notice').hide().next().show().fadeOut(1000); } else
            { $j('.follow #add_notice').hide(); alert("关注失败，请稍后重试！"); }
        }
        else
        { $j('.follow #add_notice').hide(); alert("关注失败，请稍后重试！"); }
    }, 'error': function () { $j('.follow #add_notice').hide(); openWindow(g_tmbpath + '/addfanerror_dlg.php', 430, 235, '关注开心团购'); }
    });
}
