﻿//修改 2010-12-08 添加在线发送表单到邮箱






String.prototype.trim = function()
{
    return this.replace(/(^[\s\xA0\n]+)|([\s\xA0\n]+$)/g, '');
}
String.prototype.isMatch = function(reg)
{
    if(reg.constructor == String)
    {
        reg = new RegExp(reg);
    }
    
    return(this.search(reg) != -1);
}
String.prototype.Replace = function(reg, ment)
{
    if(reg.constructor == String)
    {
        reg = new RegExp(reg);
    }
    
    return(this.replace(reg, ment));
}

function link(href)
{
    if(href.search(/\*/g) > -1)
    {
        var pn = window.location.pathname + '';
        href = href.replace(/^[^\*]+/g, '');
        var values_ = href.replace(/^\*/g, '').split('&');
        var search = window.location.search;
        
        for(var i = 0; i < values_.length; i++)
        {
            var value = values_[i];
            var p = value.replace(/^([^\=]+)(\=).+/g, '(\\?|\\&)$1\\$2.+');
            
            if(search.isMatch(p))
            {
                search = search.Replace(p, '$1' + value);
            }
            else
            {
                search += '&' + value;
            }
        }
        
        search = search.replace(/^\&+|\&+$/g, '');
        if(!search.isMatch(/^\?/g))
        {
            search = '?' + search;
        }
        
        href = pn + search;
    }
    
    
    href.replace(/([^\w]lang\=)(\w*)/g, '$1' + lang());
    
    if(href.isMatch(/[^\w]lang\=/g))
    {
        
    }
    else if(href.isMatch(/\?/g))
    {
        href += '&lang=' + lang();
    }
    else
    {
        href += '?lang=' + lang();
    }
    
    window.location.href = href;
}

function lang(s, l)
{
    if(s == null)
    {
        var l = $('body').attr('class').match(/(^|\s)([a-z]{2})(\s|$)/i)[0];
        return(l.trim());
    }
    else if(s != null)
    {
        var r = s.split('$');
        
        if($('body').is('.zh'))
        {
            if(r.length == 2)
            {
                return r[1].trim();
            }
        }
        
        return r[0].trim();
    }
}



function rootURL()
{
    var root = window.location.pathname;
    root = root.replace(/[^\/]+$/g, '');
    root = root.replace(/\/admin\/$/g, '/');

    return (root);
}
function locationURL(url)
{
    return (rootURL() + url);
}

/*添加扩展*/
$.extend(
{
    link: function(href)
    {
        if(href.search(/^\*/) >= 0)
        {
            var querys = $.extend($.querys(), $.unparam(href.replace(/^\*/, '')));
            href = $.param(querys);
            href = window.location.pathname + (href.length > 0 ? '?' + href : '');
        }
        
        if(href.search(/[^\w]lang\=\w+/) >= 0)
        {
            href = href.replace(/([^\w]lang\=)\w+/, '$1' + $.lang());
        }
        else
        {
            href = href + (href.search(/\?/) > -1 ? '&' : '?') + 'lang=' + $.lang();
        }
        
        window.location.href = href;
    },
    querys: function()
    {
        var values = window.location.search.replace(/^\?/g, '').split(/&/g);
        var r = {};
        for(var i = 0; i < values.length; i++)
        {
            var value = values[i];
            var m = value.match(/^(\w+)\=(.*)/);
            if(m)
            {
                r[m[1]] = m[2];
            }
        }
        
        return r;
    },
    lang: function()
    {
        return $('body').attr('lang').match(/^[a-z]+/i);
    },
    langs: function()
    {
        var s = $('body').attr('lang').match(/^[a-z]+\{([a-z\,]+)\}/i)[1];
        if(s != null && s.length > 0)
        {
            return s.split(',');
        }
        else
        {
            return new Array();
        }
    },
    refresh: function()
    {
        window.location.reload();
    },
    unparam: function(value)
    {
        var r = {};
        var ss = value.split('&');
        for(var i = 0; i < ss.length; i++)
        {
            if(ss[i].search(/(^\w+)\=(.*)/) >= 0)
            {
                var mtch = ss[i].match(/(^\w+)\=(.*)/);
                r[mtch[1]] = mtch[2];
            }
        }
        return r;
    },
    unjson: function(json)
    {
        var r;
        try
        {
            eval('r = ' + json);
        }
        catch(e)
        {
            r = {};
        }
        return r;
    }
});
$.extend(
{
    setHomePage: function()
    {
        var body = $('body').get(0);
        body.style.behavior = 'url(#default#homepage)';
        body.setHomePage(window.location.href.replace(/[^\/]*?$/, ''));
    },
    
    addFavorite: function()
    {
        window.external.addFavorite(window.location.href, window.document.title);
    },
    open: function(url)
    {
        window.open(url);
    },
    getStyle: function(url, fn)
    {
        if($('link[href=' + url + ']', document).size() == 0)
        {
            if($.browser.msie)
            {
                document.createStyleSheet(url);
            }
            else
            {
                var link = $('<link type="text/css" rel="stylesheet" />');
                link.attr('href', url);
                $('head').append(link);
            }
        }
        if(fn)
        {
            fn();
        }
    }
});

