// JavaScript Document
/**
 * @author hidden
 */
var _evalReturn = function(str){
    //方便脚本压缩！ for yuicompressor
    return eval(str);
}(function($){
    //http://www.json.org/json2.js
    
    var JSON = {};
    (function(){
    
        function f(n){
            // Format integers to have at least two digits.
            return n < 10 ? '0' + n : n;
        }
        
        if (typeof Date.prototype.toJSON !== 'function') {
        
            Date.prototype.toJSON = function(key){
            
                return this.getUTCFullYear() + '-' +
                f(this.getUTCMonth() + 1) +
                '-' +
                f(this.getUTCDate()) +
                'T' +
                f(this.getUTCHours()) +
                ':' +
                f(this.getUTCMinutes()) +
                ':' +
                f(this.getUTCSeconds()) +
                'Z';
            };
            
        }
        
        var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapeable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = { // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"': '\\"',
            '\\': '\\\\'
        }, rep;
        
        
        function quote(string){
        
            // If the string contains no control characters, no quote characters, and no
            // backslash characters, then we can safely slap some quotes around it.
            // Otherwise we must also replace the offending characters with safe escape
            // sequences.
            
            escapeable.lastIndex = 0;
            return escapeable.test(string) ? '"' +
            string.replace(escapeable, function(a){
                var c = meta[a];
                if (typeof c === 'string') {
                    return c;
                }
                return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
            }) +
            '"' : '"' + string + '"';
        }
        
        
        function str(key, holder){
        
            // Produce a string from holder[key].
            
            var i, // The loop counter.
 k, // The member key.
 v, // The member value.
 length, mind = gap, partial, value = holder[key];
            
            // If the value has a toJSON method, call it to obtain a replacement value.
            
            if (value && typeof value === 'object' &&
            typeof value.toJSON === 'function') {
                value = value.toJSON(key);
            }
            
            // If we were called with a replacer function, then call the replacer to
            // obtain a replacement value.
            
            if (typeof rep === 'function') {
                value = rep.call(holder, key, value);
            }
            
            // What happens next depends on the value's type.
            
            switch (typeof value) {
                case 'string':
                    return quote(value);
                    
                case 'number':
                    
                    // JSON numbers must be finite. Encode non-finite numbers as null.
                    
                    return isFinite(value) ? String(value) : 'null';
                    
                case 'boolean':
                case 'null':
                    
                    // If the value is a boolean or null, convert it to a string. Note:
                    // typeof null does not produce 'null'. The case is included here in
                    // the remote chance that this gets fixed someday.
                    
                    return String(value);
                    
                // If the type is 'object', we might be dealing with an object or an array or
                // null.
                
                case 'object':
                    
                    // Due to a specification blunder in ECMAScript, typeof null is 'object',
                    // so watch out for that case.
                    
                    if (!value) {
                        return 'null';
                    }
                    
                    // Make an array to hold the partial results of stringifying this object value.
                    
                    gap += indent;
                    partial = [];
                    
                    // If the object has a dontEnum length property, we'll treat it as an array.
                    
                    if (typeof value.length === 'number' &&
                    !value.propertyIsEnumerable('length')) {
                    
                        // The object is an array. Stringify every element. Use null as a placeholder
                        // for non-JSON values.
                        
                        length = value.length;
                        for (i = 0; i < length; i += 1) {
                            partial[i] = str(i, value) || 'null';
                        }
                        
                        // Join all of the elements together, separated with commas, and wrap them in
                        // brackets.
                        
                        v = partial.length === 0 ? '[]' : gap ? '[\n' + gap +
                        partial.join(',\n' + gap) +
                        '\n' +
                        mind +
                        ']' : '[' + partial.join(',') + ']';
                        gap = mind;
                        return v;
                    }
                    
                    // If the replacer is an array, use it to select the members to be stringified.
                    
                    if (rep && typeof rep === 'object') {
                        length = rep.length;
                        for (i = 0; i < length; i += 1) {
                            k = rep[i];
                            if (typeof k === 'string') {
                                v = str(k, value);
                                if (v) {
                                    partial.push(quote(k) + (gap ? ': ' : ':') + v);
                                }
                            }
                        }
                    }
                    else {
                    
                        // Otherwise, iterate through all of the keys in the object.
                        
                        for (k in value) {
                            if (Object.hasOwnProperty.call(value, k)) {
                                v = str(k, value);
                                if (v) {
                                    partial.push(quote(k) + (gap ? ': ' : ':') + v);
                                }
                            }
                        }
                    }
                    
                    // Join all of the member texts together, separated with commas,
                    // and wrap them in braces.
                    
                    v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
                    mind +
                    '}' : '{' + partial.join(',') + '}';
                    gap = mind;
                    return v;
            }
        }
        
        // If the JSON object does not yet have a stringify method, give it one.
        
        if (typeof JSON.stringify !== 'function') {
            JSON.stringify = function(value, replacer, space){
            
                // The stringify method takes a value and an optional replacer, and an optional
                // space parameter, and returns a JSON text. The replacer can be a function
                // that can replace values, or an array of strings that will select the keys.
                // A default replacer method can be provided. Use of the space parameter can
                // produce text that is more easily readable.
                
                var i;
                gap = '';
                indent = '';
                
                // If the space parameter is a number, make an indent string containing that
                // many spaces.
                
                if (typeof space === 'number') {
                    for (i = 0; i < space; i += 1) {
                        indent += ' ';
                    }
                    
                    // If the space parameter is a string, it will be used as the indent string.
                
                }
                else 
                    if (typeof space === 'string') {
                        indent = space;
                    }
                
                // If there is a replacer, it must be a function or an array.
                // Otherwise, throw an error.
                
                rep = replacer;
                if (replacer && typeof replacer !== 'function' &&
                (typeof replacer !== 'object' ||
                typeof replacer.length !== 'number')) {
                    throw new Error('JSON.stringify');
                }
                
                // Make a fake root object containing our value under the key of ''.
                // Return the result of stringifying the value.
                
                return str('', {
                    '': value
                });
            };
        }
        
        
        // If the JSON object does not yet have a parse method, give it one.
        
        if (typeof JSON.parse !== 'function') {
            JSON.parse = function(text, reviver){
            
                // The parse method takes a text and an optional reviver function, and returns
                // a JavaScript value if the text is a valid JSON text.
                
                var j;
                
                function walk(holder, key){
                
                    // The walk method is used to recursively walk the resulting structure so
                    // that modifications can be made.
                    
                    var k, v, value = holder[key];
                    if (value && typeof value === 'object') {
                        for (k in value) {
                            if (Object.hasOwnProperty.call(value, k)) {
                                v = walk(value, k);
                                if (v !== undefined) {
                                    value[k] = v;
                                }
                                else {
                                    delete value[k];
                                }
                            }
                        }
                    }
                    return reviver.call(holder, key, value);
                }
                
                
                // Parsing happens in four stages. In the first stage, we replace certain
                // Unicode characters with escape sequences. JavaScript handles many characters
                // incorrectly, either silently deleting them, or treating them as line endings.
                
                cx.lastIndex = 0;
                if (cx.test(text)) {
                    text = text.replace(cx, function(a){
                        return '\\u' +
                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
                    });
                }
                
                // In the second stage, we run the text against regular expressions that look
                // for non-JSON patterns. We are especially concerned with '()' and 'new'
                // because they can cause invocation, and '=' because it can cause mutation.
                // But just to be safe, we want to reject all unexpected forms.
                
                // We split the second stage into 4 regexp operations in order to work around
                // crippling inefficiencies in IE's and Safari's regexp engines. First we
                // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
                // replace all simple value tokens with ']' characters. Third, we delete all
                // open brackets that follow a colon or comma or that begin the text. Finally,
                // we look to see that the remaining characters are only whitespace or ']' or
                // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
                
                if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
                
                    // In the third stage we use the eval function to compile the text into a
                    // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
                    // in JavaScript: it can begin a block or an object literal. We wrap the text
                    // in parens to eliminate the ambiguity.
                    
                    j = _evalReturn('(' + text + ')');
                    
                    // In the optional fourth stage, we recursively walk the new structure, passing
                    // each name/value pair to a reviver function for possible transformation.
                    
                    return typeof reviver === 'function' ? walk({
                        '': j
                    }, '') : j;
                }
                
                // If the text is not JSON parseable, then a SyntaxError is thrown.
                return null;
                //throw new SyntaxError('JSON.parse');
            };
        }
    })();
    
    
    //检测,log
    $.extend($, {
        isUndefined: function(_1){
            return typeof _1 == "undefined";
        },
        isString: function(_2){
            return typeof _2 == "string";
        },
        isElement: function(_3){
            return _3 && _3.nodeType == 1;
        },
        isObject: function(_5){
            return typeof _5 == "object";
        },
        isArray: function(_6){
            return _6 !== null && typeof _6 == "object" && "splice" in _6 && "join" in _6;
        },
        isNumber: function(_7){
            return typeof _7 == "number";
        },
        isChinese: function(temp){
            var re = /[^\u4e00-\u9fa5]/;
            if (re.test(temp)) 
                return false;
            return true;
            
        },
        isUrl: function(str){
            return /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"])*$/.test(str);
        },
        isEmail: function(str){
            return /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(str);
        },
        toString: function(a1, a2, a3){
            return $.isObject(a1) ? JSON.stringify(a1, a2, a3) : a1.toString();
        },
        toJSON: function(a1, a2, a3){
            return JSON.parse(a1, a2, a3);
        },
        substring: function(cont, start, length){
            var l = 0, a = [], c = cont.split(''), ln = c.length;
            for (var i = 0; i < ln; i++) {
                if (l >= length || l < start) 
                    break;
                else {
                    if (c[i].charCodeAt(0) > 255) 
                        l += 2;
                    else 
                        l++;
                    a.push(c[i]);
                }
                
            }
            return a.join('');
        },
        size: function(a, chinese){
            if ($.isArray(a)) 
                return a.length;
            if ($.isString(a)) {
                if (!chinese) 
                    return a.length;
                var count = 0;
                for (var i = 0; i < a.length; i++) {
                    if (a.charCodeAt(i) > 255) 
                        count += 2;
                    else 
                        count++;
                }
                return count;
            }
            if ($.isObject(a)) {
                var n = 0;
                $.each(a, function(){
                    n++;
                });
                return n;
            }
            return -1;
            
        },
        log: function(str){
            if (!window.console) {
                //alert(str);
                $("#log").html(str);
                return false;
            }
            else {
                console.log(arguments[0]);//用firefox firebug插件 的console查看
                return false;
            }
        }
    });
    
    /*
     国际化，语言,format
     添加： $.lang.add(name,str);$.lang.add({name:str,name:str})
     获取： $.lang(name,args);
     */
    $.lang = function(name, args){
        str = $.lang.data[name];
        if ($.isUndefined(str)) {
            //$.log(name + ":$.lang is " + (typeof str));
            str = name;
        }
        if (args) {
            for (var key in args) {
                str = str.replace('{' + key + '}', args[key]);
            }
            
        }
        return str;
    };
    $.lang.data = [];
    
    $.lang.add = function(name, val){
        var name = arguments[0];
        var val = arguments[1];
        var type = (typeof name).toLowerCase();
        
        switch (type) {
            case "object":
                for (var key in name) {
                    $.lang.data[key] = name[key];
                }
                break;
            case "string":
                $.lang.data[name] = val;
                break;
        }
    };
    $.objectEvent = {
        _initEvent: function(){
            if (!this.element) 
                this.element = $('<div>');
            $.data(this.element[0], 'objectEvent', this);
        },
        element: null,
        trigger: function(eventName, data, e){
            e = e ||
            $.event.fix({
                type: eventName,
                target: this.element[0]
            });
            this.element.triggerHandler(eventName, [e, data, this], this.options[eventName]);
            return this;
            
        },
        one: function(eventName, data, fn){
            this.element.one(eventName, data, fn);
            return this;
        },
        bind: function(eventName, data, fn){
            this.element.bind(eventName, data, fn);
            return this;
        },
        unbind: function(eventName, fn){
            this.element.unbind(eventName, fn);
            return this;
        }
        
    };
    
    
    
})(jQuery);





