/*!
* touchslide v1.1
* javascript触屏滑动特效插件,移动端滑动特效,触屏焦点图,触屏tab切换,触屏多图切换等
* 详尽信息请看官网:http://www.superslide2.com/touchslide/
*
* copyright 2013 大话主席
*
* 请尊重原创,保留头部版权
* 在保留版权的前提下可应用于个人或商业用途
* 1.1 宽度自适应(修复安卓横屏时滑动范围不变的bug)
*/
var touchslide = function(a) {
a = a || {};
var b = {
slidecell: a.slidecell || "#touchslide",
titcell: a.titcell || ".hd li",
maincell: a.maincell || ".bd",
effect: a.effect || "left",
autoplay: a.autoplay || !1,
delaytime: a.delaytime || 200,
intertime: a.intertime || 2500,
defaultindex: a.defaultindex || 0,
titonclassname: a.titonclassname || "on",
autopage: a.autopage || !1,
prevcell: a.prevcell || ".prev",
nextcell: a.nextcell || ".next",
pagestatecell: a.pagestatecell || ".pagestate",
pnloop: "undefined " == a.pnloop ? !0 : a.pnloop,
startfun: a.startfun || null,
endfun: a.endfun || null,
switchload: a.switchload || null
},
c = document.getelementbyid(b.slidecell.replace("#", ""));
if (!c) return ! 1;
var d = function(a, b) {
a = a.split(" ");
var c = [];
b = b || document;
var d = [b];
for (var e in a) 0 != a[e].length && c.push(a[e]);
for (var e in c) {
if (0 == d.length) return ! 1;
var f = [];
for (var g in d) if ("#" == c[e][0]) f.push(document.getelementbyid(c[e].replace("#", "")));
else if ("." == c[e][0]) for (var h = d[g].getelementsbytagname("*"), i = 0; i < h.length; i++) {
var j = h[i].classname;
j && -1 != j.search(new regexp("\\b" + c[e].replace(".", "") + "\\b")) && f.push(h[i])
} else for (var h = d[g].getelementsbytagname(c[e]), i = 0; i < h.length; i++) f.push(h[i]);
d = f
}
return 0 == d.length || d[0] == b ? !1 : d
},
e = function(a, b) {
var c = document.createelement("div");
c.innerhtml = b,
c = c.children[0];
var d = a.clonenode(!0);
return c.appendchild(d),
a.parentnode.replacechild(c, a),
m = d,
c
},
g = function(a, b) { ! a || !b || a.classname && -1 != a.classname.search(new regexp("\\b" + b + "\\b")) || (a.classname += (a.classname ? " ": "") + b)
},
h = function(a, b) { ! a || !b || a.classname && -1 == a.classname.search(new regexp("\\b" + b + "\\b")) || (a.classname = a.classname.replace(new regexp("\\s*\\b" + b + "\\b", "g"), ""))
},
i = b.effect,
j = d(b.prevcell, c)[0],
k = d(b.nextcell, c)[0],
l = d(b.pagestatecell)[0],
m = d(b.maincell, c)[0];
if (!m) return ! 1;
var n, o, n = m.children.length,
o = d(b.titcell, c),
p = o ? o.length: n,
q = b.switchload,
r = parseint(b.defaultindex),
s = parseint(b.delaytime),
t = parseint(b.intertime),
u = "false" == b.autoplay || 0 == b.autoplay ? !1 : !0,
v = "false" == b.autopage || 0 == b.autopage ? !1 : !0,
w = "false" == b.pnloop || 0 == b.pnloop ? !1 : !0,
x = r,
y = null,
z = null,
a = null,
b = 0,
c = 0,
d = 0,
e = 0,
g = /hp-tablet/gi.test(navigator.appversion),
h = "ontouchstart" in window && !g,
i = h ? "touchstart": "mousedown",
j = h ? "touchmove": "",
k = h ? "touchend": "mouseup",
m = m.parentnode.clientwidth,
p = n;
if (0 == p && (p = n), v) {
p = n,
o = o[0],
o.innerhtml = "";
var q = "";
if (1 == b.autopage || "true" == b.autopage) for (var r = 0; p > r; r++) q += "
" + (r + 1) + "";
else for (var r = 0; p > r; r++) q += b.autopage.replace("$", r + 1);
o.innerhtml = q,
o = o.children
}
"leftloop" == i && (p += 2, m.appendchild(m.children[0].clonenode(!0)), m.insertbefore(m.children[n - 1].clonenode(!0), m.children[0])),
n = e(m, ''),
m.style.csstext = "width:" + p * m + 2 + "px;" + "position:relative;overflow:hidden;padding:0;margin:0;";
for (var r = 0; p > r; r++) m.children[r].style.width = m + "px";
var s = function() {
"function" == typeof b.startfun && b.startfun(r, p)
},
t = function() {
"function" == typeof b.endfun && b.endfun(r, p)
},
u = function(a) {
var b = ("leftloop" == i ? r + 1 : r) + a,
c = function(a) {
for (var b = m.children[a].getelementsbytagname("img"), c = 0; c < b.length; c++) b[c].getattribute(q) && (b[c].setattribute("src", b[c].getattribute(q)), b[c].removeattribute(q))
};
if (c(b), "leftloop" == i) switch (b) {
case 0:
c(n);
break;
case 1:
c(n + 1);
break;
case n:
c(0);
break;
case n + 1 : c(1)
}
},
v = function() {
m = n.clientwidth,
m.style.width = p * m + "px";
for (var a = 0; p > a; a++) m.children[a].style.width = m + "px";
var b = "leftloop" == i ? r + 1 : r;
w( - b * m, 0)
};
window.addeventlistener("resize", v, !1);
var w = function(a, b, c) {
c = c ? c.style: m.style,
c.webkittransitionduration = c.moztransitionduration = c.mstransitionduration = c.otransitionduration = c.transitionduration = b + "ms",
c.webkittransform = "translate(" + a + "px,0)" + "translatez(0)",
c.mstransform = c.moztransform = c.otransform = "translatex(" + a + "px)"
},
x = function(a) {
switch (i) {
case "left":
r >= p ? r = a ? r - 1 : 0 : 0 > r && (r = a ? 0 : p - 1),
null != q && u(0),
w( - r * m, s),
x = r;
break;
case "leftloop":
null != q && u(0),
w( - (r + 1) * m, s),
-1 == r ? (z = settimeout(function() {
w( - p * m, 0)
},
s), r = p - 1) : r == p && (z = settimeout(function() {
w( - m, 0)
},
s), r = 0),
x = r
}
s(),
a = settimeout(function() {
t()
},
s);
for (var c = 0; p > c; c++) h(o[c], b.titonclassname),
c == r && g(o[c], b.titonclassname);
0 == w && (h(k, "nextstop"), h(j, "prevstop"), 0 == r ? g(j, "prevstop") : r == p - 1 && g(k, "nextstop")),
l && (l.innerhtml = "" + (r + 1) + "/" + p)
};
if (x(), u && (y = setinterval(function() {
r++,
x()
},
t)), o) for (var r = 0; p > r; r++) !
function() {
var a = r;
o[a].addeventlistener("click",
function() {
cleartimeout(z),
cleartimeout(a),
r = a,
x()
})
} ();
k && k.addeventlistener("click",
function() { (1 == w || r != p - 1) && (cleartimeout(z), cleartimeout(a), r++, x())
}),
j && j.addeventlistener("click",
function() { (1 == w || 0 != r) && (cleartimeout(z), cleartimeout(a), r--, x())
});
var y = function(a) {
cleartimeout(z),
cleartimeout(a),
o = void 0,
d = 0;
var b = h ? a.touches[0] : a;
b = b.pagex,
c = b.pagey,
m.addeventlistener(j, z, !1),
m.addeventlistener(k, $, !1)
},
z = function(a) {
if (!h || !(a.touches.length > 1 || a.scale && 1 !== a.scale)) {
var b = h ? a.touches[0] : a;
if (d = b.pagex - b, e = b.pagey - c, "undefined" == typeof o && (o = !!(o || math.abs(d) < math.abs(e))), !o) {
switch (a.preventdefault(), u && clearinterval(y), i) {
case "left":
(0 == r && d > 0 || r >= p - 1 && 0 > d) && (d = .4 * d),
w( - r * m + d, 0);
break;
case "leftloop":
w( - (r + 1) * m + d, 0)
}
null != q && math.abs(d) > m / 3 && u(d > -0 ? -1 : 1)
}
}
},
$ = function(a) {
0 != d && (a.preventdefault(), o || (math.abs(d) > m / 10 && (d > 0 ? r--:r++), x(!0), u && (y = setinterval(function() {
r++,
x()
},
t))), m.removeeventlistener(j, z, !1), m.removeeventlistener(k, $, !1))
};
m.addeventlistener(i, y, !1)
};