$.fn.extend(
{
    float: function(options)
    {
        var defaults = {
            content: null,
            width: -1,
            height: -1,
            left: 0,
            top: 0,
            offsetX: 0,
            offsetY: 0,
            place: 'right', //left right [leftTop top] [leftBottom bottom] rightTop rightBottom  
            event: 'click'
        }
        
        var t = $(this);
        options = $.extend(defaults, options);
        var dialog = $(options.content);
        if(dialog.parent().size() == 0)
        {
            dialog.appendTo($('body'));
        }
        dialog.css({position: 'absolute', display: 'none'});
        
        
        t.bind(options.event, function()
        {
            var position = t.offset();
            var left = position.left;
            var top = position.top;
            
            
            if(options.place == 'left')
            {
                
            }
            else if(options.place == 'right')
            {
                left += t.outerWidth();
            }
            else if(options.place == 'leftTop' || options.place == 'top')
            {
                top = top - dialog.outerHeight();
            }
            else if(options.place == 'leftBottom' || options.place == 'bottom')
            {
                top += t.outerHeight();
            }
            else if(options.place == 'rightTop')
            {
                left += t.outerWidth();
                top = top - dialog.outerHeight();
            }
            else if(options.place == 'rightBottom')
            {
                left += t.outerWidth();
                top += t.outerHeight();
            }
            
            left += options.offsetX;
            top += options.offsetY;
            
            dialog.css({left: left + 'px', top: top + 'px'})
            
            
            dialog.data('show', true);
            dialog.fadeIn('slow');
        });
        
        
        
        
        var hideDialog = function()
        {
            if(dialog.data('show'))
            {
                dialog.show();
            }
            else
            {
                dialog.fadeOut('slow');
            }
        }
        
        
        
        if(options.event == 'mouseover')
        {
            t.bind('mouseout', function()
            {
                dialog.data('show', false);
                setTimeout(hideDialog, 200);
            });
            
            dialog.mouseover(function()
            {
                $(this).data('show', true);
            });
            dialog.mouseout(function()
            {
                $(this).data('show', false);
                setTimeout(hideDialog, 200);
            });
        }
        else if(options.event == 'click')
        {
            t.bind('blur', function()
            {
                dialog.data('show', false);
                hideDialog();
            });
        }
    },
    zoom: function()
    {
        var t = $(this);
        var scriptURL = locationURL('libs/jquery/lightbox/lightbox.js');
        var cssURL = locationURL('libs/jquery/lightbox/css/jquery.lightbox.css');
        
        t.css({cursor: 'pointer'})
        
        $.getScript(scriptURL, function()
        {
            t.lightBox({fixedNavigation:true});
        });
        
        $.getStyle(cssURL);
        
        return t;
    },
    datebox: function()
    {
        var t = $(this);
        
        var scriptURL = locationURL('libs/jquery/ui/ui.datepicker.js');
        
        var cssURL_1 = locationURL('libs/jquery/ui/themes/base/ui.theme.css');
        var cssURL_2 = locationURL('libs/jquery/ui/themes/base/ui.core.css');
        var cssURL_3 = locationURL('libs/jquery/ui/themes/base/ui.datepicker.css');
        
        
        $.getScript(scriptURL, function()
        {
            var data = {
            dateFormat: 'yy-mm-dd',
            buttonImage: 'calendar.gif',
            buttonImageOnly: false,
            yearRange: '1950:2020',
            clearText:'清除',
            closeText:'关闭',
            prevText:'前一月',
            nextText:'后一月',
            hideIfNoPrevNext: false,
            currentText: '',
            dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
            dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
            changeMonth: true,
            changeYear: true,
            monthNames: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
            monthNamesShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
            }
            
            t.datepicker(data);
        });
        
        $.getStyle(cssURL_1);
        $.getStyle(cssURL_2);
        $.getStyle(cssURL_3);
    },
    thumbnail: function(width, height)
    {
        var t = $(this);
        
        var imageSize = function(img, src, fn)
        {
            img.style.position = 'absolute';
            img.style.visibility = 'hidden';
            img.style.top = '0px';
            img.style.left = '0px';
            
            if($.browser.msie)
            {
                img.attachEvent('onload', fn);
                document.body.insertAdjacentElement('beforeend', img);
            }
            else if($.browser.safari)
            {
                img.addEventListener('load', fn, false);
                document.body.insertAdjacentElement('beforeend', img);
            }
            else if($.browser.opera)
            {
                img.addEventListener('load', fn, false);
                document.body.insertAdjacentElement('beforeend', img);
            }
            else if($.browser.mozilla)
            {
                img.addEventListener('load', fn, false);
                document.body.insertBefore(img, null);
            }
            
            img.src = src;
        }
        
        var img = document.createElement('img');
        var fn = function()
        {
            var _w = width;
            var _h = height;
            
            var W = 0;
            var H = 0;
            
            
            var WW = img.offsetWidth;
            var HH = img.offsetHeight;
            
            
            if(WW > _w)
            {
                H = (_w * HH) / WW;
                if(H > _h)
                {
                    H = _h;
                    W = (H * WW) / HH;
                }
                else
                {
                    W = _w;
                }
            }
            else if(HH > _h)
            {
                W = (_h * WW) / HH;
                if (WW > _w)
                {
                    W = _w
                    H = (W * HH) / WW
                }
                else
                {
                    H = _h
                }
            }
            else
            {
                W = WW;
                H = HH;
            }
            
            
            if(WW < _w && HH < _h)
            {
                t.height(HH);
                t.width(WW);
            }
            else
            {
                t.height(H);
                t.width(W);
            }
        }
        
        imageSize(img, t.attr('src'), fn);
        
        return t;
    },
    dropMenu: function(options, data)
    {
        if(options == null)
        {
            options = {};
        }
        var defaults = {
            css: 'sinoDropMenu',
            
            left: 0,
            top: 0,
            offsetX: 5,
            offsetY: 0,
            place: 'right',
            event: 'mouseover'
        }
        
        var t = $(this);
        options = $.extend(defaults, options);
        var flag = 'prentDropMenu';
        
        var traversal = function(data, main, prent)
        {
            var table = $('<table class="dropMenu ' + options.css + '" cellpadding="0" cellspacing="0"></table>');
            table.hide();
            table.css({position: 'absolute'});
            table.hide();
            table.data('prent', prent);
            $('body').append(table);
            
            for(key in data)
            {
                var menu = data[key];
                
                var tr = $('<tr></tr>');
                table.append(tr);
                
                var td = $('<td></td>');
                tr.append(td);
                td.hover(function(){$(this).addClass('hover')}, function(){$(this).removeClass('hover')});
                td.mouseover(function()
                {
                    var p = prent;
                    while(true)
                    {
                        if(p == null)
                        {
                            break;
                        }
                        else
                        {
                            p.data('show', true);
                            
                            p = p.data('prent');
                        }
                    }
                });
                
                
                td.mouseout(function()
                {
                    var p = prent;
                    while(true)
                    {
                        if(p == null)
                        {
                            break;
                        }
                        else
                        {
                            var dialog = p;
                            var hideDialog = function()
                            {
                                if(dialog.data('show'))
                                {
                                    dialog.show();
                                }
                                else
                                {
                                    dialog.fadeOut('slow');
                                }
                            }
                            
                            p.data('show', false);
                            setTimeout(hideDialog, 200);
                            p = p.data('prent');
                        }
                    }
                });
                
                
                
                
                
                /*
                if(options.event == 'mouseover')
                {
                    t.bind('mouseout', function()
                    {
                        dialog.data('show', false);
                        setTimeout(hideDialog, 200);
                    });
                    
                    dialog.mouseover(function()
                    {
                        $(this).data('show', true);
                    });
                    dialog.mouseout(function()
                    {
                        $(this).data('show', false);
                        setTimeout(hideDialog, 200);
                    });
                }*/
                
                
                var a = $('<a></a>');
                td.append(a);
                
                a.html(menu.title + '&nbsp;');
                a.attr('href', menu.link);
                
                if(menu.menus)
                {
                    td.addClass('menus');
                    traversal(menu.menus, td, table);
                }
            }
            
            
            var floatOptions;
            if(t == main)
            {
                floatOptions = {
                    content: table,
                    
                    left: options.left,
                    top: options.top,
                    offsetX: options.offsetX,
                    offsetY: options.offsetY,
                    place: options.place,
                    event: options.event
                }
            }
            else
            {
                floatOptions = {
                    content: table,
                    
                    left: 0,
                    top: 0,
                    offsetX: 1,
                    offsetY: -1,
                    place: 'right',
                    event: 'mouseover'
                }
            }
            
            main.float(floatOptions);
        }
        traversal(data, t, null);
        
        return t;
    },
    form: function()
    {
        var t = $(this);
        var scriptURL = locationURL('libs/jquery/validate/validate.js');
        
        $.getScript(scriptURL, function()
        {
            if($.lang() == 'zh')
            {
                $.validator.messages = {
                    required: '必选字段',
                    remote: '请修正该字段',
                    email: '请输入正确格式的电子邮件',
                    url: '请输入合法的网址',
                    date: '请输入合法的日期',
                    dateISO: '请输入合法的日期 (ISO).',
                    number: '请输入合法的数字',
                    digits: '只能输入整数',
                    creditcard: '请输入合法的信用卡号',
                    equalTo: '请再次输入相同的值',
                    accept: '请输入拥有合法后缀名的字符串',
                    maxlength: '请输入一个长度最多是 {0} 的字符串',
                    minlength: '请输入一个长度最少是 {0} 的字符串',
                    rangelength: '请输入一个长度介于 {0} 和 {1} 之间的字符串',
                    range: '请输入一个介于 {0} 和 {1} 之间的值',
                    max: '请输入一个最大为 {0} 的值',
                    min: '请输入一个最小为 {0} 的值'
                };
            }
            
            
            t.validate({
                errorElement: 'div',
                showErrors: function(errorMap, errorList)
                {
                    if(errorList[0])
                    {
                        alert(errorList[0].message);
                    }
                },
                onkeyup: false,
                onfocusout: false
            });
            
        });
        
        return t;
    },
    form1: function(val)
    {
        var t = $(this);
        var scriptURL = locationURL('libs/jquery/validate/validate.js');
        
        $.getScript(scriptURL, function()
        {
            if($.lang() == 'zh')
            {
                $.validator.messages = {
                    required: '必选字段',
                    remote: '请修正该字段',
                    email: '请输入正确格式的电子邮件',
                    url: '请输入合法的网址',
                    date: '请输入合法的日期',
                    dateISO: '请输入合法的日期 (ISO).',
                    number: '请输入合法的数字',
                    digits: '只能输入整数',
                    creditcard: '请输入合法的信用卡号',
                    equalTo: '请再次输入相同的值',
                    accept: '请输入拥有合法后缀名的字符串',
                    maxlength: '请输入一个长度最多是 {0} 的字符串',
                    minlength: '请输入一个长度最少是 {0} 的字符串',
                    rangelength: '请输入一个长度介于 {0} 和 {1} 之间的字符串',
                    range: '请输入一个介于 {0} 和 {1} 之间的值',
                    max: '请输入一个最大为 {0} 的值',
                    min: '请输入一个最小为 {0} 的值'
                };
            }
            
            t.validate({
                errorElement: 'div',
                showErrors: function(errorMap, errorList)
                {
                    if(errorList[0])
                    {
                        alert(errorList[0].message);
                    }
                },
                onkeyup: false,
                onfocusout: false,
                submitHandler: function(form)
                {
                    var f = $(form);
                    
                    var data = {action: val};
                    data['subject'] = f.find('*[name=subject]').val();
                    data['content'] = f.find('*[name=content]').val();
                    
                    
                    if($.querys().action == 'message')
                    {
                        data['under'] = $.querys().id;
                    }
                    else
                    {
                        
                    }
                    
                    $.post('ajax.aspx', data, function(v)
                    {
                        var json;
                        
                        try
                        {
                            eval('json = ' + v);
                            json.fn();
                        }
                        catch(e)
                        {
                            alert(v);
                        }
                        
                    }, 'text');
                    
                    
                    
                }
            });
        });
        
        return t;
    },
    Validate: function(options)
    {
        var defaults = 
        {
            errorElement: 'div',
            showErrors: function(errorMap, errorList)
            {
                if(errorList[0])
                {
                    alert(errorList[0].message);
                }
            },
            onkeyup: false,
            onfocusout: false
        }
        
        var t = $(this);
        options = $.extend(defaults, options);
        
        var scriptURL = locationURL('libs/jquery/validate/validate.js');
        $.getScript(scriptURL, function()
        {
            if($.lang() == 'zh')
            {
                $.validator.messages = {
                    required: '必选字段',
                    remote: '请修正该字段',
                    email: '请输入正确格式的电子邮件',
                    url: '请输入合法的网址',
                    date: '请输入合法的日期',
                    dateISO: '请输入合法的日期 (ISO).',
                    number: '请输入合法的数字',
                    digits: '只能输入整数',
                    creditcard: '请输入合法的信用卡号',
                    equalTo: '请再次输入相同的值',
                    accept: '请输入拥有合法后缀名的字符串',
                    maxlength: '请输入一个长度最多是 {0} 的字符串',
                    minlength: '请输入一个长度最少是 {0} 的字符串',
                    rangelength: '请输入一个长度介于 {0} 和 {1} 之间的字符串',
                    range: '请输入一个介于 {0} 和 {1} 之间的值',
                    max: '请输入一个最大为 {0} 的值',
                    min: '请输入一个最小为 {0} 的值'
                };
            }
            
            t.data('Validate', t.validate(options));
        });
        
        return t;
    },
    dialog: function(options)
    {
        var defaults = {
            content: '', 
            width: 300,
            skin: 'default',
            lock: true,
            fixed: true,
            time: 5,
            title: false,
            window: 'top',
            noFn: false,
            yesFn: false,
            yesText: ''
        };
        
        var t = $(this);
        options = $.extend(defaults, options);
        var scriptURL = locationURL('libs/artDialog/artDialog.js');
        var cssURL1 = locationURL('libs/artDialog/skin/default.css');
        var cssURL2 = locationURL('libs/artDialog/core/layout.css');
        
        
        $.getScript(scriptURL, function(){});
        t.click(function()
        {
            $.getScript(scriptURL, function()
            {
                art.dialog.tips('options', 50);
            });
        });
        
        $.getStyle(cssURL1);
        $.getStyle(cssURL2);
        
        return t;
    },
    hoverCss: function(options)
    {
        var defaultCss = {};
        for(key in options)
        {
            defaultCss[key] = $(this).css(key);
        }
        
        $(this).hover(function()
        {
            $(this).css(options);
        },function()
        {
            $(this).css(defaultCss);
        });
    },
    fly: function(options)
    {
        var t = $(this);
        
        
        var defaults = {
            distance: 169,
            count: 5,
            action: 'interval', //interval间隔(默认) smooth顺滑, 未兼容smooth模式，以后兼容
            speed: 1000,
            interval: 5000,
            buttonA: null,
            buttonB: null,
            upAndDown: false
        }
        options = $.extend(defaults, options);
        
        
        
        
        
        
        var width = options.distance * options.count;
        
        var M;
        if(options.upAndDown)
        {
            M = t.children().eq(0).outerHeight();
            t.css({overflow: 'hidden', height: width + 'px'});
            t.append(t.children().css('display', 'block').clone(true));
        }
        else
        {
            M = t.children().eq(0).outerWidth();
            t.css({overflow: 'hidden', 'white-space': 'nowrap', width: width + 'px'});
            if($.browser.msie)
            {
                t.append(t.children().css('display', 'inline').clone(true));
            }
            else
            {
                t.append(t.children().css('display', 'inline-block').clone(true));
            }
        }
        
        
        
        
        
        
        var scrollMove = function(v)
        {
            if(options.upAndDown)
            {
                if(v == null)
                {
                    return t.scrollTop();
                }
                else
                {
                    t.scrollTop(v);
                }
            }
            else
            {
                if(v == null)
                {
                    return t.scrollLeft();
                }
                else
                {
                    t.scrollLeft(v);
                }
            }

        }
        
        
        
        
        var current = 0;
        var target = 0;
        
        
        
        var move = function()
        {
            var v = options.speed;
            
            if(target < current)
            {
                if(current - v >= target)
                {
                    current = current - v;
                }
                else
                {
                    current = current - (current - target) * 0.1;
                }
                if(Math.abs(target - current) < 0.5)
                {
                    current = target;
                }
                
                if(current < 0)
                {
                    scrollMove(M + (current % M));
                }
                else
                {
                    scrollMove(current % M);
                }
            }else if(target > current)
            {
                if(current + v <= target)
                {
                    current = current + v;
                }
                else
                {
                    current = current + (target - current) * 0.1;
                }
                if(Math.abs(target - current) < 0.5)
                {
                    current = target;
                }
                
                if(current < 0)
                {
                    scrollMove(M + (current % M));
                }
                else
                {
                    scrollMove(current % M);
                }
                
            }
            else
            {
            }
            
        }
        setInterval(move, 40);
        
        var move_ = function()
        {
            if(options.upAndDown)
            {
                target = current - (options.distance * 1);
            }
            else
            {
                target = current - (options.distance * 2);
            }
        }
        var timerID = setInterval(move_, options.interval);
        
        
        
        
        
        if(options.buttonA)
        {
            options.buttonA.click(function()
            {
                clearInterval(timerID);
                target = target - width;
            });
        }
        if(options.buttonB)
        {
            options.buttonB.click(function()
            {
                clearInterval(timerID);
                target = target + width;
            });
        }
        
        
        return t;
    },
    tips: function(text, fn)
    {
        var t = $(this);
        var dialog;
        $.getScript(locationURL('libs/artDialog/artDialog.js'), function()
        {
            dialog = art.dialog({skin: 'tips', content: text, lock: true, border: false, width: 200, height: 60, title: false}, function()
            {
            });
            t.data('tips', dialog);
            fn();
        });
        
        $.getStyle(locationURL('libs/artDialog/skin/tips.css'));
        $.getStyle(locationURL('libs/artDialog/core/layout.css'));
    },
    formSendMail: function(options)
    {
        //功能: 发送网页表单到邮箱
        var t = $(this);
        
        var defaults = {
            to: '183254569@qq.com',
            subject: '来自:' + document.title
        }
        options = $.extend(defaults, options);
        
        
        var i = -1;
        t.find('input,select,textarea').each(function()
        {
            i++;
            if($(this).attr('name') == '')
            {
                $(this).attr('name', 'formSendMail_name_' + i);
            }
        });
        
        
        t.Validate({debug: true, submitHandler: function()
        {
            t.tips('正在发送您的信息，请等待...', function()
            {
                var ajaxData = {};
                ajaxData.action = 'formSendMail';
                ajaxData.to = options.to;
                ajaxData.subject = options.subject;
                
                var tClone = t.clone();
                tClone.find('input,select,textarea').each(function()
                {
                    var t = $(this);
                    var val = '';
                    
                    if(t.is(':checkbox'))
                    {
                        val = $('<span style="border: 1px solid #555555; font-size: 12px; line-height: 12px; text-align: center; width: 12px; height: 12px; display: inline-block; margin-left: 5px; margin-right: 5px;"></span>');
                        if(t.is(':checked'))
                        {
                            val.text('√');
                        }
                    }
                    else if(t.is(':radio'))
                    {
                        val = $('<span style="border: 1px solid #555555; font-size: 12px; line-height: 12px; text-align: center; width: 12px; height: 12px; display: inline-block; margin-left: 5px; margin-right: 5px;"></span>');
                        if(t.is(':checked'))
                        {
                            val.text('●');
                        }
                    }
                    else if(t.is('select'))
                    {
                        val = $('<span style="font-weight: bold;"></span>').text(t.find('option:selected').text());
                    }
                    else if(t.is('textarea'))
                    {
                        val = $('<div style="font-weight: bold;"></div>').text(t.text());
                    }
                    else
                    {
                        val = $('<span style="font-weight: bold;"></span>').text(t.val());
                    }
                    
                    if(t.is(':reset') || t.is(':submit'))
                    {
                        t.remove();
                    }
                    else
                    {
                        t.replaceWith(val);
                    }
                });
                ajaxData.content = tClone.html();
                
                $.post('ajax.aspx', ajaxData, function(v)
                {
                    var json = $.unjson(v);
                    t.data('tips').close();
                    
                    json.fn();
                    
                }, 'text');
                
            });

            return false;
        }});
        
        
        return t;
    }
});





























 