/*
 * jQuery UI @VERSION
 *
 * Copyright (c) 2008 Paul Bakaus (ui.jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
;
(function($){

    /** jQuery core modifications and additions **/
    
    var _remove = $.fn.remove;
    $.fn.remove = function(){
        $("*", this).add(this).triggerHandler("remove");
        return _remove.apply(this, arguments);
    };
    
    function isVisible(element){
        function checkStyles(element){
            var style = element.style;
            return (style.display != 'none' && style.visibility != 'hidden');
        }
        
        var visible = checkStyles(element);
        
        (visible &&
        $.each($.dir(element, 'parentNode'), function(){
            return (visible = checkStyles(this));
        }));
        
        return visible;
    }
    
    $.extend($.expr[':'], {
        data: function(a, i, m){
            return $.data(a, m[3]);
        },
        
        // TODO: add support for object, area
        tabbable: function(a, i, m){
            var nodeName = a.nodeName.toLowerCase();
            
            return ( // in tab order
a.tabIndex >= 0 &&
            
            ( // filter node types that participate in the tab order
            // anchor tag
            ('a' == nodeName && a.href) ||
            
            // enabled form element
            (/input|select|textarea|button/.test(nodeName) &&
            'hidden' != a.type &&
            !a.disabled)) &&
            
            // visible on page
            isVisible(a));
        }
    });
    
    $.keyCode = {
        BACKSPACE: 8,
        CAPS_LOCK: 20,
        COMMA: 188,
        CONTROL: 17,
        DELETE: 46,
        DOWN: 40,
        END: 35,
        ENTER: 13,
        ESCAPE: 27,
        HOME: 36,
        INSERT: 45,
        LEFT: 37,
        NUMPAD_ADD: 107,
        NUMPAD_DECIMAL: 110,
        NUMPAD_DIVIDE: 111,
        NUMPAD_ENTER: 108,
        NUMPAD_MULTIPLY: 106,
        NUMPAD_SUBTRACT: 109,
        PAGE_DOWN: 34,
        PAGE_UP: 33,
        PERIOD: 190,
        RIGHT: 39,
        SHIFT: 16,
        SPACE: 32,
        TAB: 9,
        UP: 38
    };
    
    // $.widget is a factory to create jQuery plugins
    // taking some boilerplate code out of the plugin code
    // created by Scott González and Jörn Zaefferer
    function getter(namespace, plugin, method, args){
        function getMethods(type){
            var methods = $[namespace][plugin][type] || [];
            return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
        }
        
        var methods = getMethods('getter');
        if (args.length == 1 && typeof args[0] == 'string') {
            methods = methods.concat(getMethods('getterSetter'));
        }
        return ($.inArray(method, methods) != -1);
    }
    
    $.widget = function(name, prototype){
        var namespace = name.split(".")[0];
        name = name.split(".")[1];
        
        // create plugin method
        $.fn[name] = function(options){
            var isMethodCall = (typeof options == 'string'), args = Array.prototype.slice.call(arguments, 1);
            
            // prevent calls to internal methods
            if (isMethodCall && options.substring(0, 1) == '_') {
                return this;
            }
            
            // handle getter methods
            if (isMethodCall && getter(namespace, name, options, args)) {
                var instance = $.data(this[0], name);
                return (instance ? instance[options].apply(instance, args) : undefined);
            }
            
            // handle initialization and non-getter methods
            return this.each(function(){
                var instance = $.data(this, name);
                
                // constructor
                (!instance && !isMethodCall &&
                $.data(this, name, new $[namespace][name](this, options)));
                
                // method call
                (instance && isMethodCall && $.isFunction(instance[options]) &&
                instance[options].apply(instance, args));
            });
        };
        
        // create widget constructor
        $[namespace][name] = function(element, options){
            var self = this;
            
            this.widgetName = name;
            this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
            this.widgetBaseClass = namespace + '-' + name;
            
            this.options = $.extend({}, $.widget.defaults, $[namespace][name].defaults, $.metadata && $.metadata.get(element)[name], options);
            
            this.element = $(element).bind('setData.' + name, function(e, key, value){
                return self._setData(key, value);
            }).bind('getData.' + name, function(e, key){
                return self._getData(key);
            }).bind('remove', function(){
                return self.destroy();
            });
            
            this._init();
        };
        
        // add widget prototype
        $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
        
        // TODO: merge getter and getterSetter properties from widget prototype
        // and plugin prototype
        $[namespace][name].getterSetter = 'option';
    };
    
    $.widget.prototype = {
        _init: function(){
        },
        destroy: function(){
            this.element.removeData(this.widgetName);
        },
        
        option: function(key, value){
            var options = key, self = this;
            
            if (typeof key == "string") {
                if (value === undefined) {
                    return this._getData(key);
                }
                options = {};
                options[key] = value;
            }
            
            $.each(options, function(key, value){
                self._setData(key, value);
            });
        },
        _getData: function(key){
            return this.options[key];
        },
        _setData: function(key, value){
            this.options[key] = value;
            
            if (key == 'disabled') {
                this.element[value ? 'addClass' : 'removeClass'](this.widgetBaseClass + '-disabled');
            }
        },
        
        enable: function(){
            this._setData('disabled', false);
        },
        disable: function(){
            this._setData('disabled', true);
        },
        
        _trigger: function(type, e, data){
            var eventName = (type == this.widgetEventPrefix ? type : this.widgetEventPrefix + type);
            e = e ||
            $.event.fix({
                type: eventName,
                target: this.element[0]
            });
            
            return this.element.triggerHandler(eventName, [e, data], this.options[type]);
        }
    };
    
    $.widget.defaults = {
        disabled: false
    };
    
    
    /** jQuery UI core **/
    
    $.ui = {
        plugin: {
            add: function(module, option, set){
                var proto = $.ui[module].prototype;
                for (var i in set) {
                    proto.plugins[i] = proto.plugins[i] || [];
                    proto.plugins[i].push([option, set[i]]);
                }
            },
            call: function(instance, name, args){
                var set = instance.plugins[name];
                if (!set) {
                    return;
                }
                
                
                for (var i = 0; i < set.length; i++) {
                    if (instance.options[set[i][0]]) {
                        set[i][1].apply(instance.element, args);
                    }
                }
            }
        },
        cssCache: {},
        css: function(name){
            if ($.ui.cssCache[name]) {
                return $.ui.cssCache[name];
            }
            var tmp = $('<div class="ui-gen">').addClass(name).css({
                position: 'absolute',
                top: '-5000px',
                left: '-5000px',
                display: 'block'
            }).appendTo('body');
            
            //if (!$.browser.safari)
            //tmp.appendTo('body'); 
            
            //Opera and Safari set width and height to 0px instead of auto
            //Safari returns rgba(0,0,0,0) when bgcolor is not set
            $.ui.cssCache[name] = !!((!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) ||
            !(/none/).test(tmp.css('backgroundImage')) ||
            !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor'))));
            try {
                $('body').get(0).removeChild(tmp.get(0));
            } 
            catch (e) {
            }
            return $.ui.cssCache[name];
        },
        disableSelection: function(el){
            return $(el).attr('unselectable', 'on').css('MozUserSelect', 'none').bind('selectstart.ui', function(){
                return false;
            });
        },
        enableSelection: function(el){
            return $(el).attr('unselectable', 'off').css('MozUserSelect', '').unbind('selectstart.ui');
        },
        hasScroll: function(e, a){
        
            //If overflow is hidden, the element might have extra content, but the user wants to hide it
            if ($(e).css('overflow') == 'hidden') {
                return false;
            }
            
            var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop', has = false;
            
            if (e[scroll] > 0) {
                return true;
            }
            
            // TODO: determine which cases actually cause this to happen
            // if the element doesn't have the scroll set, see if it's possible to
            // set the scroll
            e[scroll] = 1;
            has = (e[scroll] > 0);
            e[scroll] = 0;
            return has;
        }
    };
    
    
    /** Mouse Interaction Plugin **/
    
    $.ui.mouse = {
        _mouseInit: function(){
            var self = this;
            
            this.element.bind('mousedown.' + this.widgetName, function(e){
                return self._mouseDown(e);
            });
            
            // Prevent text selection in IE
            if ($.browser.msie) {
                this._mouseUnselectable = this.element.attr('unselectable');
                this.element.attr('unselectable', 'on');
            }
            
            this.started = false;
        },
        
        // TODO: make sure destroying one instance of mouse doesn't mess with
        // other instances of mouse
        _mouseDestroy: function(){
            this.element.unbind('.' + this.widgetName);
            
            // Restore text selection in IE
            ($.browser.msie &&
            this.element.attr('unselectable', this._mouseUnselectable));
        },
        
        _mouseDown: function(e){
            // we may have missed mouseup (out of window)
            (this._mouseStarted && this._mouseUp(e));
            
            this._mouseDownEvent = e;
            
            var self = this, btnIsLeft = (e.which == 1), elIsCancel = (typeof this.options.cancel == "string" ? $(e.target).parents().add(e.target).filter(this.options.cancel).length : false);
            if (!btnIsLeft || elIsCancel || !this._mouseCapture(e)) {
                return true;
            }
            
            this.mouseDelayMet = !this.options.delay;
            if (!this.mouseDelayMet) {
                this._mouseDelayTimer = setTimeout(function(){
                    self.mouseDelayMet = true;
                }, this.options.delay);
            }
            
            if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
                this._mouseStarted = (this._mouseStart(e) !== false);
                if (!this._mouseStarted) {
                    e.preventDefault();
                    return true;
                }
            }
            
            // these delegates are required to keep context
            this._mouseMoveDelegate = function(e){
                return self._mouseMove(e);
            };
            this._mouseUpDelegate = function(e){
                return self._mouseUp(e);
            };
            $(document).bind('mousemove.' + this.widgetName, this._mouseMoveDelegate).bind('mouseup.' + this.widgetName, this._mouseUpDelegate);
            
            return false;
        },
        
        _mouseMove: function(e){
            // IE mouseup check - mouseup happened when mouse was out of window
            if ($.browser.msie && !e.button) {
                return this._mouseUp(e);
            }
            
            if (this._mouseStarted) {
                this._mouseDrag(e);
                return false;
            }
            
            if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
                this._mouseStarted = (this._mouseStart(this._mouseDownEvent, e) !== false);
                (this._mouseStarted ? this._mouseDrag(e) : this._mouseUp(e));
            }
            
            return !this._mouseStarted;
        },
        
        _mouseUp: function(e){
            $(document).unbind('mousemove.' + this.widgetName, this._mouseMoveDelegate).unbind('mouseup.' + this.widgetName, this._mouseUpDelegate);
            
            if (this._mouseStarted) {
                this._mouseStarted = false;
                this._mouseStop(e);
            }
            
            return false;
        },
        
        _mouseDistanceMet: function(e){
            return (Math.max(Math.abs(this._mouseDownEvent.pageX - e.pageX), Math.abs(this._mouseDownEvent.pageY - e.pageY)) >=
            this.options.distance);
        },
        
        _mouseDelayMet: function(e){
            return this.mouseDelayMet;
        },
        
        // These are placeholder methods, to be overriden by extending plugin
        _mouseStart: function(e){
        },
        _mouseDrag: function(e){
        },
        _mouseStop: function(e){
        },
        _mouseCapture: function(e){
            return true;
        }
    };
    
    $.ui.mouse.defaults = {
        cancel: null,
        distance: 1,
        delay: 0
    };
    
})(jQuery);




