/**
 * map.js
 */


Ext.Loader.setConfig({
    enabled: true
});

Ext.Loader.setPath('Ext.ux', '../../res/extjs/examples/ux');

Ext.require([
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.ux.RowExpander',
    'Ext.selection.CheckboxModel'
]);

var sm = Ext.create('Ext.selection.CheckboxModel');
var myMask;
var baseUrl = "";
var basePath = "";
var theme = "";
var mapStyle = "";
var map;
var map1;
var mapzoom = 11;
var company_cur = 0;
var StatusStore=null,AlarmStore=null;
var firstDraw = true;
var weatherDown_mode_div = null;
var storeTime = 60000;
var centerLng = 121.475644;
var currentLng = 121.475644;
var centerLat = 31.1857;
var currentLat = 31.1857;
var rotation = 0;
var alarm_show_window=null;
var show_alarm_list;
var show_list_cur=0
var V_LOGINNAME='',V_PASSWORD='';
var listSync=true;
var synctime = 0;
var company_code = '';
var start=0;
var end = 360;
var targetZoom = 20;
var maxHeight = 10000;
var maxWidth = 10000;
var SearchList = null;
var markers = [];
var current_company_code="";
var LabelShow = false;
var MapShow = false;
var last_move;
var filterwin;
var mouseon;
var mouseoff;
var menu_click;
var real_time_alarm;
var menuidx = 'm1';
var menuidx1 = 'm1';
var menuidx2 = 'm1';
var myStore1 = null;
var wsUri = "wss://iot.usky.cn:55120";
var sm1 = Ext.create('Ext.selection.CheckboxModel');
var websocket = null;
Ext.define('CheckRecord3',{
	extend: 'Ext.data.Model',
	fields: [
		{ name:'id', type:'int'},
		{ name:'orderIdx', type:'int'},
		{ name:'device_code',	type:'string' },
		{ name:'company_code',	type:'string' },
		{ name:'company_name',	type:'string' },
		{ name:'fullname', type:'string' },
		{ name:'time', type:'string' },
		{ name:'name', type:'string' },
		{ name:'status', type:'string' },
		{ name:'data', type:'string' },
		{ name:'data2', type:'string' },
		{ name:'data4', type:'string' },
		{ name:'clzt', type:'string' },
		{ name:'clr_name', type:'string' },
		{ name:'clsj', type:'string' },
		{ name:'clnr', type:'string'},
		{ name:'clwb', type:'string'}
	]
});

var alarm_alert_config={
	title:'<table border=0 style="width:320px;"><tr><td id="rt_alarm_alert_icon" style="width:24px;height:24px;"></td><td><span id="rt_alarm_alert_title" style="text-align:right;margin-left:10px;font-widght:bold;color:#31e9ff;overflow:hidden;"></span></td><td style="width:32px;color:#ffffff;cursor:pointer;text-align:left;" onclick="close_alert()"><div style="width:16px;height:16px;background-image:url(../../res/img/common/close-tmp.gif)"></div></td></tr></table>',
	titleColor:'#ffffff',
	titleIconColor:'#ffffff',
	titleBackgroundColor:'rgba(0,0,0,0.1)',
	backgroundColor: 'rgba(23,21,57,0.2)',
	backgroundImage: 'radial-gradient(circle, rgba(23,21,57,0.2), rgba(9,9,27,0.8))',
	border: '1px solid #31e9ff',
	borderRadius:'10px',
	position:'absolute',
	width:320,
	height:120,
	bottom:-100,
	right:95,
	zIndex:990,
	bodyText:'<div><table border="0" style="border:0px solid #31e9ff;margin:5px;font-size:9px;color:#ffffff"><tr><td colspan=2 style="height:20px;"><div id="alarm_time" style="margin-top:3px;"></div><div id="alarm_company" style="margin-top:3px;"></div><div id="alarm_device" style="margin-top:3px;"></div></td></tr></table></div>'
}

var close_alert = function(){
	removeDIV("rt_alarm_alert");
}

var markerSortByRotation = function(a,b){
	if((rotation<=45)||(rotation>=315))
		return b.lat-a.lat;
	else if((rotation>45)&&(rotation<=135))
		return a.lng - b.lng;
	else if((rotation>135)&&(rotation<=270))
		return a.lat-b.lat;
	else
		return b.lng-a.lng;
}

var bigger_click = function(){
	map.zoomIn( );
}

var smaller_click = function(){
	map.zoomOut( );
}

var right_mouseover = function(){
	$("#map_btn_right").removeClass('map_btn_right_off');
	$("#map_btn_right").addClass('map_btn_right_on');
}

var right_mouseout = function(){
	$("#map_btn_right").removeClass('map_btn_right_on');
	$("#map_btn_right").addClass('map_btn_right_off');
}

var alarmSortByTime = function(a,b){
	var time_a = Date.parse(a.time);
	var time_b = Date.parse(b.time);
	return time_b-time_a;
}

var clear_detail_info = function(){
	var d0=0, d0o=0, d0oc=0, d0a=0, d0ac=0;
	var d1=0, d1o=0, d1oc=0, d1a=0, d1ac=0;
	var d2=0, d2o=0, d2oc=0, d2a=0, d2ac=0;
	var d6=0, d6o=0, d6oc=0, d6a=0, d6ac=0;
	var d7=0, d7o=0, d7oc=0, d7a=0, d7ac=0;
	var detail_info = document.getElementById('detail_info');
	var real_time_alarm_div = document.getElementById('real_time_alarm_div');
	var parent = document.getElementById('container');
	if(detail_info!=undefined){
		parent.removeChild(detail_info);
		current_company_code="";
	}else if(real_time_alarm_div!=undefined){
		parent.removeChild(real_time_alarm_div);
	}
}

