YAOHAIXIAO.COM

HTML(5),CSS(3),JavaScript,DOM,Ajax,JSON,Front-end technologies & Yaohaixiao

热门标签:JavaScript Performance 前端开发 前端性能优化 原创

Rss

Home » Downloads » YLightbox 相册特效

YLightbox 相册特效

程序简介:

YLightbox也是我3年多前,以 YUI 2.6 为基础库写的一个相册效果,看名字我想你大概也明白了,类似 lightbox 的效果,这个效果在有很多图片的页面使用,是非常不错的选择。虽然没有fancybox那么炫的zoomin,zoomout的动画效果,不过确实十分实用,兼容性也很不多错的。

YAO.YLightBox.init('y-lightbox', 'img', 'container');

演示地址:http://www.yaohaixiao.com/scripts/ylightbox/
下载地址:ylightbox.zip

程序特点:

  1. 固定屏幕中心显示
  2. 图片显示窗口会根据图片大小自动调整
  3. 支持图片缩略图显示
  4. 浏览器兼容性好

程序 JavaScript 源代码:

/**
 * @author Yaohaixiao
 */
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(/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 + ">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(oConfig){
    var oSelf = this;
    this.oCarousel = new YAO.Carousel({
        btnPrevious: (oConfig && oConfig.btnPrevious) ? oConfig.btnPrevious : oSelf.CARSOUEL_BTN_PREVIOUS,
        Container: (oConfig && oConfig.Container) ? oConfig.Container : oSelf.CARSOUEL_CONTAINER,
        Scroller: (oConfig && oConfig.Scroller) ? oConfig.Scroller : oSelf.CARSOUEL_SCROLLER,
        btnNext: (oConfig && oConfig.btnNext) ? oConfig.btnNext : oSelf.CARSOUEL_BTN_NEXT,
        items: (oConfig && oConfig.items) ? oConfig.items : oSelf.CARSOUEL_ITEM_TAG,
        stepWidth: (oConfig && oConfig.stepWidth) ? oConfig.stepWidth : oSelf.CARSOUEL_STEP_WIDTH
    });
    this.oSamples = this.oCarousel.Scroller.getElementsByTagName('a') || null;
    this.length = this.oSamples.length || 0;
    this.lastSample = this.oSamples[0] || null;
    this.photoContainer = (oConfig && oConfig.photoContainer) ? (YAO.isString(oConfig.photoContainer) ? YAO.getEl(oConfig.photoContainer) : oConfig.photoContainer) : (YAO.getEl(this.PHOTO_CONTAINER_ID) || null);
    this.photo = (oConfig && oConfig.photo) ? (YAO.isString(oConfig.photo) ? YAO.getEl(oConfig.photo) : oConfig.photo) : (YAO.getEl(this.PHOTO_ID) || null);
    this.photoIntro = (oConfig && oConfig.photoIntro) ? (YAO.isString(oConfig.photoIntro) ? YAO.getEl(oConfig.photoIntro) : oConfig.photoIntro) : (YAO.getEl(this.PHOTO_INTRO_ID) || null);
    this.PHOTO_MAX_WIDTH = (oConfig && oConfig.photoMaxWidth) ? oConfig.photoMaxWidth : this.PHOTO_MAX_WIDTH;
    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.btnPrevious = null;
YAO.YAlbum.prototype.btnNext = 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);
            }
        }
    }
};