/**
 * @author hidden
 */
(function($){
    $.lang.add('cancel', '取消');
    $.ui.module = {
        module: function(element, options){
            var self = this;
            
            //初始化init
            this.element = element = (!element || element.length == 0) ? $('<div>') : $(element);
            this.options = options = $.extend({
                appendTo: window.ATTACHBODY ? $(window.ATTACHBODY) : $('body'),
                zIndex: 1001
            }, options);
            if (!options.effect) 
                options.effect = this.effect = {};
            if (!options.effect.open) 
                options.effect.open = ['show'];
            if (!options.effect.close) 
                options.effect.close = ['hide'];
            var wrapper = this.wrapper = $('<div>').addClass('ui-module ' + this.widgetBaseClass);
            
            wrapper.css({
                width: options.width,
                height: options.height,
                top: options.top,
                left: options.left,
                zIndex: options.zIndex
            });
            this.element.addClass('module-container');
            if (!$.isUndefined(options.after)) {
                $(options.after).after(wrapper);
            }
            else 
                wrapper.appendTo(options.appendTo);
            wrapper.hide();
            
            options.closebar && self.closebar();
            options.title && this.title(options.title);
            options.buttons && this.buttons(options.buttons);
        },
        element: null, //$object
        wrapper: null,
        options: null,
        effect: null,//打开关闭效果~
        title: function(value){
            var className = "module-title";
            var element = this.element;
            var options = this.options;
            var el = $('.' + className, element);
            if (!el.length) 
                el = $('<h4 class="' + className + '"></h4>').prependTo(element);
            if ($.isUndefined(value)) 
                el.remove();
            else 
                el.html(value);
            
            options.title = value;
        },
        __ie6: $.browser.msie && $.browser.version < 7,
        __selects: null,
        ie6visible: function(show){
            var options = this.options, object_embed = 'object,embed';
            if (options.showObject) {
                object_embed = false;
            }
            
            if (this.__ie6) {
            
                if (show) 
                    this.__selects && this.__selects.css('visibility', 'visible');
                else 
                    this.__selects = $('select:visible' + (object_embed ? ',' + object_embed : '')).not($('select' + (object_embed ? ',' + object_embed : ''), this.element)).css('visibility', 'hidden');
                
            }
            else 
                if (object_embed) {
                    if (show) 
                        this.__selects && this.__selects.css('visibility', 'visible');
                    else 
                        this.__selects = $(object_embed).not($(object_embed, this.element)).css('visibility', 'hidden');
                    
                }
            
        },
        __overlay: null,
        overlay: function(show){
        
        
            var self = this, appendTo = window.ATTACHBODY ? $(window.ATTACHBODY) : $('body'), z = this.options.zIndex - 1;
            var resize = function(){
                var h = appendTo.children().height();
                h = h > 4000 ? 4000 : h;
                self.__overlay.css({
                    //opacity:0.2,
                    zIndex: z,
                    width: appendTo.children().width(),
                    height: h
                });
                
            };
            if (!this.__overlay) {
                this.__overlay = $('<div class="module-overlay"></div>').appendTo(appendTo).hide();
                resize();
                $(window).resize(function(){
                    resize();
                });
            }
            
            if (show) 
                this.__overlay.show();
            else 
                this.__overlay.hide();
        },
        buttons: function(value){
            var className = "module-buttons";
            var self = this;
            var element = this.element;
            var options = this.options;
            var el = $('.' + className, element);
            if (!el.length) 
                el = $('<div class="' + className + '"></div>').appendTo(element);
            if ($.isUndefined(value)) 
                el.remove();
            else {
                el.empty();
                var l = 0;
                $.each(value, function(name, val){
                    l = 1;
                    
                    var makup = (name == "cancel") ? '<span class="aux-wrap"><input type="button" class="inputaux"/></span>' : '<span class="button-wrap"><input type="button" class="inputbutton"/></span>';
                    name = $.lang ? $.lang(name) : name;
                    var btn = $(makup);
                    btn.children().val(name).click(function(e){
                        val.apply(self, arguments);
                        
                    });
                    el.append(btn);
                });
                if (!l) 
                    el.remove();
            }
            options.buttons = value;
        },
        loading: function(){
            this.element.html('<div class="module-loading"></div>');
            
        },
        hidemessage: false,
        message: function(m, timeout){
            //提示自动消失
            var self = this;
            if (typeof m != 'undefined') {
                //this.element.html('<div class="module-message">'+m+'</div>');
                this.element.html('<div class="dialog-body">' + m + '</div>');
                this.title('提示');
                this.buttons({
                    '确定': function(){
                        self.close();
                    }
                });
            }
            
            self.hidemessage = true;
            setTimeout(function(){
            
                self.hidemessage && self.close();
            }, isNaN(timeout) ? 1100 : timeout);
        },
        closebar: function(){
            var self = this;
            var closebar = $('<a href="#" title="关闭" class="remove module-closebar">关闭</a>').click(function(e){
                self.destroy();
                return false;
            }).prependTo(this.wrapper);
        },
        destroy: function(){
            this._trigger("destroy");
            this.wrapper.remove();
            this.__overlay && this.__overlay.remove();
        },
        isOpen: function(){
        
            return this.wrapper.hasClass('isOpen');
        },
        _open: function(){
        
            var wrapper = this.wrapper;
            var options = this.options;
            var self = this;
            if (this.isOpen()) 
                return;
            //打开效果
            this._trigger('open');
            
            var ar = options.effect.open, ef = ar[0];
            ar = Array.prototype.slice.call(ar, 1);
            var l = ar.length;
            for (var i = 0; i < l; i++) {
                if ($.isFunction(ar[i])) {
                    var _fn = ar[i];
                    ar[i] = function(){
                        _fn.apply(this, arguments);
                        self._trigger("openComplete");
                    }
                }
            }
            
            
            this.ie6visible(false);
            options.overlay && self.overlay(true);
            wrapper.addClass('isOpen').hide()[ef].apply(wrapper, ar);
            if (!_fn) {
                self._trigger("openComplete");
            }
        },
        _close: function(effect){
            var self = this;
            var wrapper = self.wrapper;
            var options = self.options;
            if (!self.isOpen()) 
                return;
            //关闭效果
            var ar = effect ? effect : options.effect.close, ef = ar[0];
            ar = Array.prototype.slice.call(ar, 1);
            self._trigger('close');
            self.ie6visible(true);
            options.overlay && self.overlay(false);
            wrapper.removeClass('isOpen').show()[ef].apply(wrapper, ar);
            
        }
    };
    $.widget("ui.menu", $.extend({}, $.ui.module, {
        _init: function(){
            var options = this.options;
            var self = this;
            if (!options.trigger) {
                $.log('$.ui.menu: need options.trigger');
                return;
            }
            
            if (!options.attach) 
                options.attach = options.trigger;
            
            this.module(this.element, this.options);
            var element = this.element;
            var wrapper = this.wrapper;
            options = this.options;
            
            // var shadow = $('<div class="menu-shadow"></div>');
            wrapper.append(element);
            
            var trigger = $(options.trigger), node = trigger[0].nodeName;
            
            if ((/input/i.test(node) && trigger[0].type == "text") || /textarea/i.test(node)) {
                trigger.bind('focus.menu', function(e){
                    $(this).addClass('menu-bar-open');
                    self.open();
                });
                
                
            }
            else {
                trigger.bind('click.menu', function(e){
                    if (self.isOpen()) {
                    
                        $(this).removeClass('menu-bar-open');
                        self.close();
                    }
                    else {
                        $(this).addClass('menu-bar-open');
                        self.open();
                    }
                    return false;
                });
            }
            this.wrapper.clickout(function(e){
            
                if (e.target !== trigger[0]) {
                
                    trigger.removeClass('menu-bar-open');
                    self.close();
                }
                
            });
            
        },
        open: function(){
            this.setPos();
            this._open();
        },
        close: function(){
        
            this._close();
        },
        setPos: function(){
            var wrapper = this.wrapper;
            var options = this.options;
            if (options.attach) {
                var pos = $.autoposition(wrapper, options.attach, ['autoY', 'auto1'], options.appendTo);
                if ($.isUndefined(options.top)) 
                    wrapper.css("top", pos.top);
                if ($.isUndefined(options.left)) 
                    wrapper.css("left", pos.left);
            }
        }
    }));
    $.ui.menu.defaults = {
        width: 200,
        effect: { //open: ['slideDown', 150]
}
    };
    $.ui.menu.getter = ['isOpen'];
    
    $.widget("ui.confirm", $.extend({}, $.ui.module, {
        _init: function(){
            var self = this;
            
            
            if (!this.options || !this.options.attach) {
                $.log('$.ui.confirm: need options.attach');
                return;
            }
            this.module(this.element, this.options);
            var element = this.element;
            var wrapper = this.wrapper;
            var options = this.options;
            
            var arrow_t = $('<div class="arrow-t"></div>');
            var arrow_b = $('<div class="arrow-b"></div>');
            
            
            wrapper.html(arrow_t).append(element).append(arrow_b);
            
            this.setArrow = function(pos){
                if (pos[0] != 2) 
                    wrapper.addClass('up');
                else 
                    wrapper.removeClass('up');
                arrow_t.add(arrow_b).css("backgroundPosition", (pos[1] * 100) + "% 0");
            };
            this.open();
        },
        open: function(attach){
            if (attach) 
                this.options.attach = attach;
            this.setPos();
            this._open();
        },
        close: function(){
        
            this._close();
        },
        setPos: function(){
            var wrapper = this.wrapper;
            var options = this.options;
            var pos = $.autoposition(wrapper, options.attach, ['autoY', 'auto0'], options.appendTo);
            wrapper.css(pos);
            this.setArrow(pos.auto);
        }
        
    }));
    
    $.ui.confirm.defaults = {
        width: 200
    };
    $.ui.confirm.getter = ['isOpen'];
    
    
    $.widget("ui.dialog", $.extend({}, $.ui.module, {
        _init: function(){
            var self = this;
            this.module(this.element, this.options);
            var element = this.element;
            var wrapper = this.wrapper;
            var options = this.options;
            this.css = {};
            //外框样式
            var h = '<div class="modFrame">' +
            '<table class="modTable table" cellpadding="0">' +
            '<tr class="thead">' +
            '<td class="mheader lt"/><td class="mheader t"/><td class="mheader rt"/>' +
            '</tr>' +
            '<tr class="tbody">' +
            '<td class="mbody l"/>' +
            '<td class="mbody c">' +
            '</td>' +
            '<td class="mbody r"/>' +
            '</tr>' +
            '<tr class="tfoot">' +
            '<td class="mfooter lb"/><td class="mfooter b"/><td class="mfooter rb"/>' +
            '</tr>' +
            '</table>' +
            '</div>';
            wrapper.html(h);
            
            //关闭按钮
            
            wrapper.find('.c').html('').append(element);
            
            
            this.closebar();
            if (options.autoOpen) 
                this.open();
            this.effect.close = ['fadeOut', 400];
            
        },
        open: function(attach){
            if (attach) 
                this.options.attach = attach;
            this.setEffect();
            this._open();
        },
        close: function(effect){
            this._close(effect);
        },
        setEffect: function(){
            if (this.isOpen()) 
                return false;
            var self = this;
            this.setPos();
            //需要 options.attachXY {}或者 options.attach $object
            var wrapper = this.wrapper;
            var options = this.options;
            
            if (!options.attach && !options.attachXY) 
                return false;
            if (options.attachXY) 
                var o = options.attachXY;
            else {
                if (!$(options.attach).length) 
                    return false;
                var o = $(options.attach).offset();
            }
            
            
            var sLT = {};
            sLT.left = options.appendTo.scrollLeft() + o.left;
            sLT.top = options.appendTo.scrollTop() + o.top;
            
            
            wrapper.css($.extend(sLT, {
                width: 0,
                height: 0,
                opacity: 0.4,
                overflow: 'hidden'
            }));
            this.effect.open = ['animate', this.css, 400, function(){
            
                $(this).css({
                    'overflow': 'visible',
                    'height': 'auto',
                    'opacity': 'none'
                });
                
            }
            
];
            
        },
        
        setPos: function(){
            var wrapper = this.wrapper;
            var options = this.options;
            var self = this;
            var WH = {
                width: options.width,
                height: wrapper.height()
            }, LT = {};
            
            var scrollLeft = $(document).scrollLeft() + options.appendTo.scrollLeft();
            var scrollTop = $(document).scrollTop() + options.appendTo.scrollTop();
            
            if (!$.isUndefined(options.left)) 
                LT.left = options.left;
            else 
                LT.left = scrollLeft + ($(window).width() / 2) - (WH.width / 2);
            if (!$.isUndefined(options.top)) 
                LT.top = options.top;
            else {
                var t = ($(window).height() / 2) - (WH.height / 2);
                //t = t > 100 ? 100 : (t<0?0:t);
                
                t = t < 0 ? 0 : t;
                LT.top = scrollTop + t;
            }
            this.css = $.extend(LT, WH, {
                opacity: 1
            });
            wrapper.css(this.css).css({
                'overflow': 'visible',
                'height': 'auto',
                'opacity': 'none'
            });
            
            
        }
    }));
    $.ui.dialog.defaults = {
        width: 500,
        autoOpen: true
    };
    $.ui.dialog.getter = ['isOpen'];
    /*
     一个浮动元素在页面内的合适定位...不超过指定外框,一个指定元素做参考坐标...
     autoPos[direction,parcent] direction: 0,1,2,3,auto 模块方向 parcent 0~1,auto相对位置
     */
    $.autoposition = function(mainExpr, relExpr, autoPos, attachExpr){
        var elem = $(mainExpr), rel = $(relExpr), attach = (typeof attachExpr == 'undefined') ? elem.parent() : $(attachExpr);
        if (!elem.length) 
            return false;
        var hw = [elem.outerHeight(), elem.outerWidth()], offset = rel.offset(), relPos = [rel.outerHeight(), rel.outerWidth(), offset.top, offset.left], offset = attach.offset(), attachPos = [attach.outerHeight(), attach.outerWidth(), offset.top, offset.left, attach.scrollTop(), attach.scrollLeft()], win = [$(window).height(), $(window).width()];
        
        if (typeof autoPos == 'undefined' || autoPos.constructor != Array || autoPos.length == 0) 
            autoPos = ['autoY', 'auto0'];
        else {
            if (!/[0-3]|auto[XY]/.test(autoPos[0])) 
                autoPos[0] = 'autoY';
            if (typeof autoPos[1] == 'undefined' || ((autoPos[1] < 0 || autoPos[1] > 1) && !/[0-3]|auto[0-1]/.test(autoPos[1]))) 
                autoPos[1] = 'auto0';
        }
        var top = 0, left = 0, wrapPos = [-attachPos[2] + attachPos[4], -attachPos[3] + attachPos[5]], aY = hw[0] > (win[0] - (relPos[2] + relPos[0])) && hw[0] < relPos[2], aX = hw[1] > (win[1] - (relPos[1] + relPos[3])) && hw[1] < relPos[3];
        if (/autoY/.test(autoPos[0])) {
            if (aY) 
                autoPos[0] = 0;
            else 
                autoPos[0] = 2;
        }
        else 
            if (/autoX/.test(autoPos[0])) {
                if (aX) 
                    autoPos[0] = 3;
                else 
                    autoPos[0] = 1;
            }
        
        if (/auto0/.test(autoPos[1])) { //自动百分比
            autoPos[1] = -1;
        }
        else 
            if (/auto1/.test(autoPos[1])) { //自动0,1
                if ((/[02]/.test(autoPos[0]) && aX) || (/[13]/.test(autoPos[0]) && aY)) 
                    autoPos[1] = 1;
                else 
                    autoPos[1] = 0;
            }
        if (autoPos[0] == 0) {
            top = relPos[2] - hw[0] + wrapPos[0];
            if (autoPos[1] == -1) 
            
                autoPos[1] = relPos[3] / (win[1] - relPos[1]);
            left = relPos[3] - (hw[1] - relPos[1]) * autoPos[1] + wrapPos[1];
        }
        else 
            if (autoPos[0] == 1) {//right
                if (autoPos[1] == -1) 
                
                    autoPos[1] = relPos[2] / (win[0] - relPos[0]);
                top = relPos[2] - (hw[0] - relPos[0]) * autoPos[1] + wrapPos[0];
                left = relPos[3] + relPos[1] + wrapPos[1];
            }
            else 
                if (autoPos[0] == 2) {//down
                    top = relPos[2] + relPos[0] + wrapPos[0];
                    if (autoPos[1] == -1) 
                    
                        autoPos[1] = relPos[3] / (win[1] - relPos[1]);
                    left = relPos[3] - (hw[1] - relPos[1]) * autoPos[1] + wrapPos[1];
                }
                else 
                    if (autoPos[0] == 3) {//left
                        if (autoPos[1] == -1) 
                        
                            autoPos[1] = relPos[2] / (win[0] - relPos[0]);
                        top = relPos[2] - (hw[0] - relPos[0]) * autoPos[1] + wrapPos[0];
                        
                        left = relPos[3] - hw[1] + wrapPos[1];
                        
                        
                    }
        return {
            top: top,
            left: left,
            auto: autoPos
        };
    };
    /*
     页面点击不在指定元素内时触发事件..
     */
    $.fn.extend({
        clickout: function(fn, expr){
            return this.each(function(){
                var elem = this, attach = expr ? $(expr) : document, type = 'mousedown.clickout' + $.data(elem);
                if (!$.isFunction(fn)) {
                    $(attach).unbind(type);
                    return;
                }
                $(attach).bind(type, function(event){
                
                    var parent = event.target;
                    while (parent && parent != elem) 
                        try {
                            parent = parent.parentNode;
                        } 
                        catch (error) {
                            parent = elem;
                        }
                    if (parent != elem) 
                        fn.call(elem, event);
                });
            });
            
        }
    });
})(jQuery);






