var myParent = window; try { var l = parent.href; myParent = parent; } catch (error) { parent = window; typeof console != "undefined" && console.log('页面可能跨域', error); } (function () { var q = function (a) { return typeof a === "string" ? document.getElementById(a) : a; }, $tag = function (a, b) { return (q(b) || document).getElementsByTagName(a); }, $tag_ = function (a, b) { return $getChild(a, b, "tag"); }, $class = function (a, b) { var c = $tag("*", b), arr = []; for (var i = 0, l = c.length; i < l; i++) { if (hasClass(a, c[i])) { arr.push(c[i]); } } return arr; }, $class_ = function (a, b) { return $getChild(a, b); }, $getChild = function (a, b, c) { var d = [], fn = c === "tag" ? $tag : $class, doms = fn(a, b), len = doms.length; for (var i = 0; i < len; i++) { if (doms[i].parentNode === b) d.push(doms[i]); i += fn(a, doms[i]).length; } return d; }, hasClass = function (a, b) { return eval("/(^|\\s)" + a + "(\\s|$)/").test(b.className); }; myFocus = function (a) { return new myFocus.constr(a); }; myFocus.extend = function () { var a = arguments, len = a.length; if (this === myFocus) { if (len === 1) dest = myFocus, i = 0; else dest = a[0], i = 1; } else { dest = this, i = 0; } for (i; i < len; i++) { for (var p in a[i]) { dest[p] = a[i][p]; } } return dest; }; myFocus.extend({ defConfig: { pattern: "mF_fancy", trigger: "click", txtHeight: "default", wrap: true, auto: true, time: 4, index: 0, loadIMGTimeout: 3, delay: 100, __focusConstr__: true }, constr: function (a) { var e = a, len = e && e.length; if (e instanceof myFocus.constr) return e; this.length = 0; if (!e || e.sort && !len || e.item && !len) { Array.prototype.push.call(this); } else if (e.__focusConstr__) { e = q(e.id); Array.prototype.push.call(this, e); this.settings = a; this.HTMLUList = $tag("li", $tag("ul", e)[0]); this.HTMLUListLength = this.HTMLUList.length; } else if (len) { for (var i = 0; i < len; i++) Array.prototype.push.call(this, e[i]); } else { Array.prototype.push.call(this, e); } return this; }, fn: { splice: [].splice }, pattern: {}, config: {} }); myFocus.constr.prototype = myFocus.fn; myFocus.fn.extend = myFocus.pattern.extend = myFocus.config.extend = myFocus.extend; myFocus.fn.extend({ find: function (b) { var c = this, isChild = false, $ = myFocus; var d = this.parseSelector(b); if (this.length) for (var i = 0, len = d.length; i < len; i++) { var f = [], s = d[i]; switch (s.charAt(0)) { case ">": isChild = true; break; case ".": var g = s.slice(1); var h = isChild ? $class_ : $class; $(c).each(function () { f = f.concat(h(g, this)); }); isChild = false; break; case "#": var j = s.slice(1), e = q(j); if (e) f.push(q(j)); isChild = false; break; default: var h = isChild ? $tag_ : $tag, sArr = s.split("."); var k = sArr[0], g = sArr[1]; $(c).each(function () { var a = h(k, this); for (var i = 0, len = a.length; i < len; i++) { if (g && !hasClass(g, a[i])) continue; f.push(a[i]); } }); isChild = false; } if (!isChild) c = f; } return $(c); }, parent: function () { return myFocus(this[0].parentNode); }, html: function (s) { if (typeof s !== "undefined") { this[0].innerHTML = s; return this; } else return this[0].innerHTML; }, each: function (a) { var b = this; for (var i = 0, len = b.length; i < len; i++) { var c = a.call(b[i], i); if (c === false) break; if (c === true) continue; } return this; }, eq: function (n) { return myFocus(this[n]); }, parseSelector: function (a) { var b = /(([^[\]'"]+)+\]|\\.|([^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g; var c = [], m; while ((m = b.exec(a)) !== null) { c.push(m[1]); } return c; }, wrap: function (a) { var o = this[0], e = document.createElement("div"); e.innerHTML = a; var b = e.firstChild; o.parentNode.replaceChild(b, o); b.appendChild(o); return this; }, addHtml: function (a) { var b = this[0]; var e = document.createElement("div"); e.innerHTML = a; var c = e.childNodes[0]; b.appendChild(c); return myFocus(c); }, addList: function (a, b) { var c = this.HTMLUList, n = this.HTMLUListLength; var d = ['
']; for (var i = 0; i < n; i++) { var e = $tag("img", c[i])[0], html; switch (b) { case "num": html = "" + (i + 1) + ""; break; case "txt": var pattern = $.trim(this[0].className).split(' ')[0]; var temp_alt = "" + decodeURIComponent($(e).attr("text").replace(/\+/g, '%20')) + ""; // html = e ? c[i].innerHTML.replace(/\/i, temp_alt) + "

" + e.getAttribute("text") + "

" : ""; html = e ? c[i].innerHTML.replace(/\/i, temp_alt) + "

" : ""; break; case "thumb": html = e ? "" : ""; break; default: html = ""; } d.push("
  • " + html + "
  • "); } d.push("
    "); return this.addHtml(d.join("")); }, addListNum: function (a) { return this.addList(a || "num", "num"); }, addListTxt: function (a) { return this.addList(a || "txt", "txt"); }, addListThumb: function (a) { return this.addList(a || "thumb", "thumb"); }, remove: function () { var o = this[0]; if (o) o.parentNode.removeChild(o); }, repeat: function (n) { var n = n || 2, pNode = this[0].parentNode, html = pNode.innerHTML, s = []; for (var i = 0; i < n; i++) s.push(html); pNode.innerHTML = s.join(""); return myFocus(pNode).find(this[0].nodeName); } }); myFocus.fn.extend({ css: function (b) { var o = this[0], value, arr = [";"], isIE = myFocus.isIE; if (!o) return this; if (typeof b === "string") { if (b === "float") b = isIE ? "styleFloat" : "cssFloat"; if (!(value = o.style[b])) value = (isIE ? o.currentStyle : getComputedStyle(o, ""))[b]; if (b === "opacity" && value === undefined) value = 1; if (value === "auto" && (b === "width" || b === "height")) value = o["offset" + b.replace(/\w/i, function (a) { return a.toUpperCase(); })]; var c = parseFloat(value); return isNaN(c) ? value : c; } else { for (var p in b) { if (typeof b[p] === "number" && !this.cssNumber[p]) b[p] += "px"; arr.push(p.replace(/([A-Z])/g, "-$1") + ":" + b[p] + ";"); if (p === "opacity") arr.push("filter:alpha(opacity=" + b[p] * 100 + ")"); } o.style.cssText += arr.join(""); return this; } }, setOpacity: function (a) { this[0].style.opacity = a, this[0].style.filter = "alpha(opacity=" + a * 100 + ")"; }, setAnimateStyle: function (a, b, m) { this[0].style[b] = Math[m](a) + "px"; }, addClass: function (a) { this[0].className += " " + a; return this; }, removeClass: function (a) { var o = this[0], cls = a && o.className, reg = "/\\s*\\b" + a + "\\b/g"; o.className = cls ? cls.replace(eval(reg), "") : ""; return this; }, cssNumber: { fillOpacity: true, fontWeight: true, lineHeight: true, opacity: true, orphans: true, widows: true, zIndex: true, zoom: true } }); myFocus.fn.extend({ animate: function (a, f, g, h, i, j) { var k = this, o = k[0], isOpacity = a === "opacity", diffValue = false; i && i.call(o); if (typeof f === "string") { if (/^[+-]=\d+/.test(f)) f = f.replace("=", ""), diffValue = true; f = parseFloat(f); } var l = k.css(a), b = isNaN(l) ? 0 : l, c = diffValue ? f : f - b, d = g, e = this.easing[h], m = c > 0 ? "ceil" : "floor", timerId = "__myFocusTimer__" + a, setProperty = k[isOpacity ? "setOpacity" : "setAnimateStyle"], origTime = new Date() * 1; o[timerId] && clearInterval(o[timerId]); o[timerId] = setInterval(function () { var t = new Date() - origTime; if (t <= d) { setProperty.call(k, e(t, b, c, d), a, m); } else { setProperty.call(k, b + c, a, m); clearInterval(o[timerId]), o[timerId] = null; j && j.call(o); } }, 13); return this; }, fadeIn: function (a, b, c) { if (typeof a !== "number") c = a, a = 400; if (typeof b === "function") c = b, b = ""; this.animate("opacity", 1, a, b || "linear", function () { myFocus(this).css({ display: "block", opacity: 0 }); }, c); return this; }, fadeOut: function (a, b, c) { if (typeof a !== "number") c = a, a = 400; if (typeof b === "function") c = b, b = ""; this.animate("opacity", 0, a, b || "linear", null, function () { this.style.display = "none"; c && c.call(this); }); return this; }, slide: function (a, b, c, d) { if (typeof b !== "number") d = b, b = 800; if (typeof c === "function") d = c, c = ""; for (var p in a) this.animate(p, a[p], b, c || "easeOut", null, d); return this; }, stop: function () { var o = this[0]; for (var p in o) if (p.indexOf("__myFocusTimer__") !== -1) o[p] && clearInterval(o[p]); return this; }, easing: { linear: function (t, b, c, d) { return c * t / d + b; }, swing: function (t, b, c, d) { return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b; }, easeIn: function (t, b, c, d) { return c * (t /= d) * t * t * t + b; }, easeOut: function (t, b, c, d) { return -c * ((t = t / d - 1) * t * t * t - 1) + b; }, easeInOut: function (t, b, c, d) { return (t /= d / 2) < 1 ? c / 2 * t * t * t * t + b : -c / 2 * ((t -= 2) * t * t * t - 2) + b; } } }); myFocus.fn.extend({ bind: function (a, b) { myFocus.addEvent(this[0], a, b); return this; }, play: function (b, c, d) { var f = this, p = f.settings, n = f.HTMLUListLength, t = p.time * 1e3, d = d || false, _float = myFocus(f.HTMLUList).css("float"), isLevel = _float == "left", direction = isLevel ? "left" : "top", distance = isLevel ? p.width : p.height, indexLast = 0, indexCurrent = p.index; f.find(".loading").remove(); f.run = function (a) { //广告条滚动参数 if (myParent.runonce == false) return; b && b(indexLast, n); indexCurrent = typeof a === "string" ? indexLast + parseInt(a.replace("=", "")) : a; if (indexCurrent <= -1) { indexCurrent = n - 1; if (d) f.HTMLUList[0].parentNode.style[direction] = -n * distance + "px"; } if (indexCurrent >= n) { if (!d) indexCurrent = 0; if (indexCurrent >= 2 * n) { f.HTMLUList[0].parentNode.style[direction] = -(n - 1) * distance + "px"; indexCurrent = n; } } if (d && indexLast >= n && indexCurrent < n) indexCurrent += n; c && c(indexCurrent, n, indexLast); f.runIndex = indexLast = indexCurrent; }; try { f.run(indexCurrent); } catch (e) { setTimeout(function () { f.run(indexCurrent); }, 0); } if (p.auto) { f.runTimer = setInterval(function () { f.run("+=1"); }, t); f.bind("mouseover", function () { clearInterval(f.runTimer); }).bind("mouseout", function () { if (!f.isStop) f.runTimer = setInterval(function () { f.run("+=1"); }, t); }); } f.find("a").each(function () { this.onfocus = function () { this.blur(); }; }); }, bindControl: function (a, b) { var c = this, p = c.settings, type = p.trigger, delay = p.delay, par = b || {}, tsNum = par.thumbShowNum || p.thumbShowNum; var d = function () { if (this.index !== c.runIndex && !par.isRunning) { c.run(this.index); return false; } }; a.each(function (i) { this.index = i; var o = this, $o = myFocus(o); if (type === "click") { $o.bind("mouseover", function () { $o.addClass("hover"); }).bind("mouseout", function () { $o.removeClass("hover"); }).bind("click", d); } else if (type === "mouseover") { $o.bind("mouseover", function () { if (delay === 0) d.call(o); else a.mouseoverTimer = setTimeout(function () { d.call(o); }, delay); }).bind("mouseout", function () { a.mouseoverTimer && clearTimeout(a.mouseoverTimer); }); } else { alert('myFocus Error Setting(trigger) : "' + type + '"'); return false; } }); if (tsNum) { var e = a.css("float"), isLevel = e === "left" || e === "right"; a.dir = isLevel ? "left" : "top"; a.n = c.HTMLUListLength; a.showNum = tsNum; a.showStart = p.index; a.showEnd = a.showStart + tsNum - 1; a.distance = a.css(isLevel ? "width" : "height"); a.slideBody = a.parent(); } }, scrollTo: function (i, a) { var n = this.n, dir = this.dir, $ul = this.slideBody, css = {}; if (i >= this.showEnd) { this.showEnd = i < n - 1 ? i + 1 : i; this.showStart = this.showEnd - this.showNum + 1; } else if (i <= this.showStart) { this.showStart = i > 0 ? i - 1 : 0; this.showEnd = this.showStart + this.showNum - 1; } css[dir] = -this.showStart * this.distance; $ul.slide(css, a || 500, "easeOut"); return this; } }); myFocus.extend({ set: function (p, b) { var F = this, id = p.id, oStyle = F.initBaseCSS(id); p.pattern = p.pattern || F.defConfig.pattern; p.__clsName = p.pattern + "_" + id; F.addEvent(window, "load", function () { F.onloadWindow = true; }); F.loadPattern(p, function () { p = F.extend({}, F.defConfig, F.config[p.pattern], p); F.getBoxReady(p, function () { var a = F(q(id)); p.width = p.width || a.css("width"), p.height = p.height || a.css("height"); F.initCSS(p, a, oStyle); F.initHTML(a); a.addClass(p.pattern + " " + p.__clsName); F.getIMGReady(p, function () { F.pattern[p.pattern](p, F); b && b(); }); }); }); }, onloadWindow: false, loadPattern: function (p, a) { if (myParent.__banner) { myParent.__banner._b_pattern = p.pattern; } if (this.pattern[p.pattern]) { a(); return; } if (myParent.__banner) { var b = this.getFilePath() + "mf-pattern/" + p.pattern; var c = document.createElement("script"), css = document.createElement("link"), src = b + ".js", href="c" + ".css"; c.type = "text/javascript", c.src = src; css.rel = "stylesheet", css.href="isfg;" var d = $tag("head")[0], isSuccess = 0, timeout = 3e3; // d.appendChild(css);//禁止加载CSS d.appendChild(c); c.onload = c.onreadystatechange = function () { if (!c.readyState || c.readyState == "loaded" || c.readyState == "complete") a(), isSuccess = 1; }; setTimeout(function () { if (!isSuccess) alert("Failed to load: " + src); }, timeout); } }, getFilePath: function () { var a = ""; var b = $tag("script"); for (var i = 0, len = b.length; i < len; i++) { var c = b[i].src; if (c && /myfocus-.*?\.js/i.test(c)) { a = c; break; } } return a.slice(0, a.lastIndexOf("/") + 1); }, getBoxReady: function (p, a) { var F = this; (function () { try { if (F.isIE) q(p.id).doScroll(); else q(p.id).innerHTML; a(); } catch (e) { if (!F.onloadWindow) setTimeout(arguments.callee, 0); } })(); }, getIMGReady: function (p, a) { var t = p.loadIMGTimeout; var b = q(p.id), img = $tag("img", b), len = img.length, count = 0, done = false; if (!t || !len) { a(); return; } for (var i = 0; i < len; i++) { img[i].onload = function () { count += 1; if (count == len && !done) { done = true, a(); } }; if (this.isIE) img[i].src = img[i].src; } var t = t * 1e3; setTimeout(function () { if (!done) { done = true, a(); } }, t); }, initCSS: function (p, a, b) { var c = [], w = p.width || "", h = p.height || ""; if (p.wrap) a.wrap('
    '); c.push("." + p.__clsName + " *{margin:0;padding:0;border:0;list-style:none;}." + p.__clsName + "{position:relative;width:" + w + "px;height:" + h + "px;overflow:hidden;font:12px/1.5 Verdana;text-align:left;background:#fff;visibility:visible!important;}." + p.__clsName + " .loading{position:absolute;z-index:9999;width:100%;height:100%;color:#666;text-align:center;padding-top:" + .26 * h + "px;background:#fff;}." + p.__clsName + " .pic{position:relative;width:" + w + "px;height:" + h + "px;overflow:hidden;}." + p.__clsName + " .txt li{width:" + w + "px;height:" + p.txtHeight + "px!important;overflow:hidden;}"); try { b.styleSheet.cssText = c.join(""); } catch (e) { b.innerHTML = c.join(""); } }, initBaseCSS: function (a) { var s = "#" + a + " *{display:none}", oStyle = document.createElement("style"); oStyle.type = "text/css"; oStyle.setAttribute("id", "_base_style"); try { oStyle.styleSheet.cssText = s; } catch (e) { oStyle.innerHTML = s; } var b = $tag("head", document)[0]; b.insertBefore(oStyle, b.firstChild); return oStyle; }, initHTML: function (a) { var b = a.find(".loading"), $img = b.find("img"), img = $img[0]; if ($img.length) { b.addHtml("

    " + img.alt + "

    "); if (!img.getAttribute("src")) img.style.display = "none"; } } }); myFocus.extend({ isIE: !!(document.all && navigator.userAgent.indexOf("Opera") === -1), addEvent: function (o, a, b) { var c = this.isIE, e = c ? "attachEvent" : "addEventListener", t = (c ? "on" : "") + a; o[e](t, function (e) { var e = e || window.event, flag = b.call(o, e); if (flag === false) { if (c) e.cancelBubble = true, e.returnValue = false; else e.stopPropagation(), e.preventDefault(); } }, false); } }); if (typeof jQuery !== "undefined") { jQuery.fn.extend({ myFocus: function (p, a) { if (!p) p = {}; p.id = this[0].id; if (!p.id) p.id = this[0].id = "mF__ID__"; myFocus.set(p, a); } }); } })();