YAO.YLightBox = {
    isHidden: false,
    photos: null,
    length: 0,
    YOverlay: null,
    YBox: null,
    YBoxDefaultWidth: 500,
    YBoxDefaultHeight: 0,
    YBoxHd: null,
    YBoxHdHeight: 0,
    YBoxTitle: null,
    YBoxToolBar: null,
    closeable: true,
    YBoxCloseBar: null,
    maximizable: true,
    YBoxMaximizeBar: null,
    newindowable: true,
    YBoxNewWinBar: null,
    YBoxBd: null,
    YBoxBDefaultHeight: 0,
    YBoxPhoto: null,
    YBoxPhotoDefaultWidth: 0,
    YBoxPhotoDefaultHeight: 0,
    YBoxTips: null,
    YBoxIndex: null,
    YBoxLastIndex: 0,
    carouselable: true,
    YCarousel: null,
    YBoxCarousel: null,
    YBoxScroller: null,
    YBoxBtnLastGroup: null,
    YBoxBtnNextGroup: null,
    YBoxLastSample: null,
    albumabel: true,
    YAlbum: null,
    YBoxBtnPrevious: null,
    YBoxBtnNext: null,
    BTN_DISABLED_CLASS: 'dis',
    IMG_BTN_PREVIOUS: 'url(img/last-photo.gif)',
    IMG_BTN_NEXT: 'url(img/next-photo.gif)',
    
    init: function(itemClass, itemTag, rootId){
        var i, oSelf = this;
        this.photos = YAO.getElByClassName(itemClass, itemTag, rootId);
        this.length = this.photos.length;
        for (i = 0; i < this.length; ++i) {
            YAO.on(this.photos[i], 'click', function(index){
                return function(event){
                    var evt = event || window.event;
                    this.YBoxLastIndex = index;
                    this.YBoxPhotoDefaultWidth = this.photos[this.YBoxLastIndex].width;
                    this.YBoxPhotoDefaultHeight = this.photos[this.YBoxLastIndex].height;
                    this.initComponent();
                    this.zoom();
                    YAO.stopEvent(evt);
                }
            }(i), this.photos[i], oSelf);
        }
    },
    initComponent: function(){
        if (!this.YBox) {
            this.create();
            this.initEvents();
        }
        else {
            this.show();
        }
        this.currentSample();
    },
    create: function(){
        var D = document, i, oDfBox = D.createDocumentFragment(), oDfTip = D.createDocumentFragment(), docWidth = YAO.getDocumentWidth(), docHeight = YAO.getDocumentHeight(), oSelf = this;
        oImage = this.photos[this.YBoxLastIndex];
        oDfBox.appendChild(YAO.Builder.Node('div', {
            id: 'yl-shardow'
        }));
        oDfBox.appendChild(YAO.Builder.Node('div', {
            id: 'yl-box'
        }, [YAO.Builder.Node('div', {
            id: 'yl-box-hd'
        }, [YAO.Builder.Node('h3', {
            id: 'yl-box-tlt'
        }, oImage.alt), YAO.Builder.Node('span', {
            id: 'yl-box-toolbar'
        })]), YAO.Builder.Node('div', {
            id: 'yl-box-bd'
        }, [YAO.Builder.Node('img', {
            src: oImage.src,
            alt: oImage.alt,
            id: 'yl-photo'
        }), YAO.Builder.Node('div', {
            id: 'carousel'
        }, YAO.Builder.Node('div', {
            id: 'carousel_container'
        }))])]));
        D.body.appendChild(oDfBox);
        
        this.YOverlay = YAO.getEl('yl-shardow');
        YAO.setStyles(this.YOverlay, {
            height: docHeight + 'px'
        });
        
        this.YBox = YAO.getEl('yl-box');
        this.YBoxHd = YAO.getEl('yl-box-hd');
        this.YBoxHdHeight = this.YBoxHd.offsetHeight;
        this.YBoxTitle = YAO.getEl('yl-box-tlt');
        this.YBoxToolBar = YAO.getEl('yl-box-toolbar');
        
        this.initTools();
        
        this.YBoxBd = YAO.getEl('yl-box-bd');
        this.YBoxCarousel = YAO.getEl('carousel');
        this.YBoxCarouselCnt = YAO.getEl('carousel_container');
        this.YBoxPhoto = YAO.getEl('yl-photo');
        
        this.initPlgins();
        
        oDfTip.appendChild(YAO.Builder.Node('div', {
            id: 'yl-tips'
        }, [YAO.Builder.Node('em', {
            id: 'yl-curIndex'
        }, (this.YBoxLastIndex + 1) + ''), ' / ' + this.length + ' pictures']));
        this.YBoxCarousel.appendChild(oDfTip);
        
        this.YBoxTips = YAO.getEl('yl-tips');
        this.YBoxIndex = YAO.getEl('yl-curIndex');
        
        if (this.carouselable) {
            this.YBoxLastSample = this.YCarousel.items[this.YBoxLastIndex];
        }
        
        this.isHidden = false;
    },
    initTools: function(){
        var D = document, oDfTools = D.createDocumentFragment();
        oImage = this.photos[this.YBoxLastIndex];
        if (this.newindowable) {
            oDfTools.appendChild(YAO.Builder.Node('a', {
                id: 'yl-box-newindow',
                href: oImage.src,
                target: '_blank',
                title: '新窗口打开'
            }, '新窗口打开'));
        }
        if (this.maximizable) {
            oDfTools.appendChild(YAO.Builder.Node('a', {
                id: 'yl-box-adjust',
                className: 'imgadjust',
                href: '#adjust',
                title: '显示实际尺寸'
            }, '显示实际尺寸'));
        }
        if (this.closeable) {
            oDfTools.appendChild(YAO.Builder.Node('a', {
                id: 'yl-box-closebar',
                className: 'imgclose',
                href: '#close',
                title: '关闭窗口'
            }, '关闭窗口'));
        }
        this.YBoxToolBar.appendChild(oDfTools);
        this.YBoxNewWinBar = YAO.getEl('yl-box-newindow');
        this.YBoxMaximizeBar = YAO.getEl('yl-box-adjust');
        this.YBoxCloseBar = YAO.getEl('yl-box-closebar');
    },
    initPlgins: function(){
        var D = document, oSelf = this, oCConfig = {}, oAConfig = {}, i, oDfSamples = D.createDocumentFragment(), oDfBtnsGroups = D.createDocumentFragment(), oDfBtnsPhoto = D.createDocumentFragment();
        
        if (this.carouselable) {
            this.YBoxCarouselCnt.appendChild(YAO.Builder.Node('ul', {
                id: 'samples_list'
            }));
            this.YBoxScroller = YAO.getEl('samples_list');
            
            for (i = 0; i < this.length; ++i) {
                oDfSamples.appendChild(YAO.Builder.Node('li', {
                    className: i === oSelf.YLastIndex ? 'current' : ''
                }, YAO.Builder.Node('a', {
                    href: oSelf.photos[i].src,
                    title: oSelf.photos[i].alt,
                    target: 'blank'
                }, YAO.Builder.Node('img', {
                    src: oSelf.photos[i].src,
                    alt: oSelf.photos[i].alt
                }))));
            }
            this.YBoxScroller.appendChild(oDfSamples);
            
            oDfBtnsGroups.appendChild(YAO.Builder.Node('div', {
                id: 'carousel_btn_lastgroup'
            }, YAO.Builder.Node('a', {
                href: '#lastgroup',
                title: '上一组'
            }, '上一组')));
            oDfBtnsGroups.appendChild(YAO.Builder.Node('div', {
                id: 'carousel_btn_nextgroup'
            }, YAO.Builder.Node('a', {
                href: '#nextgroup',
                title: '下一组'
            }, '下一组')));
            this.YBoxCarousel.appendChild(oDfBtnsGroups);
            
            this.YBoxBtnLastGroup = YAO.getEl('carousel_btn_lastgroup');
            this.YBoxBtnNextGroup = YAO.getEl('carousel_btn_nextgroup');
            
            oCConfig = {
                btnPrevious: oSelf.YBoxBtnLastGroup,
                Container: oSelf.YBoxCarouselCnt,
                Scroller: oSelf.YBoxScroller,
                btnNext: oSelf.YBoxBtnNextGroup,
                stepWidth: 100,
                items: 'li'
            };
            this.YCarousel = new YAO.Carousel(oCConfig);
        }
        
        if (this.albumabel) {
            oDfBtnsPhoto.appendChild(YAO.Builder.Node('a', {
                id: 'carousel_previous_photo',
                className: 'previous',
                href: (oSelf.YLastIndex - 1 > 0) ? oSelf.photos[oSelf.YLastIndex - 1].src : oSelf.photos[0].src,
                title: '上一张',
                target: '_blank'
            }, '上一张'));
            oDfBtnsPhoto.appendChild(YAO.Builder.Node('a', {
                id: 'carousel_next_photo',
                className: 'next',
                href: (oSelf.YLastIndex + 1 < oSelf.length - 1) ? oSelf.photos[oSelf.YLastIndex + 1].src : oSelf.photos[oSelf.length - 1].src,
                title: '下一张',
                target: '_blank'
            }, '下一张'));
            this.YBoxBd.appendChild(oDfBtnsPhoto);
            
            this.YBoxBtnPrevious = YAO.getEl('carousel_previous_photo');
            this.YBoxBtnNext = YAO.getEl('carousel_next_photo');
        }
    },
    show: function(){
        var oImage = this.photos[this.YBoxLastIndex];
        if (this.YOverlay && this.YBox && this.isHidden) {
            this.YBoxTitle.innerHTML = oImage.alt;
            this.YBoxNewWinBar.href = oImage.src;
            YAO.Builder.Attributes(this.YBoxPhoto, {
                src: oImage.src,
                alt: oImage.alt
            });
            this.YBoxIndex.innerHTML = (this.YBoxLastIndex + 1);
            YAO.setStyle(this.YOverlay, 'display', 'block');
            YAO.setStyle(this.YBox, 'display', 'block');
            this.isHidden = false;
        }
    },
    initBtns: function(){
        var oSelf = this;
        if (this.albumabel) {
            if (YAO.ua.ie) {
                YAO.setStyle(this.YBoxBtnPrevious, 'backgroundImage', oSelf.IMG_BTN_PREVIOUS);
                YAO.setStyle(this.YBoxBtnNext, 'backgroundImage', oSelf.IMG_BTN_NEXT);
            }
            if (this.YBoxLastIndex === 0) {
                YAO.addClass(this.YBoxBtnPrevious, this.BTN_DISABLED_CLASS);
                if (YAO.ua.ie) {
                    YAO.setStyle(this.YBoxBtnPrevious, 'backgroundImage', 'none');
                }
            }
            if (this.YBoxLastIndex === (this.length - 1)) {
                YAO.addClass(this.YBoxBtnNext, this.BTN_DISABLED_CLASS);
                if (YAO.ua.ie) {
                    YAO.setStyle(this.YBoxBtnNext, 'backgroundImage', 'none');
                }
            }
        }
    },
    initEvents: function(){
        var i;
        
        if (this.maximizable) {
            YAO.on(this.YBoxHd, 'dblclick', this.toggleMaximize, this.YBoxHd, this);
            YAO.on(this.YBoxMaximizeBar, 'click', this.toggleMaximize, this.YBoxMaximizeBar, this);
        }
        if (this.closeable) {
            YAO.on(this.YBoxCloseBar, 'click', this.close, this.YBoxCloseBar, this);
        }
        
        if (this.carouselable) {
            for (i = 0; i < this.length; ++i) {
                YAO.on(this.YCarousel.items[i], 'click', function(index){
                    return function(event){
                        var evt = event || window.event;
                        this.YBoxLastIndex = index;
                        this.btnsEnabled();
                        this.changePhoto();
                        YAO.stopEvent(evt);
                    }
                }(i), this.YCarousel.items[i], this);
            }
            
            YAO.on(this.YBoxTips, 'click', this.showCarousel, this.YBoxTips, this);
        }
        
        if (this.albumabel) {
            YAO.on(this.YBoxBtnPrevious, 'click', this.previousPhoto, this.YBoxBtnPrevious, this);
            YAO.on(this.YBoxBtnNext, 'click', this.nextPhoto, this.YBoxBtnNext, this);
        }
        
        YAO.on(window, 'scroll', this.fixPosition, window, this);
        YAO.on(window, 'resize', this.fixPosition, window, this);
    },
    close: function(event){
        var evt = event || window.event;
        if (this.YOverlay && this.YBox && !this.isHidden) {
            YAO.setStyle(this.YOverlay, 'display', 'none');
            YAO.setStyle(this.YBox, 'display', 'none');
            this.minimize();
            this.isHidden = true;
            this.YBoxLastIndex = 0;
        }
        YAO.stopEvent(evt);
    },
    zoom: function(){
        var percent = this.YBoxPhotoDefaultWidth / this.YBoxPhotoDefaultHeight, height = this.YBoxDefaultWidth / percent;
        this.YBoxDefaultHeight = height + this.YBoxHdHeight;
        this.YBoxBDefaultHeight = height;
        if (this.YBoxPhotoDefaultWidth > this.YBoxDefaultWidth) {
            this.minimize();
        }
        else {
            this.restore();
        }
        this.initBtns();
        this.fixPosition();
    },
    minimize: function(){
        var oSelf = this;
        YAO.setStyles(this.YBoxPhoto, {
            width: oSelf.YBoxDefaultWidth + 'px',
            height: oSelf.YBoxDefaultHeight + 'px'
        });
        YAO.setStyles(this.YBoxBd, {
            width: oSelf.YBoxDefaultWidth + 'px',
            height: oSelf.YBoxBDefaultHeight + 'px'
        });
        YAO.setStyles(this.YBox, {
            width: oSelf.YBoxDefaultWidth + 'px',
            height: oSelf.YBoxDefaultHeight + 'px'
        });
        if (this.YBoxMaximizeBar) {
            this.YBoxMaximizeBar.title = '显示实际尺寸';
        }
        if (YAO.ua.ie && this.albumable) {
            YAO.setStyle(this.YBoxBtnPrevious, 'height', (this.YBoxDefaultHeight + 'px'));
            YAO.setStyle(this.YBoxBtnNext, 'height', (this.YBoxDefaultHeight + 'px'));
        }
    },
    restore: function(){
        var oSelf = this;
        YAO.setStyles(this.YBoxPhoto, {
            width: oSelf.YBoxPhotoDefaultWidth + 'px',
            height: oSelf.YBoxPhotoDefaultHeight + 'px'
        });
        YAO.setStyles(this.YBoxBd, {
            width: oSelf.YBoxPhotoDefaultWidth + 'px',
            height: oSelf.YBoxPhotoDefaultHeight + 'px'
        });
        YAO.setStyles(this.YBox, {
            width: oSelf.YBoxPhotoDefaultWidth + 'px',
            height: (oSelf.YBoxPhotoDefaultHeight + oSelf.YBoxHdHeight) + 'px'
        });
        if (this.YBoxMaximizeBar) {
            this.YBoxMaximizeBar.title = '显示缩略图';
        }
        if (YAO.ua.ie && this.albumable) {
            YAO.setStyle(this.YBoxBtnPrevious, 'height', (this.YBoxPhotoDefaultWidth + 'px'));
            YAO.setStyle(this.YBoxBtnNext, 'height', (this.YBoxPhotoDefaultHeight + 'px'));
        }
    },
    toggleMaximize: function(event){
        var evt = event || window.event;
        if (this.YBoxPhotoDefaultWidth > this.YBoxDefaultWidth) {
            if (this.YBoxPhoto.width === this.YBoxDefaultWidth) {
                this.restore();
            }
            else {
                this.minimize();
            }
            this.fixPosition();
        }
        YAO.stopEvent(evt);
    },
    fixPosition: function(){
        var documentWidth = YAO.getDocumentWidth(), documentHeight = YAO.getDocumentHeight(), viewportWidth = YAO.getViewportWidth(), viewportHeight = YAO.getViewportHeight(), xScroll = YAO.getXScroll(), yScroll = YAO.getYScroll(), YBoxWidth = this.YBox.offsetWidth, YBoxHeight = this.YBox.offsetHeight, left = xScroll + ((viewportWidth - YBoxWidth) / 2), top = yScroll + ((viewportHeight - YBoxHeight) / 2);
        
        if (YBoxWidth > viewportWidth) {
            if ((YBoxWidth < documentWidth) && ((YBoxWidth + xScroll) < documentWidth)) {
                left = xScroll;
            }
            else {
                left = documentWidth - YBoxWidth;
            }
        }
        else {
            if (YBoxWidth > documentWidth) {
                left = 0;
            }
        }
        if (YBoxHeight > viewportHeight) {
            if ((YBoxHeight < documentHeight) && ((YBoxHeight + yScroll) <= documentHeight)) {
                top = yScroll;
            }
            else {
                top = documentHeight - YBoxHeight;
            }
        }
        else {
            if (YBoxHeight > documentHeight) {
                top = 0;
            }
        }
        
        if (!this.isHidden) {
            YAO.setStyles(this.YBox, {
                margin: 0,
                left: left + 'px',
                top: top + 'px'
            });
        }
    },
    showCarousel: function(){
        var top = parseInt(YAO.getStyle(this.YBoxCarousel, 'top'), 10);
        if (top === -120) {
            YAO.moveElement(this.YBoxCarousel, 0, 0, 50);
            YAO.setStyle(this.YBoxBtnLastGroup, 'display', 'block');
            YAO.setStyle(this.YBoxBtnNextGroup, 'display', 'block');
        }
        else {
            YAO.moveElement(this.YBoxCarousel, 0, -120, 50);
            YAO.setStyle(this.YBoxBtnLastGroup, 'display', 'none');
            YAO.setStyle(this.YBoxBtnNextGroup, 'display', 'none');
        }
    },
    currentSample: function(){
        var curSample = null;
        if (this.carouselable) {
            curSample = this.YCarousel.items[this.YBoxLastIndex];
            
            if (curSample !== this.YBoxLastSample) {
                YAO.removeClass(this.YBoxLastSample, 'current');
            }
            YAO.addClass(curSample, 'current');
            this.YBoxLastSample = curSample;
        }
    },
    scrollCarousel: function(){
        if (this.carouselable) {
            var curScreen = Math.ceil(((this.YBoxLastIndex + 1) * this.YCarousel.itemWidth) / this.YCarousel.stepWidth) - 1;
            if (curScreen != this.YCarousel.movedNum) {
                this.YCarousel.scroll(curScreen);
                this.YCarousel.movedNum = curScreen;
                if (this.YCarousel.movedNum !== 0 && YAO.hasClass(this.YCarousel.lnkBtnPrevious, this.BTN_DISABLED_CLASS)) {
                    YAO.removeClass(this.YCarousel.lnkBtnPrevious, this.BTN_DISABLED_CLASS);
                }
                else {
                    if (this.YCarousel.movedNum === 0) {
                        YAO.addClass(this.YCarousel.lnkBtnPrevious, this.BTN_DISABLED_CLASS);
                    }
                }
                if (this.YCarousel.movedNum !== this.YCarousel.maxMovedNum && YAO.hasClass(this.YCarousel.lnkBtnNext, this.BTN_DISABLED_CLASS)) {
                    YAO.removeClass(this.YCarousel.lnkBtnNext, this.BTN_DISABLED_CLASS);
                }
                else {
                    if (this.YCarousel.movedNum === this.YCarousel.maxMovedNum) {
                        YAO.addClass(this.YCarousel.lnkBtnNext, this.BTN_DISABLED_CLASS);
                    }
                }
            }
        }
    },
    btnsEnabled: function(){
        if (this.albumabel) {
            if (this.YBoxLastIndex !== 0) {
                if (YAO.hasClass(this.YBoxBtnPrevious, this.BTN_DISABLED_CLASS)) {
                    YAO.removeClass(this.YBoxBtnPrevious, this.BTN_DISABLED_CLASS);
                }
                if (YAO.ua.ie) {
                    YAO.setStyle(this.YBoxBtnPrevious, 'backgroundImage', this.IMG_BTN_PREVIOUS);
                }
                this.YBoxBtnPrevious.href = this.photos[this.YBoxLastIndex - 1].src;
            }
            else {
                if (this.YBoxLastIndex === 0) {
                    YAO.addClass(this.YBoxBtnPrevious, this.BTN_DISABLED_CLASS);
                    if (YAO.ua.ie) {
                        YAO.setStyle(this.YBoxBtnPrevious, 'backgroundImage', 'none');
                    }
                    this.YBoxBtnPrevious.href = this.photos[this.YBoxLastIndex].src;
                }
            }
            if (this.YBoxLastIndex !== (this.length - 1)) {
                if (YAO.hasClass(this.YBoxBtnNext, this.BTN_DISABLED_CLASS)) {
                    YAO.removeClass(this.YBoxBtnNext, this.BTN_DISABLED_CLASS);
                }
                if (YAO.ua.ie) {
                    YAO.setStyle(this.YBoxBtnNext, 'backgroundImage', this.IMG_BTN_NEXT);
                }
                this.YBoxBtnNext.href = this.photos[this.YBoxLastIndex + 1].src;
            }
            else {
                if (this.YBoxLastIndex === (this.length - 1)) {
                    YAO.addClass(this.YBoxBtnNext, this.BTN_DISABLED_CLASS);
                    if (YAO.ua.ie) {
                        YAO.setStyle(this.YBoxBtnNext, 'backgroundImage', 'none');
                    }
                    this.YBoxBtnNext.href = this.photos[this.YBoxLastIndex].src;
                }
            }
        }
    },
    previousPhoto: function(event){
        var evt = event || window.event;
        this.YBoxLastIndex -= 1;
        
        if (YAO.hasClass(this.YBoxBtnNext, this.BTN_DISABLED_CLASS)) {
            YAO.removeClass(this.YBoxBtnNext, this.BTN_DISABLED_CLASS);
        }
        if (this.YBoxLastIndex >= 1) {
            this.YBoxBtnPrevious.href = this.photos[this.YBoxLastIndex - 1].src;
        }
        
        if (this.YBoxLastIndex < 0) {
            this.YBoxLastIndex = 0;
            YAO.addClass(this.YBoxBtnPrevious, this.BTN_DISABLED_CLASS);
            this.YBoxBtnPrevious.href = this.photos[this.YBoxLastIndex].src;
        }
        this.YBoxBtnNext.href = this.photos[this.YBoxLastIndex + 1].src;
        
        this.changePhoto();
        YAO.stopEvent(evt);
    },
    nextPhoto: function(event){
        var evt = event || window.event;
        this.YBoxLastIndex += 1;
        
        if (YAO.hasClass(this.YBoxBtnPrevious, this.BTN_DISABLED_CLASS)) {
            YAO.removeClass(this.YBoxBtnPrevious, this.BTN_DISABLED_CLASS);
        }
        if (this.YBoxLastIndex <= (this.length - 2)) {
            this.YBoxBtnNext.href = this.photos[this.YBoxLastIndex + 1].src;
        }
        
        if (this.YBoxLastIndex > (this.length - 1)) {
            this.YBoxLastIndex = this.length - 1;
            YAO.addClass(this.YBoxBtnNext, this.BTN_DISABLED_CLASS);
            this.YBoxBtnNext.href = this.photos[this.YBoxLastIndex].src;
        }
        this.YBoxBtnPrevious.href = this.photos[this.YBoxLastIndex - 1].src;
        
        this.changePhoto();
        YAO.stopEvent(evt);
    },
    changePhoto: function(){
        this.YBoxPhotoDefaultWidth = this.photos[this.YBoxLastIndex].width;
        this.YBoxPhotoDefaultHeight = this.photos[this.YBoxLastIndex].height;
        this.YBoxTitle.innerHTML = this.photos[this.YBoxLastIndex].alt;
        this.YBoxIndex.innerHTML = (this.YBoxLastIndex + 1);
        this.YBoxPhoto.src = this.photos[this.YBoxLastIndex].src;
        this.YBoxPhoto.alt = this.photos[this.YBoxLastIndex].alt;
        if (this.YBoxNewWinBar) {
            this.YBoxNewWinBar.href = this.photos[this.YBoxLastIndex].src;
        }
        this.currentSample();
        this.scrollCarousel();
        this.zoom();
    }
};

声明:本文采用BY-NC-SA协议进行授权。转载请注明转自:YLightbox 相册特效

« »

2 条评论

  • 不好意思,弄错了,是另一个相册 Yalbum,已经在那个页面提交问题。

  • 当时看到DZ的一个效果,结果发现还要收费,所以自己就谢了这么一个功能更多的。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(Spamcheck Enabled)