/*common set*/
jQuery.ajaxSetup({
    cache: false
});


$(document).ready(function(){

    $(document).find('a').focus(function(){
        $(this).blur();
    });
    
    
    $('.menuDown').hover(function(){
        $('.menuDownList').css('left', 0);
    }, function(){
        $('.menuDownList').css('left', -9999);
    })
    
    
    $('#navSearchInput').focus(function(){
        if ($(this).val() == '搜人...') {
            $(this).css('color', '#333');
            $(this).val('');
        }
    }).blur(function(){
        if ($(this).val() == '') {
            $(this).css('color', '#666');
            $(this).val('搜人...');
        }
        
    });
    
    
    $('.app_list .moreApp').hover(function(){
        var width = $('.moreApp_lists').find('ul').length * 140;
        $('.moreApp_lists').width(width);
        $(this).addClass('moreAppOn');
    }, function(){
        $(this).removeClass('moreAppOn');
    })
})

/*presence-----------------------------------------------------------------*/
var presence = {};
$.extend(presence, {
    /*tool*/
	//控制第一次不加载的全局变量
	total_add_numadd:0,
	//原来存在的未读数字
	total_add_numall:0,
    timer: 30000,
    init: function(url){
        var self = this;
        self.loader(url);
		$('.presence_logo').clickout(function(){
			if(self.appMode){
				self.appHide();
			    self.presence_logo_btn_close();	
			}							  
		});
    },
    loader: function(url){
        var self = this;
        $.ajax({
            url: url,
            dataType: 'json',
            success: function(data){
                self.upNum(data);
                window.setTimeout(function(){
                    self.loader(url);
                }, self.timer);
            }
        })
    },
    upNum: function(data){
		
        var feeds = parseInt($('#noti_feeds_num').html());
		
        var walls = parseInt($('#noti_walls_num').html());
        var msgs = parseInt($('#noti_msgs_num').html());
		
        var notifications = parseInt($('#noti_notifications_num').html());
        var viewers = parseInt($('#noti_viewers_num').html());
		/*闪动开关*/
		
		var total_add_numold=0;
	    var total_add_numnew=0;
		var total_add = false;
        if (data.friendfeed > feeds) {
            $('#noti_feeds_num').html(data.friendfeed);
            $('#noti_feeds_block').show();
			total_add_numnew+=data.friendfeed;
			total_add_numold+=feeds;
        }else if(data.friendfeed < feeds){
			this.total_add_numall=1;
		}
        if (data.walls > walls) {
            $('#noti_walls_num').html(data.walls);
            $('#noti_walls_block').show();
			total_add_numnew+=data.walls;
			total_add_numold+=walls;
        }else if(data.walls < walls){
			this.total_add_numall=1;
		}
        if (data.msgs > msgs) {
            $('#noti_msgs_num').html(data.msgs);
            $('#noti_msgs_block').show();
			total_add_numnew+=data.msgs;
			total_add_numold+=msgs;
        }else if(data.msgs < msgs){
			this.total_add_numall=1;
		}
        if (data.notifications > notifications) {
            $('#noti_notifications_num').html(data.notifications);
            $('#noti_notifications_block').show();
			total_add_numnew+=data.notifications;
			total_add_numold+=notifications;
        }else if(data.notifications < notifications){
			this.total_add_numall=1;
		}
        if (data.viewers > viewers) {
            $('#noti_viewers_num').html(data.viewers);
            $('#noti_viewers_block').show();
			total_add_numnew+=data.viewers;
			total_add_numold+=viewers;
        }else if(data.viewers < viewers){
			this.total_add_numall=1;
		}
		if(total_add_numnew>total_add_numold){
			//第一次加载不闪动
			this.total_add_numadd++;
		}
		if(this.total_add_numadd>1){
			total_add=true;
			//++大于3后表示已存在闪动
			this.total_add_numadd++
		}
		if(this.total_add_numall==1){
			total_add=false;
			this.total_add_numall=0;
			this.total_add_numadd=1;
		}
		//是否闪动
		if(total_add){
			this.flashTitle.title_scroll = true;
			/*在闪动的情况下，保持闪动但不叠加效果*/
			if(this.total_add_numadd<4){
				this.flashTitle.flash_title();
			}
		}else{
			this.flashTitle.title_scroll = false;
			parent.document.title = this.flashTitle.parent_title;
		}
	//闪动功能
    },flashTitle:{
		flash_step:0,
		parent_title :parent.document.title,
		title_scroll :true,
		flash_title:function(){
			if(this.title_scroll){
			this.flash_step++;
			if (this.flash_step==3) {
				this.flash_step=1;
			}
			if (this.flash_step==1) {
			　　	parent.document.title= "【　　　】 - " + this.parent_title;
			}else if (this.flash_step==2) {
			　　	parent.document.title= "【新消息】 - " + this.parent_title;
			}
			if(this.title_scroll){
				setTimeout("presence.flashTitle.flash_title()",1000);
			}
			}
		}	
	},
    /*appList*/
    appMode: false,
    appShow: function(){
        var self = this;
        if (!self.appMode) {
            $('.presence_logo').addClass('presence_logo_open');
            self.appMode = true;
        }
        return false;
    },
    appHide: function(){
        var self = this;
        if (self.appMode) {
            $('.presence_logo').removeClass('presence_logo_open');
            self.appMode = false;
        }
    },
    appToggle: function(){
        var self = this;
        if (!self.appMode) {
            self.appShow();
			self.firstUse();
			self.presence_logo_btn_open();
        }
        else {
            self.appHide();
			self.presence_logo_btn_close();
        }
    },
    showMore: function(){
        $('.presence_appList_more ul').css('left', '150px');
    },
    hideMore: function(){
        $('.presence_appList_more ul').css('left', '-9999px');
    },
	firstUse: function(){
		if($('.presence_start').length > 0){
		   $.get('/ajax/rooster_ajax.php',{storyid:57},function(data){
			  $('.presence_start').remove();							  
		   })
		}
	},
	presence_logo_btn_open: function(){
	    $('.presence_logo_btn').addClass('presence_logo_btn_open');	
	},
	presence_logo_btn_close: function(){
	    $('.presence_logo_btn').removeClass('presence_logo_btn_open');	
	},
	show_channel_hidelist:function(){
		
		$('#presence_channel_news').hide()
		var event = window.event || this.show_channel_hidelist.caller.arguments[0];
		if(window.event)
			event.cancelBubble = true;
		else
			event.stopPropagation(); 
		if(this.channel_hidelist_open==1||!this.channel_hidelist_open){//1=close,2=open
				if(!this.channel_hidelist_open){
					$("body").bind("click", function(){presence.hide_channel_hidelist()});
				}
				this.channel_hidelist_open=2;
				$('#presence_btn_channel').addClass('presence_logo_btn_open');
				$('#toolbarChannelPanel').show();
		}else if(this.channel_hidelist_open==2){
			this.hide_channel_hidelist();
		}
	},
	hide_channel_hidelist:function(){
		this.channel_hidelist_open=1;
		$('#toolbarChannelPanel').hide();
		$('#presence_btn_channel').removeClass('presence_logo_btn_open')
	},
	loadding:function(){
		var h='';
		var h_star='';
		var h_end='';
		var but=$('#presence_btn_channel');
		if (!but.length){
			return false;
		}
		h_star+='<div class="toolbar-channel-lists toolbar-pop-panel" id="toolbarChannelPanel" style="display: none;">';
		h_star+='<div class="title" style="cursor:pointer;">同学频道<b class="close" onclick="presence.hide_channel_hidelist()"></b></div>';
		h_star+='<ul id="toolbarChannelPanelLists" style="height:auto; overflow:visible;"><li><img src="http://site.tongxueimg.com/v4/k/images/ico_loading16.gif" /></li>';
		h_end+='</ul>';
		h_end+='<div class="more"><a href="http://tongxue.com/channel/">更多频道</a></div>';
		h_end+='</div>';
		h=h_star+h_end;
		but.after(h);
		$.get('/channel/getChannelData_ajax.php',function(d){
			eval('var t='+d);
			if(typeof t!='object' || t.result.length==0){
				h_star+='';
				var h_content='<li><a href="http://tongxue.com/channel/create_channel.php">创建频道</a></li>';
			}else{
				if(t.result.length>=11){
					$('#toolbarChannelPanelLists').attr("style",""); 
				}
				var h_content='';
				var newmsgnum=0;
				for(var i=0;i<t.result.length;i++){
					newmsgnum+=parseInt(t.result[i][2]);
					h_content+='<li><a href="'+t.result[i][3]+'">'
					if(t.result[i][2]!=0){
						h_content+='<span style="float:right; line-height:30px;_line-height:23px;padding-right:10px;" title="'+t.result[i][2]+'条新消息">('+t.result[i][2]+')</span>'
					}                                                     
					h_content+='<img alt="'+t.result[i][0]+'" src="'+t.result[i][1]+'" class="toolbar-channel-logo" />'+t.result[i][0]+'</a>'
					h_content+='</li>';
				}
			}
			h=h_content;
			$('#toolbarChannelPanelLists').html(h);
			if(typeof newmsgnum=='number' && newmsgnum>0){
				$('#presence_channel_news').show();
			}
		})
	}/*,
	time_new_channel_msg:function(){//ajax查看是否有新频道信息，这个功能可以和留言整合成一次ajax
		$.get('/channel/getChannelData_ajax.php?t=check',function(d){
			eval('var t='+d);
			if(t.result==true && (!presence.channel_hidelist_open || presence.channel_hidelist_open==1)){
				$('#presence_channel_news').show();
			}
		})
	}*/
})