var draw_pie = function(id, total, num){
	var mColor= '#34abf5';
    var percent = 100;
    if(total>0)
        percent = Number(((num*100)/total).toString().match(/^\d+(?:\.\d{0,2})?/));
    if(percent<60)
        mColor = '#f66167';
    else if(percent<80)
        mColor = '#DDDF0D';
    if(id=='data_pie_1'){
	    $("#title-label-11").css({
	    	color:mColor
	    }).html(percent+'%');
	    $("#title-label-12").html(total);
    }else if(id=='data_pie_2'){
    	$("#title-label-21").css({
	    	color:mColor
	    }).html(percent+'%');
	    $("#title-label-22").html(total);
    }else if(id=='data_pie_3'){
    	$("#title-label-31").css({
	    	color:mColor
	    }).html(percent+'%');
	    $("#title-label-32").html(total);
    }else if(id=='data_pie_4'){
    	$("#title-label-41").css({
	    	color:mColor
	    }).html(percent+'%');
	    $("#title-label-42").html(total);
    }
    Highcharts.getOptions().colors = Highcharts.map(['#f66167','#34abf5', '#DDDF0D'], function (color) {
    	return {
    		radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
    		stops: [
    			[0, color],
    			[1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
    		]
    	};
    });
	Highcharts.chart(id,{
	    chart: {
	        type: 'pie',
	        backgroundColor: 'rgba(0,0,0,0)',
	        height:'100%',
	        options3d: {
	            enabled: true,
	            alpha: 45,
	            beta: 0
	        }
	    },
	    title: {
	        text: '处置率:'+percent+'%',
	        floating:true,
	          y:85,
	          style:{fontSize:'12px',color:'#ffffff'}
	    },
      exporting: {   
	      enabled: false
	  },
	  credits: {
	      enabled: false
	  },
	  tooltip: {
//	      enabled: false
		  pointFormat: '{point.percentage:.2f}%'
	  },
	    plotOptions: {
	        pie: {
	            allowPointSelect: true,
	            
	            cursor: 'pointer',
	            depth: 15,
	            dataLabels: {
	                enabled: false,
	                format: '{point.name}'
	            }
	        }
	    },
	    series: [{
	        type: 'pie',
	        name: '处置率',
	        startAngle:90,
	        data: [{
	        	name:'待处理',
	        	y:100-percent,
	        	sliced: true,
				selected: true
				},
	            ['已处理', percent]
	        ]
	    }]
    });
}

var showBuilding = function(company_code){
	if((StatusStore!=null)&&(StatusStore.length>0)){
		for(var i=0;i<StatusStore.length;i++){
			if(StatusStore[i].company_code==company_code){
				map.setCenter(new AMap.LngLat(StatusStore[i].lng,StatusStore[i].lat,true));
				map.setPitch(83);
				map.setZoom(18);
				break;
			}
		}
	}
}

var showInfo = function(e){
	var pixel = e.pixel;
	var company_code = e.target.getExtData().company_code;
	var detail_info;
	var parent = document.getElementById('container')
	for(var i=0;i<StatusStore.length;i++){
		if(StatusStore[i].company_code==company_code){
			if(current_company_code==company_code)
				return;
			clear_detail_info();
			current_company_code=company_code;
			var qobj = new Object();
			qobj.V_LOGINNAME = $("#V_LOGINNAME").val();
			qobj.V_PASSWORD = $("#V_PASSWORD").val();
			qobj.V_COMPANYID = company_code;
			qobj.I_COMMAND = 4;
			var qdata = "queryJson="+JSON.stringify(qobj);
			var qurl = 'https://iot.usky.cn/YtIoT/cgi-bin/WebAction2.cgi';
			$.ajax({
				type:'POST',
				url: qurl,
				data: qdata,
				success:function(result){
					var json = eval('(' + result + ')');
					if(json.action=='getAlarmList'){
						$(".alarm_tab_area").remove();
						if((json.ALARM==undefined)||(json.ALARM.length==0))
							return;
						var parent = document.getElementById('container');
						json.ALARM.sort(alarmSortByTime);
						var area = document.createElement('div');
						area.id= 'alarm_tab_area';
						area.setAttribute('class','alarm_tab_area');
						parent.appendChild(area);
					}
				}
				
			});
			detail_info = document.createElement('div');
			detail_info.id = 'detail_info';
			detail_info.style.position='absolute';
			detail_info.style.top=(pixel.getY()-310)+'px';
			detail_info.style.left=(pixel.getX()-0)+'px';
			detail_info.style.width='300px';
			detail_info.style.height='312px';
			detail_info.style.backgroundImage='url(../../res/img/03index/info_bg.png)';
			detail_info.style.zIndex='500';
			detail_info.onmouseleave=clear_detail_info;
			parent.appendChild(detail_info);
			var info_title = document.createElement('div');
			info_title.id='info_title';
			info_title.setAttribute('class','info_title');
			info_title.innerHTML='<div style="display:inline-block;vertical-align:middle;align-self:center;">'+StatusStore[i].company_name+'</div>';
			detail_info.appendChild(info_title);
			
			var info_body0 = document.createElement('div');
			info_body0.id = 'info_body0';
			info_body0.setAttribute('class','info_body0');
			info_body0.innerHTML='地址：'+StatusStore[i].address;
			detail_info.appendChild(info_body0);
			var info_body1 = document.createElement('div');
			info_body1.id = 'info_body1';
			info_body1.setAttribute('class','info_body1');
			info_body1.innerHTML='联系人：'+StatusStore[i].username;
			detail_info.appendChild(info_body1);
			var info_body2 = document.createElement('div');
			info_body2.id = 'info_body2';
			info_body2.setAttribute('class','info_body2');
			info_body2.innerHTML='联系电话：'+StatusStore[i].phone;
			detail_info.appendChild(info_body2);
			var info_btn = document.createElement('div');
			info_btn.id = 'info_btn';
			info_btn.setAttribute('class','info_btn');
			info_btn.innerHTML='查看详情';
			info_btn.company_code=company_code;
			info_btn.onclick=function(e){
				var event = e;
				location.href = baseUrl+'view/frontpage/company.jsp?company_code='+event.currentTarget.company_code;
			}
			detail_info.appendChild(info_btn);
			break;
		}
	}
}

var draw_all = function(){
	if(company_cur>0)
		return;
	var d0=0, d0o=0, d0oc=0, d0a=0, d0ac=0;
	var d1=0, d1o=0, d1oc=0, d1a=0, d1ac=0;
	var d2=0, d2o=0, d2oc=0, d2a=0, d2ac=0;
	var d6=0, d6o=0, d6oc=0, d6a=0, d6ac=0;
	var d7=0, d7o=0, d7oc=0, d7a=0, d7ac=0;
	var totalLat=0, totalLng=0, latngCount=0;
//	map.clearMap();
	clear_detail_info();
	markers = [];
	var zoom = map.getZoom();
	var iconWidth = 28;
	var iconHeight = 28;
	if((StatusStore!=null)&&(StatusStore.length>0)){
		rotation = map.getRotation();
		StatusStore.sort(markerSortByRotation);		
		for(var i=0;i<StatusStore.length;i++){
			var obj = StatusStore[i];
			var iconurl = baseUrl+'res/img/icons/building.png';
			if((obj.d0a!=obj.d0ac)
					||(obj.d0o!=obj.d0oc)
					||(obj.d1a!=obj.d1ac)
					||(obj.d1o!=obj.d1oc)
					||(obj.d2a!=obj.d2ac)
					||(obj.d2o!=obj.d2oc)
					||(obj.d6a!=obj.d6ac)
					||(obj.d6o!=obj.d6oc)
					||(obj.d7a!=obj.d7ac)
					||(obj.d7o!=obj.d7oc))
				iconurl = baseUrl+'res/img/icons/building_alarm.png';
			d1  += obj.d1;
			d1o += obj.d1o;
			d1a += obj.d1a;
			d1oc+= obj.d1oc;
			d1ac+= obj.d1ac;
			d2  += obj.d2;
			d2o += obj.d2o;
			d2a += obj.d2a;
			d2oc+= obj.d2oc;
			d2ac+= obj.d2ac;
			d6  += obj.d6;
			d6o += obj.d6o;
			d6a += obj.d6a;
			d6oc+= obj.d6oc;
			d6ac+= obj.d6ac;
			d7  += obj.d7;
			d7o += obj.d7o;
			d7a += obj.d7a;
			d7oc+= obj.d7oc;
			d7ac+= obj.d7ac;
			if((obj.lat>30)&&(obj.lat<33)&&(obj.lng>120)&&(obj.lng<125)){
				totalLng += obj.lng;
				totalLat += obj.lat;
				latngCount++;
				var marker= new AMap.Marker({
	                icon:new AMap.Icon({
	                	size:new AMap.Size(iconWidth,iconHeight),
	                	image:iconurl,
	                	imageSize:new AMap.Size(iconWidth,iconHeight)
	                }),
	                position: new AMap.LngLat(obj.lng,obj.lat),
	                extData:{
	                	icontype:'company',
	                    company_code:obj.company_code
	                },
	                offset: new AMap.Pixel(-(iconWidth/2), -(iconHeight/2)),
	                draggable:false,
	                raiseOnDrag:false,
	                autoRotation:false,
	                label:{
	                	offset: new AMap.Pixel(-iconWidth-5,-(iconHeight/2)-10),
	                	content:"<div id='label_"+obj.company_code+"' class='info "+(LabelShow?'shown':'hiden')+"'>"+obj.company_name+"</div>",
	                	direction: 'right'
	                }
	            });
	            AMap.event.addListener(marker,'click',showBuilding,this);
	            AMap.event.addListener(marker,'mouseover',showInfo,this);
	            if(!MapShow){
	            marker.setMap(map);
	            markers.push(marker);
	            }
			}			
		}
		var sts = [{
            url: baseUrl+'res/img/icons/icon_juhe_grade1.png',
            size: new AMap.Size(40, 40),
            offset: new AMap.Pixel(-16, -16)
        }, {
            url: baseUrl+'res/img/icons/icon_juhe_grade2.png',
            size: new AMap.Size(40, 40),
            offset: new AMap.Pixel(-16, -16)
        }, {
            url: baseUrl+'res/img/icons/icon_juhe_grade3.png',
            size: new AMap.Size(40, 40),
            offset: new AMap.Pixel(-18, -18)
        }];
		if(!MapShow){
			MapShow=true;
//		map.plugin(["AMap.MarkerClusterer"],function(){
//			 cluster = new AMap.MarkerClusterer(map, markers, {
//	                styles: sts,
//	                gridSize:80,
//	                maxZoom:18
////	                minClusterSize:3
////		                renderClusterMarker:_renderClusterMarker
//	            });   
//		});
		}
		if((latngCount>0)&&(firstDraw)){
			map.setCenter(new AMap.LngLat(totalLng/latngCount,totalLat/latngCount,true));
			map.setFitView();
			firstDraw = false;
		}
		showOperat();
	}
	
}

var real_time_alarm = function(obj){
	obj.title = obj.innerHTML;
}

var alarm_sound = function(){
	var audio = document.createElement('audio');
	 audio.src="../../8773.wav";
	 audio.autoplay="autoplay";
	 document.getElementById("title_right_02").appendChild(audio);
}

var initWebSocket = function() {
	try{
		if(typeof MozWebSocket == 'function')
			WebSocket =MozWebSocket;
		if( websocket && websocket.readyState == 1)
			websocket.close();
		websocket = new WebSocket(wsUri);
		websocket.onopen = function(evt){
			var json = {};
			json.agentid = $("#V_LOGINNAME").val();
			console.log("Connected.");
			(function(){})()
			websocket.send(JSON.stringify(json));
		};
		websocket.onclose = function(evt){
			console.log("DisConnected.");
			(function(){})()
			initWebSocket();
		};
		var i =0;
		websocket.onmessage = function(evt){
			console.log("Received:",evt.data);
			var jData =  eval('(' + evt.data + ')');
			if(jData.dwtype!=undefined){
				if(document.getElementById('rt_alarm_alert')!=undefined)
					removeDIV('rt_alarm_alert');
//				 var alarm_alert= new UNote();
//			 	 alarm_alert.create("rt_alarm_alert","container",alarm_alert_config);
				 var Li = document.createElement('li');
				 Li.setAttribute('class','alarm_tab03');
				 Li.style.top=(52*i)+'px';
				 document.getElementById("title_right_02_ul").appendChild(Li);
				 var Icon = document.createElement('img');
				 Icon.width='32';
				 Icon.height='32';
				 Icon.style.verticalAlign='middle';
				 Icon.src="../../res/img/icons/alarm_tab_04.gif"
				 if(jData.detype==1){
				 	Icon.src="../../res/img/icons/alarm_tab_01.gif"
				 }else if(jData.dwtype==2){
				 	Icon.src="../../res/img/icons/alarm_tab_03.gif"
				 }else if(jData.dwtype==6){
				 	Icon.src="../../res/img/icons/alarm_tab_04.gif"
				 }else if(jData.dwtype==7){
				 	Icon.src="../../res/img/icons/alarm_tab_02.gif"
				 }else if(jData.dwtype==16){
				 	Icon.src="../../res/img/icons/alarm_tab_05.gif"
				 }
//				 document.getElementById("rt_alarm_alert_icon").innerHTML="";
				 Li.appendChild(Icon);
				 var span1 = document.createElement('span');
				 span1.innerHTML=jData.evtname+'\n'+jData.time+'\n'+jData.company+'\n'+jData.devicename;
				 span1.setAttribute('onmouseover',"real_time_alarm(this)");
				 span1.setAttribute('class','alarm_tab03_span');
				 Li.appendChild(span1);
				 i++;
				 var title_right_02 = document.getElementById('title_right_02');
				 title_right_02.scrollTop = title_right_02.scrollHeight;
				 alarm_sound();
			}
		};
		websocket.onerror = function(evt){
			console.log("Error:",evt.data);
			(function(){})()
		};
	}catch(exception){
		console.log("Exception:",exception);
		(function(){})()
	}
}

var getCurrentData = function(){
	if(((new Date()).getTime()-synctime)<storeTime)
		return;
	$("#fp_backbtn").css("display","none");
	synctime = (new Date()).getTime();
	var query = new Object();
	query.V_LOGINNAME = V_LOGINNAME;
	query.V_PASSWORD = V_PASSWORD;
	query.V_COMMAND = 'FRONTPAGE';
	query.COMMSTATUS = "NO";
	if($("#company_code").val().length>0)
		query.company_code = $("#company_code").val();
	var qdata = JSON.stringify(query);
	var qurl = 'http://47.103.74.123:8080/YtIoT/cgi-bin/WebAction.cgi';
	if((baseUrl.indexOf('localhost')>=0)||(baseUrl.indexOf('127.0.0.1')>=0))
		qurl = 'http://47.103.74.123:8080/YtIoT/cgi-bin/WebAction.cgi';
    $.ajax({
        type:'POST',
        url: qurl,
        data: qdata,
        success: function(result){
        	if((result==undefined)||(result.length==0)){
        		Ext.Msg.alert('错误信息', '访问权限错误，请重新登录', function(){
        			window.parent.document.location=baseUrl;
        		});
        	}else{
	            var json = eval('(' + result + ')');
	            if(json.check=='false'){
	            	Ext.Msg.alert('错误信息', '访问权限错误，请重新登录', function(){
            			window.parent.document.location=baseUrl;
            		});
	            }
	            if(json.action=='getFrontpageQuery'){
	            	if(json.check=='true'){
	            		if(json.LIST!=undefined)
	            			StatusStore = json.LIST;
	            		if(json.ALARM!=undefined)
	            			AlarmStore = json.ALARM;
	                	draw_all();

	            	}
	            }
        	}
            myMask.hide();
        }
    });
    setTimeout(getCurrentData,storeTime);
}

var chk_company_cur = function(idx){
	var nrow=0;
	while(1){
		idx++;
		if(idx>=StatusStore.length)
			idx = 0;
		var obj = StatusStore[idx];
		if((obj.lat>30)&&(obj.lat<33)&&(obj.lng>120)&&(obj.lng<125))
			return idx;
		nrow++;
		if(nrow>=StatusStore.length)
			return -1;
	}
}

var show_cur_comany = function(){
	var current_t = Date.parse(new Date());
	if((current_t-last_move)>30000){
		last_move = current_t;
		if((StatusStore!=null)&&(StatusStore.length>0)){
			company_cur = chk_company_cur(company_cur);
			if(company_cur>=0){
				var obj = StatusStore[company_cur];
				showBuilding(obj.company_code);
				LabelShow = false;
		    	shower_click();
			}
		}
	}
	setTimeout(show_cur_comany,5000);
}

var evaluate_container_method = function(type){
	var myColor = ['#A8CFFF', '#00FFAE', '#A8CFFF', '#A8CFFF'];
	var myData = null;
	var myDataInfo = null;
	if(type==1){
		myData = ['巡检人员数量', '今日任务', '超时任务', '今日完成'];
		myDataInfo = [xjrysl, jrrw, csrw, jrwcrw];
	}else if(type==2){
		myData = ['维保人员数量', '今日任务', '超时任务', '今日完成'];
		myDataInfo = [xjrysl, jrrw, csrw, jrwcrw];
	}else if(type==3){
		myData = ['报修人员数量', '今日任务', '超时任务', '今日完成'];
		myDataInfo = [ConfirmStore[0].zrs, ConfirmStore[0].jrsj, ConfirmStore[0].cssj, ConfirmStore[0].jrjj];
	}
    echarts.init(document.getElementById('evaluate_container')).setOption({
        grid: {
            left: '5%',
            right: '5%',
            bottom: '5%',
            top: '10%',
            containLabel: true
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'none'
            },
            formatter: function(params) {
                return params[0].name + '<br/>' +
                    // "<span style='display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:rgba(36,207,233,0.9)'></span>" +
                    // params[0].seriesName + ' : ' +
                     Number((params[0].value.toFixed(4) / 1).toFixed(2)).toLocaleString() + '<br/>'
            }
        },
        // backgroundColor: 'rgb(20,28,52)',
        xAxis: {
            show: false,
            type: 'value'
        },
        yAxis: [{
            type: 'category',
            inverse: true,
            axisLabel: {
                show: true,
                textStyle: {
                    color: '#fff'
                },
            },
            splitLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            axisLine: {
                show: false
            },
            data: myData
        }, {
            type: 'category',
            inverse: true,
            axisTick: 'none',
            axisLine: 'none',
            show: true,
            axisLabel: {
                textStyle: {
                    color: '#ffffff',
                    fontSize: '12'
                },
                formatter: function(value) {
                    if (value >= 10000) {
                    } else {
                        return value.toLocaleString();
                    }
                },
            },
            data: myDataInfo
        }],
        series: [
            {
                // name: '金额',
                type: 'bar',
                zlevel: 1,
                itemStyle: {
                    normal: {
                        barBorderRadius: [ 0, 10, 10, 0],
                        // color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                        //     offset: 0,
                        //     color: 'rgb(57,89,255,1)'
                        // }, {
                        //     offset: 1,
                        //     color: 'rgb(46,200,207,1)'
                        // }]),
                        color: function(params) {
                        var num = myColor.length;
                        return myColor[params.dataIndex % num]
                        },
                    },
                },
                barWidth: 14,
                data: myDataInfo
            },
            {
                // name: '背景',
                type: 'bar',
                barWidth: 14,
                barGap: '-100%',
                data: [1000, 1000, 1000, 1000],
                itemStyle: {
                    normal: {
                        color: 'rgba(14,69,81,0.5)',
                        barBorderRadius: 0,
                    }
                },
            },
        ]
    });
}

