var yao = function(){ var d = document, oa = '[object array]', fc = "[object function]", op = object.prototype, nt = "nodetype", listeners = [], webkitkeymap = { 63232: 38, // up 63233: 40, // down 63234: 37, // left 63235: 39, // right 63276: 33, // page up 63277: 34, // page down 25: 9 // shift-tab (safari provides a different key code in }, patterns = { hyphen: /(-[a-z])/i, root_tag: /body|html/i }, lasterror = null; return { isarray: function(obj){ return op.tostring.apply(obj) === oa; }, isstring: function(s){ return typeof s === 'string'; }, isboolean: function(b){ return typeof b === 'boolean'; }, isfunction: function(func){ return op.tostring.apply(func) === fc; }, isnull: function(obj){ return obj === null; }, isnumber: function(num){ return typeof num === 'number' && isfinite(num); }, isobject: function(str){ return (str && (typeof str === "object" || this.isfunction(str))) || false; }, isundefined: function(obj){ return typeof obj === 'undefined'; }, hasownproperty: function(obj, prper){ if (op.hasownproperty) { return obj.hasownproperty(prper); } return !this.isundefined(obj[prper]) && obj.constructor.prototype[prper] !== obj[prper]; }, ismobile: function(mobile){ return /^(13|15|18)\d{9}$/.test(yao.trim(mobile)); }, isname: function(name){ return /^[\w\u4e00-\u9fa5]{1}[\w\u4e00-\u9fa5 \.]{0,19}$/.test(yao.trim(name)); }, keys: function(obj){ var b = []; for (var p in obj) { b.push(p); } return b; }, values: function(obj){ var a = []; for (var p in obj) { a.push(obj[p]); } return a; }, isxmldoc: function(obj){ return obj.documentelement && !obj.body || obj.tagname && obj.ownerdocument && !obj.ownerdocument.body; }, formatnumber: function(b, e){ e = e || ''; b += ''; var d = b.split('.'); var a = d[0]; var c = d.length > 1 ? '.' + d[1] : ''; var f = /(\d+)(\d{3})/; while (f.test(a)) { a = a.replace(f, '$1,$2'); } return e + a + c; }, unformatnumber: function(a){ return a.replace(/([^0-9\.\-])/g, '') * 1; }, stringbuffer: function(){ var a = []; for (var i = 0; i < arguments.length; ++i) { a.push(arguments[i]); } return a.join(''); }, trim: function(str){ try { return str.replace(/^\s+|\s+$/g, ''); } catch (a) { return str; } }, striptags: function(str){ return str.replace(/<\/?[^>]+>/gi, ''); }, stripscripts: function(str){ return str.replace(/]*>([\\s\\s]*?)<\/script>/g, ''); }, isjson: function(obj){ obj = obj.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); return (/^[,:{}\[\]0-9.\-+eaeflnr-u \n\r\t]*$/).test(obj); }, encodehtml: function(str){ return str.replace(/&/g, '&').replace(//g, '>'); }, decodehtml: function(str){ return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); }, tocamel: function(property){ if (!patterns.hyphen.test(property)) { return property; } if (propertycache[property]) { return propertycache[property]; } var converted = property; while (patterns.hyphen.exec(converted)) { converted = converted.replace(regexp.$1, regexp.$1.substr(1).touppercase()); } propertycache[property] = converted; return converted; }, cookie: { set: function(g, c, f, b){ var e = new date(); var a = new date(); if (f == null || f == 0) { f = 1; } a.settime(e.gettime() + 3600000 * 24 * f); d.cookie = g + '=' + encodeuri(c) + ';expires=' + a.togmtstring() + ';domain=' + b + '; path=/'; }, get: function(e){ var b = d.cookie; var d = e + '='; var c = b.indexof('; ' + d); if (c == -1) { c = b.indexof(d); if (c != 0) { return null; } } else { c += 2; } var a = d.cookie.indexof(';', c); if (a == -1) { a = b.length; } return decodeuri(b.substring(c + d.length, a)); }, clear: function(b, a){ if (this.get(b)) { d.cookie = b + '=' + ((domain) ? '; domain=' + a : '') + '; expires=thu, 01-jan-70 00:00:01 gmt'; } } }, ua: function(){ var c = { ie: 0, opera: 0, gecko: 0, webkit: 0, mobile: null, air: 0, caja: 0 }, b = navigator.useragent, a; if ((/khtml/).test(b)) { c.webkit = 1; } a = b.match(/applewebkit\/([^\s]*)/); if (a && a[1]) { c.webkit = parsefloat(a[1]); if (/ mobile\//.test(b)) { c.mobile = 'apple'; } else { a = b.match(/nokian[^\/]*/); if (a) { c.mobile = a[0]; } } a = b.match(/adobeair\/([^\s]*)/); if (a) { c.air = a[0]; } } if (!c.webkit) { a = b.match(/opera[\s\/]([^\s]*)/); if (a && a[1]) { c.opera = parsefloat(a[1]); a = b.match(/opera mini[^;]*/); if (a) { c.mobile = a[0]; } } else { a = b.match(/msie\s([^;]*)/); if (a && a[1]) { c.ie = parsefloat(a[1]); } else { a = b.match(/gecko\/([^\s]*)/); if (a) { c.gecko = 1; a = b.match(/rv:([^\s\)]*)/); if (a && a[1]) { c.gecko = parsefloat(a[1]); } } } } } a = b.match(/caja\/([^\s]*)/); if (a && a[1]) { c.caja = parsefloat(a[1]); } return c; }(), extend: function(subclass, superclass, override){ if (!superclass || !subclass) { throw new error('extend failed, please check that all dependencies are included.'); } var f = function(){}; f.prototype = superclass.prototype; subclass.prototype = new f(); subclass.prototype.constructor = subclass; subclass.superclass = superclass.prototype; if (superclass.prototype.constructor == object.prototype.constructor) { superclass.prototype.constructor = superclass; } if (override) { for (var p in override) { subclass.prototype[p] = override[p]; } } }, augmentproto: function(sub, sup){ if (!sub || !sup) { throw new error('augment failed, please check that all dependencies are included.'); } var d = sub.prototype, g = sup.prototype, b = arguments, c, h; if (b[2]) { for (c = 2; c < b.length; c += 1) { d[b[c]] = g[b[c]]; } } else { for (h in g) { if (!d[h]) { d[h] = g[h]; } } } }, augmentobject: function(e, d){ if (!d || !e) { throw new error('augment failed, please check that all dependencies are included.'); } var b = arguments, c, f; if (b[2]) { if (yao.isstring(b[2])) { e[b[2]] = d[b[2]]; } else { for (c = 0; c < b[2].length; c += 1) { e[b[2][c]] = d[b[2][c]]; } } } else { for (f in d) { e[f] = d[f]; } } return e; }, clone: function(d, f){ var e = function(){ }, b, c = arguments; e.prototype = d; b = new e; if (f) { for (p in f) { b[p] = f[p]; } } return b; }, addlistener: function(el, stype, fn, obj, overridecontext, bcapture){ var oel = null, context = null, wrappedfn = null; if(yao.isstring(el)){ oel = yao.getel(el); el = oel; } if(!el || !fn || !fn.call){ return false; } context = el; if (overridecontext) { if (overridecontext === true) { context = obj; } else { context = overridecontext; } } wrappedfn = function(e){ return fn.call(context, yao.getevent(e, el), obj); }; try { try { el.addeventlistener(stype, wrappedfn, bcapture); } catch (e) { try { el.attachevent('on' + stype, wrappedfn); } catch (e) { el['on' + stype] = wrappedfn; } } } catch (e) { lasterror = e; this.removelistener(el, stype, wrappedfn, bcapture); return false; } if ('unload' != stype) { // cache the listener so we can try to automatically unload listeners[listeners.length] = [el, stype, fn, wrappedfn, bcapture]; } return true; }, removelistener: function(el, stype, fn, bcapture){ try { if (window.removeeventlistener) { return function(el, stype, fn, bcapture){ el.removeeventlistener(stype, fn, (bcapture)); }; } else { if (window.detachevent) { return function(el, stype, fn){ el.detachevent("on" + stype, fn); }; } else { return function(){ }; } } } catch (e) { lasterror = e; return false; } return true; }, on: function(el, stype, fn, obj, overridecontext){ var oel = obj || el, scope = overridecontext || this; return yao.addlistener(el, stype, fn, oel, scope, false); }, stopevent: function(evt){ this.stoppropagation(evt); this.preventdefault(evt); }, stoppropagation: function(evt){ if (evt.stoppropagation) { evt.stoppropagation(); } else { evt.cancelbubble = true; } }, preventdefault: function(evt){ if (evt.preventdefault) { evt.preventdefault(); } else { evt.returnvalue = false; } }, getevent: function(e, boundel){ var ev = e || window.event; if (!ev) { var c = this.getevent.caller; while (c) { ev = c.arguments[0]; if (ev && event == ev.constructor) { break; } c = c.caller; } } return ev; }, getcharcode: function(ev){ var code = ev.keycode || ev.charcode || 0; // webkit key normalization if (yao.ua.webkit && (code in webkitkeymap)) { code = webkitkeymap[code]; } return code; }, _unload: function(e){ var j, l; if (listeners) { for (j = listeners.length - 1; j > -1; j--) { l = listeners[j]; if (l) { yao.removelistener(l[0], l[1], l[3], l[4]); } } l = null; } yao.removelistener(window, "unload", yao._unload); }, getel: function(elem){ var elemid, e, m, i, k, length, len; if (elem) { if (elem[nt] || elem.item) { return elem; } if (yao.isstring(elem)) { elemid = elem; elem = d.getelementbyid(elem); if (elem && elem.id === elemid) { return elem; } else { if (elem && elem.all) { elem = null; e = d.all[elemid]; for (i = 0, len = e.length; i < len; i += 1) { if (e[i].id === elemid) { return e[i]; } } } } return elem; } else { if (elem.dom_events) { elem = elem.get("element"); } else { if (yao.isarray(elem)) { m = []; for (k = 0, length = elem.length; k < length; k += 1) { m[m.length] = yao.getel(elem[k]); } return m; } } } } return null; }, hasclass: function(elem, classname){ var has = new regexp("(?:^|\\s+)" + classname + "(?:\\s+|$)"); return has.test(elem.classname); }, addclass: function(elem, classname){ if (yao.hasclass(elem, classname)) { return; } elem.classname = [elem.classname, classname].join(" "); }, removeclass: function(elem, classname){ var replace = new regexp("(?:^|\\s+)" + classname + "(?:\\s+|$)", "g"); if (!yao.hasclass(elem, classname)) { return; } var o = elem.classname; elem.classname = o.replace(replace, " "); if (yao.hasclass(elem, classname)) { yao.removeclass(elem, classname); } }, replaceclass: function(elem, newclass, oldclass){ if (newclass === oldclass) { return false; } var has = new regexp("(?:^|\\s+)" + newclass + "(?:\\s+|$)", "g"); if (!yao.hasclass(elem, newclass)) { yao.addclass(elem, oldclass); return; } elem.classname = elem.classname.replace(has, " " + oldclass + " "); if (yao.hasclass(elem, newclass)) { yao.replaceclass(elem, newclass, oldclass); } }, getelbyclassname: function(classname, tag, rootid){ var elems = [], i, tempcnt = yao.getel(rootid).getelementsbytagname(tag), len = tempcnt.length; for (i = 0; i < len; ++i) { if (yao.hasclass(tempcnt[i], classname)) { elems.push(tempcnt[i]); } } if (elems.length < 1) { return false; } else { return elems; } }, getstyle: function(el, property){ if (document.defaultview && document.defaultview.getcomputedstyle) { var value = null; if (property == 'float') { property = 'cssfloat'; } var computed = document.defaultview.getcomputedstyle(el, ''); if (computed) { value = computed[yao.tocamel(property)]; } return el.style[property] || value; } else { if (document.documentelement.currentstyle && yao.ua.ie) { switch (yao.tocamel(property)) { case 'opacity': var val = 100; try { val = el.filters['dximagetransform.microsoft.alpha'].opacity; } catch (e) { try { val = el.filters('alpha').opacity; } catch (e) { } } return val / 100; break; case 'float': property = 'stylefloat'; default: var value = el.currentstyle ? el.currentstyle[property] : null; return (el.style[property] || value); } } else { return el.style[property]; } } }, setstyle: function(el, property, val){ if (yao.ua.ie) { switch (property) { case 'opacity': if (yao.isstring(el.style.filter)) { el.style.filter = 'alpha(opacity=' + val * 100 + ')'; if (!el.currentstyle || !el.currentstyle.haslayout) { el.style.zoom = 1; } } break; case 'float': property = 'stylefloat'; default: el.style[property] = val; } } else { if (property == 'float') { property = 'cssfloat'; } el.style[property] = val; } }, setstyles: function(el, propertys){ for(var p in propertys){ yao.setstyle(el,p,propertys[p]); } return el; }, getelementsby: function(method, tag, root){ tag = tag || "*"; var m = []; if (root) { root = yao.getel(root); if (!root) { return m; } } else { root = document; } var oelem = root.getelementsbytagname(tag); if (!oelem.length && (tag === "*" && root.all)) { oelem = root.all; } for (var n = 0, j = oelem.length; n < j; ++n) { if (method(oelem[n])) { m[m.length] = oelem[n]; } } return m; }, getdocumentwidth: function(){ var k = yao.getscrollwidth(); var j = math.max(k, yao.getviewportwidth()); return j; }, getdocumentheight: function(){ var k = yao.getscrollheight(); var j = math.max(k, yao.getviewportheight()); return j; }, getscrollwidth: function(){ var j = (d.compatmode == "css1compat") ? d.body.scrollwidth : d.element.scrollwidth; return j; }, getscrollheight: function(){ var j = (d.compatmode == "css1compat") ? d.body.scrollheight : d.documentelement.scrollheight; return j; }, getxscroll: function(){ var j = self.pagexoffset || d.documentelement.scrollleft || d.body.scrollleft; return j; }, getyscroll: function(){ var j = self.pageyoffset || d.documentelement.scrolltop || d.body.scrolltop; return j; }, getviewportwidth: function(){ var j = self.innerwidth; var k = d.compatmode; if (k || yao.ua.ie) { j = (k == "css1compat") ? d.documentelement.clientwidth : d.body.clientwidth; } return j; }, getviewportheight: function(){ var j = self.innerheight; var k = d.compatmode; if ((k || yao.ua.ie) && !yao.ua.opera) { j = (k == "css1compat") ? d.documentelement.clientheight : d.body.clientheight; } return j; }, removechildren: function(j){ if (!(prent = yao.getel(j))) { return false; } while (j.firstchild) { j.firstchild.parentnode.removechild(j.firstchild); } return j; }, prependchild: function(k, j){ if (!(k = yao.getel(k)) || !(j = yao.getel(j))) { return false; } if (k.firstchild) { k.insertbefore(j, k.firstchild); } else { k.appendchild(j); } return k; }, insertafter: function(l, j){ var k = j.parentnode; if (k.lastchild == j) { k.appendchild(l); } else { k.insertbefore(l, j.nextsibling); } }, setopacity: function(el, val){ yao.setstyle(el, 'opacity', val); }, builder: { nidx: 0, nodemap: { area: 'map', caption: 'table', col: 'table', colgroup: 'table', legend: 'fieldset', optgroup: 'select', option: 'select', param: 'object', tbody: 'table', td: 'table', tfoot: 'table', th: 'table', thead: 'table', tr: 'table' }, attr_map: { 'classname': 'class', 'htmlfor': 'for', 'readonly': 'readonly', 'maxlength': 'maxlength', 'cellspacing': 'cellspacing' }, empty_tag: /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i, // ׷��link�ڵ㣨���css��ʽ��� linknode: function(url, cssid, charset){ var c = charset || 'utf-8', link = null; var head = d.getelementsbytagname('head')[0]; link = this.node('link', { 'id': cssid || ('link-' + (yao.builder.nidx++)), 'type': 'text/css', 'charset': c, 'rel': 'stylesheet', 'href': url }); head.appendchild(link); return link; }, // ׷��script�ڵ� scriptnode: function(url, scriptid, win, charset){ var d = win || document.body; var c = charset || 'utf-8'; return d.appendchild(this.node('script', { 'id': scriptid || ('script-' + (yao.builder.nidx++)), 'type': 'text/javascript', 'charset': c, 'src': url })); }, // ����Ԫ�ؽڵ� node: function(tag, attr, children){ tag = tag.touppercase(); // try innerhtml approach var parenttag = yao.builder.nodemap[tag] || 'div'; var parentelement = d.createelement(parenttag); var elem = null; try { // prevent ie "feature": http://dev.rubyonrails.org/ticket/2707 if (this.empty_tag.test(tag)) { //alert(tag); } else { parentelement.innerhtml = "<" + tag + ">"; } } catch (e) { } elem = parentelement.firstchild; // see if browser added wrapping tags if (elem && (elem.tagname.touppercase() != tag)) { elem = elem.getelementsbytagname(tag)[0]; } // fallback to createelement approach if (!elem) { if (yao.isstring(tag)) { elem = d.createelement(tag); } } // abort if nothing could be created if (!elem) { return; } else { if (attr) { this.attributes(elem, attr); } if (children) { this.child(elem, children); } return elem; } }, // ���ڵ�������� attributes: function(elem, attr){ var attrname = '', i; for (i in attr) { if (attr[i] && yao.hasownproperty(attr, i)) { attrname = i in yao.builder.attr_map ? yao.builder.attr_map[i] : i; if (attrname === 'class') { elem.classname = attr[i]; } else { elem.setattribute(attrname, attr[i]); } } } return elem; }, // ׷���ӽڵ� child: function(parent, child){ if (child.tagname) { parent.appendchild(child); return false; } if (yao.isarray(child)) { var i, length = child.length; for (i = 0; i < length; i += 1) { if (child[i].tagname) { parent.appendchild(child[i]); } else { if (yao.isstring(child[i])) { parent.appendchild(d.createtextnode(child[i])); } } } } else { if (yao.isstring(child)) { parent.appendchild(d.createtextnode(child)); } } } }, batch: function(el, method, o, override){ var id = el; el = yao.getel(el); var scope = (override) ? o : window; if (!el || el.tagname || !el.length) { if (!el) { return false; } return method.call(scope, el, o); } var collection = []; for (var i = 0, len = el.length; i < len; ++i) { if (!el[i]) { id = el[i]; } collection[collection.length] = method.call(scope, el[i], o); } return collection; }, fadeup: function(elem){ if (elem) { var level = 0, fade = function(){ var timer = null; level += 0.05; if (timer) { cleartimeout(timer); timer = null; } if (level > 1) { yao.setopacity(elem, 1); return false; } else { yao.setopacity(elem, level); } timer = settimeout(fade, 50); }; fade(); } }, zebra: function(){ var j, length = arguments.length; for (j = 0; j < length; ++j) { (function(config){ var root = yao.getel(config.roottag) || (config.root || null), rows = root.getelementsbytagname(config.rowtag) || (config.rows || null), i, len = rows.length, lastclass = []; if (root && rows && len > 1) { for (var i = 0; i < len; ++i) { rows[i].classname = i % 2 === 0 ? 'even' : 'odd'; lastclass[i] = rows[i].classname; yao.on(rows[i],'mouseover', function(index){ return function(){ yao.replaceclass(this, lastclass[index], 'hover'); } }(i),rows[i],true); yao.on(rows[i], 'mouseout', function(index){ return function(){ yao.replaceclass(this, 'hover', lastclass[index]); } }(i),rows[i],true); } } else { return false; } })(arguments[j]); } }, moveelement: function(element, finalx, finaly, speed){ var elem = yao.isstring(element) ? yao.getel(element) : element, style = null; if (elem) { if (elem.movement) { cleartimeout(elem.movement); } if (!elem.style.left) { elem.style.left = "0"; } if (!elem.style.top) { elem.style.top = "0"; } var xpos = parseint(elem.style.left); var ypos = parseint(elem.style.top); if (xpos == finalx && ypos == finaly) { return true; } if (xpos < finalx) { var dist = math.ceil((finalx - xpos) / 10); xpos = xpos + dist; } if (xpos > finalx) { var dist = math.ceil((xpos - finalx) / 10); xpos = xpos - dist; } if (ypos < finaly) { var dist = math.ceil((finaly - ypos) / 10); ypos = ypos + dist; } if (ypos > finaly) { var dist = math.ceil((ypos - finaly) / 10); ypos = ypos - dist; } elem.style.left = xpos + "px"; elem.style.top = ypos + "px"; elem.movement = settimeout(function(){ yao.moveelement(element, finalx, finaly, speed); }, speed); } }, ajax: function(config){ var oxhr, method = config.method ? config.method.touppercase() : 'get', url = config.url || '', fn = config.fn || null, postdata = config.data || null, elem = config.id ? yao.getel(config.id) : (config.element || null), load = config.loadfn ? config.loadfn : (config.loading || '���ڻ�ȡ���ݣ����ժ�...'); if (!url) { return; } if (window.xmlhttprequest) { oxhr = new xmlhttprequest(); } else { if (window.activexobject) { oxhr = new activexobject("microsoft.xmlhttp"); } } if (oxhr) { try { oxhr.open(method, url, true); oxhr.onreadystatechange = function(){ if (oxhr.readystate !== 4) { return false } if (oxhr.readystate == 4) { if (oxhr.status == 200 || location.href.indexof('http') === -1) { if (fn) { fn.success(oxhr); } else { elem.innerhtml = oxhr.responsetext; } } else { if (fn) { fn.failure(oxhr.status); } else { if (yao.isfunction(load)) { load(); } else { elem.innerhtml = load; } } } } }; oxhr.setrequestheader('x-requested-with', 'xmlhttprequest'); if (postdata) { oxhr.setrequestheader('content-type', 'application/x-www-form-urlencoded; charset=utf-8'); } oxhr.send(postdata); } catch (e) { throw new error(e); return false; } } else{ throw new error("your browser does not support xmlhttp."); return false; } }, json: function(){ function f(n){ return n < 10 ? '0' + n : n; } date.prototype.tojson = function(){ return this.getutcfullyear() + '-' + f(this.getutcmonth() + 1) + '-' + f(this.getutcdate()) + 't' + f(this.getutchours()) + ':' + f(this.getutcminutes()) + ':' + f(this.getutcseconds()) + 'z'; }; var m = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' }; function stringify(value, whitelist){ var a, i, k, l, r = /["\\\x00-\x1f\x7f-\x9f]/g, v; switch (typeof value) { case 'string': return r.test(value) ? '"' + value.replace(r, function(a){ var c = m[a]; if (c) { return c; } c = a.charcodeat(); return '\\u00' + math.floor(c / 16).tostring(16) + (c % 16).tostring(16); }) + '"' : '"' + value + '"'; case 'number': return isfinite(value) ? string(value) : 'null'; case 'boolean': case 'null': return string(value); case 'object': if (!value) { return 'null'; } if (typeof value.tojson === 'function') { return stringify(value.tojson()); } a = []; if (typeof value.length === 'number' && !(value.propertyisenumerable('length'))) { l = value.length; for (i = 0; i < l; i += 1) { a.push(stringify(value[i], whitelist) || 'null'); } return '[' + a.join(',') + ']'; } if (whitelist) { l = whitelist.length; for (i = 0; i < l; i += 1) { k = whitelist[i]; if (typeof k === 'string') { v = stringify(value[k], whitelist); if (v) { a.push(stringify(k) + ':' + v); } } } } else { for (k in value) { if (typeof k === 'string') { v = stringify(value[k], whitelist); if (v) { a.push(stringify(k) + ':' + v); } } } } return '{' + a.join(',') + '}'; } } return { stringify: stringify, parse: function(text, filter){ var j; function walk(k, v){ var i, n; if (v && typeof v === 'object') { for (i in v) { if (op.hasownproperty.apply(v, [i])) { n = walk(i, v[i]); if (n !== undefined) { v[i] = n; } else { delete v[i]; } } } } return filter(k, v); } if (/^[\],:{}\s]*$/.test(text.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[ee][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { j = eval('(' + text + ')'); return typeof filter === 'function' ? walk('', j) : j; } throw new syntaxerror('parsejson'); } }; }(), ytabs: function(){ var j, len = arguments.length, tabs = []; for (j = 0; j < len; ++j) { tabs[j] = new yao.singletab(arguments[j]); } return tabs; }, scrollnews: function(s, si, rt, ct){ var sn = new yao.scrollvertical(s, si, rt, ct); sn.speed = 4000; sn.ispause = true; var tm = settimeout(function(){ if (tm) { cleartimeout(tm); } sn.ispause = false; }, 2000); yao.on(sn.scrollarea, 'mouseover', function(){ sn.ispause = true; }); yao.on(sn.scrollarea, 'mouseout', function(){ sn.ispause = false; }); } }; yao.on(window, "unload", yao._unload); }(); yao.singletab = function(oconfigs){ this.tabroot = yao.isstring(oconfigs.tabroot) ? yao.getel(oconfigs.tabroot) : (oconfigs.tabroot || null); this.tabs = yao.isstring(oconfigs.tabs) ? this.tabroot.getelementsbytagname(oconfigs.tabs) : (oconfigs.tabs || null); this.contents = yao.isstring(oconfigs.contents) ? this.tabroot.getelementsbytagname(oconfigs.contents) : (oconfigs.contents || null); if(!this.tabs || !this.contents){ return false; } this.length = this.tabs.length || 0; this.defaultindex = oconfigs.defaultindex || 0; this.lastindex = this.defaultindex; this.lasttab = this.tabs[this.lastindex] || null; this.lastcontent = this.contents[this.lastindex] || null; this.evtname = oconfigs.evt || 'mouseover'; this.defaultclass = oconfigs.defaultclass || this.current_tab_class; this.previousclass = oconfigs.previousclass || ''; this.hideall = oconfigs.hideall || false; this.auto = oconfigs.auto || false; this.autospeed = oconfigs.autospeed || 6000; this.fadeup = oconfigs.fadeup || false; this.scroll = oconfigs.scroll || false; this.scrollid = oconfigs.scrollid || null; this.scrollspeed = oconfigs.scrollspeed || 5; this.direction = oconfigs.direction || 'v'; this.activetag = oconfigs.activetag || 'img'; this.stepheight = oconfigs.stepheight || 0; this.stepwidth = oconfigs.stepwidth || 0; this.ajax = oconfigs.ajax || false; this.ajaxdefaultinfo = this.contents.innerhtml; this.apath = oconfigs.apath || ''; this.init(); }; yao.singletab.prototype.timer = null; yao.singletab.prototype.ispause = false; yao.singletab.prototype.current_tab_class = 'current'; yao.singletab.prototype.init = function(){ var i, that = this; if (this.tabs && this.contents) { if (this.auto) { this.timer = settimeout(function(){ that.autochange(); }, that.autospeed); } if (!this.hideall) { yao.addclass(this.lasttab, this.defaultclass); if (!this.ajax && !this.scroll) { if (this.lastcontent) { this.lastcontent.style.display = 'block'; } } if (this.ajax) { this.ajaxtab(this.lasttab); } if (this.scroll) { this.scrollcnt((this.lastcontent || this.contents), this.defaultindex); } } else { yao.removeclass(this.lasttab, this.defaultclass); } for (i = 0; i < this.length; ++i) { if (i !== this.defaultindex) { yao.removeclass(this.tabs[i], this.current_tab_class); if (!this.ajax && !this.scroll) { this.contents[i].style.display = 'none'; } } yao.on(this.tabs[i], this.evtname, function(index){ return function(event){ var evt = null, curclass = (this.tabs[index] === this.tabs[this.defaultindex]) ? this.defaultclass : this.current_tab_class; if (!yao.hasclass(this.tabs[index], curclass)) { var currentcontent = (this.ajax || (this.scroll && (this.stepheight || this.stepwidth))) ? this.contents : (this.contents[index] || null); this.setcurrent(currentcontent, index); this.lastindex = index; } if (this.auto) { this.ispause = true; } evt = event || window.event; yao.stopevent(evt); } }(i), this.tabs[i], that); yao.on(this.tabs[i], 'mouseout', function(index){ return function(){ var curtab = this.tabs[index]; if (this.hideall && this.evtname === 'mouseover') { if (this.lasttab === curtab) { yao.removeclass(curtab, (yao.hasclass(curtab, that.defaultclass) ? this.defaultclass : this.current_tab_class)); } if (this.previousclasstab) { yao.removeclass(this.previousclasstab, this.previousclass); } if (!this.scroll && !this.ajax) { this.contents[index].style.display = 'none'; } } else { if (this.auto) { this.ispause = false; } } } }(i), this.tabs[i], that); } } }; yao.singletab.prototype.autochange = function(){ var that = this; if (!this.ispause) { var currentcontent = null, currenttab = null; if (this.timer) { cleartimeout(this.timer); this.timer = null; } this.lastindex = this.lastindex + 1; if (this.lastindex === this.length) { this.lastindex = 0; } currentcontent = this.ajax ? this.contents : (this.contents[this.lastindex] || null); this.setcurrent(currentcontent, this.lastindex); this.timer = settimeout(function(){ that.autochange(); }, this.autospeed); } else { this.timer = settimeout(function(){ that.autochange() }, this.autospeed); return false; } }; yao.singletab.prototype.setcurrent = function(curcnt, index){ var activeobj = null; curtab = this.tabs[index]; yao.removeclass(this.lasttab, (yao.hasclass(this.lasttab, this.defaultclass) ? this.defaultclass : this.current_tab_class)); if (curtab === this.tabs[this.defaultindex]) { yao.addclass(curtab, this.defaultclass); } else { yao.addclass(curtab, this.current_tab_class); } if (this.previousclass) { if (this.previousclasstab) { yao.removeclass(this.previousclasstab, this.previousclass); } if (index !== 0) { yao.addclass(this.tabs[index - 1], this.previousclass); if ((index - 1) === this.defaultindex) { yao.removeclass(this.tabs[index - 1], this.defaultclass); } this.previousclasstab = (this.tabs[index - 1]); } } if (!this.scroll && !this.ajax) { if (this.lastcontent) { this.lastcontent.style.display = "none"; } if (curcnt) { curcnt.style.display = "block"; } } if (this.fadeup) { activeobj = (curcnt.tagname.touppercase() === 'img') ? curcnt : curcnt.getelementsbytagname('img')[0]; if (this.lastcontent !== curcnt) { yao.fadeup(activeobj); } } else { if (this.scroll) { this.scrollcnt(curcnt, index); } } if (!this.ajax) { this.lastcontent = curcnt; } else { if (this.ajax) { this.ajaxtab(curtab); } } this.lasttab = curtab; }; yao.singletab.prototype.scrollcnt = function(curcnt, index){ var activeobj = null, itemheight = 0, itemwidth = 0, scrollwidth = 0, scrollheight = 0; if (this.activetag) { activeobj = (curcnt.tagname.touppercase() === this.activetag) ? curcnt : curcnt.getelementsbytagname(this.activetag)[0]; } if (this.direction === 'v') { itemheight = activeobj ? activeobj.offsetheight : this.stepheight; scrollheight = -(index * itemheight); } else { itemwidth = activeobj ? activeobj.offsetwidth : this.stepwidth; scrollwidth = -(index * itemwidth); } yao.moveelement(this.scrollid, scrollwidth, scrollheight, this.scrollspeed); }; yao.singletab.prototype.ajaxtab = function(curtab){ var url = '', ajaxlink = null, cnt = this.contents, uridata = this.apath.split('/'); ajaxlink = (curtab.tagname.touppercase() === 'a') ? curtab : curtab.getelementsbytagname('a')[0]; url = uridata[0] + '/' + ajaxlink.rel + uridata[1] + uridata[2] + ajaxlink.rel; if (curtab === this.tabs[this.defaultindex]) { cnt.innerhtml = this.ajaxdefaultinfo; } else { yao.ajax({ url: url, element: cnt, load: cnt.innerhtml }); } }; yao.scrollvertical = function(disp, msg, tg, stg){ var d = document; if (yao.isstring(disp)) { this.scrollarea = d.getelementbyid(disp); } else { this.scrollarea == disp; } if (yao.isstring(msg)) { this.scrollmsg = d.getelementbyid(msg); } else { this.scrollmsg = msg; } var s_msg = this.scrollmsg; var s_area = this.scrollarea; if (!tg) { var tg = 'li'; } this.unitheight = s_msg.getelementsbytagname(tg)[0].offsetheight; this.msgheight = this.unitheight * s_msg.getelementsbytagname(tg).length; s_msg.style.position = "absolute"; s_msg.style.top = "0"; s_msg.style.left = "0"; var copydiv = d.createelement(stg || 'div'); copydiv.id = s_area.id + "_copymsgid"; copydiv.innerhtml = s_msg.innerhtml; copydiv.style.height = this.msgheight + "px"; s_area.appendchild(copydiv); copydiv.style.position = "absolute"; copydiv.style.left = "0"; copydiv.style.top = this.msgheight + "px"; this.copymsg = copydiv; this.play(this); }; yao.scrollvertical.prototype.scrollarea = null; yao.scrollvertical.prototype.scrollmsg = null; yao.scrollvertical.prototype.unitheight = 0; yao.scrollvertical.prototype.msgheight = 0; yao.scrollvertical.prototype.copymsg = null; yao.scrollvertical.prototype.scrollvalue = 0; yao.scrollvertical.prototype.scrollheight = 0; yao.scrollvertical.prototype.isstop = true; yao.scrollvertical.prototype.ispause = false; yao.scrollvertical.prototype.scrolltimer = null; yao.scrollvertical.prototype.speed = 2000; yao.scrollvertical.prototype.play = function(o){ var s_msg = o.scrollmsg, c_msg = o.copymsg, s_area = o.scrollarea, msg_h = o.msgheight, ismoz = function(){ if (navigator.useragent.tolowercase().match(/mozilla/)) { return 1; } }, anim = function(){ if (o.scrolltimer) { cleartimeout(o.scrolltimer); } if (o.ispause) { o.scrolltimer = settimeout(anim, 50); return; } if (msg_h - o.scrollvalue <= 0) { o.scrollvalue = 0; } else { o.scrollvalue += 1; o.scrollheight += 1; } if (ismoz) { s_area.scrolltop = o.scrollvalue; } else { s_msg.style.top = -1 * o.scrollvalue + "px"; c_msg.style.top = (msg_h - o.scrollvalue) + "px"; } if (o.scrollheight % s_area.offsetheight == 0) { o.scrolltimer = settimeout(anim, o.speed); } else { o.scrolltimer = settimeout(anim, 50); } }; anim(); }; yao.chkall = function(config){ this.chkallitem = yao.isstring(config.chkallitem) ? yao.getel(config.chkallitem) : (config.chkallitem || null); this.list = yao.isstring(config.list) ? yao.getel(config.list) : (config.list || null); this.items = yao.isstring(config.items) ? this.list.getelementsbytagname(config.items) : (config.items || null); if(!this.chkallitem || !this.list || !this.items){ return false; } this.length = this.items.length; this.itemsnumperpage = config.itemsnumperpage || this.length; this.pages = math.ceil(this.length/this.itemsnumperpage); this.curpage = (this.itemsnumperpage !== this.length && config.curpage) ? config.curpage : 0; this.init(); }; yao.chkall.prototype.chknum = 0; yao.chkall.prototype.chked_row_class = 'chked'; yao.chkall.prototype.init = function(){ if (this.chkallitem && this.items) { var i, oself = this; for (i = 0; i < this.length; ++i) { yao.on(this.items[i], 'click', function(){ oself.chgitembg.call(oself,this); },this.items[i],true); } yao.on(this.chkallitem, 'click', function(){ oself.all.call(oself); },this.chkallitem,true); } }; yao.chkall.prototype.all = function(){ var i, startnum = this.curpage * this.itemsnumperpage, len = (this.length < startnum + this.itemsnumperpage) ? this.length : (startnum + this.itemsnumperpage); for (i = startnum; i < len; ++i) { this.items[i].checked = this.chkallitem.checked; this.chgitembg(this.items[i]); } }; yao.chkall.prototype.chgitembg = function(item){ var i, row = item.parentnode, curallitemlength = (this.length < ((this.curpage+1) * this.itemsnumperpage)) ? (this.length - (this.curpage * this.itemsnumperpage)) : this.itemsnumperpage; if (item.checked) { yao.addclass(row, this.chked_row_class); this.chknum += 1; if (this.chknum >= curallitemlength) { this.chknum = curallitemlength; this.chkallitem.checked = true; } } else { yao.removeclass(row, this.chked_row_class); if(this.chkallitem.checked){ this.chkallitem.checked = false; } this.chknum -= 1; if (this.chknum < 0) { this.chknum = 0; } } }; yao.carousel = function(oconfig){ this.btnprevious = yao.isstring(oconfig.btnprevious) ? yao.getel(oconfig.btnprevious) : (oconfig.btnprevious || null); this.lnkbtnprevious = this.btnprevious.getelementsbytagname('a')[0] || null; this.container = yao.isstring(oconfig.container) ? yao.getel(oconfig.container) : (oconfig.container || null); this.scroller = yao.isstring(oconfig.scroller) ? yao.getel(oconfig.scroller) : (oconfig.scroller || null); this.btnnext = yao.isstring(oconfig.btnnext) ? yao.getel(oconfig.btnnext) : (oconfig.btnnext || null); this.lnkbtnnext = this.btnnext.getelementsbytagname('a')[0] || null; this.items = yao.isstring(oconfig.items) ? this.container.getelementsbytagname(oconfig.items) : (oconfig.items || null); if(!this.btnprevious || !this.lnkbtnprevious || !this.container || !this.scroller || !this.btnnext || !this.lnkbtnnext || !this.items){ return false; } this.length = this.items.length; this.itemwidth = this.items[0].offsetwidth; this.itemheight = this.items[0].offsetheight; this.scrollerwidth = this.itemwidth * this.length; this.scrollheight = this.itemheight * this.length; this.derection = oconfig.derection || 'h'; this.stepheight = oconfig.stepheight || this.itemheight; this.stepwidth = oconfig.stepwidth || this.itemwidth; this.groups = this.derection === 'h' ? math.ceil(this.scrollerwidth / this.stepwidth) : math.ceil(this.scrollheight / this.stepheight); this.maxmovednum = this.derection === 'h' ? (this.groups - (this.container.offsetwidth / this.stepwidth)) : (this.groups - (this.container.offsetheight / this.stepheight)); this.scrollspeed = oconfig.speed || 50; this.init(); }; yao.carousel.prototype.movednum = 0; yao.carousel.prototype.lnk_btns_disabled_class = 'dis'; yao.carousel.prototype.init = function(){ var oself = this; if (this.derection === 'h') { this.scroller.style.width = this.scrollerwidth + 'px'; } else { this.scroller.style.height = this.scrollerheight + 'px'; } this.container.style.overflow = 'hidden'; if (this.lnkbtnnext && this.movednum === this.maxmovednum) { yao.addclass(this.lnkbtnnext, this.lnk_btns_disabled_class); } if (this.lnkbtnprevious && this.movednum === 0) { yao.addclass(this.lnkbtnprevious, this.lnk_btns_disabled_class); } yao.on(this.btnprevious, 'click', this.scrollprevious, this.btnprevious, oself); yao.on(this.btnnext, 'click', this.scrollnext, this.btnnext, oself); }; yao.carousel.prototype.scrollprevious = function(event){ var evt = event || window.event; if (this.movednum > 0) { this.movednum -= 1; if (this.lnkbtnnext && yao.hasclass(this.lnkbtnnext, this.lnk_btns_disabled_class)) { yao.removeclass(this.lnkbtnnext, this.lnk_btns_disabled_class); } if (this.movednum <= 0) { this.movednum = 0; if (this.lnkbtnprevious) { yao.addclass(this.lnkbtnprevious, this.lnk_btns_disabled_class); } } this.scroll(this.movednum); } yao.stopevent(evt); }; yao.carousel.prototype.scrollnext = function(event){ var evt = event || window.event; if (this.movednum < this.maxmovednum) { this.movednum += 1; if (this.lnkbtnprevious && yao.hasclass(this.lnkbtnprevious, this.lnk_btns_disabled_class)) { yao.removeclass(this.lnkbtnprevious, this.lnk_btns_disabled_class); } if (this.movednum >= this.maxmovednum) { this.movednum = this.maxmovednum; if (this.lnkbtnnext) { yao.addclass(this.lnkbtnnext, this.lnk_btns_disabled_class); } } this.scroll(this.movednum); } yao.stopevent(evt); }; yao.carousel.prototype.scroll = function(steps){ var scrollwidth = 0, scrollheight = 0; if (this.derection === 'h') { if (this.stepwidth) { scrollwidth = -(this.stepwidth * steps); } else { scrollwidth = -(this.itemwidth * steps); } } else { if (this.stepheight) { scrollheight = -(this.stepheight * steps); } else { scrollheight = -(this.itemheight * steps); } } yao.moveelement(this.scroller, scrollwidth, scrollheight, this.scrollspeed); }; yao.yalbum = function(){ var oself = this; this.ocarousel = new yao.carousel({ btnprevious: oself.carsouel_btn_previous, container: oself.carsouel_container, scroller: oself.carsouel_scroller, btnnext: oself.carsouel_btn_next, items: oself.carsouel_item_tag, stepwidth: oself.carsouel_step_width }) || null; this.osamples = this.ocarousel.scroller.getelementsbytagname('a') || null; this.length = this.osamples.length || 0; this.lastsample = this.osamples[0] || null; this.photocontainer = yao.getel(this.photo_container_id) || null; this.photo = yao.getel(this.photo_id) || null; this.photointro = yao.getel(this.photo_intro_id) || null; this.sintro = this.photo.alt || ''; this.init(); }; yao.yalbum.prototype.lastindex = 0; yao.yalbum.prototype.isloading = false; yao.yalbum.prototype.lastphotoheight = 0; yao.yalbum.prototype.loadshardow = null; yao.yalbum.prototype.loadimg = null; yao.yalbum.prototype.carsouel_btn_previous = yao.getel('carousel_btn_lastgroup'); yao.yalbum.prototype.carsouel_container = yao.getel('carousel_container'); yao.yalbum.prototype.carsouel_scroller = yao.getel('samples_list'); yao.yalbum.prototype.carsouel_btn_next = yao.getel('carousel_btn_nextgroup'); yao.yalbum.prototype.carsouel_item_tag = 'li'; yao.yalbum.prototype.carsouel_step_width = 672; yao.yalbum.prototype.photo_max_width = 800; yao.yalbum.prototype.photo_container_id = 'carousel_photo_container'; yao.yalbum.prototype.photo_id = 'carousel_photo'; yao.yalbum.prototype.photo_intro_id = 'carousel_photo_intro'; yao.yalbum.prototype.btn_next_id = 'carousel_next_photo'; yao.yalbum.prototype.btn_next_class = 'next'; yao.yalbum.prototype.btn_previous_id = 'carousel_previous_photo'; yao.yalbum.prototype.btn_previous_class = 'previous'; yao.yalbum.prototype.btn_disabled_class = 'dis'; yao.yalbum.prototype.img_btn_previous = 'url(img/last-photo.gif)'; yao.yalbum.prototype.img_btn_next = 'url(img/next-photo.gif)'; yao.yalbum.prototype.shardow_id = 'carousel_photo_shardow'; yao.yalbum.prototype.load_img_path = 'img/loading.gif'; yao.yalbum.prototype.load_img_id = 'carousel_photo_loading'; yao.yalbum.prototype.init = function(){ var oself = this, i; yao.addclass(this.lastsample, 'current'); this.btnprevious = yao.builder.node('a', { href: oself.osamples[oself.lastindex].href, id: oself.btn_previous_id, classname: oself.btn_previous_class, title: '��һ��' }, '��һ��'); this.photocontainer.appendchild(this.btnprevious); this.btnnext = yao.builder.node('a', { href: oself.osamples[oself.lastindex + 1].href, id: oself.btn_next_id, classname: oself.btn_next_class, title: '��һ��' }, '��һ��'); this.photocontainer.appendchild(this.btnnext); this.load(this.photo.src); yao.on(this.btnprevious, 'click', function(event){ var evt = event || window.event; this.previous(); yao.stopevent(evt); }, this.btnprevious, oself); yao.on(this.btnnext, 'click', function(event){ var evt = event || window.event; this.next(); yao.stopevent(evt); }, this.btnnext, oself); for (i = 0; i < this.length; ++i) { yao.on(this.osamples[i], 'click', function(index){ return function(event){ var evt = event || window.event, cursample = this.osamples[index]; if (this.lastsample !== cursample && !this.isloading) { this.lastindex = index; this.btnsenabled(); this.chgphoto(); } yao.stopevent(evt); } }(i), this.osamples[i], oself); } }; yao.yalbum.prototype.btnsenabled = function(){ if (this.lastindex !== 0 && yao.hasclass(this.btnprevious, this.btn_disabled_class)) { yao.removeclass(this.btnprevious, this.btn_disabled_class); if (yao.ua.ie) { this.btnprevious.style.backgroundimage = this.img_btn_previous; } this.btnprevious.href = this.osamples[this.lastindex - 1]; } else { if (this.lastindex === 0) { yao.addclass(this.btnprevious, this.btn_disabled_class); if (yao.ua.ie) { this.btnprevious.style.backgroundimage = 'none'; } this.btnprevious.href = this.osamples[this.lastindex]; } } if (this.lastindex !== (this.length - 1) && yao.hasclass(this.btnnext, this.btn_disabled_class)) { yao.removeclass(this.btnnext, this.btn_disabled_class); if (yao.ua.ie) { this.btnnext.style.backgroundimage = this.img_btn_next; } this.btnnext.href = this.osamples[this.lastindex + 1]; } else { if (this.lastindex === (this.length - 1)) { yao.addclass(this.btnnext, this.btn_disabled_class); if (yao.ua.ie) { this.btnnext.style.backgroundimage = 'none'; } this.btnnext.href = this.osamples[this.lastindex]; } } }; yao.yalbum.prototype.load = function(path){ var oimage = new image(), odf = document.createdocumentfragment(); oimage.src = path; if (oimage.complete) { this.resize(oimage); } else { this.isloading = true; this.loadshardow = yao.builder.node('div', { id: this.shardow_id }); this.loadimg = yao.builder.node('img', { src: this.load_img_path, id: this.load_img_id }); odf.appendchild(this.loadshardow); if (yao.ua.ie) { this.loadshardow.style.height = this.lastphotoheight ? this.lastphotoheight + 'px' : this.photocontainer.offsetheight + 'px'; } odf.appendchild(this.loadimg); this.photocontainer.appendchild(odf); yao.on(oimage, 'load', function(){ this.resize(oimage); }, oimage, this); } }; yao.yalbum.prototype.resize = function(oimage){ var oself = this; var width = oimage.width; var height = oimage.height; var percent = width / height; if (width > this.photo_max_width) { width = this.photo_max_width; height = width / percent; } if (yao.ua.ie) { this.lastphotoheight = height; yao.setstyles(this.btnprevious, { height: height + 'px', backgroundimage: oself.img_btn_previous }); yao.setstyles(this.btnnext, { height: height + 'px', backgroundimage: oself.img_btn_next }); } if (this.lastindex === 0) { yao.addclass(this.btnprevious, this.btn_disabled_class); if (yao.ua.ie) { this.btnprevious.style.backgroundimage = 'none'; } } if (this.lastindex === (this.length - 1)) { yao.addclass(this.btnnext, this.btn_disabled_class); if (yao.ua.ie) { this.btnnext.style.backgroundimage = 'none'; } } this.photointro.innerhtml = this.sintro; yao.setstyle(this.photocontainer, 'width', (width + 'px')); yao.setstyles(this.photo, { width: width + 'px', height: height + 'px' }); if (this.loadimg && this.loadshardow) { this.isloading = false; this.photocontainer.removechild(this.loadimg); this.loadimg = null; this.photocontainer.removechild(this.loadshardow); this.loadshardow = null; } }; yao.yalbum.prototype.previous = function(){ if (this.lastindex !== 0) { this.lastindex -= 1; if (yao.hasclass(this.btnnext, this.btn_disabled_class)) { yao.removeclass(this.btnnext, this.btn_disabled_class); } if (this.lastindex >= 1) { this.btnprevious.href = this.osamples[this.lastindex - 1].href; } if (this.lastindex < 0) { this.lastindex = 0; yao.addclass(this.btnprevious, this.btn_disabled_class); this.btnprevious.href = this.osamples[this.lastindex].href; } this.btnnext.href = this.osamples[this.lastindex+1].href; this.chgphoto(); } }; yao.yalbum.prototype.next = function(){ if (this.lastindex < (this.length - 1)) { this.lastindex += 1; if (yao.hasclass(this.btnprevious, this.btn_disabled_class)) { yao.removeclass(this.btnprevious, this.btn_disabled_class); } if (this.lastindex <= (this.length - 2)) { this.btnnext.href = this.osamples[this.lastindex + 1].href; } if (this.lastindex > (this.length - 1)) { this.lastindex = (this.length - 1); yao.addclass(this.btnnext, this.btn_disabled_class); this.btnnext.href = this.osamples[this.lastindex].href; } this.btnprevious.href = this.osamples[this.lastindex-1].href; this.chgphoto(); } }; yao.yalbum.prototype.chgphoto = function(){ var path = ''; this.sintro = this.osamples[this.lastindex].title; path = this.osamples[this.lastindex].href; yao.removeclass(this.lastsample, 'current'); yao.addclass(this.osamples[this.lastindex], 'current'); this.lastsample = this.osamples[this.lastindex]; this.photo.src = path; this.load(path); this.scroll(); }; yao.yalbum.prototype.scroll = function(){ var curscreen = math.ceil(((this.lastindex + 1) * this.ocarousel.itemwidth) / this.ocarousel.stepwidth) - 1; if (curscreen != this.ocarousel.movednum) { this.ocarousel.scroll(curscreen); this.ocarousel.movednum = curscreen; if (this.ocarousel.movednum !== 0 && yao.hasclass(this.ocarousel.lnkbtnprevious, this.btn_disabled_class)) { yao.removeclass(this.ocarousel.lnkbtnprevious, this.btn_disabled_class); } else { if (this.ocarousel.movednum === 0) { yao.addclass(this.ocarousel.lnkbtnprevious, this.btn_disabled_class); } } if (this.ocarousel.movednum !== this.ocarousel.maxmovednum && yao.hasclass(this.ocarousel.lnkbtnnext, this.btn_disabled_class)) { yao.removeclass(this.ocarousel.lnkbtnnext, this.btn_disabled_class); } else { if (this.ocarousel.movednum === this.ocarousel.maxmovednum) { yao.addclass(this.ocarousel.lnkbtnnext, this.btn_disabled_class); } } } };