$(document).ready(function()
{
    $('.number,.serialnumber', this).keyup(function()
    {
        this.value = this.value.replace(/[^\d\.]/g, '');
    });
    
    //身份证限制字数
    $('.identity .serialnumber', this).attr('maxlength', 18);
    
    
    $('form[key=search][method=get]').each(function()
    {
        var searchs = window.location.search.toString().replace(/^\?/i, '').split('&');
        for(var i = 0; i < searchs.length; i++)
        {
            var v = searchs[i].split('=');
            if(v.length == 2)
            {
                if(v[0] == 'page')
                {
                    v[1] = '0';
                }
                
                $(this).append('<input type="hidden" name="' + v[0] + '" value="' + v[1] + '" />');
            }
        }
    });
    
    
    
    
    
    
    
    
    
    
    
    $('input').each(function()
    {
        var t = $(this).attr('type');
        
        if(t == 'checkbox')
        {
            var v = $(this).attr('checked_');
            if(v != '' && v != '0' && v != null && v != undefined)
            {
                $(this).attr('checked', true);
            }
            else
            {
                $(this).attr('checked', false);
            }
        }
    });
    
    
    
    //单选的SELECT
    $('select').each(function()
    {
        for(var i = 0; i < this.options.length; i++)
        {
            this.options[i].innerHTML = lang(this.options[i].innerHTML);
        }
    });
    
    
    

    
    
    
    
    $('select[value_]').each(function()
    {
        var value_ = $(this).attr('value_');
        for(var i = 0; i < this.options.length; i++)
        {
            if(this.options[i].value == value_)
            {
                this.selectedIndex = i;
            }
        }
    });
    
    
    
    //多选的SELECT
    $('.MultipleValue').each(function()
    {
        var optgroup;
        var multiple = $(this).next();
        
        var user_or_admin = '';
        $('option', multiple).each(function()
        {
            if($(this).text().isMatch(/^.+?\-\-\-\-/g))
            {
                var newLabel = $(this).text().match(/^.+?\-\-\-\-/g) + '';
                newLabel = newLabel.replace(/\-\-\-\-$/g, '');
                
                if(newLabel != '')
                {
                    var label = '';
                    if(optgroup)
                    {
                        label = optgroup.attr('label');
                    }
                    
                    if(label == newLabel)
                    {
                        
                    }
                    else
                    {
                        optgroup = $('<optgroup label="">');
                        optgroup.attr('label', newLabel);
                        multiple.append(optgroup);
                    }
                    
                    var text_ = $(this).text().replace(/^.+?\-\-\-\-/g, '');
                    text_ = text_.replace(/\$/, '和')
                    text_ = text_ + ' [' + $(this).attr('value') + ']'
                    
                    if($(this).attr('value').search(/^(user|admin)_/g) != -1)
                    {
                        if($(this).attr('value').search(/_form$/g) != -1)
                        {
                            text_ = text_;
                        }
                        if($(this).attr('value').search(/_list$/g) != -1)
                        {
                            text_ = text_;
                        }
                        if($(this).attr('value').search(/_out$/g) != -1)
                        {
                            text_ = text_;
                        }
                    }
                    
                    $(this).text(text_);
                    optgroup.append($(this));
                    
                    
                    if($(this).attr('value').search(/^user_/g) != -1)
                    {
                        user_or_admin = 'user';
                    }
                    else if($(this).attr('value').search(/^admin_/g) != -1)
                    {
                        if(user_or_admin == 'user')
                        {
                            optgroup = $('<optgroup label="">');
                            optgroup.attr('label', '----------'.replace(/\-/g, '----------'));
                            multiple.append(optgroup);
                        }
                        user_or_admin = 'admin';
                    }
                    else
                    {
                        
                    }
                }
            }

        });
        
        
        
        
        
        
        var symbol = {on: '■', off: '□'};
        
        if($.browser.msie && $.browser.version > 6)
        {
            symbol = {on: '☑', off: '☐'};
        }
        
        $(this).val($(this).val().replace(/^\,*|\,*$|^$/g, ','));
        var MultipleValue = $(this);
        $('option', $(this).next()).each(function()
        {
            var option = $(this);
            var ids = MultipleValue.val();
            
            if(ids.isMatch('\,' + option.val() + '\,'))
            {
                $(this).text(symbol.on + ' ' + $(this).text());
            }
            else
            {
                $(this).text(symbol.off + ' ' + $(this).text());
            }
        });
        $(this).next().dblclick(function()
        {
            var ids = MultipleValue.val();
            
            var option;
            for(var i = 0; i < $(this).get(0).options.length; i++)
            {
                if($($(this).get(0).options[i]).val() == $(this).val())
                {
                    option = $($(this).get(0).options[i]);
                }
            }
            
            if(ids.isMatch('\,' + option.val() + '\,'))
            {
                ids = ids.Replace('\,' + option.val() + '\,', ',');
                option.text(option.text().Replace('^\\' + symbol.on, symbol.off));
            }
            else
            {
                option.text(option.text().Replace('^\\' + symbol.off, symbol.on));
                ids += option.val() + ','
            }
            
            MultipleValue.val(ids);
            
            this.blur();
        });
    })
    
});