var get_evaluation_data = function(type){
	var evaluation_url = null;
	if(type==1){
	    evaluation_url = baseUrl+"iot/spotoperationrecord/getList2";
	}else if(type==2){
		evaluation_url = baseUrl+"iot/spotoperationrecord/getList3";
	}else if(type==3){
		evaluation_url = baseUrl+"iot/xjeventprocessing/getList";
	}
	var query = new Object();
	query.V_LOGINNAME = V_LOGINNAME;
	query.V_PASSWORD = V_PASSWORD;
	if((company_code!=null)&&(company_code!='null')&&(company_code.length>0))
		query.company_code = company_code;
	$.ajax({
        type:'POST',
        url: evaluation_url,
        data: {
        	queryJson : Ext.JSON.encode(query)
    	 },
        success: function(result){
            var json = eval('(' + result + ')');
            if(type==1||type==2){
            	xjrysl = json.xjrysl;
    			jrwcrw = json.jrwcrw;
    			csrw = json.csrw;
    			jrrw = json.jrrw;
                evaluate_container_method(type);
        	}else if(type==3){
        		ConfirmStore = json.RESULT;
                evaluate_container_method(type);
        	}
            
        }
    });
}

/**
 * 
 * @param dateNow :Date类
 * @param intervalDays ：间隔天数
 * @param bolPastTime  ：Boolean,判断在参数date之前，还是之后，
 */
function getDateRange(dateNow,intervalDays,bolPastTime){
  let oneDayTime = 24 * 60 * 60 * 1000;
  let list = [];
  let lastDay;

  if(bolPastTime == true){
	  for(var i=0;i<=intervalDays;i++){
		  lastDay = new Date(dateNow.getTime() - i * oneDayTime);
	      list.push(this.formateDate(lastDay));
	  }
      
  }else{
      lastDay = new Date(dateNow.getTime() + intervalDays * oneDayTime);
      list.push(this.formateDate(dateNow));
      list.push(this.formateDate(lastDay));
  }
  return list;
}
function formateDate(time){
  let year = time.getFullYear()
  let month = time.getMonth() + 1
  let day = time.getDate()

  if (month < 10) {
    month = '0' + month
  }

  if (day < 10) {
    day = '0' + day
  }

  return year + '-' + month + '-' + day + ''

}

var get_alarm_data = function(type){
	var date = new Date();
    var list = this.getDateRange(date,6,true)
    var yData;
	var yData1;
    if(type==1){
    	yData = [3,5,7,82,25,14,23];
    	yData1 = [2,1,3,50,25,13,20];
    }else if(type==2){
    	yData = [140,87,7,82,175,135,47];
    	yData1 = [125,64,3,50,25,124,20];
    }else if(type==3){
    	yData = [114,74,28,57,146,135,69];
    	yData1 = [98,64,14,50,58,124,58];
    }else if(type==4){
    	yData = [4,241,189,341,182,652,193];
    	yData1 = [1,64,14,50,58,124,58];
    }else if(type==5){
    	yData = [742,180,658,41,852,12,29];
    	yData1 = [268,78,541,12,156,8,15];
    }
	
	Highcharts.getOptions().colors = Highcharts.map(['#f66167', '#34abf5'], function (color) {
		return {
			linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
			stops: [
				[0, color],
				[1, Highcharts.Color(color).setOpacity(0).get('rgb')] // darken
			]
		};
	});
	Highcharts.chart('alarm_container',{
		chart:{
			type:'area',
//			zoomType: 'x',
			backgroundColor: 'rgba(0,0,0,0)'
		},
		color:['#2995E6', '#00FFD8'],
		title:{
			text:null,
//			text:'水系统监控告警处理情况跟踪',
			float:true,
			style:{fontSize:'14px',color:'#2995E6',fontWeight:'bold'}
		},
		legend:{
			enabled:false,
			floating:true,
			x:410,
			y:-210,
			itemStyle:{fontSize:'12px',color:'#00FFD8',fontWeight:'bold'}
		},
//		colors:['#f66167', '#34abf5'],
	    exporting: {   
	        enabled: false
	    },
	    credits: {
	        enabled: false
	    },
		xAxis:{
			categories:list,
			tickmarkPlacement:'on',

			gridLineWidth:0,
			labels:{
				enabled:false,
				style:{fontSize:'10px',color:'#2995E6',fontWeight:'bold'}
			},
			title:{
				enabled:false
			}
		},
		yAxis:{
			title:{
				enabled:false,
				text:'次',
				style:{fontSize:'10px',color:'#2995E6',fontWeight:'bold'}
			},
			gridLineWidth:1,
			gridLineColor:'rgba(0,0,0,0.2)',
			labels:{
//				enabled:false,
				formatter:this.value,
				style:{fontSize:'10px',color:'#2995E6',fontWeight:'bold'}
			}
		},
		plotOptions:{
			area:{
				enabled:false,
				stackiung:'normal',
//				fillOpacity:0.1,
//				lineColor:'#666666',
//				lineWidth:1,
				marker:{
					lineWidth:0,
					enabled:false,
					radius:0
//					lineColor:'#666666'
				}
			}
		},
		series:[
			{
				name:'告警次数',
				data:yData,
				lineColor:'rgba(41,149,230,1)',
				fillColor: {
					linearGradient: {
						x1: 0,
						y1: 0,
						x2: 0,
						y2: 1
					},
					stops: [
						[0, 'rgba(41,149,230,0.5)'],
						[1, 'rgba(41,149,230,0.1)']
					]
				}
			},{
				name:'处理次数',
				data:yData1,
				lineColor:'rgba(0,255,216,1)',
				fillColor: {
					linearGradient: {
						x1: 0,
						y1: 0,
						x2: 0,
						y2: 1
					},
					stops: [
						[0, 'rgba(0,255,216,0.5)'],
						[1, 'rgba(0,255,216,0.1)']
					]
				},
			}
		]
	});
}



var right_echart1_method  = function(type){
	let value = 0;
	if(type==1){
		value = hjresult;
	}else{
		value = sonresult;
	}
	let angle = 0; //角度，用来做简单的动画效果的
	
	echarts.init(document.getElementById('right_echart1')).setOption({
		title: {
	         text: '{a|' + value + '}{c|}',
	         x: 'center',
	         y: 'center',
	         textStyle: {
	             rich: {
	                 a: {
	                     fontSize: 16,
	                     color: '#29EEF3'
	                 },

	                 c: {
	                     fontSize: 14,
	                     color: '#ffffff',
	                     // padding: [5,0]
	                 }
	             }
	         }
	     },
	     legend: {
	         type: "plain",
	         orient: "vertical",
	         right: 0,
	         top: "10%",
	         align: "auto",
	         data: [{
	             name: '火灾',
	             icon: "circle"
	         }, {
	             name: 'rtu',
	             icon: "circle"
	         }, {
	             name: '水系统',
	             icon: "circle"
	         }, {
	             name: '电气火灾',
	             icon: "circle"
	         }],
	         textStyle: {
	             color: "white",
	             fontSize: 16,
	             padding: [10, 1, 10, 0]
	         },
	         selectedMode: false
	     },

	     series: [
	          {
	             name: '离线设备占比',
	             type: 'pie',
	             radius: ['58%', '45%'],
	             silent: true,
	             clockwise: true,
	             startAngle: 90,
	             z: 0,
	             zlevel: 0,
	             label: {
	                 normal: {
	                     position: "center",

	                 }
	             },
	             data: [{
	                     value: value,
	                     name: "",
	                     itemStyle: {
	                         normal: {
	                             color: { // 完成的圆环的颜色
	                                 colorStops: [{
	                                     offset: 1,
	                                     color: 'rgba(19,235,249,1)' // 0% 处的颜色
	                                 }, {
	                                     offset: 0,
	                                     color: 'rgba(19,235,249,0.05)' // 100% 处的颜色
	                                 }]
	                             },
	                         }
	                     }
	                 },
	                 {
	                     value: 100 - value,
	                     name: "",
	                     label: {
	                         normal: {
	                             show: false
	                         }
	                     },
	                     itemStyle: {
	                         normal: {
	                             color: "rgba(11, 27, 36, .7)"
	                         }
	                     }
	                 }
	             ]
	         },

	         {
	             name: "",
	             type: "gauge",
	             radius: "58%",
	             center: ['50%', '50%'],
	             startAngle: 0,
	             endAngle: 359.9,
	             splitNumber: 32,
	             hoverAnimation: true,
	             axisTick: {
	                 show: false
	             },
	             splitLine: {
	                 length: 17,
	                 lineStyle: {
	                     width: 5,
	                     color: "rgba(13, 22, 41, .7)"
	                 }
	             },
	             axisLabel: {
	                 show: false
	             },
	             pointer: {
	                 show: false
	             },
	             axisLine: {
	                 lineStyle: {
	                     opacity: 0
	                 }
	             },
	             detail: {
	                 show: false
	             },
	             data: [{
	                 value: 0,
	                 name: ""
	             }]
	         },

	     ]
	});
}

