(function () {
    var path = location.protocol + "//" + location.host + "/Scripts/",
    scripts = document.getElementsByTagName("script"),
    script = scripts[scripts.length - 1], src = script.src, a = src.split("?");
    var v = "1";
    if (a.length > 1) {
        a = a[1].split("&");
        a.forEach(function (p) {
            var a2 = p.split("=");
            if (a2[0] == "v" && a2.length > 1) v = a2[1];
        });
    }
    v = "?v=" + v;
    require.config({
        paths: {
            'baseVm': path + "Modules/BaseVm.js"+v,
            'plugins': path + "Modules/Plugin.js"+v,
            'requiretext': path + "avalon/avalon.require.text.js", //远程读取文本类库
            'filters': path + "avalon/avalon.filters.js"+v, //avalon过滤器
            'leftMenu': path + 'CBCRMUI/leftMenu.js'+v, //左侧菜单控件
            'jquery': path + "Jquery/jquery-1.8.3.min",
            'jqueryui': path + "JqueryPlguins/jquery-ui.min.js",
            'dialog': path + 'ArtDialog/artDialog.js', //弹出框
            'dialogTools': path + 'ArtDialog/plugins/iframeTools.js', //弹出框
            'upload': path + 'Uploadify/jquery.uploadify.js',  //上传
            "cookie": path + "JqueryPlguins/jquery.cookie.js", //js操作cookie
            "json": path + "JqueryPlguins/json2.js", //json序列化、反序列化
            "jscal2": path + "JsCal2/js/jscal2.js",               //小日历
            'jcal': path + "JsCal/jCal.js",
            'jqselect': path + 'Jqselect/jQselect.js',
            "kindedit": path + "Kindedit/lang/zh_CN.js",         //文本编辑器
            "kindeditCN": path + 'Kindedit/kindeditor-min.js',
            "query": path + "JqueryPlguins/Jquery.Query.js",   //jquery url 参数查询类库
            "lightbox": path + "JqueryPlguins/jquery.lightbox_me.js", //弹出层展示图片
            "ztree": path + "ZTree/jquery.ztree.all-3.5.js",  //树形菜单
            "zclip": path + "JqueryZclip/jquery.zclip.min.js", //js复制
            "snippet": path + "JqueryZclip/jquery.snippet.min.js", //js复制
            "highlight": path + "JqueryPlguins/jquery.highlight.js", //关键字高亮
            "raty": path + "JqueryPlguins/jquery.raty.min.js",  //评级
            "fusionCharts": path + "Charts/FusionCharts.js",  //统计图标
            "jqPlot": path + "Jqplot/jquery.jqplot.min.js", //jqplot 图表
            "jqBar": path + "Jqplot/plugins/jqplot.barRenderer.min.js", //jqplot 饼图
            "jqPlotPie": path + "Jqplot/plugins/jqplot.pieRenderer.min.js", //jqplot 饼图
            "jqPointLabels": path + "Jqplot/plugins/jqplot.pointLabels.min.js", //j
            "jqCategory": path + "Jqplot/plugins/jqplot.categoryAxisRenderer.min.js", //j
            "jqCanvasText": path + "Jqplot/plugins/jqplot.canvasTextRenderer.min.js", //j
            "jqCanvasAxisLabel": path + "Jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js", //j
            "jqCanvasAxisTick": path + "Jqplot/plugins/jqplot.canvasAxisTickRenderer.min.js", //j
            "jqEnhancedLegend": path + "Jqplot/plugins/jqplot.enhancedLegendRenderer.min.js", //j
            "jqPointLabel": path + "Jqplot/plugins/jqplot.pointLabels.min.js", //j
            "jqCursor": path + "Jqplot/plugins/jqplot.cursor.min.js", //j
            "jqHighlighter": path + "Jqplot/plugins/jqplot.highlighter.min.js", //j
            "jqMeterGauge": path + "Jqplot/plugins/jqplot.meterGaugeRenderer.js", //j
            "Qpin": path + "HanZitoPinYin/jQuery.JianPin-min.js", //汉字 To 全拼
            "Jpin": path + "HanZitoPinYin/jQuery.JianPin-min.js", //汉字 To 简拼
            "common": path + "Avalon/common.js" + v,                   //常用函数的简单封装
            "commonui": path + "CBCRMUI/common-ui.js"+v,                   //常用UI包
            "modelFactory": path + "Modules/ModelFactory.js" + v,                   //常用UI包
            "bootstrap": path + "Bootstrap/bootstrap.js",                  //常用UI包
            "allmodule": path + "Modules/AllModule.js" + v,                   //所有模块数据(测试用)
            "allmenu": path + "Modules/AllMenu.js" + v,                   //所有菜单数据(测试用)
            'slides': path + 'Slides/js/slides.min.jquery.js',         //新闻中心滚动图片
            'floatCalc': path + 'CBCRMUI/chaobo-floatCalc.js',  //运算修正
            'saleTarget': path + 'CBCRMUI/chaobo-saletarget.js' + v,  //销售目标
            //以下是日历控件
            'wgCal': path + 'WdCalendar/js/jquery.calendar.js',
            'wgCal_date': path + 'WdCalendar/js/jquery.datepicker.js',
            'wgCal_common': path + 'WdCalendar/js/common.js',
            'wgCal_alert': path + 'WdCalendar/js/jquery.alert.js',
            'wgCal_iframe': path + 'WdCalendar/js/jquery.ifrmdailog.js',
            'wgCal_lang': path + 'WdCalendar/js/wdCalendar_lang_Zh-CN.js',
            'wgCal_color': path + 'WdCalendar/js/jquery.colorselect.js',
            'lightbox': path + 'JqueryPlguins/jquery.lightbox_me.js',
            'cypto': path + 'avalon/enc-base64-min.js',
            'sha512': path + 'avalon/sha512.js',
            'jqPrint': path + 'JqueryPlguins/jquery.PrintArea',
            'map': path + 'BaiduMap/bmap_v1.5',
            'mapPublic': path + 'BaiduMap/public',
            'ConditionFactory': path + 'Avalon/ConditionFactory.js'+v,
            //地图 
            'bdmap': 'http://api.map.baidu.com/getscript?v=2.0&ak=225ec0d19b6a2e29301640397eab4e50&services=&t=20140411133140',
            'bdmapTool': path + "BaiduMap/bdmapTool.js"+v,
            //zoom
            'imageZoom': path + 'Zoom/ImageZoom.js',
            'cjlmin': path + 'Zoom/CJL.0.1.min.js',
            'fancyBox': path + 'FancyBox/jquery.fancybox.js',
            //图片滚动
            'bjqs': path + 'bjqs/bjqs-1.3.js',
            //新版日历
            'cbcalendar': path + 'FullCalendar/js/jquery-ui-1.10.2.custom.min.js',
            'cbcalendarExt': path + 'FullCalendar/js/fullcalendar.min.js',
            'swfobject': path + "Swf/swfobject.js",
            'flexslider': path + "JqueryPlguins/jquery.flexslider-min.js"
        },
        shim: {
            'filters':{
                deps: '',
                exports: "avalonfilters"
            },
            'imageZoom': {
                deps: ["css!" + path + "Zoom/zoom.css"],
                exports: "imageZoom"
            },
            'cjlmin': {
                deps: 'imageZoom',
                exports: "cjlmin"
            },
            'bdmap': {
                deps: '',
                exports: "BMap"
            },
            'saleTarget': {
                deps: '',
                exports: 'saleTarget'
            },
            'mapPublic':{
                deps: '',
                exports: 'mapPublic'
            },
            'map': {
                deps: ['mapPublic'],
                exports:'map'
            },
            'jqPrint': {
                deps: ['jquery'],
                exports: 'jqPrint'
            },
            'sha512': {
                deps: [],
                exports: 'sha512'
            },
            'cypto': {
                deps: ['sha512'],
                exports:'cypto'
            },
            'lightbox': {
                deps: ['jquery'],
                exports: "lightbox"
            },
            "jquery": {
                deps: [],
                exports: "jQuery"
            },
            "jqueryui":{
                deps: [],
                exports: "jqueryui"
            },
            "bootstrap": {
                deps: [],
                exports: 'bootstrap'
            },
            'dialog': {
                deps: ['css!' + path + 'ArtDialog/skins/default.css'],
                exports: 'dialog'
            },
            'dialogTools': {
                deps: ['dialog'],
                exports: 'dialogTools'
            },
            'upload': {
                deps: ['jquery', 'css!' + path + 'Uploadify/uploadify.css'],
                exports: 'upload'
            },
            "cookie": {
                deps: ["jquery"],
                exports: "cookie"
            },
            "json": {
                deps: ["jquery"],
                exports: "json"
            },
            "jscal2": {
                deps: ["css!" + path + "JsCal2/css/steel/steel.css", "css!" + path + "JsCal2/css/jscal2.css"],
                exports: "jscal2"
            },
            "jcal": {
                deps: ["css!" + path + "JsCal/jCal.css"],
                exports: "jcal"
            },
            "jqselect": {
                deps: ["css!" + path + "Jqselect/jQselect.css", 'jquery'],
                exports: "jqselect"
            },
            "kindedit": {
                deps: ['kindeditCN', "css!" + path + 'Kindedit/themes/default/default.css'],
                exports: "kindedit"
            },
            "kindeditCN": {
                deps: [],
                exports: 'kindeditCN'
            },
            "query": {
                deps: ["jquery"],
                exports: "query"
            },
            "lightbox": {
                deps: ["jquery"],
                exports: "lightbox"
            },
            "ztree": {
                deps: ["jquery", 'css!' + path + 'ZTree/Style/zTreeStyle.css'],
                exports: "zTree"
            },
            "zclip": {
                deps: ["jquery"],
                exports: "zclip"
            },
            "snippet": {
                deps: ["zclip"],
                exports: "snippet"
            },
            "highlight": {
                deps: ["jquery"],
                exports: "highlight"
            },
            "raty": {
                deps: ["jquery"],
                exports: "raty"
            },
            "fusionCharts": {
                deps: [],
                exports: "FusionCharts"
            },
            "jqPlot": {
                deps: ["jquery", 'css!' + path + 'Jqplot/jquery.jqplot.min.css'],
                exports:"jqPlot"
            },
            "jqBar": {
                deps: ["jquery", "jqPlot"],
                exports: "jqBar"
            },
            "jqPlotPie": {
                deps: ["jquery", "jqPlot"],
                exports: "jqPlotPie"
            },
            "jqPointLabels": {
                deps: ["jquery", "jqPlot"],
                exports: "jqPointLabels"
            },
            "jqCategory": {
                deps: ["jquery", "jqPlot"],
                exports: "jqCategory"
            },
            "jqCanvasText": {
                deps: ["jquery", "jqPlot"],
                exports: "jqCanvasText"
            },
            "jqCanvasAxisLabel": {
                deps: ["jquery", "jqPlot"],
                exports: "jqCanvasAxisLabel"
            },
            "jqCanvasAxisTick": {
                deps: ["jquery", "jqPlot"],
                exports: "jqCanvasAxisTick"
            },
            "jqEnhancedLegend": {
                deps: ["jquery", "jqPlot"],
                exports: "jqEnhancedLegend"
            },
            "jqPointLabel": {
                deps: ["jquery", "jqPlot"],
                exports: "jqPointLabel"
            },
            "jqCursor": {
                deps: ["jquery", "jqPlot"],
                exports: "jqCursor"
            },
            "jqHighlighter": {
                deps: ["jquery", "jqPlot"],
                exports: "jqHighlighter"
            },
            "jqMeterGauge": {
                deps: ["jquery", "jqPlot"],
                exports: "jqMeterGauge"
            },
            "Qpin": {
                //汉字 To 全拼
                deps: [],
                exports: 'Qpin'
            },
            "Jpin": {
                //汉字 To 简拼
                deps: [],
                exports: 'Jpin'
            },
            "common": {
                deps: ['jquery'],
                exports: 'common'
            },
            "slides": {
                deps: [],
                exports: 'slides'
            },
            "floatCalc": {
                deps: [],
                exports: 'floatCalc'
            },
            "wgCal": {
                //日程任务
                deps: [
                    'wgCal_date', 'wgCal_common', 'wgCal_alert', 'wgCal_iframe', 'wgCal_lang','wgCal_color',
                    'css!' + path + 'WdCalendar/css/dailog.css',
                    'css!' + path + 'WdCalendar/css/calendar.css',
                    'css!' + path + 'WdCalendar/css/dp.css', 
                    'css!' + path + 'WdCalendar/css/alert.css',
                    'css!' + path + 'WdCalendar/css/main.css',
                    'css!' + path + 'WdCalendar/css/colorselect.css',
                    'css!' + path + 'WdCalendar/css/lhhnew.css',
                ],
                exports: 'wgCal'
            },
            "wgCal_date": {
                deps: [],
                exports: 'wgCal_date'
            },
            "wgCal_common": {
                deps: [],
                exports: 'wgCal_common'
            },
            "wgCal_alert": {
                deps: [],
                exports: 'wgCal_alert'
            },
            "wgCal_iframe": {
                deps: [],
                exports: 'wgCal_iframe'
            },
            "wgCal_lang": {
                deps: [],
                exports: 'wgCal_lang'
            },
            'wgCal_color': {
                deps: [],
                exports: 'wgCal_color'
            },
            'fancyBox': {
                deps: ['css!' + path + 'FancyBox/jquery.fancybox.css'],
                exports: 'fancyBox'
            },
            'bjqs': {
                deps: [],
                exports: 'bjqs'
            },
            'cbcalendar': {
                deps: ['css!' + path + 'FullCalendar/css/fullcalendar.css', 'cbcalendarExt'],
                exports: 'cbcalendar'
            },
            'cbcalendarExt': {
                deps: [],
                exports: 'cbcalendarExt'
            },
            'swfobject': {
                deps: [],
                exports: 'swfobject'
            },
            'flexslider': {
                deps: ['jquery'],
                exports: 'flexslider'
            }
        }
    })
})()