$(document).ready(function()
{
    $('.ListTable *[key] input:checkbox', this).each(function()
    {
        $(this).attr('title', lang('双击全选$Double-click Select All'))
        $(this).dblclick(function()
        {
            $('input[name=' + $(this).attr('name') + ']', document).attr('checked', $(this).attr('checked'));
        });
    });
    
    $('input[name=search]', this).each(function()
    {
        var value = $(this).val();
        $(this).click(function()
        {
            if($(this).val() == value)
            {
                $(this).val('');
            }
        });
    });
    
    
    $('a[href*=*]', this).each(function()
    {
        var pn = window.location.pathname + '';
        var href = $(this).attr('href');
        href = href.replace(/^[^\*]+/g, '');
        var values_ = href.replace(/^\*/g, '').split('&');
        var search = window.location.search;
        
        for(var i = 0; i < values_.length; i++)
        {
            var value = values_[i];
            var p = value.replace(/^([^\=]+)(\=).+/g, '(\\?|\\&)$1\\$2.+');
            
            if(search.isMatch(p))
            {
                search = search.Replace(p, '$1' + value);
            }
            else
            {
                //value = value.replace(/^page\=\d+$/i, 'page=0');
                search += '&' + value;
            }
        }
        
        
        search = search.replace(/^\&+|\&+$/g, '');
        if(!search.isMatch(/^\?/g))
        {
            search = '?' + search;
        }
        
        $(this).attr('href', pn + search);
    });
    
    
    $('marquee>*', this).each(function()
    {
	    $(this).css('display', 'inline');
	
	    for(var i = 0; i < 8; i++)
        {
            $(this).after($(this).clone());
        }
    });
});










































$(function()
{

    
    
    $('*[oninit]', document).each(function()
    {
        try
        {
            eval($(this).attr('oninit'));
        }
        catch(e)
        {
            alert('错误代码:' + $(this).attr('oninit') + ' 错误信息:' + e.toString());
        }
    });

    $('p[align=center],img[align=center]', document).each(function ()
    {
        $(this).css({ 'text-align': 'center', 'margin-left': 'auto', 'margin-right': 'auto', 'display': 'block' });
    });
    
    var alert_ = $.querys().alert || '';
    if(alert_.length > 0)
    {
       alert(lang(decodeURI(alert_)));
    }
});