var show_page = function(){
	var mid = "div_down_bg";
	var mid1 = "div_right_bg_tab";
	var mid2 = "div_down_alarm_bg";
	if(menuidx=='m1'){
		mid += '1';
	}else if(menuidx=='m2'){
		mid += '2';
	}else if(menuidx=='m3'){
		mid += '3';
	}
	
	if(menuidx1=='m1'){
		mid1 += '1';
	}else if(menuidx1=='m2'){
		mid1 += '2';
	}else if(menuidx1=='m3'){
		mid1 += '3';
	}else if(menuidx1=='m4'){
		mid1 += '4';
	}else if(menuidx1=='m5'){
		mid1 += '5';
	}else if(menuidx1=='m6'){
		mid1 += '6';
	}else if(menuidx1=='m7'){
		mid1 += '7';
	}
	
	if(menuidx2=='m1'){
		mid2 += '1';
	}else if(menuidx2=='m2'){
		mid2 += '2';
	}else if(menuidx2=='m3'){
		mid2 += '3';
	}else if(menuidx2=='m4'){
		mid2 += '4';
	}else if(menuidx2=='m5'){
		mid2 += '5';
	}
	for(var i=1;i<4;i++){
		var id = "div_down_bg"+i;
		$("#"+id).removeClass(id+'_on');
		$("#"+id).addClass(id);
	}
	for(var i=1;i<8;i++){
		var id = "div_right_bg_tab"+i;
		$("#"+id).removeClass(id+'_on');
		$("#"+id).addClass(id);
	}
	for(var i=1;i<6;i++){
		var id = "div_down_alarm_bg"+i;
		$("#"+id).removeClass(id+'_on');
		$("#"+id).addClass(id);
	}
	$("#"+mid).removeClass(mid);
	$("#"+mid).addClass(mid+'_on');
	$("#"+mid1).removeClass(mid1);
	$("#"+mid1).addClass(mid1+'_on');
	$("#"+mid2).removeClass(mid2);
	$("#"+mid2).addClass(mid2+'_on');
}

var get_offline_data = function(type){
	var query = new Object();
	query.V_LOGINNAME = V_LOGINNAME;
	query.V_PASSWORD = V_PASSWORD;
	query.dwtype = type;
	if((company_code!=null)&&(company_code!='null')&&(company_code.length>0))
		query.company_code = company_code;
	$.ajax({
        type:'POST',
        url: baseUrl+"iot/alarm/view/getHjOfflineList",
        data: {
        	queryJson : Ext.JSON.encode(query)
    	 },
        success: function(result){
            var json = eval('(' + result + ')');
            if(json.action=='getHjOfflineList'){
            	hjtotalCount = json.hjtotalCount;
            	hjresult = json.hjresult;
            	sontotalCount = json.sontotalCount;
            	sonresult = json.sonresult;
            	if(type==1){
            		document.getElementById('div_right_bg2_tab3_div').innerHTML=hjtotalCount;
            		document.getElementById('div_right_bg2_tab2_div').innerHTML=hjtotalCount;
            	}else{
            		document.getElementById('div_right_bg2_tab3_div').innerHTML=sontotalCount;
            		document.getElementById('div_right_bg2_tab2_div').innerHTML=sontotalCount;
            	}
            	right_echart1_method(type);
            }
        }
    });
}

mouseon = function(obj){
	var id = obj.id;
	$("#"+id).removeClass(id);
	$("#"+id).addClass(id+'_on');
}

 mouseoff = function(obj){
	 if((obj.id).indexOf("div_down_bg") != -1){
		var mid = "div_down_bg";
		for(var i=1;i<4;i++){
			var id = "div_down_bg"+i;
			$("#"+id).removeClass(id+'_on');
			$("#"+id).addClass(id);
		}
		if(menuidx=='m1'){
			mid += '1';
		$("#"+mid).removeClass(mid);
		$("#"+mid).addClass(mid+'_on');
		}
		else if(menuidx=='m2'){
			mid += '2';
		$("#"+mid).removeClass(mid);
		$("#"+mid).addClass(mid+'_on');
		}
		else if(menuidx=='m3'){
			mid += '3';
		$("#"+mid).removeClass(mid);
		$("#"+mid).addClass(mid+'_on');
		}
	 }else if((obj.id).indexOf("div_right_bg") != -1){
		var mid = "div_right_bg_tab";
		for(var i=1;i<8;i++){
			var id = "div_right_bg_tab"+i;
			$("#"+id).removeClass(id+'_on');
			$("#"+id).addClass(id);
		}
		if(menuidx1=='m1'){
			mid += '1';
		$("#"+mid).removeClass(mid);
		$("#"+mid).addClass(mid+'_on');
		}
		else if(menuidx1=='m2'){
			mid += '2';
		$("#"+mid).removeClass(mid);
		$("#"+mid).addClass(mid+'_on');
		}
		else if(menuidx1=='m3'){
			mid += '3';
		$("#"+mid).removeClass(mid);
		$("#"+mid).addClass(mid+'_on');
		}
		else if(menuidx1=='m4'){
			mid += '4';
		$("#"+mid).removeClass(mid);
		$("#"+mid).addClass(mid+'_on');
		}
		else if(menuidx1=='m5'){
			mid += '5';
		$("#"+mid).removeClass(mid);
		$("#"+mid).addClass(mid+'_on');
		}
		else if(menuidx1=='m6'){
			mid += '6';
		$("#"+mid).removeClass(mid);
		$("#"+mid).addClass(mid+'_on');
		}
		else if(menuidx1=='m7'){
			mid += '7';
		$("#"+mid).removeClass(mid);
		$("#"+mid).addClass(mid+'_on');
		}
	 }else if((obj.id).indexOf("div_down_alarm") != -1){
			var mid = "div_down_alarm_bg";
			for(var i=1;i<6;i++){
				var id = "div_down_alarm_bg"+i;
				$("#"+id).removeClass(id+'_on');
				$("#"+id).addClass(id);
			}
			if(menuidx2=='m1'){
				mid += '1';
			$("#"+mid).removeClass(mid);
			$("#"+mid).addClass(mid+'_on');
			}
			else if(menuidx2=='m2'){
				mid += '2';
			$("#"+mid).removeClass(mid);
			$("#"+mid).addClass(mid+'_on');
			}
			else if(menuidx2=='m3'){
				mid += '3';
			$("#"+mid).removeClass(mid);
			$("#"+mid).addClass(mid+'_on');
			}
			else if(menuidx2=='m4'){
				mid += '4';
			$("#"+mid).removeClass(mid);
			$("#"+mid).addClass(mid+'_on');
			}
			else if(menuidx2=='m5'){
				mid += '5';
			$("#"+mid).removeClass(mid);
			$("#"+mid).addClass(mid+'_on');
			}
		 }
}

 menu_click = function(obj){
	var id = obj.id;
	if(id=='div_down_bg1'){
		menuidx = 'm1';
		get_evaluation_data(1);
	}
	else if(id=='div_down_bg2'){
		menuidx = 'm2';
		get_evaluation_data(2);
	}
	else if(id=='div_down_bg3'){
		menuidx = 'm3';
		get_evaluation_data(3);
	}
	else if(id=='div_right_bg_tab1'){
		menuidx1 = 'm1';
		get_offline_data(1);
	}
	else if(id=='div_right_bg_tab2'){
		menuidx1 = 'm2';
		get_offline_data(6);
	}
	else if(id=='div_right_bg_tab3'){
		menuidx1 = 'm3';
		get_offline_data(2);
	}
	else if(id=='div_right_bg_tab4'){
		menuidx1 = 'm4';
		get_offline_data(7);
	}
	else if(id=='div_right_bg_tab5'){
		menuidx1 = 'm5';
		get_offline_data(16);
	}
	else if(id=='div_right_bg_tab6'){
		menuidx1 = 'm6';
		get_offline_data(128);
	}
	else if(id=='div_right_bg_tab7'){
		menuidx1 = 'm7';
		get_offline_data(17);
	}
	else if(id=='div_down_alarm_bg1'){
		menuidx2 = 'm1';
		get_alarm_data(1);
	}
	else if(id=='div_down_alarm_bg2'){
		menuidx2 = 'm2';
		get_alarm_data(2);
	}
	else if(id=='div_down_alarm_bg3'){
		menuidx2 = 'm3';
		get_alarm_data(3);
	}
	else if(id=='div_down_alarm_bg4'){
		menuidx2 = 'm4';
		get_alarm_data(4);
	}
	else if(id=='div_down_alarm_bg5'){
		menuidx2 = 'm5';
		get_alarm_data(5);
	}
}
 
 var timer_start = function(){
		
		var start_count = (start_count+1);
		if(start_count>10){
			menu_shown = false;
			hide_menu();
			setTimeout("timer_start()", 1000); 
			return;
		}
		$("#weatherDown_mode_div").html((new Date()).Format("yyyy-MM-dd hh:mm:ss"));
		setTimeout("timer_start()", 1000); 
}
 
 var get_weather_data_div = function(){
	 var weatherDown_mode = document.getElementById('weatherDown_mode');
	 weatherDown_mode_div = document.getElementById('weatherDown_mode_div1');
	 if(weatherDown_mode_div){
		 document.getElementById('weatherDown_mode_div2').innerHTML= lives[0].weather+lives[0].temperature+'℃'+'  '+lives[0].winddirection+lives[0].windpower+'级';
     }else{
     	var weatherDown_mode_div = document.createElement('span');
         weatherDown_mode_div.id= 'weatherDown_mode_div';
         weatherDown_mode_div.setAttribute('class','div_down_alarm weatherDown_mode_div');
         weatherDown_mode.appendChild(weatherDown_mode_div);
         var weatherDown_mode_div1 = document.createElement('img');
         weatherDown_mode_div1.id= 'weatherDown_mode_div1';
         weatherDown_mode_div1.setAttribute('class','div_down_alarm weatherDown_mode_div1');
         weatherDown_mode_div1.src='../../res/img/03index/e-time_icon.png';
         weatherDown_mode.appendChild(weatherDown_mode_div1);
         var weatherDown_mode_div2 = document.createElement('span');
         weatherDown_mode_div2.id= 'weatherDown_mode_div2';
         weatherDown_mode_div2.setAttribute('class','div_down_alarm weatherDown_mode_div');
         weatherDown_mode_div2.innerHTML= lives[0].weather+lives[0].temperature+'℃'+'  '+lives[0].winddirection+lives[0].windpower+'级';
         weatherDown_mode.appendChild(weatherDown_mode_div2);
     }
 }
 
 var get_weather_data = function(){
		$.ajax({
	        type:'GET',
	        url: "https://restapi.amap.com/v3/weather/weatherInfo?key=eb1ae4db1ab6cbb4ff967a4f4005eab0&city=310000",
	        success: function(result){
	        	console.log(result);
//	            var json = eval('(' + result + ')');
	                lives = result.lives;
	                get_weather_data_div();
	                
//	                weatherDown_mode.innerHTML=lives[0].weather;
	            
	        }
	    });
	}
 
    var  show_all_fireAlarm = function(){
		if($("#V_LOGINNAME").val()=='guest')
			return;
		parent.window.keep_menu();
		if($("#company_code").val()!=undefined)
			location.href = baseUrl + 'view/fireAlarm/subFireAlarm.jsp?theme='+theme+'&company_code='+($("#company_code").val());
		else
			location.href = baseUrl + 'view/fireAlarm/subFireAlarm.jsp?theme='+theme;
	}

	var show_all_waterAlarm = function(){
		if($("#V_LOGINNAME").val()=='guest')
			return;
		parent.window.keep_menu();
		if($("#company_code").val()!=undefined)
			location.href = baseUrl + 'view/waterAlarm/subWaterAlarm.jsp?theme='+theme+'&company_code='+($("#company_code").val());
		else
			location.href = baseUrl + 'view/waterAlarm/subWaterAlarm.jsp?theme='+theme;
	}

	var show_all_rtuAlarm = function(){
		if($("#V_LOGINNAME").val()=='guest')
			return;
		parent.window.keep_menu();
		if($("#company_code").val()!=undefined)
			location.href = baseUrl + 'view/rtuAlarm/subRtuAlarm.jsp?theme='+theme+'&company_code='+($("#company_code").val());
		else
			location.href = baseUrl + 'view/rtuAlarm/subRtuAlarm.jsp?theme='+theme;
	}

	var show_all_efireAlarm = function () {
		if($("#V_LOGINNAME").val()=='guest')
			return;
		parent.window.keep_menu();
		if($("#company_code").val()!=undefined)
			location.href = baseUrl + 'view/efireAlarm/subeFireAlarm.jsp?theme='+theme+'&company_code='+($("#company_code").val());
		else
			location.href = baseUrl + 'view/efireAlarm/subeFireAlarm.jsp?theme='+theme;
	}

