﻿/**
* description: appraisal.com,Online
* author : hn-man@live.cn
* version: 1.0.10.1129
*/
Object.extend = function(destination, source) {
    for (var property in source) {
        destination[property] = source[property];
    }
    return destination;
}
var Class = {
    create: function() {
        return {};
    }
}
// 动态字符串：类似C#
if (typeof StringBuilder == "undefined" || !window.StringBuilder) {
    var StringBuilder = function() {
        this.cache = [];
        if (arguments.length) this.append.apply(this, arguments);
    }
}
// 添加其对应属性
StringBuilder.prototype = {
    prepend: function() {
        this.cache.splice.apply(this.cache, [].concat.apply([0, 0], arguments));
        return this;
    },
    append: function() {
        this.cache = this.cache.concat.apply(this.cache, arguments);
        return this;
    },
    toString: function() {
        return this.getString();
    },
    getString: function() {
        return this.cache.join('');
    }
};
//去空格
String.prototype.ltrim = String.prototype.LTrim = function() {
    return this.replace(/(^\s*)/g, "");
}
String.prototype.rtrim = String.prototype.RTrim = function() {
    return this.replace(/(\s*$)/g, "");
}
String.prototype.trim = String.prototype.Trim = function() {
    return this.replace(/^[\s\n\t]*|[\s\n\t]*$/g, "");
}
//HTML编码
String.prototype.HtmlEncode = function(isTextArea) {
    var result = this.valueOf();
    result = result.replace(/\&/g, "&amp;");
    result = result.replace(/\>/g, "&gt;");
    result = result.replace(/\</g, "&lt;");
    result = result.replace(/\"/g, "&quot;");
    result = result.replace(/\'/g, "&#39;");
    if (!isTextArea) result = result.replace(/\n/g, "<br/>");
    return result;
}
//HTML解码
String.prototype.HtmlDescode = function() {
    var result = this.valueOf();
    result = result.replace(/&amp;/g, "&");
    result = result.replace(/&gt;/g, ">");
    result = result.replace(/&lt;/g, "<");
    result = result.replace(/&quot;/g, '"');
    result = result.replace(/&#39;/g, "'");
    return result;
}
//移除HTML标签
String.prototype.stripTags = String.prototype.StripTags = function() {
    var result = this.valueOf();
    if(result=="") return "";
    result = result.replace(/\<[^\<\>]+\>/g, "");
    result = result.replace(/ +/g, " ");
    result = result.replace(/\n+/g, "\n");
    return result;
}
//安全的属性值引用号转换
String.prototype.safeQuote = String.prototype.SafeQuote = function(bSingleQuote) {
    var result = this.valueOf();
    if (bSingleQuote) {
        result = result.replace(/\'/ig, "\\\'");
    } else {
        result = result.replace(/\"/ig, "\\\"");
    }
    return result;
}
//检查字符串是否含有"% \' \" \\ \/ "的字符
String.prototype.HaveSpecialChar = function() {
    var sReg = /[,%\'\"\/\\;|\<\>]/;
    if (this.valueOf().search(sReg) == -1) return false;
    return true;
}
/*转换json字符串到对象
* @return (obj)转换后的对象，如果解析失败返回false*/
String.prototype.ToJson = function() {
    try {
        return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
                this.replace(/'(\\.|[^"\\])*'/g, ''))) &&
            eval('(' + this + ')');
    } catch (e) {
        return false;
    }
}
//字符转数字
String.prototype.StrToInt = function() {
    return parseInt(this, 10);
}
//是否全为中文
String.prototype.isZh = function() {
    return /^[\u4e00-\u9fa5]+$/.test(this.valueOf());
}
//是否全为英文
String.prototype.isEn = function() {
    return /^[A-Za-z]+$/.test(this.valueOf());
},
//是否为Int32类型的数字
String.prototype.isNumber = function() {
    return /^[-]?[0-9]*[.]?[0-9]*$/.test(this.valueOf());
}
//是否为数字
String.prototype.isInteger = function() {
    if (result == "") return false;
    return /^(\-?)(\d+)$/.test(this.valueOf());
}
//是否为HTTP路径
String.prototype.isURL = function() {
    return /^(http:\/\/)?(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_,-](\?)?)*)*$/i.test(this.valueOf());
}
//是否为手机号码
String.prototype.isMobile = function() {
    return /^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/.test(this.valueOf());
}
//是否为Email
String.prototype.isEmail = function() {
    return /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(this.valueOf());
}
//正则包含字符类型系数
String.prototype.RegxSafeVal = function(nums, len) {
    var str = this.valueOf();
    if (str == "") {
        return 0;
    } else if (str.length < nums || str.length > len) {
        return 1;
    } else {
        return str.match(/[a-z](?![^a-z]*[a-z])|[A-Z](?![^A-Z]*[A-Z])|d(?![^d]*d)|[^a-zA-Zd](?![a-zA-Zd]*[^a-zA-Zd])/g).length;
    }
}
// 动态加载JS文件
var JsLoader = Class.create();
Object.extend(JsLoader, {
    load: function(sUrl, fCallback) {
        var _script = document.createElement('script');
        _script.setAttribute('type', 'text/javascript');
        _script.setAttribute('src', sUrl);
        document.getElementsByTagName('head')[0].appendChild(_script);
        if ($.browser.msie) {
            _script.onreadystatechange = function() { if (this.readyState == 'loaded' || this.readyState == 'complete') { fCallback(); } }
        } else {
            _script.onload = function() { fCallback(); }
        }
    }
});

/** 
* extension of JSON, type for jQuery 
* AUTHOR: xushengs@gmail.com 
* LICENSE: http://www.opensource.org/licenses/mit-license.php 
* WEBSITE: http://ooboy.net/ 
*/
(function($) {
    // the code of this function is from  
    // http://lucassmith.name/pub/typeof.html 
    $.type = function(o) {
        var _toS = Object.prototype.toString;
        var _types = {
            'undefined': 'undefined',
            'number': 'number',
            'boolean': 'boolean',
            'string': 'string',
            '[object Function]': 'function',
            '[object RegExp]': 'regexp',
            '[object Array]': 'array',
            '[object Date]': 'date',
            '[object Error]': 'error'
        };
        return _types[typeof o] || _types[_toS.call(o)] || (o ? 'object' : 'null');
    };
    // the code of these two functions is from mootools 
    // http://mootools.net 
    var $specialChars = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' };
    var $replaceChars = function(chr) {
        return $specialChars[chr] || '\\u00' + Math.floor(chr.charCodeAt() / 16).toString(16) + (chr.charCodeAt() % 16).toString(16);
    };
    $.toJSON = function(o) {
        var s = [];
        switch ($.type(o)) {
            case 'undefined':
                return 'undefined';
                break;
            case 'null':
                return 'null';
                break;
            case 'number':
            case 'boolean':
            case 'date':
            case 'function':
                return o.toString();
                break;
            case 'string':
                return '"' + o.replace(/[\x00-\x1f\\"]/g, $replaceChars) + '"';
                break;
            case 'array':
                for (var i = 0, l = o.length; i < l; i++) {
                    s.push($.toJSON(o[i]));
                }
                return '[' + s.join(',') + ']';
                break;
            case 'error':
            case 'object':
                for (var p in o) {
                    s.push(p + ':' + $.toJSON(o[p]));
                }
                return '{' + s.join(',') + '}';
                break;
            default:
                return '';
                break;
        }
    };
    $.evalJSON = function(s) {
        if ($.type(s) != 'string' || !s.length) return null;
        return eval('(' + s + ')');
    };
})(jQuery);
/*
* .tabSwitch
*/
(function($) {
    $.fn.tabSwitch = function(command, Arguements, EndFunction) {
        var defaults = {
            type: "slide", //Type of effect
            cols: 2, //This only used when you're using type = table
            toggle: "fade", //This specific which type of toggle effect
            ease: 40,
            easeType: "linear", //This isn't work for this version yet
            loopback: 1, //If it's 1 it will loop when it reach the ends
            width: 400, // Size of the viewport
            height: 400,
            index: 0, //The current tab index
            speed: 500, //Speed of the animation
            interval: 5000, //The interval of auto-animate
            step: 1, //How many step you want to use in moveStep
            wrapperClass: "", //You could add extra class for the wraper
            viewportClass: "" //You could add extra class for the viewport
        };

        var Args = $.extend(defaults, Arguements);
        var Obj = this;
        //For quicker access
        var jFirstObj = Obj.eq(1);
        var DOMFirstObj = Obj.eq(1).get(0);
        if (!$.isFunction(EndFunction)) {
            //Set the index in the cache
            var Callback = function() {
                $.data(DOMFirstObj, "index", Args.index);
            };
        }
        else {
            var Callback = function() {
                $.data(DOMFirstObj, "index", Args.index);
                EndFunction();
            };
        }
        //Back up orginal information
        StoreToCache = function() {
            //Now store the tab type in the cache for further use
            $.data(DOMFirstObj, "type", Args.type);
            $.data(DOMFirstObj, "toggle", Args.toggle);
            $.data(DOMFirstObj, "cols", Args.cols);
            $.data(DOMFirstObj, "ease", Args.ease);
            $.data(DOMFirstObj, "easeType", Args.easeType);
            $.data(DOMFirstObj, "index", Args.index);
            $.data(DOMFirstObj, "loopback", Args.loopback);
            //Before do anything to the object, keep a backup so we could revert it
            if (jFirstObj.attr('style')) {
                $.data(DOMFirstObj, "orgAttr", jFirstObj.attr('style'));
            } else {
                $.data(DOMFirstObj, "orgAttr", "");
            }
        }
        //Remove all the data in cache and reset the object back to original
        backFromCache = function() {
            Obj.attr('style', $.data(DOMFirstObj, "orgAttr"));
            var ViewPortObj = $("#ViewPort" + $.data(DOMFirstObj));
            ViewPortObj.replaceWith(Obj);
            //Remove auto if it's running
            stopAuto();
            //Clear cacke
            $.removeData(DOMFirstObj);
        }
        //Execute when input comment is create
        var createTab = function() {
            //Back up orginal information
            StoreToCache();
            //Construct the form
            //Set all the CSS for the list div, this;s the common setting for all type of tab
            if (Args.width) Obj.width(Args.width);
            if (Args.height) Obj.height(Args.height);
            //A big wraper around and change some CSS of the wrap
            var WraperSelector = "WideDiv" + $.data(DOMFirstObj);
            Obj.wrapAll("<div id='" + WraperSelector + "'></div>");
            var WraperObj = $("#" + WraperSelector);
            WraperObj.addClass(Args.wraperClass);
            WraperObj.css({ "position": "relative" });
            WraperObj.wrap("<div id='" + WraperSelector.replace("WideDiv", "ViewPort") + "'></div>")
            //Now create the viewport with the input size
            var ViewPortObj = $("#" + WraperSelector.replace("WideDiv", "ViewPort"));
//             ViewPortObj.width(Args.width);加在下面，自适应
            ViewPortObj.height(Args.height);
            ViewPortObj.css({ "display": "block", "overflow": "hidden", "position": "relative","width":"100%"});
            ViewPortObj.addClass(Args.viewportClass);
            switch (Args.type) {
                case "slide":
                    Obj.css({ "float": "left" });
                    //A big wraper around and change some CSS of the wrap
                    WraperObj.width((Args.width + 2) * Obj.length);
                    //Now create the viewport with the input size
                    break;
                case "scroll":
                    //A big wraper around and change some CSS of the wrap				
                    WraperObj.width(Args.width);
                    WraperObj.height((Args.height + 2) * Obj.length);
                    break;
                case "toggle":
                    WraperObj.width(Args.width);
                    WraperObj.height(Args.height);
                    Obj.css({ "position": "absolute", "left": "-999px" });
                    Obj.eq(Args.index).css({ "left": "0px", "top": "0px" });
                    Obj.eq(Args.index).css("opacity", 1);
                    break;
                case "table":
                    WraperObj.width(Args.width * Args.cols);
                    Obj.css("float", "left");
            }
            moveTo();
        }
        // Move object to a position set by Args.Index
        var moveTo = function() {
            //get the easeLevel from the cache
            var ease = 0;
            //Check if the next idx is out of the limit or not
            if (!Args.easeType) {
                Args.easeType = (DOMFirstObj, "easeType");
            }
            if (Args.index > Obj.length - 1) {
                if ($.data(DOMFirstObj, "loopback") != 0) {
                    Args.index = 0;
                    ease = -$.data(DOMFirstObj, "ease");
                }
                else return;
            }
            if (Args.index < 0) {
                if ($.data(DOMFirstObj, "loopback") != 0) {
                    Args.index = Obj.length - 1;
                    ease = $.data(DOMFirstObj, "ease");
                } else return;
            }
            var WraperSelector = "WideDiv" + $.data(DOMFirstObj);
            var WraperObj = $("#" + WraperSelector);
            //See what type of effect we stimulate
            switch ($.data(DOMFirstObj, "type")) {
                case 'slide':
                    //Get how much ease we set and start the animation
                    if (ease != 0) {
                        var easeLevel = (parseInt(WraperObj.css("left").replace("px", "")) + ease);
                        WraperObj.animate({ left: easeLevel + "px" }, Args.speed, function() {
                            WraperObj.animate({ left: -(Obj.outerWidth(true) * Args.index) + "px" }, Args.speed, Args.easeType, Callback());
                        });
                    } else {
                        WraperObj.animate({ left: -(Obj.outerWidth(true) * Args.index) + "px" }, Args.speed, Args.easeType, Callback());
                    }
                    break;
                case 'scroll':
                    //Get how much ease we set and start the animation
                    if (ease != 0) {
                        var easeLevel = (parseInt(WraperObj.css("top").replace("px", "")) + ease);
                        WraperObj.animate({ top: easeLevel + "px" }, Args.speed, function() {
                            WraperObj.animate({ top: -(Obj.outerHeight(true) * Args.index) + "px" }, Args.speed, Args.easeType, Callback());
                        });
                    } else {
                        WraperObj.animate({ top: -(Obj.outerHeight(true) * Args.index) + "px" }, Args.speed, Args.easeType, Callback());
                    }
                    break;
                case 'toggle':
                    //move the new one on top of the old div
                    Obj.eq(Args.index).css({ "left": "0px", "top": "0px" });
                    $.extend(Args, { speed: 150 }); //邓鹏20100319修改动画时长的毫秒数值
                    switch ($.data(DOMFirstObj, "toggle")) {
                        case "fade":
                            Obj.eq(Args.index).css({ "opacity": 0 });
                            Obj.eq(Args.index).animate({ "opacity": 1 }, Args.speed);
                            if ($.data(DOMFirstObj, "index") != Args.index) {
                                Obj.eq($.data(DOMFirstObj, "index")).animate({ "opacity": 0 }, Args.speed, function() {
                                    $(this).css("left", -999);
                                    Callback();
                                });
                            }
                            break;
                        case "toggle":
                            if ($.data(DOMFirstObj, "index") != Args.index) {
                                Obj.eq(Args.index).css({ "display": "none" });
                                Obj.eq($.data(DOMFirstObj, "index")).slideUp(Args.speed, function() {
                                    Obj.eq(Args.index).slideDown(Args.speed, function() { Callback(); });
                                    $(this).css("left", -999);
                                });
                            }
                            break;
                        case "show":
                            if ($.data(DOMFirstObj, "index") != Args.index) {
                                Obj.eq(Args.index).css({ "display": "none" });
                                Obj.eq($.data(DOMFirstObj, "index")).hide(Args.speed, function() {
                                    Obj.eq(Args.index).show(Args.speed, function() { Callback(); });
                                    $(this).css("left", -999);
                                });
                            }
                            break;
                        case "noeffect":
                            if ($.data(DOMFirstObj, "index") != Args.index) {
                                Obj.eq($.data(DOMFirstObj, "index")).css("left", -999);
                                Callback();
                            }
                            break;
                    }
                    break;
                case "table":
                    var cols = $.data(DOMFirstObj, "cols");
                    //Where the next idx in the table
                    var nextX = -(Args.index % cols) * Obj.width();
                    var nextY = -Math.floor(Args.index / cols) * Obj.height();
                    //Move horizontal first
                    WraperObj.animate({ "left": nextX }, Args.speed, Args.easeType, function() {
                        WraperObj.animate({ "top": nextY }, Args.speed, Args.easeType, Callback());
                    });
                    break;
                default:
                    $('html,body').animate({ "scrollTop": Obj.eq(Args.index).offset().top }, Args.speed);
                    break;

            }
        };

        //Move by steps
        moveStep = function() {
            var currentIdx = $.data(DOMFirstObj, "index");
            //Calculate the next index
            Args.index = parseInt(currentIdx) + parseInt(Args.step);
            //Then move to it
            moveTo();
        }
        //Set it run auto
        startAuto = function() {
            //Save the autoswitch into memory and start it
            $.data(DOMFirstObj, "AutoSwitch", setInterval(moveStep, Args.interval));
        }
        //Stop the auto
        stopAuto = function() {
            //Stop the interval and clear the cache
            clearInterval($.data(DOMFirstObj, "AutoSwitch"));
            $.removeData(DOMFirstObj, "AutoSwitch");
        }
        //Toggle auto
        toggleAuto = function() {
            if (isAuto()) {
                stopAuto();
            } else {
                startAuto();
            }
        }
        //Return if this is auto or not
        isAuto = function() {
            if ($.data(DOMFirstObj, "AutoSwitch")) {
                return true;
            } else {
                return false;
            }
        }
        if (!command) command = "";
        //Check what user want
        switch (command.toLowerCase()) {
            case "index":
                if ($.data(DOMFirstObj, "index")) {
                    return $.data(DOMFirstObj, "index");
                } else {
                    return 0;
                }
                break;
            case "moveto":
                moveTo();
                break;
            case "movestep":
                moveStep();
                break;
            case "destroy":
                backFromCache();
                break;
            case "create":
                createTab();
                break;
            case "isauto":
                return isAuto();
                break;
            case "toggleauto":
                toggleAuto();
                break;
            case "startauto":
                startAuto();
                break;
            case "stopauto":
                stopAuto();
                break;
        }
    };
})(jQuery);
/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
*       used when the cookie was set.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
*                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
*                             If set to null or omitted, the cookie will be a session cookie and will not be retained
*                             when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
*                        require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/

/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

/*
*  jQuery滚动返回顶部插件
*  Demo:scrolltotop.init()
*/
var scrolltotop = {
    //startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
    //scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
    setting: { startline: 100, scrollto: 0, scrollduration: 1000, fadeduration: [500, 100] },
    controlHTML: '<div style="display: block;" id="gotoTop"><a title="回顶部" href="javascript:void(0);">回顶部</a></div>', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
    controlattrs: { offsetx: 5, offsety: 5 }, //offset of control relative to right/ bottom of window corner
    anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links

    state: { isvisible: false, shouldvisible: false },

    scrollup: function() {
        if (!this.cssfixedsupport) //if control is positioned using JavaScript
            this.$control.css({ opacity: 0 }) //hide control immediately after clicking it
        var dest = isNaN(this.setting.scrollto) ? this.setting.scrollto : parseInt(this.setting.scrollto)
        if (typeof dest == "string" && jQuery('#' + dest).length == 1) //check element set by string exists
            dest = jQuery('#' + dest).offset().top
        else
            dest = 0
        this.$body.animate({ scrollTop: dest }, this.setting.scrollduration);
    },

    keepfixed: function() {
        var $window = jQuery(window)
        var controlx = $window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx
        var controly = $window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety
        this.$control.css({ left: controlx + 'px', top: controly + 'px' })
    },

    togglecontrol: function() {
        var scrolltop = jQuery(window).scrollTop()
        if (!this.cssfixedsupport)
            this.keepfixed()
        this.state.shouldvisible = (scrolltop >= this.setting.startline) ? true : false
        if (this.state.shouldvisible && !this.state.isvisible) {
            this.$control.stop().animate({ opacity: 1 }, this.setting.fadeduration[0])
            this.state.isvisible = true
        }
        else if (this.state.shouldvisible == false && this.state.isvisible) {
            this.$control.stop().animate({ opacity: 0 }, this.setting.fadeduration[1])
            this.state.isvisible = false
        }
    },

    init: function() {
        jQuery(document).ready(function($) {
            var mainobj = scrolltotop
            var iebrws = document.all
            mainobj.cssfixedsupport = !iebrws || iebrws && document.compatMode == "CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
            mainobj.$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body')
            mainobj.$control = $('<div id="topcontrol">' + mainobj.controlHTML + '</div>')
				.css({ position: mainobj.cssfixedsupport ? 'fixed' : 'absolute', bottom: mainobj.controlattrs.offsety, right: mainobj.controlattrs.offsetx, opacity: 0, cursor: 'pointer' })
				.attr({ title: 'Scroll Back to Top' })
				.click(function() { mainobj.scrollup(); return false })
				.appendTo('body')
            if (document.all && !window.XMLHttpRequest && mainobj.$control.text() != '') //loose check for IE6 and below, plus whether control contains any text
                mainobj.$control.css({ width: mainobj.$control.width() }) //IE6- seems to require an explicit width on a DIV containing text
            mainobj.togglecontrol()
            $('a[href="' + mainobj.anchorkeyword + '"]').click(function() {
                mainobj.scrollup()
                return false
            })
            $(window).bind('scroll resize', function(e) {
                mainobj.togglecontrol()
            })
        })
    }
}; 
            
/*
* .tabSwitch
*/
(function($) {
    $.fn.tabSwitch = function(command, Arguements, EndFunction) {
        var defaults = {
            type: "slide", //Type of effect
            cols: 2, //This only used when you're using type = table
            toggle: "fade", //This specific which type of toggle effect
            ease: 40,
            easeType: "linear", //This isn't work for this version yet
            loopback: 1, //If it's 1 it will loop when it reach the ends
            width: 400, // Size of the viewport
            height: 400,
            index: 0, //The current tab index
            speed: 500, //Speed of the animation
            interval: 5000, //The interval of auto-animate
            step: 1, //How many step you want to use in moveStep
            wrapperClass: "", //You could add extra class for the wraper
            viewportClass: "" //You could add extra class for the viewport
        };

        var Args = $.extend(defaults, Arguements);
        var Obj = this;
        //For quicker access
        var jFirstObj = Obj.eq(1);
        var DOMFirstObj = Obj.eq(1).get(0);
        if (!$.isFunction(EndFunction)) {
            //Set the index in the cache
            var Callback = function() {
                $.data(DOMFirstObj, "index", Args.index);
            };
        }
        else {
            var Callback = function() {
                $.data(DOMFirstObj, "index", Args.index);
                EndFunction();
            };
        }
        //Back up orginal information
        StoreToCache = function() {
            //Now store the tab type in the cache for further use
            $.data(DOMFirstObj, "type", Args.type);
            $.data(DOMFirstObj, "toggle", Args.toggle);
            $.data(DOMFirstObj, "cols", Args.cols);
            $.data(DOMFirstObj, "ease", Args.ease);
            $.data(DOMFirstObj, "easeType", Args.easeType);
            $.data(DOMFirstObj, "index", Args.index);
            $.data(DOMFirstObj, "loopback", Args.loopback);
            //Before do anything to the object, keep a backup so we could revert it
            if (jFirstObj.attr('style')) {
                $.data(DOMFirstObj, "orgAttr", jFirstObj.attr('style'));
            } else {
                $.data(DOMFirstObj, "orgAttr", "");
            }
        }
        //Remove all the data in cache and reset the object back to original
        backFromCache = function() {
            Obj.attr('style', $.data(DOMFirstObj, "orgAttr"));
            var ViewPortObj = $("#ViewPort" + $.data(DOMFirstObj));
            ViewPortObj.replaceWith(Obj);
            //Remove auto if it's running
            stopAuto();
            //Clear cacke
            $.removeData(DOMFirstObj);
        }
        //Execute when input comment is create
        var createTab = function() {
            //Back up orginal information
            StoreToCache();
            //Construct the form
            //Set all the CSS for the list div, this;s the common setting for all type of tab
            if (Args.width) Obj.width(Args.width);
            if (Args.height) Obj.height(Args.height);
            //A big wraper around and change some CSS of the wrap
            var WraperSelector = "WideDiv" + $.data(DOMFirstObj);
            Obj.wrapAll("<div id='" + WraperSelector + "'></div>");
            var WraperObj = $("#" + WraperSelector);
            WraperObj.addClass(Args.wraperClass);
            WraperObj.css({ "position": "relative" });
            WraperObj.wrap("<div id='" + WraperSelector.replace("WideDiv", "ViewPort") + "'></div>")
            //Now create the viewport with the input size
            var ViewPortObj = $("#" + WraperSelector.replace("WideDiv", "ViewPort"));
            //             ViewPortObj.width(Args.width);加在下面，自适应
            ViewPortObj.height(Args.height);
            ViewPortObj.css({ "display": "block", "overflow": "hidden", "position": "relative", "width": "100%" });
            ViewPortObj.addClass(Args.viewportClass);
            switch (Args.type) {
                case "slide":
                    Obj.css({ "float": "left" });
                    //A big wraper around and change some CSS of the wrap
                    WraperObj.width((Args.width + 2) * Obj.length);
                    //Now create the viewport with the input size
                    break;
                case "scroll":
                    //A big wraper around and change some CSS of the wrap				
                    WraperObj.width(Args.width);
                    WraperObj.height((Args.height + 2) * Obj.length);
                    break;
                case "toggle":
                    WraperObj.width(Args.width);
                    WraperObj.height(Args.height);
                    Obj.css({ "position": "absolute", "left": "-999px" });
                    Obj.eq(Args.index).css({ "left": "0px", "top": "0px" });
                    Obj.eq(Args.index).css("opacity", 1);
                    break;
                case "table":
                    WraperObj.width(Args.width * Args.cols);
                    Obj.css("float", "left");
            }
            moveTo();
        }
        // Move object to a position set by Args.Index
        var moveTo = function() {
            //get the easeLevel from the cache
            var ease = 0;
            //Check if the next idx is out of the limit or not
            if (!Args.easeType) {
                Args.easeType = (DOMFirstObj, "easeType");
            }
            if (Args.index > Obj.length - 1) {
                if ($.data(DOMFirstObj, "loopback") != 0) {
                    Args.index = 0;
                    ease = -$.data(DOMFirstObj, "ease");
                }
                else return;
            }
            if (Args.index < 0) {
                if ($.data(DOMFirstObj, "loopback") != 0) {
                    Args.index = Obj.length - 1;
                    ease = $.data(DOMFirstObj, "ease");
                } else return;
            }
            var WraperSelector = "WideDiv" + $.data(DOMFirstObj);
            var WraperObj = $("#" + WraperSelector);
            //See what type of effect we stimulate
            switch ($.data(DOMFirstObj, "type")) {
                case 'slide':
                    //Get how much ease we set and start the animation
                    if (ease != 0) {
                        var easeLevel = (parseInt(WraperObj.css("left").replace("px", "")) + ease);
                        WraperObj.animate({ left: easeLevel + "px" }, Args.speed, function() {
                            WraperObj.animate({ left: -(Obj.outerWidth(true) * Args.index) + "px" }, Args.speed, Args.easeType, Callback());
                        });
                    } else {
                        WraperObj.animate({ left: -(Obj.outerWidth(true) * Args.index) + "px" }, Args.speed, Args.easeType, Callback());
                    }
                    break;
                case 'scroll':
                    //Get how much ease we set and start the animation
                    if (ease != 0) {
                        var easeLevel = (parseInt(WraperObj.css("top").replace("px", "")) + ease);
                        WraperObj.animate({ top: easeLevel + "px" }, Args.speed, function() {
                            WraperObj.animate({ top: -(Obj.outerHeight(true) * Args.index) + "px" }, Args.speed, Args.easeType, Callback());
                        });
                    } else {
                        WraperObj.animate({ top: -(Obj.outerHeight(true) * Args.index) + "px" }, Args.speed, Args.easeType, Callback());
                    }
                    break;
                case 'toggle':
                    //move the new one on top of the old div
                    Obj.eq(Args.index).css({ "left": "0px", "top": "0px" });
                    $.extend(Args, { speed: 150 }); //邓鹏20100319修改动画时长的毫秒数值
                    switch ($.data(DOMFirstObj, "toggle")) {
                        case "fade":
                            Obj.eq(Args.index).css({ "opacity": 0 });
                            Obj.eq(Args.index).animate({ "opacity": 1 }, Args.speed);
                            if ($.data(DOMFirstObj, "index") != Args.index) {
                                Obj.eq($.data(DOMFirstObj, "index")).animate({ "opacity": 0 }, Args.speed, function() {
                                    $(this).css("left", -999);
                                    Callback();
                                });
                            }
                            break;
                        case "toggle":
                            if ($.data(DOMFirstObj, "index") != Args.index) {
                                Obj.eq(Args.index).css({ "display": "none" });
                                Obj.eq($.data(DOMFirstObj, "index")).slideUp(Args.speed, function() {
                                    Obj.eq(Args.index).slideDown(Args.speed, function() { Callback(); });
                                    $(this).css("left", -999);
                                });
                            }
                            break;
                        case "show":
                            if ($.data(DOMFirstObj, "index") != Args.index) {
                                Obj.eq(Args.index).css({ "display": "none" });
                                Obj.eq($.data(DOMFirstObj, "index")).hide(Args.speed, function() {
                                    Obj.eq(Args.index).show(Args.speed, function() { Callback(); });
                                    $(this).css("left", -999);
                                });
                            }
                            break;
                        case "noeffect":
                            if ($.data(DOMFirstObj, "index") != Args.index) {
                                Obj.eq($.data(DOMFirstObj, "index")).css("left", -999);
                                Callback();
                            }
                            break;
                    }
                    break;
                case "table":
                    var cols = $.data(DOMFirstObj, "cols");
                    //Where the next idx in the table
                    var nextX = -(Args.index % cols) * Obj.width();
                    var nextY = -Math.floor(Args.index / cols) * Obj.height();
                    //Move horizontal first
                    WraperObj.animate({ "left": nextX }, Args.speed, Args.easeType, function() {
                        WraperObj.animate({ "top": nextY }, Args.speed, Args.easeType, Callback());
                    });
                    break;
                default:
                    $('html,body').animate({ "scrollTop": Obj.eq(Args.index).offset().top }, Args.speed);
                    break;

            }
        };

        //Move by steps
        moveStep = function() {
            var currentIdx = $.data(DOMFirstObj, "index");
            //Calculate the next index
            Args.index = parseInt(currentIdx) + parseInt(Args.step);
            //Then move to it
            moveTo();
        }
        //Set it run auto
        startAuto = function() {
            //Save the autoswitch into memory and start it
            $.data(DOMFirstObj, "AutoSwitch", setInterval(moveStep, Args.interval));
        }
        //Stop the auto
        stopAuto = function() {
            //Stop the interval and clear the cache
            clearInterval($.data(DOMFirstObj, "AutoSwitch"));
            $.removeData(DOMFirstObj, "AutoSwitch");
        }
        //Toggle auto
        toggleAuto = function() {
            if (isAuto()) {
                stopAuto();
            } else {
                startAuto();
            }
        }
        //Return if this is auto or not
        isAuto = function() {
            if ($.data(DOMFirstObj, "AutoSwitch")) {
                return true;
            } else {
                return false;
            }
        }
        if (!command) command = "";
        //Check what user want
        switch (command.toLowerCase()) {
            case "index":
                if ($.data(DOMFirstObj, "index")) {
                    return $.data(DOMFirstObj, "index");
                } else {
                    return 0;
                }
                break;
            case "moveto":
                moveTo();
                break;
            case "movestep":
                moveStep();
                break;
            case "destroy":
                backFromCache();
                break;
            case "create":
                createTab();
                break;
            case "isauto":
                return isAuto();
                break;
            case "toggleauto":
                toggleAuto();
                break;
            case "startauto":
                startAuto();
                break;
            case "stopauto":
                stopAuto();
                break;
        }
    };
})(jQuery);

// 全局函数
var app = Class.create();
Object.extend(app, {
    // 加为收藏夹
    AddFavorite: function(sURL, sTitle) {
        try {
            window.external.addFavorite(sURL, sTitle);
        } catch (ex) {
            try {
                window.sidebar.addPanel(sTitle, sURL, "");
            } catch (e) {
                alert("加入收藏失败，请使用Ctrl+D进行添加");
            }
        }
    },
    // 设置为首页
    SetHome: function(obj, vrl) {
        try {
            obj.style.behavior = 'url(#default#homepage)';
            obj.setHomePage(vrl);
        } catch (ex) {
            if (window.netscape) {
                try {
                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                } catch (e) {
                    alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
                }
                var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                prefs.setCharPref('browser.startup.homepage', vrl);
            }
        }
    },
    // 查询参数
    QueryString: function(paras) {
        var url = location.href;
        var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
        var paraObj = {};
        for (i = 0; j = paraString[i]; i++) {
            paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
        }
        var returnValue = paraObj[paras.toLowerCase()];
        if (typeof (returnValue) == "undefined") {
            return "";
        } else {
            return returnValue;
        }
    },
    // 加载js文件
    loadJs: function() {
        var src = "common/jscript/";
        JsLoader.load(src + "cmm.stringbuilder.js", function() {
            International.loadLanguage();
            //alert($lang("language"));
        });
    },
    // 中止冒泡
    stopBubble: function(evt) {
        var e = window.event || evt;
        if (e && e.stopPropagation) {
            // firefox
            e.stopPropagation();
        } else {
            // ie 
            window.event.cancelBubble = true;
        }
    },
    //输入框禁止键盘输入
    noPermitInput: function(e) {
        var evt = window.event || e;
        if (evt.keyCode != 9) {
            if ($.browser.msie) {
                evt.returnValue = false; //ie 禁止键盘输入   
            } else {
                evt.preventDefault(); //fire fox 禁止键盘输入   
            }
        }
    }
});


var sideBar=Class.create();
Object.extend(sideBar,{
    //  侧边栏固定
    fixed:function () {
	    var topdistance = $(window).scrollTop();
	    $("#sidebarfixed").css("top",topdistance-$(".mainWraper").offset().top+'px');
	    if(topdistance > 255)
	    {
		    $(".sidebar").hide();
		    $("#sidebarfixed").show();
	    }
	    else
	    {
		    $(".sidebar").show();
		    $("#sidebarfixed").hide();
	    }
	    $(window).scroll(function(){
		    $(document).sidebarfixed();
	    });
	    $(window).resize(function(){
		    $(document).sidebarfixed();
	    });
	    $(window).load(function(){
		    $(document).sidebarfixed();
	    });
    },
    //  侧边栏隐藏/显示
    show_display:function () {
	    $("a.indexshow").click(
		    function(){
			    $(".suoyin .sidebar .show").css("display","block");
			    $(".suoyin .sidebar .hide").css("display","none");
			    $(".suoyin .wrap").removeClass("wide");
			    $(".suoyin .wrap").addClass("narrow");
		    }
	    );
	    $("a.indexhide").click(
		    function(){
			    $(".suoyin .sidebar .show").css("display","none");
			    $(".suoyin .sidebar .hide").css("display","block");
			    $(".suoyin .wrap").removeClass("narrow");
			    $(".suoyin .wrap").addClass("wide");
		    }
	    );
    }
});
