﻿String.prototype.Format = function () { var tmpStr = this; var iLen = arguments.length; for (var i = 0; i < iLen; i += 1) tmpStr = tmpStr.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]); return tmpStr; };
String.prototype.format = function () {
    var args = arguments;
    return this.replace(/\{(\d+)\}/g, function (m, i, o, n) {
        return args[i];
    });
};
function subString(str, len, hasDot) {//截取字符串 包含中文处理 (串,长度,增加...)
    var newLength = 0, newStr = "", chineseRegex = /[^\x00-\xff]/g, singleChar = "";
    var strLength = str.replace(chineseRegex, "**").length;
    for (var i = 0; i < strLength; i++) {
        singleChar = str.charAt(i).toString();
        if (singleChar.match(chineseRegex) != null) newLength += 2;
        else newLength++;
        if (newLength > len) break;
        newStr += singleChar;
    };
    if (hasDot && strLength > len) newStr += "...";
    return newStr;
};
if (!window.JTTMasterPage) window.JTTMasterPage = { Extend: function (dest, source, replace) { for (prop in source) { if (replace == false && dest[prop] != null) continue; dest[prop] = source[prop]; }; return dest; } };
function gb(objName) {
    if (document.getElementById) return document.getElementById(objName);
    else if (document.layers) return eval("document.layers['" + objName + "']");
    else return eval('document.all.' + objName);
};
function SetWinHeight(obj) {
    var win = obj;
    if (document.getElementById) {
        if (win && !window.opera) {
            if (win.contentDocument && win.contentDocument.body.offsetHeight) {
                win.height = win.contentDocument.body.offsetHeight;
                win.width = win.contentDocument.body.offsetWidth;
            }
            else if (win.Document && win.Document.body.scrollHeight) {
                win.height = win.Document.body.scrollHeight + "30px";
                win.width = win.Document.body.scrollWidth;
            }
        }
    }
}

function showPMD(F, E, A, D) { var C = gb(A); C.innerHTML = F[E]; if (E + 1 >= F.length) { E = 0 } else { E++ } function B() { showPMD(F, E, A, D) } setTimeout(B, D) };
function page_header_ggba_init() {//ggba
    var callbackGongGao = function (msg) {
        if (msg != null) {
            //var bArray = new Array();
			var html = ""
            try {
                msg = eval(msg);
                for (var i = 0; i < msg.length; i++) {
                   // bArray.push('<a href="ArticleShowContent.aspx?Seq={0}" target="_blank">{1}</a>'.Format(msg[i].Seq, subString(msg[i].Title, 82, true)));
				   html +="<a href=\"ArticleShowContent.aspx?Seq={0}\" target=\"_blank\">{1}</a>　　".Format(msg[i].Seq, subString(msg[i].Title, 82, true));
                }
            } catch (ex) { }
        }
		$("#newsTopRollBar").html(html);
        //showPMD(bArray, 0, "newsTopRollBar", 5000);
    };
    var callbackFoucePic = function (msg) {
        if (msg != null) {
            var bArray = new Array();
            var html = "";
            var html_ul = "";
            try {
                msg = eval(msg);
                for (var i = 0; i < msg.length; i++) {
                    html += "<div class=\"panel\">";
                    html += "  <a href=\"ArticleShowContent.aspx?Seq={0}\" target=\"_blank\"><img src=\"/UploadFiles/{1}\" /></a>".Format(msg[i].Seq, msg[i].ImgUrl);
                    html += "  <div class=\"panel-overlay\">";
                    html += "    <span>{0}</span>".Format(subString(msg[i].Title, 28, true));
                    html += "  </div>";
                    html += "</div>";
                    html += "";
                    html_ul += "  <li><img src=\"/UploadFiles/{0}\" alt=\"{1}\" title=\"{1}\" /></li>".Format(msg[i].ImgUrl, msg[i].Title);
               }
                html += "<ul class=\"filmstrip\">"
                html += html_ul;
                html += "</ul>";
            } catch (ex) { }
            $("#photos").html(html);
            $('#photos').galleryView({});
        }
    };
    function ts(objSd) {
        try {
            var _res = JTTMasterPage.Res.Laba;
            var objDate = ((new Date()).getTime() - Date.parse(objSd)) / (1000 * 60 * 60 * 24);
            if (objDate > 0) {
                e_hr = (objDate) * 24;
                hr = Math.floor(e_hr);
                e_min = (e_hr - hr) * 60;
                min = Math.floor((e_hr - hr) * 60);
                sec = Math.floor((e_min - min) * 60);
                var r = (hr > 0) ? hr + _res[1] : "";
                r += (min > 0) ? min + _res[2] : "";
                r += (sec > 0) ? sec + _res[3] : "";
                return r;
            }
            else return _res[4];

        }
        catch (ex) { }
    };
    AjaxUpdate("gonggao",callbackGongGao);
    AjaxUpdate("FoucsPic",callbackFoucePic);
};
function AjaxUpdate(AjaxMethod,callback){
    $.post(
            "Ajax/Index.ashx",
            {
                AjaxMethod: AjaxMethod
            },
            function (data) {
                callback(data);
            },
            "json"
    );
};

        (function (win) { //ShowJTT 扩展方法
            if (!win.ShowJTT)
                var F = { Extend: function (dest, source, replace) { for (prop in source) { if (replace == false && dest[prop] != null) continue; dest[prop] = source[prop]; }; return dest; } };
            win.ShowJTT = F;
        })(window);

        (function () {//ShowJTT页面方法转移
             var F = {
                 OpenUrl: function (id) { window.open("a" + id); },
                 Config: {
                     'd1': [{ id1: 'one1', id2: 'con_one_1', scn: 'after', hcn: '' },
                            { id1: 'one2', id2: 'con_one_2', scn: 'after', hcn: '' },
                            { id1: 'one3', id2: 'con_one_3', scn: 'after', hcn: '' }],
                     'd2': [{ id1: 'two1', id2: 'con_two_1', scn: 'after', hcn: '' },
                            { id1: 'two2', id2: 'con_two_2', scn: 'after', hcn: ''}],
                     'd3': [{ id1: 'three1', id2: 'con_three_1', scn: 'after', hcn: '' },
                            { id1: 'three2', id2: 'con_three_2', scn: 'after', hcn: ''}],
                     'd4': [{ id1: 'four1', id2: 'con_four_1', scn: 'after', hcn: '' },
                            { id1: 'four2', id2: 'con_four_2', scn: 'after', hcn: ''},
                            { id1: 'four3', id2: 'con_four_3', scn: 'after', hcn: ''},
                            { id1: 'four4', id2: 'con_four_4', scn: 'after', hcn: ''},
                            { id1: 'four5', id2: 'con_four_5', scn: 'after', hcn: ''}],
                     'd5': [{ id1: 'five1', id2: 'con_five_1', scn: 'after', hcn: '' },
                            { id1: 'five2', id2: 'con_five_2', scn: 'after', hcn: ''},
                            { id1: 'five3', id2: 'con_five_3', scn: 'after', hcn: ''}]
                 },
                 Switch: function (type, e) { //切换标签
                     var _data = ShowJTT.Config[type];
                     for (var i = 0, l = _data.length; i < l; i++) {
                         gb(_data[i].id1).className = (e.id == _data[i].id1 ? _data[i].scn : _data[i].hcn);
                         gb(_data[i].id2).style.display = (e.id == _data[i].id1 ? 'block' : 'none');
                     };
                     return false;
                 }
             }
             JTTMasterPage.Extend(ShowJTT, F, false); //绑定扩展方法
 })();