var showOperat = function(){
	menuidx = 'm1';
	menuidx1 = 'm1';
	menuidx2 = 'm1';
	var d0=0, d0o=0, d0oc=0, d0a=0, d0ac=0;
	var d1=0, d1o=0, d1oc=0, d1a=0, d1ac=0;
	var d2=0, d2o=0, d2oc=0, d2a=0, d2ac=0;
	var d6=0, d6o=0, d6oc=0, d6a=0, d6ac=0;
	var d7=0, d7o=0, d7oc=0, d7a=0, d7ac=0;
	var parent = document.getElementById('container');
	var lineLeft_mode = document.getElementById('lineLeft_mode');
	var container1 = document.getElementById('container1');
	var lineDown_mode = document.getElementById('lineDown_mode');
	var lineRight_mode = document.getElementById('lineRight_mode');
	var title_down_03 = document.getElementById('title_down_03');
		var qobj = new Object();
		qobj.V_LOGINNAME = $("#V_LOGINNAME").val();
		qobj.V_PASSWORD = $("#V_PASSWORD").val();
		qobj.V_COMPANYID = company_code;
		qobj.I_COMMAND = 4;
		var qdata = "queryJson="+JSON.stringify(qobj);
		var qurl = 'https://47.103.74.123:8080/YtIoT/cgi-bin/WebAction2.cgi';
		for(var i=0;i<StatusStore.length;i++){
			var obj = StatusStore[i];
			d1  += obj.d1;
			d1o += obj.d1o;
			d1a += obj.d1a;
			d1oc+= obj.d1oc;
			d1ac+= obj.d1ac;
			d2  += obj.d2;
			d2o += obj.d2o;
			d2a += obj.d2a;
			d2oc+= obj.d2oc;
			d2ac+= obj.d2ac;
			d6  += obj.d6;
			d6o += obj.d6o;
			d6a += obj.d6a;
			d6oc+= obj.d6oc;
			d6ac+= obj.d6ac;
			d7  += obj.d7;
			d7o += obj.d7o;
			d7a += obj.d7a;
			d7oc+= obj.d7oc;
			d7ac+= obj.d7ac;		
		}
//		$.ajax({
//			type:'POST',
//			url: qurl,
//			data: qdata,
//			success:function(result){
//				var json = eval('(' + result + ')');
//				if(json.action=='getAlarmList'){
//					if((json.ALARM==undefined)||(json.ALARM.length==0))
//						return;
		            if(container1){
			
		            }else{
		            	
//		            	var chartleftbg1 = document.createElement('div');
//		            	chartleftbg1.id= 'chart_left_bg1';
//		            	chartleftbg1.setAttribute('class','chart_left_bg1');
//						lineLeft_mode.appendChild(chartleftbg1);
//						var chartleftbg2 = document.createElement('div');
//						chartleftbg2.id= 'chart_left_bg2';
//						chartleftbg2.setAttribute('class','chart_left_bg2');
//						lineLeft_mode.appendChild(chartleftbg2);
//						var chartleftbg3 = document.createElement('div');
//						chartleftbg3.id= 'chart_left_bg3';
//						chartleftbg3.setAttribute('class','chart_left_bg3');
//						lineLeft_mode.appendChild(chartleftbg3);
//						var chartleftbg4 = document.createElement('div');
//						chartleftbg4.id= 'chart_left_bg4';
//						chartleftbg4.setAttribute('class','chart_left_bg4');
//						lineLeft_mode.appendChild(chartleftbg4);
						var chartleftbg1_data = document.createElement('div');
						chartleftbg1_data.id= 'container1';
						chartleftbg1_data.setAttribute('class','chart_left_data1');
						chartleftbg1_data.setAttribute('onclick','show_all_fireAlarm()');
						lineLeft_mode.appendChild(chartleftbg1_data);
						var chartleftbg2_data = document.createElement('div');
						chartleftbg2_data.id= 'container2';
						chartleftbg2_data.setAttribute('class','chart_left_data2');
						chartleftbg2_data.setAttribute('onclick','show_all_efireAlarm()');
						lineLeft_mode.appendChild(chartleftbg2_data);
						var chartleftbg3_data = document.createElement('div');
						chartleftbg3_data.id= 'container3';
						chartleftbg3_data.setAttribute('class','chart_left_data3');
						chartleftbg3_data.setAttribute('onclick','show_all_waterAlarm()');
						lineLeft_mode.appendChild(chartleftbg3_data);
						var chartleftbg4_data = document.createElement('div');
						chartleftbg4_data.id= 'container4';
						chartleftbg4_data.setAttribute('class','chart_left_data4');
						chartleftbg4_data.setAttribute('onclick','show_all_rtuAlarm()');
						lineLeft_mode.appendChild(chartleftbg4_data);
						var divleftbg5 = document.createElement('div');
						divleftbg5.id= 'div_left_bg5';
						divleftbg5.setAttribute('class','div_down_alarm div_left_bg5');
						divleftbg5.innerHTML='火灾监控处置率';
						lineLeft_mode.appendChild(divleftbg5);
						var divleftbg6 = document.createElement('div');
						divleftbg6.id= 'div_left_bg6';
						divleftbg6.setAttribute('class','div_down_alarm div_left_bg6');
						divleftbg6.innerHTML='电气火灾监控处置率';
						lineLeft_mode.appendChild(divleftbg6);
						var divleftbg7 = document.createElement('div');
						divleftbg7.id= 'div_left_bg7';
						divleftbg7.setAttribute('class','div_down_alarm div_left_bg7');
						divleftbg7.innerHTML='水系统监控处置率';
						lineLeft_mode.appendChild(divleftbg7);
						var divleftbg8 = document.createElement('div');
						divleftbg8.id= 'div_left_bg8';
						divleftbg8.setAttribute('class','div_down_alarm div_left_bg8');
						divleftbg8.innerHTML='RTU监控处置率';
						lineLeft_mode.appendChild(divleftbg8);
//						var chartleftbg1_data_div = document.createElement('div');
//						chartleftbg1_data_div.id= 'chartleftbg1_data_div';
//						chartleftbg1_data_div.setAttribute('class','chartleftbg_data_div chartleftbg1_data_div');
//						chartleftbg1_data_div.innerHTML=percent+'%';
//						lineLeft_mode.appendChild(chartleftbg1_data_div);
//						var chartleftbg2_data_div = document.createElement('div');
//						chartleftbg2_data_div.id= 'chartleftbg2_data_div';
//						chartleftbg2_data_div.setAttribute('class','chartleftbg_data_div chartleftbg2_data_div');
//						chartleftbg2_data_div.innerHTML='80%';
//						lineLeft_mode.appendChild(chartleftbg2_data_div);
//						var chartleftbg3_data_div = document.createElement('div');
//						chartleftbg3_data_div.id= 'chartleftbg3_data_div';
//						chartleftbg3_data_div.setAttribute('class','chartleftbg_data_div chartleftbg3_data_div');
//						chartleftbg3_data_div.innerHTML='80%';
//						lineLeft_mode.appendChild(chartleftbg3_data_div);
//						var chartleftbg4_data_div = document.createElement('div');
//						chartleftbg4_data_div.id= 'chartleftbg4_data_div';
//						chartleftbg4_data_div.setAttribute('class','chartleftbg_data_div chartleftbg4_data_div');
//						chartleftbg4_data_div.innerHTML='80%';
//						lineLeft_mode.appendChild(chartleftbg4_data_div);
						
						//下侧模块
						var chartdownbg1_data = document.createElement('div');
						chartdownbg1_data.id= 'alarm_container';
						chartdownbg1_data.setAttribute('class','chart_down_data1');
						lineDown_mode.appendChild(chartdownbg1_data);
						var chartdownbg2_data = document.createElement('div');
						chartdownbg2_data.id= 'evaluate_container';
						chartdownbg2_data.setAttribute('class','chart_down_data2');
						lineDown_mode.appendChild(chartdownbg2_data);
						var divdownbg = document.createElement('div');
						divdownbg.id= 'div_down_bg_title';
						divdownbg.setAttribute('class','div_down_bg_title');
						divdownbg.innerHTML='物管考评';
						lineDown_mode.appendChild(divdownbg);
						var divdownbg1 = document.createElement('div');
						divdownbg1.id= 'div_down_bg1';
						divdownbg1.setAttribute('class','div_down div_down_bg1');
						divdownbg1.setAttribute('onmouseover',"mouseon(this)");
						divdownbg1.setAttribute('onmouseout',"mouseoff(this)");
						divdownbg1.setAttribute('onclick',"menu_click(this)");
						divdownbg1.innerHTML='巡检记录';
						lineDown_mode.appendChild(divdownbg1);
						var divdownbg2 = document.createElement('div');
						divdownbg2.id= 'div_down_bg2';
						divdownbg2.setAttribute('class','div_down div_down_bg2');
						divdownbg2.setAttribute('onmouseover',"mouseon(this)");
						divdownbg2.setAttribute('onmouseout',"mouseoff(this)");
						divdownbg2.setAttribute('onclick',"menu_click(this)");
						divdownbg2.innerHTML='维保工作';
						lineDown_mode.appendChild(divdownbg2);
						var divdownbg3 = document.createElement('div');
						divdownbg3.id= 'div_down_bg3';
						divdownbg3.setAttribute('class','div_down div_down_bg3');
						divdownbg3.setAttribute('onmouseover',"mouseon(this)");
						divdownbg3.setAttribute('onmouseout',"mouseoff(this)");
						divdownbg3.setAttribute('onclick',"menu_click(this)");
						divdownbg3.innerHTML='报修服务';
						lineDown_mode.appendChild(divdownbg3);
						var divdownbg4 = document.createElement('div');
						divdownbg4.id= 'div_down_bg4';
						divdownbg4.setAttribute('class','div_down_bg4');
//						divdownbg4.innerHTML='<iframe src="http://www.thingjs.com/s/f3f828772e4823f45559f83b?params=105b0f77fd24654d4eebc434e9" style="width:98%;height:100%;border:1px solid #25bfff;"></iframe>';
						title_down_03.appendChild(divdownbg4);
						var divdownbg5 = document.createElement('div');
						divdownbg5.id= 'div_down_bg5';
						divdownbg5.setAttribute('class','div_down_bg5');
						divdownbg5.innerHTML='设备工况';
						lineDown_mode.appendChild(divdownbg5);
						var divdownbg6 = document.createElement('div');
						divdownbg6.id= 'div_down_bg6';
						divdownbg6.setAttribute('class','div_down_bg6');
						divdownbg6.innerHTML='离线处理情况跟踪报表';
						lineDown_mode.appendChild(divdownbg6);
						var divdownbg7 = document.createElement('div');
						divdownbg7.id= 'div_down_alarm_bg1';
						divdownbg7.setAttribute('class','div_down_alarm div_down_alarm_bg1');
						divdownbg7.setAttribute('onmouseover',"mouseon(this)");
						divdownbg7.setAttribute('onmouseout',"mouseoff(this)");
						divdownbg7.setAttribute('onclick',"menu_click(this)");
						divdownbg7.innerHTML='RTU监控';
						lineDown_mode.appendChild(divdownbg7);
						var divdownbg8 = document.createElement('div');
						divdownbg8.id= 'div_down_alarm_bg2';
						divdownbg8.setAttribute('class','div_down_alarm div_down_alarm_bg2');
						divdownbg8.setAttribute('onmouseover',"mouseon(this)");
						divdownbg8.setAttribute('onmouseout',"mouseoff(this)");
						divdownbg8.setAttribute('onclick',"menu_click(this)");
						divdownbg8.innerHTML='火灾监控';
						lineDown_mode.appendChild(divdownbg8);
						var divdownbg9 = document.createElement('div');
						divdownbg9.id= 'div_down_alarm_bg3';
						divdownbg9.setAttribute('class','div_down_alarm div_down_alarm_bg3');
						divdownbg9.setAttribute('onmouseover',"mouseon(this)");
						divdownbg9.setAttribute('onmouseout',"mouseoff(this)");
						divdownbg9.setAttribute('onclick',"menu_click(this)");
						divdownbg9.innerHTML='视频监控';
						lineDown_mode.appendChild(divdownbg9);
						var divdownbg10 = document.createElement('div');
						divdownbg10.id= 'div_down_alarm_bg4';
						divdownbg10.setAttribute('class','div_down_alarm div_down_alarm_bg4');
						divdownbg10.setAttribute('onmouseover',"mouseon(this)");
						divdownbg10.setAttribute('onmouseout',"mouseoff(this)");
						divdownbg10.setAttribute('onclick',"menu_click(this)");
						divdownbg10.innerHTML='电梯状态监控';
						lineDown_mode.appendChild(divdownbg10);
						var divdownbg11 = document.createElement('div');
						divdownbg11.id= 'div_down_alarm_bg5';
						divdownbg11.setAttribute('class','div_down_alarm div_down_alarm_bg5');
						divdownbg11.setAttribute('onmouseover',"mouseon(this)");
						divdownbg11.setAttribute('onmouseout',"mouseoff(this)");
						divdownbg11.setAttribute('onclick',"menu_click(this)");
						divdownbg11.innerHTML='消防水系统监控';
						lineDown_mode.appendChild(divdownbg11);
						
						//右侧模块
						var chartrightbg1 = document.createElement('div');
						chartrightbg1.id= 'chart_right_bg1';
						chartrightbg1.setAttribute('class','chart_right_bg1');
						lineRight_mode.appendChild(chartrightbg1);
						var chartrightbg1_data = document.createElement('div');
						chartrightbg1_data.id= 'right_echart1';
						chartrightbg1_data.setAttribute('class','chart_right_data1');
						lineRight_mode.appendChild(chartrightbg1_data);
//						var chartrightbg2_data = document.createElement('div');
//						chartrightbg2_data.id= 'right_echart2';
//						chartrightbg2_data.setAttribute('class','chart_right_data2');
//						lineRight_mode.appendChild(chartrightbg2_data);
						var divrightbg = document.createElement('div');
						divrightbg.id= 'div_right_bg';
						divrightbg.setAttribute('class','div_right_bg');
						lineRight_mode.appendChild(divrightbg);
						var divrightbg_tab1 = document.createElement('div');
						divrightbg_tab1.id= 'div_right_bg_tab1';
						divrightbg_tab1.setAttribute('class','div_right_bg_tab div_right_bg_tab1');
						divrightbg_tab1.setAttribute('onmouseover',"mouseon(this)");
						divrightbg_tab1.setAttribute('onmouseout',"mouseoff(this)");
						divrightbg_tab1.setAttribute('onclick',"menu_click(this)");
						divrightbg_tab1.innerHTML='火灾';
						divrightbg.appendChild(divrightbg_tab1);
						var divrightbg_tab2 = document.createElement('div');
						divrightbg_tab2.id= 'div_right_bg_tab2';
						divrightbg_tab2.setAttribute('class','div_right_bg_tab div_right_bg_tab2');
						divrightbg_tab2.setAttribute('onmouseover',"mouseon(this)");
						divrightbg_tab2.setAttribute('onmouseout',"mouseoff(this)");
						divrightbg_tab2.setAttribute('onclick',"menu_click(this)");
						divrightbg_tab2.innerHTML='RTU';
						divrightbg.appendChild(divrightbg_tab2);
						var divrightbg_tab3 = document.createElement('div');
						divrightbg_tab3.id= 'div_right_bg_tab3';
						divrightbg_tab3.setAttribute('class','div_right_bg_tab div_right_bg_tab3');
						divrightbg_tab3.setAttribute('onmouseover',"mouseon(this)");
						divrightbg_tab3.setAttribute('onmouseout',"mouseoff(this)");
						divrightbg_tab3.setAttribute('onclick',"menu_click(this)");
						divrightbg_tab3.innerHTML='水系统';
						divrightbg.appendChild(divrightbg_tab3);
						var divrightbg_tab4 = document.createElement('div');
						divrightbg_tab4.id= 'div_right_bg_tab4';
						divrightbg_tab4.setAttribute('class','div_right_bg_tab div_right_bg_tab4');
						divrightbg_tab4.setAttribute('onmouseover',"mouseon(this)");
						divrightbg_tab4.setAttribute('onmouseout',"mouseoff(this)");
						divrightbg_tab4.setAttribute('onclick',"menu_click(this)");
						divrightbg_tab4.innerHTML='电气火灾';
						divrightbg.appendChild(divrightbg_tab4);
						var divrightbg_tab5 = document.createElement('div');
						divrightbg_tab5.id= 'div_right_bg_tab5';
						divrightbg_tab5.setAttribute('class','div_right_bg_tab div_right_bg_tab5');
						divrightbg_tab5.setAttribute('onmouseover',"mouseon(this)");
						divrightbg_tab5.setAttribute('onmouseout',"mouseoff(this)");
						divrightbg_tab5.setAttribute('onclick',"menu_click(this)");
						divrightbg_tab5.innerHTML='视频监控';
						divrightbg.appendChild(divrightbg_tab5);
						var divrightbg_tab6 = document.createElement('div');
						divrightbg_tab6.id= 'div_right_bg_tab6';
						divrightbg_tab6.setAttribute('class','div_right_bg_tab div_right_bg_tab6');
						divrightbg_tab6.setAttribute('onmouseover',"mouseon(this)");
						divrightbg_tab6.setAttribute('onmouseout',"mouseoff(this)");
						divrightbg_tab6.setAttribute('onclick',"menu_click(this)");
						divrightbg_tab6.innerHTML='井盖监控';
						divrightbg.appendChild(divrightbg_tab6);
						var divrightbg_tab7 = document.createElement('div');
						divrightbg_tab7.id= 'div_right_bg_tab7';
						divrightbg_tab7.setAttribute('class','div_right_bg_tab div_right_bg_tab7');
						divrightbg_tab7.setAttribute('onmouseover',"mouseon(this)");
						divrightbg_tab7.setAttribute('onmouseout',"mouseoff(this)");
						divrightbg_tab7.setAttribute('onclick',"menu_click(this)");
						divrightbg_tab7.innerHTML='电梯监控';
						divrightbg.appendChild(divrightbg_tab7);
						var divrightbg2 = document.createElement('div');
						divrightbg2.id= 'div_right_bg2';
						divrightbg2.setAttribute('class','div_right_bg2');
						lineRight_mode.appendChild(divrightbg2);
						var divrightbg2_tab1 = document.createElement('div');
						divrightbg2_tab1.id= 'div_right_bg2_tab1';
						divrightbg2_tab1.setAttribute('class','div_right_bg2_tab1');
						divrightbg2.appendChild(divrightbg2_tab1);
						var divrightbg2_tab2 = document.createElement('div');
						divrightbg2_tab2.id= 'div_right_bg2_tab2';
						divrightbg2_tab2.setAttribute('class','div_right_bg2_tab2');
						divrightbg2.appendChild(divrightbg2_tab2);
//						var divrightbg2_tab2_data_div = document.createElement('div');
//						divrightbg2_tab2_data_div.id= 'divrightbg2_tab2_data_div';
//						divrightbg2_tab2_data_div.setAttribute('class','divrightbg2_tab2_data_div');
//						divrightbg2_tab2_data_div.innerHTML='80%';
//						divrightbg2_tab2.appendChild(divrightbg2_tab2_data_div);
						var divrightbg2_tab3 = document.createElement('div');
						divrightbg2_tab3.id= 'div_right_bg2_tab3';
						divrightbg2_tab3.setAttribute('class','div_right_bg2_tab3');
						divrightbg2.appendChild(divrightbg2_tab3);
						var divrightbg2_tab3_div = document.createElement('div');
						divrightbg2_tab3_div.id= 'div_right_bg2_tab3_div';
						divrightbg2_tab3_div.setAttribute('class','div_right_bg2_tab3_div');
						divrightbg2_tab3_div.innerHTML='145';
						divrightbg2_tab3.appendChild(divrightbg2_tab3_div);
						var divrightbg2_tab4 = document.createElement('div');
						divrightbg2_tab4.id= 'div_right_bg2_tab4';
						divrightbg2_tab4.setAttribute('class','div_right_bg2_tab4');
						divrightbg2.appendChild(divrightbg2_tab4);
						var divrightbg2_tab2_div = document.createElement('div');
						divrightbg2_tab2_div.id= 'div_right_bg2_tab2_div';
						divrightbg2_tab2_div.setAttribute('class','div_right_bg2_tab2_div');
						divrightbg2_tab2_div.innerHTML='145';
						divrightbg2_tab2.appendChild(divrightbg2_tab2_div);
						var divrightbg2_tab5 = document.createElement('div');
						divrightbg2_tab5.id= 'div_right_bg2_tab5';
						divrightbg2_tab5.setAttribute('class','div_right_bg2_tab5');
						divrightbg2.appendChild(divrightbg2_tab5);
						var divrightbg3 = document.createElement('div');
						divrightbg3.id= 'div_right_bg3';
						divrightbg3.setAttribute('class','div_right_bg3');
						divrightbg3.innerHTML='前一天';
						lineRight_mode.appendChild(divrightbg3);
						var divrightbg4 = document.createElement('div');
						divrightbg4.id= 'div_right_bg4';
						divrightbg4.setAttribute('class','div_right_bg4');
						divrightbg4.innerHTML='当前';
						lineRight_mode.appendChild(divrightbg4);
						var divrightbg5 = document.createElement('div');
						divrightbg5.id= 'div_right_bg5';
						divrightbg5.setAttribute('class','div_right_bg5');
						divrightbg5.innerHTML='告警信息';
						lineRight_mode.appendChild(divrightbg5);
						var divrightbg6 = document.createElement('div');
						divrightbg6.id= 'div_right_bg6';
						divrightbg6.setAttribute('class','div_right_bg6');
						divrightbg6.innerHTML='实时告警';
						lineRight_mode.appendChild(divrightbg6);
//						var divrightbg7 = document.createElement('div');
//						divrightbg7.id= 'div_right_bg7';
//						divrightbg7.setAttribute('class','div_right_bg7');
//						divrightbg7.innerHTML='实时告警';
//						lineRight_mode.appendChild(divrightbg7);
		            }
		            draw_pie("container1",d1a,d1ac);
		            draw_pie("container2",d7a,d7ac);
		            draw_pie("container3",d2a,d2ac);
		            draw_pie("container4",d6a,d6ac);
		            get_offline_data(1);
		            get_evaluation_data(1);
		            show_page();
		            get_weather_data();
		            get_alarm_data(1);
		            var colors = ['#FB9E40', '#FC4747'];
//		            Highcharts.getOptions().colors = Highcharts.map(colors, function (color) {
//		            	return {
//		            		linearGradient: { x1: 1, x2: 0, y1: 0, y2: 0 },
//		            		stops: [
//		            			[0, 'rgba(0,255,216,1)'],
//		            			[1, 'rgba(0,255,216,0)']
//		            		]
//		            	};
//		            });
//		            Highcharts.chart('container1', {
//		            	chart: {
//		            		type: 'solidgauge',
//		            		marginTop: 50,
//		            		backgroundColor: 'rgba(0,0,0,0)'
//		            	},
//		            	credits: {
//		            		enabled:false
//		            	},
//		            	exporting: {
//		            		enabled:false
//		            	},
//		            	title: {
//		            		text:null
//		            	},
//		            	tooltip: {
////		            		enabled : false,
//		            		borderWidth: 0,
//		            		backgroundColor: 'rgba(5,24,36,0.7)',
//		            		shadow: false,
//		            		style: {
//		            			fontSize: '12px'
//		            		},
//		            		pointFormat: '<span style="font-size:1em; color: #ffffff; font-weight: bold">{series.name}</span><br><span style="font-size:1em; color: #ffffff; font-weight: bold">待处理：{point.y}</span>',
//		            		positioner: function (labelWidth) {
//		            			return {
//		            				x: 280 - labelWidth / 2,
//		            				y: 60
//		            			};
//		            		}
//		            	},
//		            	pane: {
//		            		startAngle: 0,
//		            		endAngle: 360,
//		            		background: [{ // Track for Move
//		            			outerRadius: '112%',
//		            			innerRadius: '88%',
//		            			backgroundColor: 'rgba(0,0,0,0)',
//		            			//Highcharts.Color(Highcharts.getOptions().colors[1]).setOpacity(0.3).get(),
//		            			borderWidth: 0
//		            		}]
//		            	},
//		            	yAxis: {
//		            		min: 0,
//		            		max: 100,
//		            		lineWidth: 0,
//		            		tickPositions: []
//		            	},
//		            	plotOptions: {
//		            		solidgauge: {
//		            			borderWidth: '12px',
//		            			dataLabels: {
//		            				enabled: false
//		            			},
//		            			linecap: 'round',
//		            			stickyTracking: false
//		            		}
//		            	},
//		            	series: [{
//		            		 name: '报告总数：1,256',
//		            		// borderColor: Highcharts.getOptions().colors[1],
//		            		borderColor:Highcharts.getOptions().colors[1],
//		            		data: [{
//		            			color: 'yellow',
//		            			// color:'yellow',
//		            			radius: '100%',
//		            			innerRadius: '100%',
//		            			y: 80
//		            		}]
//		            	}]
//		            });
					
//		            Highcharts.getOptions().colors = Highcharts.map(colors, function (color) {
//		            	return {
//		            		linearGradient: { x1: 1, x2: 0, y1: 0, y2: 0 },
//		            		stops: [
//		            			[0, 'rgba(6,183,245,1)'],
//		            			[1, 'rgba(6,183,245,0.05)']
//		            		]
//		            	};
//		            });
//		            Highcharts.chart('container2', {
//		            	chart: {
//		            		type: 'solidgauge',
//		            		marginTop: 50,
//		            		backgroundColor: 'rgba(0,0,0,0)'
//		            	},
//		            	credits: {
//		            		enabled:false
//		            	},
//		            	exporting: {
//		            		enabled:false
//		            	},
//		            	title: {
//		            		text:null
//		            	},
//		            	tooltip: {
////		            		enabled : false,
//		            		borderWidth: 0,
//		            		backgroundColor: 'rgba(5,24,36,0.7)',
//		            		shadow: false,
//		            		style: {
//		            			fontSize: '12px'
//		            		},
//		            		pointFormat: '<span style="font-size:1em; color: #ffffff; font-weight: bold">{series.name}</span><br><span style="font-size:1em; color: #ffffff; font-weight: bold">待处理：{point.y}</span>',
//		            		positioner: function (labelWidth) {
//		            			return {
//		            				x: 280 - labelWidth / 2,
//		            				y: 60
//		            			};
//		            		}
//		            	},
//		            	pane: {
//		            		startAngle: 0,
//		            		endAngle: 360,
//		            		background: [{ // Track for Move
//		            			outerRadius: '112%',
//		            			innerRadius: '88%',
//		            			backgroundColor: 'rgba(0,0,0,0)',
//		            			//Highcharts.Color(Highcharts.getOptions().colors[1]).setOpacity(0.3).get(),
//		            			borderWidth: 0
//		            		}]
//		            	},
//		            	yAxis: {
//		            		min: 0,
//		            		max: 100,
//		            		lineWidth: 0,
//		            		tickPositions: []
//		            	},
//		            	plotOptions: {
//		            		solidgauge: {
//		            			borderWidth: '12px',
//		            			dataLabels: {
//		            				enabled: false
//		            			},
//		            			linecap: 'round',
//		            			stickyTracking: false
//		            		}
//		            	},
//		            	series: [{
//		            		 name: '报告总数：1,256',
//		            		// borderColor: Highcharts.getOptions().colors[1],
//		            		borderColor:Highcharts.getOptions().colors[1],
//		            		data: [{
//		            			color: 'yellow',
//		            			// color:'yellow',
//		            			radius: '100%',
//		            			innerRadius: '100%',
//		            			y: 80
//		            		}]
//		            	}]
//		            });
		            
//		            Highcharts.getOptions().colors = Highcharts.map(colors, function (color) {
//		            	return {
//		            		linearGradient: { x1: 1, x2: 0, y1: 0, y2: 0 },
//		            		stops: [
//		            			[0, 'rgba(255,174,0,1)'],
//		            			[1, 'rgba(255,174,0,0.05)']
//		            		]
//		            	};
//		            });
//		            Highcharts.chart('container3', {
//		            	chart: {
//		            		type: 'solidgauge',
//		            		marginTop: 50,
//		            		backgroundColor: 'rgba(0,0,0,0)'
//		            	},
//		            	credits: {
//		            		enabled:false
//		            	},
//		            	exporting: {
//		            		enabled:false
//		            	},
//		            	title: {
//		            		text:null
//		            	},
//		            	tooltip: {
////		            		enabled : false,
//		            		borderWidth: 0,
//		            		backgroundColor: 'rgba(5,24,36,0.7)',
//		            		shadow: false,
//		            		style: {
//		            			fontSize: '12px'
//		            		},
//		            		pointFormat: '<span style="font-size:1em; color: #ffffff; font-weight: bold">{series.name}</span><br><span style="font-size:1em; color: #ffffff; font-weight: bold">待处理：{point.y}</span>',
//		            		positioner: function (labelWidth) {
//		            			return {
//		            				x: 280 - labelWidth / 2,
//		            				y: 60
//		            			};
//		            		}
//		            	},
//		            	pane: {
//		            		startAngle: 0,
//		            		endAngle: 360,
//		            		background: [{ // Track for Move
//		            			outerRadius: '112%',
//		            			innerRadius: '88%',
//		            			backgroundColor: 'rgba(0,0,0,0)',
//		            			//Highcharts.Color(Highcharts.getOptions().colors[1]).setOpacity(0.3).get(),
//		            			borderWidth: 0
//		            		}]
//		            	},
//		            	yAxis: {
//		            		min: 0,
//		            		max: 100,
//		            		lineWidth: 0,
//		            		tickPositions: []
//		            	},
//		            	plotOptions: {
//		            		solidgauge: {
//		            			borderWidth: '12px',
//		            			dataLabels: {
//		            				enabled: false
//		            			},
//		            			linecap: 'round',
//		            			stickyTracking: false
//		            		}
//		            	},
//		            	series: [{
//		            		name: '报告总数：1,256',
//		            		// borderColor: Highcharts.getOptions().colors[1],
//		            		borderColor:Highcharts.getOptions().colors[1],
//		            		data: [{
//		            			color: 'yellow',
//		            			// color:'yellow',
//		            			radius: '100%',
//		            			innerRadius: '100%',
//		            			y: 80
//		            		}]
//		            	}]
//		            });
//		            
//		            Highcharts.getOptions().colors = Highcharts.map(colors, function (color) {
//		            	return {
//		            		linearGradient: { x1: 1, x2: 0, y1: 0, y2: 0 },
//		            		stops: [
//		            			[0, 'rgba(195,38,21,1)'],
//		            			[1, 'rgba(195,38,21,0.05)']
//		            		]
//		            	};
//		            });
//		            Highcharts.chart('container4', {
//		            	chart: {
//		            		type: 'solidgauge',
//		            		marginTop: 50,
//		            		backgroundColor: 'rgba(0,0,0,0)'
//		            	},
//		            	credits: {
//		            		enabled:false
//		            	},
//		            	exporting: {
//		            		enabled:false
//		            	},
//		            	title: {
//		            		text:null
//		            	},
//		            	tooltip: {
////		            		enabled : false,
//		            		borderWidth: 0,
//		            		backgroundColor: 'rgba(5,24,36,0.7)',
//		            		shadow: false,
//		            		style: {
//		            			fontSize: '12px'
//		            		},
//		            		pointFormat: '<span style="font-size:1em; color: #ffffff; font-weight: bold">{series.name}</span><br><span style="font-size:1em; color: #ffffff; font-weight: bold">待处理：{point.y}</span>',
//		            		positioner: function (labelWidth) {
//		            			return {
//		            				x: 280 - labelWidth / 2,
//		            				y: 60
//		            			};
//		            		}
//		            	},
//		            	pane: {
//		            		startAngle: 0,
//		            		endAngle: 360,
//		            		background: [{ // Track for Move
//		            			outerRadius: '112%',
//		            			innerRadius: '88%',
//		            			backgroundColor: 'rgba(0,0,0,0)',
//		            			//Highcharts.Color(Highcharts.getOptions().colors[1]).setOpacity(0.3).get(),
//		            			borderWidth: 0
//		            		}]
//		            	},
//		            	yAxis: {
//		            		min: 0,
//		            		max: 100,
//		            		lineWidth: 0,
//		            		tickPositions: []
//		            	},
//		            	plotOptions: {
//		            		solidgauge: {
//		            			borderWidth: '12px',
//		            			dataLabels: {
//		            				enabled: false
//		            			},
//		            			linecap: 'round',
//		            			stickyTracking: false
//		            		}
//		            	},
//		            	series: [{
//		            		name: '报告总数：1,256',
//		            		// borderColor: Highcharts.getOptions().colors[1],
//		            		borderColor:Highcharts.getOptions().colors[1],
//		            		data: [{
//		            			color: 'yellow',
//		            			// color:'yellow',
//		            			radius: '100%',
//		            			innerRadius: '100%',
//		            			y: 80
//		            		}]
//		            	}]
//		            });
		            
		            map1 = new AMap.Map('div_down_bg4', {
		                mapStyle: mapStyle, //样式URL
		                viewMode: '3D',
		                turboMode: false,
		                resizeEnable: true,
		                zoom: mapzoom,
		                center: [121.475644, 31.1857],
		                features:['bg', 'road', 'building'],
		                pitch: 45,
		                forceVector: true
		            });
		            
		            
					
					
					
//					xData = ["Mo", "Tu", "We","Th","Fr","Sa","Su"];
//					yData = [333, 1230, 425,178,258,674,941];
//					echarts.init(document.getElementById('right_echart2')).setOption({
////						backgroundColor: '#061326',
//					    "grid": {
//					        "top": "25%",
//					        "left": "-5%",
//					        "bottom": "5%",
//					        "right": "5%",
//					        "containLabel": true
//					    },
//					    tooltip:{
//					      show:true 
//					    },
//					    animation: false,
//					    "xAxis": [{
//					        "type": "category",
//					        "data": xData,
//					        "axisTick": {
//					            "alignWithLabel": true
//					        },
//					        "nameTextStyle": {
//					            "color": "#82b0ec"
//					        },
//					        "axisLine": {
//					            show: false,
//					            "lineStyle": {
//					                "color": "#82b0ec"
//					            }
//					        },
//					        "axisLabel": {
//					            "textStyle": {
//					                "color": "#fff"
//					            },
//					            margin: 30
//					        }
//					    }],
//					    "yAxis": [{
//					        show: false,
//					        "type": "value",
//					        "axisLabel": {
//					            "textStyle": {
//					                "color": "#fff"
//					            },
//					        },
//					        "splitLine": {
//					            "lineStyle": {
//					                "color": "#0c2c5a"
//					            }
//					        },
//					        "axisLine": {
//					            "show": false
//					        }
//					    }],
//					    "series": [{
//					            "name": "",
//					            type: 'pictorialBar',
//					            symbolSize: [10, 4],
//					            symbolOffset: [0, -6],
//					            symbolPosition: 'end',
//					            z: 12,
//					            // "barWidth": "0",
//					            "label": {
//					                "normal": {
//					                    "show": true,
//					                    "position": "top",
//					                    // "formatter": "{c}%"
//					                    fontSize: 12,
//					                    fontWeight: 'bold',
//					                    color: '#34DCFF'
//					                }
//					            },
//					            color: "#2DB1EF",
//					            data: yData
//					        },
//					        {
//					            name: '',
//					            type: 'pictorialBar',
//					            symbolSize: [40, 10],
//					            symbolOffset: [0, 7],
//					            // "barWidth": "20",
//					            z: 12,
//					            "color": "#2DB1EF",
//					            "data": yData
//					        },
//					        {
//					            name: '',
//					            type: 'pictorialBar',
//					            symbolSize: [15, 8],
//					            symbolOffset: [0, 12],
//					            z: 10,
//					            itemStyle: {
//					                normal: {
//					                    color: 'transparent',
//					                    borderColor: '#2EA9E5',
//					                    borderType: 'solid',
//					                    borderWidth: 1
//					                }
//					            },
//					            data: yData
//					        },
//					        {
//					            name: '',
//					            type: 'pictorialBar',
//					            symbolSize: [20, 10],
//					            symbolOffset: [0, 18],
//					            z: 10,
//					            itemStyle: {
//					                normal: {
//					                    color: 'transparent',
//					                    borderColor: '#19465D',
//					                    borderType: 'solid',
//					                    borderWidth: 2
//					                }
//					            },
//					            data: yData
//					        },
//					        {
//					            type: 'bar',
//					            //silent: true,
//					            "barWidth": "20",
//					            barGap: '10%', // Make series be overlap
//					            barCateGoryGap: '10%',
//					            itemStyle: {
//					                normal: {
//					                    color: new echarts.graphic.LinearGradient(0, 0, 0, 0.3, [{
//					                            offset: 0,
//					                            color: "rgba(15,182,196,1)"
//					                        },
//					                        {
//					                            offset: 1,
//					                            color: "rgba(26,216,232,1)"
//					                        }
//					                    ]),
//					                    opacity: .8
//					                },
//					            },
//					            data: yData
//					        }
//					    ]
//			        });
					
		            
		            
		            Highcharts.chart('div_right_bg2_tab4', {
		            	chart: {
		            		type: 'solidgauge',
		            		backgroundColor: 'rgba(0,0,0,0)'
		            	},
		            	credits: {
		            		enabled:false
		            	},
		            	exporting: {
		            		enabled:false
		            	},
		            	title: {
		            		text:null
		            	},
		            	tooltip: {
		            		enabled:false,
		            		borderWidth: 0,
		            		backgroundColor: 'none',
		            		shadow: false,
		            		style: {
		            			fontSize: '12px'
		            		},
		            		pointFormat: '{series.name}<br><span style="font-size:1em; color: {point.color}; font-weight: bold">{point.y}%</span>',
		            		positioner: function (labelWidth) {
		            			return {
		            				x: 80 - labelWidth / 2,
		            				y: 60
		            			};
		            		}
		            	},
		            	pane: {
		            		startAngle: 0,
		            		endAngle: 360,
		            		background: [{ // Track for Move
		            			outerRadius: '112%',
		            			innerRadius: '88%',
		            			backgroundColor: 'rgba(0,0,0,0)',
		            			//Highcharts.Color(Highcharts.getOptions().colors[1]).setOpacity(0.3).get(),
		            			borderWidth: 0
		            		}]
		            	},
		            	yAxis: {
		            		min: 0,
		            		max: 100,
		            		lineWidth: 0,
		            		tickPositions: []
		            	},
		            	plotOptions: {
		            		solidgauge: {
		            			borderWidth: '2px',
		            			dataLabels: {
		            				enabled: false
		            			},
		            			linecap: 'round',
		            			stickyTracking: false
		            		}
		            	},
		            	series: [{
		            		// name: 'Move',
		            		// borderColor: Highcharts.getOptions().colors[1],
		            		borderColor:'#147E94',
		            		data: [{
		            			color: 'yellow',
		            			// color:'yellow',
		            			radius: '100%',
		            			innerRadius: '100%',
		            			y: 80
		            		}]
		            	}]
		            });
		            
		            Highcharts.chart('div_right_bg2_tab5', {
		            	chart: {
		            		type: 'solidgauge',
		            		backgroundColor: 'rgba(0,0,0,0)'
		            	},
		            	credits: {
		            		enabled:false
		            	},
		            	exporting: {
		            		enabled:false
		            	},
		            	title: {
		            		text:null
		            	},
		            	tooltip: {
		            		enabled:false,
		            		borderWidth: 0,
		            		backgroundColor: 'none',
		            		shadow: false,
		            		style: {
		            			fontSize: '12px'
		            		},
		            		pointFormat: '{series.name}<br><span style="font-size:1em; color: {point.color}; font-weight: bold">{point.y}%</span>',
		            		positioner: function (labelWidth) {
		            			return {
		            				x: 80 - labelWidth / 2,
		            				y: 60
		            			};
		            		}
		            	},
		            	pane: {
		            		startAngle: 0,
		            		endAngle: 360,
		            		background: [{ // Track for Move
		            			outerRadius: '112%',
		            			innerRadius: '88%',
		            			backgroundColor: 'rgba(0,0,0,0)',
		            			//Highcharts.Color(Highcharts.getOptions().colors[1]).setOpacity(0.3).get(),
		            			borderWidth: 0
		            		}]
		            	},
		            	yAxis: {
		            		min: 0,
		            		max: 100,
		            		lineWidth: 0,
		            		tickPositions: []
		            	},
		            	plotOptions: {
		            		solidgauge: {
		            			borderWidth: '2px',
		            			dataLabels: {
		            				enabled: false
		            			},
		            			linecap: 'round',
		            			stickyTracking: false
		            		}
		            	},
		            	series: [{
		            		// name: 'Move',
		            		// borderColor: Highcharts.getOptions().colors[1],
		            		borderColor:'#95B3CA',
		            		data: [{
		            			color: 'yellow',
		            			// color:'yellow',
		            			radius: '100%',
		            			innerRadius: '100%',
		            			y: 80
		            		}]
		            	}]
		            });
}