/*status_list*/
var statusList = {};
$.extend(statusList, {
    status_list_on: function(obj){
        var obj = $(obj);
        obj.addClass('status_list_on');
    },
    status_list_out: function(obj){
        var obj = $(obj);
        obj.removeClass('status_list_on');
    },
    status_list_fav: function(obj){
        var obj = $(obj);
        if (obj.hasClass('status_list_btn_fav')) {
            obj.html('');
            obj.removeClass('status_list_btn_fav').addClass('status_list_btn_throbber').html('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
            $.ajax({
                url: '/ajax/favorite_status.php',
                data: {
                    status_id: obj.attr('status_id'),
                    favorite_id: obj.attr('favorite_id'),
                    t: 'save'
                },
                success: function(data){
                    obj.removeClass('status_list_btn_throbber').addClass('status_list_btn_unfav').attr('title', '取消分享');
                    obj.parent().append('<a href="#" class="status_list_btn_star" onfocus="this.blur()">已分享</a>');
                    obj.html('取消');
                }
            })
        }
        if (obj.hasClass('status_list_btn_unfav')) {
            obj.html('');
            obj.removeClass('status_list_btn_unfav').addClass('status_list_btn_throbber').html('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
            ;
            $.ajax({
                url: '/ajax/favorite_status.php',
                data: {
                    status_id: obj.attr('status_id'),
                    t: 'del'
                },
                success: function(){
                    obj.removeClass('status_list_btn_throbber').addClass('status_list_btn_fav').attr('title', '分享');
                    obj.parent().find('.status_list_btn_star').remove();
                    obj.html('收藏');
                }
            })
        }
    },
    status_list_del: function(obj){
        var curObj = $(obj);
        var obj = $('#status_' + $(obj).attr('status_id'));
        var dialog = '<div>您确定删除此条消息?</div>';
        $(dialog).dialog({
            title: null,
            overlay: true,
            resizable: false,
            buttons: {
                '确定': function(){
                    var self = this;
                    self.destroy();
                    $.ajax({
                        url: '/ajax/del_status.php',
                        data: {
                            status_id: curObj.attr('status_id'),
                            reply_user_id: curObj.attr('uid')
                        },
                        success: function(data){
                            obj.fadeOut('slow', function(){
                                obj.remove();
                                $('#updateCounter').html(parseInt($('#updateCounter').html()) - 1);
                            });
                        }
                    })
                },
                '取消': function(){
                    var self = this;
                    self.destroy();
                    return false;
                }
            }
        })
    },
    status_list_overplus: function(){
        var num = 140 - parseInt($('#status_reply_msg').val().length);
        $('#status_reply_num').html(num);
        if (num <= 0) {
            $('#status_reply_num').html('0');
            $('#status_reply_msg').val($('#status_reply_msg').val().substring(0, 140));
            return false;
        }
    },
    dialog: null,
    status_list_reply: function(obj){
        var obj = $(obj);
        var self = this;
        var url = obj.attr('href')
        self.dialog = $('<div class="dialogReply"><div class="loading_clock"></div></div>');
        self.dialog.dialog({
            overlay: true,
            width: 505
        });
        $.ajax({
            url: url,
            data: {},
            success: function(data){
                if ($('.dialogReply').html(data)) 
                    self.status_list_overplus();
            }
        })
    },
    
    status_list_reply_sub: function(){
        var self = this;
        $('.dialogReply').prepend('<div class="loading_clock"></div>');
        $('.status_replyPannal').hide();
        $.ajax({
            url: '/ajax/add_status_2.php',
            data: {
                in_reply_to_status_id: $('#in_reply_to_status_id').val(),
                in_reply_to_user_id: $('#in_reply_to_user_id').val(),
                response_json: $('#response_json').val(),
                text: $('#status_reply_msg').val(),
                user_nick: $('#user_nick').val()
            },
            success: function(data){
                $('.dialogReply').css('text-align', 'center').html('发送成功!');
                window.setTimeout(function(){
                    self.dialog.dialog('destroy', false)
                }, 1000);
            }
        })
    },
    showTimeLink: function(obj){
        var obj = $(obj);
        var url = obj.attr('href');
        var dialog = $('<div class="dialogShowTime"><div class="loading_clock"></div></div>');
        dialog.dialog({
            title: null,
            overlay: true
        });
        $.ajax({
            url: url,
            success: function(data){
                $('.dialogShowTime').html(data);
                $('.dialogShowTime').find('.status_reply_Sub').bind('click', function(){
                    if (dialog != null) {
                        dialog.dialog('destroy', true);
                    }
                })
            }
        })
    },
    showLookat: function(obj){
        var obj = $(obj);
        var url = obj.attr('href');
        var dialog = $('<div class="dialogShowLookat"><div class="loading_clock"></div></div>');
        dialog.dialog({
            title: null,
            overlay: true
        });
        $.ajax({
            url: url,
            success: function(data){
                $('.dialogShowLookat').html(data);
                $('.dialogShowLookat').find('.status_reply_Sub').bind('click', function(){
                    if (dialog != null) {
                        dialog.dialog('destroy', true);
                    }
                })
            }
        })
    }
})
/*showSwf*/
function loadimg(){
    (new Image()).src = 'http://site.tongxueimg.com/v4/def5/images/swf_mini.gif?v=7';
	(new Image()).src = 'http://site.tongxueimg.com/v4/def5/images/swf_max.gif?v=7';
}
loadimg();
function showSwf_resize(obj){
	var obj = $(obj);
	if(obj.attr('resize') == 'yes'){
	    obj.css('background-image','url(http://site.tongxueimg.com/v4/def5/images/swf_mini.gif?v=7)');
	    obj.parents('.showSwf').width('420px').height('400px');
	    obj.parents('.showSwf').find('embed').width('420px').height('400px');
	    obj.attr('resize','no');
    }else if(obj.attr('resize') == 'no'){
		obj.css('background-image','url(http://site.tongxueimg.com/v4/def5/images/swf_max.gif?v=7)');
		obj.parents('.showSwf').width('225px').height('200px');
		obj.parents('.showSwf').find('embed').width('225px').height('200px');
		obj.attr('resize','yes');
	}
	obj.parents('.showSwf');
}

var ajaxReplyVip={
	os:{},
	init:function(th,mid,bid,boxid,rname){
		if(!this.os[mid]){
			this.os[mid]=new this.f(mid,bid,boxid);
		}
		if(bid==''){
			this.os[mid].mth=th;
			this.os[mid].mReplay();
		}else{
			this.os[mid].rname=rname;
			this.os[mid].bth=th;
			this.os[mid].bReplay(bid);
		}
	},
	f:function(mid,bid,boxid){
		this.replyurl='http://t.tongxue.com/ajax/add_reply_status.php';
		this.getlisturl='http://t.tongxue.com/ajax/commentlist.php?sid=818c3be1db66b472263605428932232a';
		this.box=document.getElementById(boxid);
		this.boxid=boxid;
		this.rname;
		this.mid=mid;
		this.bid=bid;
		this.mth;
		this.bth;
		this.c='';
		this.textarea=document.getElementById(mid+'_c');
	}
}
ajaxReplyVip.f.prototype={
	mReplay:function(){
		//this.disabled();
		this.getC();
		this.mSbm();
	},
	bReplay:function(bid){
		this.textarea.focus();
		this.textarea.value='回复'+this.rname+':';
		if(this.bid!=bid){
			this.bid=bid;
		}
		
	},
	mSbm:function(){
		var b=this;
		$.post(this.replyurl,{ in_reply_to_main_status_id: this.mid, in_reply_to_slave_status_id: this.bid, content:this.c},function(data){
			b.getlise();
		});
	},
	getC:function(){
		this.c=this.textarea.value;
	},
	disabled:function(){
		this.mth.setAttribute('disabled','disabled');
	},
	reabled:function(){
		this.mth.removeAttribute("disabled")
	},
	getlise:function(){
		var b=this;
		$.post(this.getlisturl/*+'?sid='+this.mid*/,function(data){
				eval('r='+data);
				$('#'+b.boxid).html(r.result)
		})
	}
}
/*-----ajaxReplyVip end----*/

//点击回复自动加载回复列表和回复功能
var ajaxReply={
	//开关,绑定这个方法开始运得函数
	init:function(th,vip){
		if(vip && vip.vip=='vip'){
			var urlnum=vip.sid;
		}else{
			var urlnum=th.getAttribute('sid');
		}
		
		//要打开的DIV
		var boxid='boxid_'+urlnum;
		
		var box=document.getElementById(boxid);
		
		var r=null;
		//只判断DIV是打开还是关闭
		if(vip && vip.vip=='vip'){
			ajaxReply._getviplist(urlnum,box,boxid);
		}else{
			if(box.style.display=='none'){
				box.style.display='';
				ajaxReply._getlist(urlnum,box,boxid);
			}else{
				box.style.display='none';
				box.innerHTML='';
			}
		}
		return false;
	},
	//加载列表和绑定事件功能方法
	_getlist:function(urlnum,box,boxid,isajax){
		/*在提交的时候传这个参数为true，则不显示loadgif图片效果 */
		if(!isajax){
			box.innerHTML='<img style="margin-left:250px;" src="http://site.tongxueimg.com/v4/k/images/ico_loading16.gif"></img>';
		}
		//ajax列表
		$.post('/ajax/commentlist.php?sid='+urlnum,function(data){
                //IE7返回为文档,这里可能存在错误，应该找返回内容去找
				eval('r='+data);
				$('#'+boxid).html(r.result)
				//box.innerHTML=r.result;
				//把值传给一个hiddeninput，提交的时候使用，
				document.getElementById('in_reply_to_main_status_id_'+urlnum).value=urlnum;
				//为本回复列表里的所有删除按钮绑定click事件
				$('#'+boxid+' .del').click(function(){
					var sinnum=this.getAttribute('sid');	
					//重新加载
					ajaxReply.isdel(sinnum,urlnum,box,boxid);
			    });
				//为提交按钮取消原绑定未知click事件
				$('#reply_submit_'+urlnum).click(function(){
					return false;
				})
		});
	},
		
	//加载列表和绑定事件功能方法ajaxReply._getviplist(urlnum,box,boxid,true);
	_getviplist:function(urlnum,box,boxid,isajax){
		/*在提交的时候传这个参数为true，则不显示loadgif图片效果 */
		if(!isajax){
			box.innerHTML='<img style="margin-left:250px;" src="http://site.tongxueimg.com/v4/k/images/ico_loading16.gif"></img>';
		}
		//ajax列表
		$.post('/vip/photo_commentlist.php?sid='+urlnum,function(data){
                //IE7返回为文档,这里可能存在错误，应该找返回内容去找
				eval('r='+data);
				$('#'+boxid).html(r.result)
				//box.innerHTML=r.result;
				//把值传给一个hiddeninput，提交的时候使用，
				document.getElementById('in_reply_to_main_status_id_'+urlnum).value=urlnum;
				//为本回复列表里的所有删除按钮绑定click事件
				$('#'+boxid+' .del').click(function(){
					var sinnum=this.getAttribute('sid');	
					//重新加载
					ajaxReply.isdelcomment(sinnum,urlnum,box,boxid);
			    });
				//为提交按钮取消原绑定未知click事件
				$('#reply_submit_'+urlnum).click(function(){
					return false;
				})
		});
	},
	//是否删除留言
	isdel:function(sinnum,urlnum,box,boxid,actnum/*=2=最终页*/){
		box=document.getElementById(boxid);
		ajaxReply.isdel.del=function(){
			$.post('/ajax/del_reply_status.php',{ sid: sinnum},function(data){//删除
				if(actnum==2){//最终页
					var rolenum=document.getElementById('reply_list_role').value;															   
					ajaxReply.getlist_2('/ajax/commentlist.php?sid='+urlnum,{act:2,role:rolenum},'_reply_list');//重载
				}else{
					ye_dialog.close()
					ajaxReply._getlist(urlnum,box,boxid,actnum);
				}
				ye_dialog.close()
			});	
		}
		var showSwf = '<div class="showSwfPannal"><h3 style="margin-top:20px;">确定要删除该回复吗？</h3><p><input type="button" class="btn w2" onclick="ajaxReply.isdel.del()"  value="确定"/> <input type="button" onclick="ye_dialog.close()" value="取消" class="btn w2"/>';
  		ye_dialog.openHtml(showSwf,'提示',350);
	},
	//是否删除留言isdelcomment
	isdelcomment:function(sinnum,urlnum,box,boxid,actnum/*=2=最终页*/){
		box=document.getElementById(boxid);
		var showdelSwf = '<div class="showSwfPannal"><h3 style="margin-top:20px;">确定要删除该回复吗？</h3><p><input type="button" class="btn w2" onclick="ajaxReply.isdelcomment.del()"  value="确定"/> <input type="button" onclick="ye_dialog.close()" value="取消" class="btn w2"/>';
  		ye_dialog.openHtml(showdelSwf,'提示',350);
		ajaxReply.isdelcomment.del=function(){
			$.post('/vip/del_comment.php',{ sid: sinnum,pid:urlnum},function(data){//删除
				if(actnum==2){//最终页
					var rolenum=document.getElementById('reply_list_role').value;															   
					ajaxReply.getlist_2('/vip/commentlist.php?sid='+urlnum,{act:2,role:rolenum},'_reply_list');//重载
				}else{
					ye_dialog.close()
					ajaxReply._getviplist(urlnum,box,boxid,actnum);
				}
				ye_dialog.close()
			});	
		}
	},
    //回复单个人事件
	lose:function(th,topsid){
		//得到回复人名称
		var reName=th.parentNode.parentNode.getElementsByTagName('p')[0].getElementsByTagName('a')[0].innerHTML;
		//回复内容
		var otext=document.getElementById('text_'+topsid);
		//回复给哪条信息的标识
		var sidvalue=th.getAttribute('sid');
		//如果回复单条信息把名字放到内容框
		otext.focus();
		otext.innerHTML='回复'+reName+':';
		otext.value='回复'+reName+':';
		//hiddeninput
		document.getElementById('in_reply_to_slave_status_id_'+topsid).value=sidvalue;
		return false;
	},
	//为提交按钮绑定click事件
	sbmbot:function(th,topsid){
		//提交后禁用完成后再启用
		var oldevent=th.onclick;
		th.style.color='#999';
		th.onclick=function(){return};
		var urlnum=document.getElementById('in_reply_to_main_status_id_'+topsid).value;
		var reName=document.getElementById('in_reply_to_slave_status_id_'+topsid).value;
		var test=document.getElementById('text_'+topsid).value;
		var boxid='boxid_'+topsid;
		var box=document.getElementById(boxid);
		if(test!=''){
		$.post('/ajax/add_reply_status.php',{ in_reply_to_main_status_id: urlnum, in_reply_to_slave_status_id: reName, content:test},function(data){
			th.onclick=oldevent;
			th.style.color='';
			ajaxReply._getlist(urlnum,box,boxid,true);
		});
		}else{
			alert('内容为空');
			th.style.color='';
			th.onclick=oldevent;
		}
		return false;
	},
		
			//为提交按钮绑定click事件
	sbmbot_vip:function(th,topsid){
		//提交后禁用完成后再启用
		var oldevent=th.onclick;
		th.style.color='#999';
		th.onclick=function(){return};
		var urlnum=document.getElementById('in_reply_to_main_status_id_'+topsid).value;
		var reName=document.getElementById('in_reply_to_slave_status_id_'+topsid).value;
		var test=document.getElementById('text_'+topsid).value;
		var boxid='boxid_'+topsid;
		var box=document.getElementById(boxid);
		if(test!=''){
		$.post('/vip/add_comment.php',{ in_reply_to_main_status_id: urlnum, in_reply_to_slave_status_id: reName, content:test},function(data){
			th.onclick=oldevent;
			th.style.color='';
			ajaxReply._getviplist(urlnum,box,boxid,true);
		});
		}else{
			alert('内容为空');
			th.style.color='';
			th.onclick=oldevent;
		}
		return false;
	},
		//回复列表最终页，独立于init,加载地址相同但逻辑不同
		//回复单条时打开回复框功能
	init_2:function(th,topnum){
		var urlnum=th.getAttribute('sid');
		//要打开的DIV
		var boxid='boxid_'+urlnum;
		var box=document.getElementById(boxid);
		if(box.style.display=='none'){
			box.style.display='';
			var reName=th.parentNode.parentNode.parentNode.getElementsByTagName('p')[0].getElementsByTagName('a')[0].innerHTML;
			var otext=document.getElementById('text_'+urlnum);
			otext.focus();
			otext.innerHTML='回复'+reName+':';
			otext.value='回复'+reName+':';
			
		}else{
			box.style.display='none';
		}
	},
	//为回复单条和回复全部的提交，HTML绑定提交事件
	sbmbot_2:function(th,topsid,thissid){
		var oldevent=th.onclick;
		th.style.color='#999';
		th.onclick=function(){return};
		
		if(thissid){
			var test=document.getElementById('text_'+thissid).value;
		}else{//回复主内容
			var test=document.getElementById('detail_reply_textarea').value;
		}
		var boxid='boxid_'+topsid;
		var box=document.getElementById(boxid);
		//判断提交时是全部，我关注的人，还是陌生人
		var rolenum=document.getElementById('reply_list_role').value;
		var islockedup;//在不是关前组的时候显示发送成功信息
		if(rolenum !=0){
			ye_msg_2.open("", 60, 2);
			islockedup=1;
		}
		if(test!=''){
			if(thissid){
				$.post('/ajax/add_reply_status.php',{ in_reply_to_main_status_id: topsid, in_reply_to_slave_status_id: thissid, content:test},function(data){
					th.onclick=oldevent;
					th.style.color='';
					ajaxReply.getlist_2('/ajax/commentlist.php?sid='+topsid,{act:2,role:rolenum},'_reply_list',islockedup);
					
				});
			}else{//回复主内容
				$.post('/ajax/add_reply_status.php',{ in_reply_to_main_status_id: topsid, content:test},function(data){
					th.onclick=oldevent;
					th.style.color='';
					ajaxReply.getlist_2('/ajax/commentlist.php?sid='+topsid,{act:2,role:rolenum},'_reply_list',islockedup);
					
				});
			}
		}else{
			alert('内容为空');
			th.style.color='';
			th.onclick=oldevent;
		}
		return false;
		
	},
	//加载内容
	getlist_2:function(url,act,boxid,lockedup){
		$.post(url,act,function(data){
								
			    var box=document.getElementById(boxid);
				var r=null;
				eval('r='+data);
				$('#'+boxid).html(r.result);
				//box.innerHTML=r.result;
				if(lockedup==1){
					ye_msg.open('\u56de\u590d\u6210\u529f', 1, 1);
				ye_msg_2.closer(1);
				}
				
		  })
	},
	//加载分类,全部，我关注的人，陌生人
	getclass:function(th,topsid,rolenum){
		ajaxReply.getlist_2('/ajax/commentlist.php?sid='+topsid,{act:2,role:rolenum},'_reply_list');
	},
	//输入不能超过140个字符
	ordernum:140,
	/*动态判断textarea行数*/
	ordertextnum:function(th,height){
		var textnumrule=document.getElementById('textnumrule_'+th.id);
		//实现回车
	    textnumrule.innerHTML=th.value.replace(/\n/g,"<br />")+"<br />";
		//最小高度
		if(textnumrule.clientHeight>=44){
		th.style.height=textnumrule.clientHeight+'px';
		}else{
		th.style.height=height+'px';
		}
		//限定字数
		if(th.value.length>ajaxReply.ordernum-1){
			var orderstr=th.value.substring(0,ajaxReply.ordernum)
			ajaxReply.textnum=orderstr;
			th.value=ajaxReply.textnum;
			th.innerHTML=ajaxReply.textnum;
		}
	}
}

//滚动图片组091012
var rollImg={
	boxid:'',
	imgboxid:'imgbox',//ulid
	distance:520,//滚动距离
	showimgnum:4,//每次滚动图片张数
	times:null,
	interval:4000,//时间隔
	speed:500,//滚动速度
	init:function(boxid){
		rollImg.boxid=boxid;
		var imgnum=document.getElementById(boxid).getElementsByTagName('li').length;
		//左按钮
		$('#'+rollImg.boxid+' .arr-left').bind("click", function(){ 
				clearTimeout(rollImg.times,0);
				setTimeout(rollImg.move2,200);
		});
		//右按钮
		$('#'+rollImg.boxid+' .arr-right').bind("click", function(){ 
				clearTimeout(rollImg.times,0);
				setTimeout(rollImg.move,200);
		});
		//暂停
		$('#'+rollImg.boxid+' div').eq(0).hover(
			function(){
				clearTimeout(rollImg.times,0);
			},
			function(){
				setTimeout(rollImg.move,rollImg.interval);
			}
		)
		//滚动
		if(imgnum>rollImg.showimgnum){
			setTimeout(rollImg.move,2000);
		}
	},
	//move left
	move2:function(){
			
			$('#'+rollImg.imgboxid).css('left',-rollImg.distance+'px').fadeTo(200, 0.5);
			for(var i=0;i<rollImg.showimgnum;i++){
				$('#'+rollImg.imgboxid+' li').eq($('#'+rollImg.imgboxid+' li').length-1).prependTo('#'+rollImg.imgboxid);
			}
			$('#'+rollImg.imgboxid).animate({ left: '0px' }, rollImg.speed,function(){
				$('#'+rollImg.imgboxid).fadeTo(200, 1);
			});
		clearTimeout(rollImg.times,0);	
		rollImg.times=setTimeout(rollImg.move,rollImg.interval);
	},
	//move right
	move:function(){
			
			$('#'+rollImg.imgboxid).fadeTo(200, 0.5).animate({ left: -rollImg.distance+'px' }, rollImg.speed,function(){
				for(var i=0;i<rollImg.showimgnum;i++){
					$('#'+rollImg.imgboxid+' li').eq(0).appendTo('#'+rollImg.imgboxid);
				}
				$('#'+rollImg.imgboxid).css('left','0').fadeTo(200, 1);
			});
		clearTimeout(rollImg.times,0);	
		rollImg.times=setTimeout(rollImg.move,rollImg.interval);
	}
}

//搜索分类功能
var searchr_point={
	ud:2,
	init:function(th,appendbox,evt){
		var v=th.value;
		th.onkeyup=function(){searchr_point.keyup(th)};
		//have content and no element searchr_point_box ,create it.
		if(v && !document.getElementById('searchr_point_box')){
			v=searchr_point.gbtrim(v,11,'...');
			$('<ul id="searchr_point_box" class="point"><li>\u8bf7\u9009\u62e9\u641c\u7d22\u8303\u56f4</li><li onmouseover="searchr_point.over(this)" onclick="searchr_point.sbm(2,event)"  class="option hover">\u542b<span>'+v+'</span>\u7684\u6d88\u606f</li><li onmouseover="searchr_point.over(this)" onclick="searchr_point.sbm(1,event)" class="option">\u542b<span>'+v+'</span>\u7684\u4eba</li></ul>').appendTo("#searchr")
		}
		//stopPropagation
		th.onclick=function(evt){
			var e=(evt)?evt:window.event;  
			if (window.event) {  
				 e.cancelBubble=true;  
			} else {  
				 e.stopPropagation();  
			} 
		}
		document.getElementById('searchr-submit').onclick=function(evt){
			var e=(evt)?evt:window.event;  
			if (window.event) {  
				 e.cancelBubble=true;  
			} else {  
				 e.stopPropagation();  
			} 
		}
		$(document).bind("click",searchr_point.closer);
	},
	stopmp:function(evt){
		var e=(evt)?evt:window.event;  
			if (window.event) {  
				 e.cancelBubble=true;  
			} else {  
				 e.stopPropagation();  
		} 
	},
	down:function(evt){		
		var e=(evt)?evt:window.event;
		if(e.keyCode==38){//up
			if(searchr_point.ud==1){//
				$('#searchr_point_box li').eq(2).removeClass('hover');
				$('#searchr_point_box li').eq(1).addClass('hover');
				searchr_point.ud=2;
			}
		}else if(e.keyCode==40){//down
			if(searchr_point.ud==2){//
				$('#searchr_point_box li').eq(1).removeClass('hover');
				$('#searchr_point_box li').eq(2).addClass('hover');								
				searchr_point.ud=1;
			}
		}
		this.change_act();
	},
	keyup:function(th){
		var v=th.value;
		//have content and no element searchr_point_box ,create it.
		v=searchr_point.gbtrim(v,11,'...');
		if(v && !document.getElementById('searchr_point_box')){
			if(searchr_point.ud==1){
			$('<ul id="searchr_point_box" class="point"><li>\u8bf7\u9009\u62e9\u641c\u7d22\u8303\u56f4</li><li id="li2" onmouseover="searchr_point.over(this)" onclick="searchr_point.sbm(2,event)"  class="option">\u542b<span>'+v+'</span>\u7684\u6d88\u606f</li><li id="li1" onmouseover="searchr_point.over(this)" onclick="searchr_point.sbm(1,event)" class="option hover">\u542b<span>'+v+'</span>\u7684\u4eba</li></ul>').appendTo("#searchr")
			}else if(searchr_point.ud==2){
			$('<ul id="searchr_point_box" class="point"><li>\u8bf7\u9009\u62e9\u641c\u7d22\u8303\u56f4</li><li id="li2" onmouseover="searchr_point.over(this)" onclick="searchr_point.sbm(2,event)"  class="option hover">\u542b<span>'+v+'</span>\u7684\u6d88\u606f</li><li id="li1" onmouseover="searchr_point.over(this)" onclick="searchr_point.sbm(1,event)" class="option">\u542b<span>'+v+'</span>\u7684\u4eba</li></ul>').appendTo("#searchr")
			}
			this.change_act();
		}else{
			if(v){
				$('#searchr_point_box span').text(v);
			}else{
				searchr_point.closer();
			}
		}
	},
	over:function(th){
		$('#searchr_point_box li').removeClass('hover');
		th.className='option hover';
		if($('#searchr_point_box li').index($(th))==1){
			searchr_point.ud=2;			
		}else if($('#searchr_point_box li').index($(th))==2){
			searchr_point.ud=1;			
		}
		this.change_act();
	},
	out:function(th){
	},
	change_act:function(num){
		if (!num) num = searchr_point.ud;
		if(num==1){
			document.getElementById('searchr-act').value='search';
			document.getElementById('header_search_form').action='/search/search_user.php';
		}else if(num==2){
			document.getElementById('searchr-act').value='';
			document.getElementById('header_search_form').action='/search/search_status.php';
		}
	},
	sbm:function(num/*1=search blog,2=search people*/,evt){
		this.change_act(num);		
		searchr_point.stopmp(evt);
		setTimeout(function(){document.getElementById('searchr-submit').click()},100);
		
	},
	closer:function(){
		if(document.getElementById('searchr_point_box')){
			$('#searchr_point_box').remove();
			document.getElementById('searchr-act').value='search';
			searchr_point.ud=2;
		}
	},
	//处理字符串长度,当字会串长度大于10或11时后面显示...
	gbtrim :function(v,len, s) {  
		var str = '';  
		var sp  = s || '';  
		var len2 = 0;  
		for (var i=0; i<v.length; i++) {  
			if (v.charCodeAt(i)>127 || v.charCodeAt(i)==94) {  
				 len2 += 2;  
			} else {  
				 len2 ++;  
			}  
		}  
		if (len2 <= len) {  
			 return v;  
		}  
		len2 = 0;  
		len  = (len > sp.length) ? len-sp.length: len;  
		for (var i=0; i<v.length; i++) {  
			if (v.charCodeAt(i)>127 || v.charCodeAt(i)==94) {  
				len2 += 2;  
			} else {  
				 len2 ++;  
			}  
			if (len2 > len) {  
				 str += sp;  
				break;  
			}  
			str += v.charAt(i);  
		}  
		return str;  
	} 
}
//图片加载完成监听函数
//使用方法：
//var a=new SImage(callback,{oa:b[j]});
//a.get(imgurl);
//vip_show.php
function SImage(callback,t)
{
    var img = new Image();
    this.img = img;
    var appname = navigator.appName.toLowerCase();
    if (appname.indexOf("netscape") == -1)
    {
       //ie
        img.onreadystatechange = function () {
            if (img.readyState == "complete")
            {
                callback(img,t);
            }
        };
    } else {
       //firefox
        img.onload = function () {
            if (img.complete == true)
            {
                callback(img,t);
            }
        }
    }
}
SImage.prototype.get = function (url)
{
    this.img.src = url;
}
//页面加载时loadding频道内容
$(function(){
	setTimeout(presence.loadding,1000)   
})