window.zeng=window.zeng || {};
zeng.dom = {getbyid: function(id) {
return document.getelementbyid(id);
},get: function(e) {
return (typeof (e) == "string") ? document.getelementbyid(e) : e;
},createelementin: function(tagname, elem, insertfirst, attrs) {
var _e = (elem = zeng.dom.get(elem) || document.body).ownerdocument.createelement(tagname || "div"), k;
if (typeof (attrs) == 'object') {
for (k in attrs) {
if (k == "class") {
_e.classname = attrs[k];
} else if (k == "style") {
_e.style.csstext = attrs[k];
} else {
_e[k] = attrs[k];
}
}
}
insertfirst ? elem.insertbefore(_e, elem.firstchild) : elem.appendchild(_e);
return _e;
},getstyle: function(el, property) {
el = zeng.dom.get(el);
if (!el || el.nodetype == 9) {
return null;
}
var w3cmode = document.defaultview && document.defaultview.getcomputedstyle, computed = !w3cmode ? null : document.defaultview.getcomputedstyle(el, ''), value = "";
switch (property) {
case "float":
property = w3cmode ? "cssfloat" : "stylefloat";
break;
case "opacity":
if (!w3cmode) {
var val = 100;
try {
val = el.filters['dximagetransform.microsoft.alpha'].opacity;
} catch (e) {
try {
val = el.filters('alpha').opacity;
} catch (e) {
}
}
return val / 100;
} else {
return parsefloat((computed || el.style)[property]);
}
break;
case "backgroundpositionx":
if (w3cmode) {
property = "backgroundposition";
return ((computed || el.style)[property]).split(" ")[0];
}
break;
case "backgroundpositiony":
if (w3cmode) {
property = "backgroundposition";
return ((computed || el.style)[property]).split(" ")[1];
}
break;
}
if (w3cmode) {
return (computed || el.style)[property];
} else {
return (el.currentstyle[property] || el.style[property]);
}
},setstyle: function(el, properties, value) {
if (!(el = zeng.dom.get(el)) || el.nodetype != 1) {
return false;
}
var tmp, brtn = true, w3cmode = (tmp = document.defaultview) && tmp.getcomputedstyle, rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
if (typeof (properties) == 'string') {
tmp = properties;
properties = {};
properties[tmp] = value;
}
for (var prop in properties) {
value = properties[prop];
if (prop == 'float') {
prop = w3cmode ? "cssfloat" : "stylefloat";
} else if (prop == 'opacity') {
if (!w3cmode) {
prop = 'filter';
value = value >= 1 ? '' : ('alpha(opacity=' + math.round(value * 100) + ')');
}
} else if (prop == 'backgroundpositionx' || prop == 'backgroundpositiony') {
tmp = prop.slice(-1) == 'x' ? 'y' : 'x';
if (w3cmode) {
var v = zeng.dom.getstyle(el, "backgroundposition" + tmp);
prop = 'backgroundposition';
typeof (value) == 'number' && (value = value + 'px');
value = tmp == 'y' ? (value + " " + (v || "top")) : ((v || 'left') + " " + value);
}
}
if (typeof el.style[prop] != "undefined") {
el.style[prop] = value + (typeof value === "number" && !rexclude.test(prop) ? 'px' : '');
brtn = brtn && true;
} else {
brtn = brtn && false;
}
}
return brtn;
},getscrolltop: function(doc) {
var _doc = doc || document;
return math.max(_doc.documentelement.scrolltop, _doc.body.scrolltop);
},getclientheight: function(doc) {
var _doc = doc || document;
return _doc.compatmode == "css1compat" ? _doc.documentelement.clientheight : _doc.body.clientheight;
}
};
zeng.string = {regexps: {trim: /^\s+|\s+$/g,ltrim: /^\s+/,rtrim: /\s+$/,nl2br: /\n/g,s2nb: /[\x20]{2}/g,uriencode: /[\x09\x0a\x0d\x20\x21-\x29\x2b\x2c\x2f\x3a-\x3f\x5b-\x5e\x60\x7b-\x7e]/g,eschtml: {re_amp: /&/g,re_lt: //g,re_apos: /\x27/g,re_quot: /\x22/g},escstring: {bsls: /\\/g,sls: /\//g,nl: /\n/g,rt: /\r/g,tab: /\t/g},restxhtml: {re_amp: /&/g,re_lt: /</g,re_gt: />/g,re_apos: /&(?:apos|#0?39);/g,re_quot: /"/g},write: /\{(\d{1,2})(?:\:([xodqqb]))?\}/g,isurl: /^(?:ht|f)tp(?:s)?\:\/\/(?:[\w\-\.]+)\.\w+/i,cut: /[\x00-\xff]/,getreallen: {r0: /[^\x00-\xff]/g,r1: /[\x00-\xff]/g},format: /\{([\d\w\.]+)\}/g},commonreplace: function(s, p, r) {
return s.replace(p, r);
},format: function(str) {
var args = array.prototype.slice.call(arguments), v;
str = string(args.shift());
if (args.length == 1 && typeof (args[0]) == 'object') {
args = args[0];
}
zeng.string.regexps.format.lastindex = 0;
return str.replace(zeng.string.regexps.format, function(m, n) {
v = zeng.object.route(args, n);
return v === undefined ? m : v;
});
}};
zeng.object = {
routere: /([\d\w_]+)/g,
route: function(obj, path) {
obj = obj || {};
path = string(path);
var r = zeng.object.routere, m;
r.lastindex = 0;
while ((m = r.exec(path)) !== null) {
obj = obj[m[0]];
if (obj === undefined || obj === null) {
break;
}
}
return obj;
}};
var ua = zeng.useragent = {}, agent = navigator.useragent;
ua.ie = 9 - ((agent.indexof('trident/5.0') > -1) ? 0 : 1) - (window.xdomainrequest ? 0 : 1) - (window.xmlhttprequest ? 0 : 1);
if (typeof (zeng.msgbox) == 'undefined') {
zeng.msgbox = {};
}
zeng.msgbox._timer = null;
zeng.msgbox.loadinganimationpath = zeng.msgbox.loadinganimationpath || ("loading.gif");
zeng.msgbox.show = function(msghtml, type, timeout, opts) {
if (typeof (opts) == 'number') {
opts = {topposition: opts};
}
opts = opts || {};
var _s = zeng.msgbox,
template = '{loadicon}{msghtml}', loading = '', typeclass = [0, 0, 0, 0, "succ", "fail", "clear"], mbox, tips;
_s._loadcss && _s._loadcss(opts.csspath);
mbox = zeng.dom.get("q_msgbox") || zeng.dom.createelementin("div", document.body, false, {classname: "zeng_msgbox_layer_wrap"});
mbox.id = "q_msgbox";
mbox.style.display = "";
mbox.innerhtml = zeng.string.format(template, {type: typeclass[type] || "hits",msghtml: msghtml || "",loadicon: type == 6 ? loading : ""});
_s._setposition(mbox, timeout, opts.topposition);
};
zeng.msgbox._setposition = function(tips, timeout, topposition) {
timeout = timeout || 5000;
var _s = zeng.msgbox, bt = zeng.dom.getscrolltop(), ch = zeng.dom.getclientheight(), t = math.floor(ch / 2) - 40;
zeng.dom.setstyle(tips, "top", ((document.compatmode == "backcompat" || zeng.useragent.ie < 7) ? bt : 0) + ((typeof (topposition) == "number") ? topposition : t) + "px");
cleartimeout(_s._timer);
tips.firstchild.style.display = "";
timeout && (_s._timer = settimeout(_s.hide, timeout));
};
zeng.msgbox.hide = function(timeout) {
var _s = zeng.msgbox;
if (timeout) {
cleartimeout(_s._timer);
_s._timer = settimeout(_s._hide, timeout);
} else {
_s._hide();
}
};
zeng.msgbox._hide = function() {
var _mbox = zeng.dom.get("q_msgbox"), _s = zeng.msgbox;
cleartimeout(_s._timer);
if (_mbox) {
var _tips = _mbox.firstchild;
zeng.dom.setstyle(_mbox, "display", "none");
}
};