var body_resize = function() {
	$("#mask_l").css('height',$(window).innerHeight()+'px');
	$("#mask_r").css('height',$(window).innerHeight()+'px');
	$("#mask_b").css('top',($(window).innerHeight()-100)+'px');
	$("#mask_b").css('width',$(window).innerWidth()+'px');
	$("#mask_t").css('width',$(window).innerWidth()+'px');
	$("#map_header").css('left',($(window).innerWidth()-740)/2+'px');
	$("#map_header").css('height','82px');
	$("#container").css('width',$(window).innerWidth()+'px');
	$("#container").css('height',$(window).innerHeight()+'px');
	var area_height = $(window).innerHeight()-129;
	$("#data_bar_area").css('height',area_height+'px');
	$("#title_right_02").css('height',($(window).innerHeight()-680)+'px');
	draw_all();
	timer_start();
}

Ext.onReady(function(){
	var queryJson = new Object();
	queryJson.V_LOGINNAME = $("#V_LOGINNAME").val();
	queryJson.V_PASSWORD =  $("#V_PASSWORD").val();
	queryJson.company_code = $("#company_code").val();
	
	filterwin = function(spot_id){
		 var query = new Object();
		 query.dwtype = 'YTWP';
         query.company_code = spot_id.currentTarget.company_code;
         query.V_LOGINNAME = $("#V_LOGINNAME").val();
         query.V_PASSWORD =  $("#V_PASSWORD").val();
         var jsonstr = Ext.JSON.encode(query);
            myStore1.getProxy().extraParams = {
             queryJson : jsonstr
            };
         myStore1.reload();
		Ext.create('Ext.window.Window', {
		    title: '今日告警',
		    height: 300,
		    width: 500,
		    modal: true,
		    layout:'border',
		    items: MaintenanceCheckPanel1,
		    buttons:[
		    	{
		    		text:'关闭',
		    		 handler : function() {
		    			 this.up('window').hide();
		    		 }
		    	}
		    ],
		    closeAction: 'hide'
		}).show();
	}
	parent.window.hiding_menu();
	maxHeight =  document.documentElement.clientHeight;
	maxWidth = document.documentElement.clientWidth;
	if(($("#V_LOGINNAME").val().length==0)||($("#V_LOGINNAME").val()=='null')||($("#V_LOGINNAME").val()==null))
		$("#V_LOGINNAME").val(sessionStorage.getItem('V_LOGINNAME'));
	else
		sessionStorage.setItem('V_LOGINNAME',$("#V_LOGINNAME").val());
	if(($("#V_PASSWORD").val().length==0)||($("#V_PASSWORD").val()=='null')||($("#V_PASSWORD").val()==null))
		$("#V_PASSWORD").val(sessionStorage.getItem('V_PASSWORD'));
	else
		sessionStorage.setItem('V_PASSWORD',$("#V_PASSWORD").val());
    baseUrl = $("#basePath").val();
    basePath = $("#baseUrl").val();
    theme = $("#theme").val();
    V_LOGINNAME = $("#V_LOGINNAME").val();
    V_PASSWORD = $("#V_PASSWORD").val();
    viewAlarmType = $("#viewAlarmType").val();
    pieAlarmType = $("#pieAlarmType").val();
    statusType = $("#statusType").val();
    company_code = $("#company_code").val();
    mapStyle = (theme=='default')?'normal':(theme=='gray')?'amap://styles/light':'amap://styles/659dc6c4753dc6e87c65c8a874c02133';
    $("#alarm_wrapper_table").css('left',(($(document).innerWidth()-800)/2)+'px');
    if((theme=='access')||(theme==''))
    	$('#alarm_wrapper').addClass('shadow_black');
    else
    	$('#alarm_wrapper').addClass('shadow_white');
    last_move = Date.parse(new Date());
    company_cur = -1;
    myMask = new Ext.LoadMask(Ext.getBody(), {    
        msg: '查询中，请稍后！',   
        cls:'toplevel',
        removeMask: true //完成后移除    
	}); 
    map = new AMap.Map('container', {
        mapStyle: mapStyle, //样式URL
        viewMode: '3D',
        turboMode: false,
        resizeEnable: true,
        zoom: mapzoom,
        center: [121.475644, 31.1857],
        features:['bg', 'road', 'building'],
        pitch: 45,
        forceVector: true
    });

    map.on('movestart',function(e){
    	clear_detail_info();
    });
    map.on('mousemove',function(e){
    	if(company_cur<0)
    		return;
    	last_move = Date.parse(new Date());
    	company_cur=-1;
    	firstDraw = true;
    	map.setPitch(45);
    	draw_all();
    	LabelShow = true;
    	shower_click();
    	shower_mouseout();
    });
    map.on('complete',function(e){
        getCurrentData();  

    });
    $("#search_company").on('input',function(){
    	update_companyList();
    });
    myMask.show();
    window.onresize=function(){
    	body_resize();
//    	showPingfen('0');
//    	showOperat();
    };
    body_resize();
    initWebSocket();
//    showPingfen('0');
//    showOperat();
});
