$(function(){

	
	
	
	EventSum();
	function EventSum(){
		$.ajax({
			   type: "GET",
			   url: "getEventSum.do",
			   dataType : "json",
			   success: function(data){
				 eventSum(data)
			   }
			});
	}

	function eventSum(data){
		eventSum=data['rows'];
		if(eventSum.length>0){
			var sum1=0,sum2=0,sum3=0,sum4=0;
			for(var i=0;i<eventSum.length;i++){
				if("130"==eventSum[i]['name']){
					sum1=eventSum[i]['sum']; 
				}
				if("220"==eventSum[i]['name']){
					sum2=eventSum[i]['sum']; 
				}
				if("111"==eventSum[i]['name']){
					sum3=eventSum[i]['sum']; 
				}
				if("115"==eventSum[i]['name']){
					sum4=eventSum[i]['sum']; 
				}
			}
			
			var div='<p id="blink">'+
					'<a href="javascript:void(0)" class="blink_font" >'+
						'<img src="assets/images/icon_dlyh.png" style="display: block;top:18px;left:10px;position: absolute;">'+
						'<span style="top:20px;left:35px;position: absolute;"><font color="black">施工养护'+
						'</font><span style="color:red">'+sum1+
						'</span>'+
						'<font color="black">件</font></span>'+
					'</a>'+
					'<a href="javascript:void(0)" class="blink_font1" >'+
						'<img src="assets/images/icon_jtsg.png" style="display: block;top:47px;left:9px;position: absolute;">'+
						'<span style="top:50px;left:35px;position: absolute;"><font color="black">交通事故'+
						'</font><span style="color:red">'+sum2+
						'</span><font color="black">件</font></span>'+
					'</a>'+
					'<a href="javascript:void(0)" class="blink_font2" >'+
						'<img src="assets/images/icon_jtgz.png" style="display: block;top:77px;left:9px;position: absolute;">'+
						'<span style="top:80px;left:35px;position: absolute;"><font color="black">车辆故障'+
						'</font><span style="color:red">'+sum3+
						'</span><font color="black">件</font></span>'+
					'</a>'+
					'<a href="javascript:void(0)" class="blink_font3" >'+
						'<img src="assets/images/icon_whwp.png" style="display: block;top:105px;left:9px;position: absolute;">'+
						'<span style="top:108px;left:35px;position: absolute;"><font color="black">危化品事故处理'+
						'</font><span style="color:red">'+sum4+
						'</span><font color="black">件</font></span>'+
					'</a>'+
					'</p>';
			  $("#newgz").append(div);
			
			
			$(".blink_font").click(function(){
				$.ajax({
					type:"POST",
					url:"getEventTypeList.do",
					dataType:"json",
					data:{ sjlxid:'130'},
					success:function(data){
						//eventType(data);
						$(".span1").css('display','block');
						$(".span2").css('display','none');
						$(".span3").css('display','none');
						$(".span4").css('display','none');
						
						/***************************************************************/
						eventTypeList=data['result'];
						 $("#scrollUl").empty();
						if(eventTypeList.length>0){
							for(i = 0;i < eventTypeList.length;i++){
								var eventList = eventTypeList[i];
								
								var div=
								'<li>事件时间：'+eventList['time']+
								'<br>事件位置：'+eventList['ldmc']+ '<br>事件来源：'+eventList['sname']+'<br>事件描述：'+eventList['content']+
								'</li>';
								$("#scrollUl").append(div);
								$(".tab_right").show();	
								
							}
							
							var chWidth = $('#scrollDiv').width();
							var len = $('#scrollDiv>ul>li').length;
							$("#scrollDiv>ul>li").css('width',chWidth);
							$("#scrollDiv>ul").css('width',chWidth*(len));
							var index = 0;
							var pictime;
							var btn = '<div class="prenext pre"></div><div class="prenext next"></div>';

							$('#tab_con').append(btn);

							$('.prenext').css('opacity',0.8).hover(function() {
								$(this).stop().animate({'opacity':'0.5'}, 300)
							}, function() {
								$(this).stop().animate({'opacity':'0.8'}, 300)
							});
							$('.next').click(function() {
								index += 1;
								if (index==len) {
									index = 0;
								};
								showPic(index);
							});
							$('.pre').click(function() {
								 if(index!=0){
									index -= 1;
									if (index==-1) {
										index = len-1;
									};
										showPic(index);
								  }
							});
							$(".tab_con_close").click(function(){
								$("#JTspan1").css('display','none');
								$(".tab_right").hide();
								clearInterval(pictime);
								pictime=null;
								$("#scrollUl").empty();
								$("#scrollUl").css('left','0px');
								
							});
							$('#tab_con').hover(function() {
								   clearInterval(pictime);
								   $('.prenext').show();
							    }, function() {
								if($("#JTspan1").css("display")=='block'){
								    pictime = setInterval(function(){
									showPic(index);
									index++;
									if (index==len) {index=0};
								},4000)
								$('.prenext').hide();
							  }
							}).trigger('mouseleave');
							function showPic(index){
//								alert("jiao:"+index);
								var nowleft = -index*chWidth;
								$('#scrollDiv>ul').stop().animate({'left':nowleft}, 300);
							};
						
						}
						
						/*****************************************************************/
						
						
					}
				});
			});
			$(".blink_font1").click(function(){
				$.ajax({
					type:"POST",
					url:"getEventTypeList.do",
					dataType:"json",
					data:{ sjlxid:'220'},
					success:function(data){
						//DaoluType(data);
						$(".span2").css('display','block');
						$(".span1").css('display','none');
						$(".span3").css('display','none');
						$(".span4").css('display','none');
						
						/************************************************/
						var DaoluTypeList=data['result'];
						 $("#scrollUl").empty();
						if(DaoluTypeList.length>0){
							for(i = 0;i < DaoluTypeList.length;i++){
								var DaoluList = DaoluTypeList[i];
								
								var div=
								'<li>事件时间：'+DaoluList['time']+
								'<br>事件位置：'+DaoluList['ldmc']+ '<br>事件来源：'+DaoluList['sname']+'<br>事件描述：'+DaoluList['content']+
								'</li>';
								$("#scrollUl").append(div);
								$(".tab_right").show();	
								
							}
							
							var chWidth = $('#scrollDiv').width();
							var len = $('#scrollDiv>ul>li').length;
							$("#scrollDiv>ul>li").css('width',chWidth);
							$("#scrollDiv>ul").css('width',chWidth*(len));
							var index = 0;
							var btn = '<div class="prenext pre"></div><div class="prenext next"></div>';
							var picdaolutime;
							$('#tab_con').append(btn);

							$('.prenext').css('opacity',0.8).hover(function() {
								$(this).stop().animate({'opacity':'0.5'}, 300)
							}, function() {
								$(this).stop().animate({'opacity':'0.8'}, 300)
							});
							$('.next').click(function() {
								index += 1;
								if (index==len) {
									index = 0;
								};
								showPic(index);
							});
							$('.pre').click(function() {
								if(index!=0){
									index -= 1;
									if (index==-1) {
										index = len-1;
									};
										showPic(index);
								}
							});
							$(".tab_con_close").click(function(){
								$("#DLspan1").css('display','none');
								$(".tab_right").hide();
								clearInterval(picdaolutime);
								picdaolutime=null;
								$("#scrollUl").empty();
								$("#scrollUl").css('left','0px');
								
							});
							$('#tab_con').hover(function() {
							   clearInterval(picdaolutime);
							   $('.prenext').show();
						    }, function() {
							if($("#DLspan1").css("display")=='block'){
								picdaolutime = setInterval(function(){
								showPic(index);
								index++;
								if (index==len) {index=0};
							},4000)
							$('.prenext').hide();
						  }
						}).trigger('mouseleave');							
							function showPic(index){
								//alert("daolu:"+index);
								var nowleft = -index*chWidth;
								$('#scrollDiv>ul').stop().animate({'left':nowleft}, 300);
							};
						
						}
						
						
						/************************************************/
						
					}
				});
			});
			$(".blink_font2").click(function(){
				$.ajax({
					type:"POST",
					url:"getEventTypeList.do",
					dataType:"json",
					data:{ sjlxid:'111'},
					success:function(data){
						//eventType(data);
						$(".span3").css('display','block');
						$(".span2").css('display','none');
						$(".span1").css('display','none');
						$(".span4").css('display','none');
						/***************************************************************/
						eventTypeList=data['result'];
						 $("#scrollUl").empty();
						if(eventTypeList.length>0){
							for(i = 0;i < eventTypeList.length;i++){
								var eventList = eventTypeList[i];
								
								var div=
								'<li>事件时间：'+eventList['time']+
								'<br>事件位置：'+eventList['ldmc']+ '<br>事件来源：'+eventList['sname']+'<br>事件描述：'+eventList['content']+
								'</li>';
								$("#scrollUl").append(div);
								$(".tab_right").show();	
								
							}
							
							var chWidth = $('#scrollDiv').width();
							var len = $('#scrollDiv>ul>li').length;
							$("#scrollDiv>ul>li").css('width',chWidth);
							$("#scrollDiv>ul").css('width',chWidth*(len));
							var index = 0;
							var pictime;
							var btn = '<div class="prenext pre"></div><div class="prenext next"></div>';

							$('#tab_con').append(btn);

							$('.prenext').css('opacity',0.8).hover(function() {
								$(this).stop().animate({'opacity':'0.5'}, 300)
							}, function() {
								$(this).stop().animate({'opacity':'0.8'}, 300)
							});
							$('.next').click(function() {
								index += 1;
								if (index==len) {
									index = 0;
								};
								showPic(index);
							});
							$('.pre').click(function() {
								if(index!=0){
									index -= 1;
									if (index==-1) {
										index = len-1;
									};
										showPic(index);
								}
							});
							$(".tab_con_close").click(function(){
								$("#CLspan1").css('display','none');
								$(".tab_right").hide();
								clearInterval(pictime);
								pictime=null;
								$("#scrollUl").empty();
								$("#scrollUl").css('left','0px');
								
							});
							$('#tab_con').hover(function() {
								   clearInterval(pictime);
								   $('.prenext').show();
							    }, function() {
								if($("#CLspan1").css("display")=='block'){
								    pictime = setInterval(function(){
									showPic(index);
									index++;
									if (index==len) {index=0};
								},4000)
								$('.prenext').hide();
							  }
							}).trigger('mouseleave');
							function showPic(index){
//								alert("jiao:"+index);
								var nowleft = -index*chWidth;
								$('#scrollDiv>ul').stop().animate({'left':nowleft}, 300);
							};
						
						}
						
						/*****************************************************************/
						
						
					}
				});
			});
			$(".blink_font3").click(function(){
				$.ajax({
					type:"POST",
					url:"getEventTypeList.do",
					dataType:"json",
					data:{ sjlxid:'115'},
					success:function(data){
						//eventType(data);
						$(".span4").css('display','block');
						$(".span2").css('display','none');
						$(".span1").css('display','none');
						$(".span3").css('display','none');
						/***************************************************************/
						eventTypeList=data['result'];
						 $("#scrollUl").empty();
						if(eventTypeList.length>0){
							for(i = 0;i < eventTypeList.length;i++){
								var eventList = eventTypeList[i];
								
								var div=
								'<li>事件时间：'+eventList['time']+
								'<br>事件位置：'+eventList['ldmc']+ '<br>事件来源：'+eventList['sname']+'<br>事件描述：'+eventList['content']+
								'</li>';
								$("#scrollUl").append(div);
								$(".tab_right").show();	
								
							}
							
							var chWidth = $('#scrollDiv').width();
							var len = $('#scrollDiv>ul>li').length;
							$("#scrollDiv>ul>li").css('width',chWidth);
							$("#scrollDiv>ul").css('width',chWidth*(len));
							var index = 0;
							var pictime;
							var btn = '<div class="prenext pre"></div><div class="prenext next"></div>';

							$('#tab_con').append(btn);

							$('.prenext').css('opacity',0.8).hover(function() {
								$(this).stop().animate({'opacity':'0.5'}, 300)
							}, function() {
								$(this).stop().animate({'opacity':'0.8'}, 300)
							});
							$('.next').click(function() {
								index += 1;
								if (index==len) {
									index = 0;
								};
								showPic(index);
							});
							$('.pre').click(function() {
								if(index!=0){
									index -= 1;
									if (index==-1) {
										index = len-1;
									};
										showPic(index);
								}
							});
							$(".tab_con_close").click(function(){
								$("#WHPspan1").css('display','none');
								$(".tab_right").hide();
								clearInterval(pictime);
								pictime=null;
								$("#scrollUl").empty();
								$("#scrollUl").css('left','0px');
								
							});
							$('#tab_con').hover(function() {
								   clearInterval(pictime);
								   $('.prenext').show();
							    }, function() {
								if($("#WHPspan1").css("display")=='block'){
								    pictime = setInterval(function(){
									showPic(index);
									index++;
									if (index==len) {index=0};
								},4000)
								$('.prenext').hide();
							  }
							}).trigger('mouseleave');
							function showPic(index){
//								alert("jiao:"+index);
								var nowleft = -index*chWidth;
								$('#scrollDiv>ul').stop().animate({'left':nowleft}, 300);
							};
						
						}
						
						/*****************************************************************/
						
						
					}
				});
			});
		}else{
			 var div='<p id="blink">'+
				'<a href="javascript:void(0)" class="blink_font" >'+
					'<img src="assets/images/sg_min.png" style="width:18px;height: 18px;display: block;top:18px;left:10px;position: absolute;">'+
					'<span style="top:20px;left:35px;position: absolute;"><font color="black">交通事故'+
					'</font><span style="color:red">0'+
					'</span>'+
					'<font color="black">件</font></span>'+
				'</a>'+
				'<a href="javascript:void(0)" class="blink_font1" >'+
					'<img src="assets/images/sj_sgyh.png" style="width:20px;height: 20px;display: block;top:47px;left:9px;position: absolute;">'+
					'<span style="top:50px;left:35px;position: absolute;"><font color="black">道路养护'+
					'</font><span style="color:red">0'+
					'</span><font color="black">件</font></span>'+
				'</a>'+
				'<a href="javascript:void(0)" class="blink_font2" >'+
					'<img src="assets/images/jiaotonggz2.png" style="width:20px;height: 20px;display: block;top:77px;left:9px;position: absolute;">'+
					'<span style="top:80px;left:35px;position: absolute;"><font color="black">车辆故障'+
					'</font><span style="color:red">0'+
					'</span><font color="black">件</font></span>'+
				'</a>'+
				'<a href="javascript:void(0)" class="blink_font3" >'+
					'<img src="assets/images/weihua2.png" style="width:20px;height: 20px;display: block;top:105px;left:9px;position: absolute;">'+
					'<span style="top:108px;left:35px;position: absolute;"><font color="black">危化品事故处理'+
					'</font><span style="color:red">0'+
					'</span><font color="black">件</font></span>'+
				'</a>'+
				'</p>';
		  $("#newgz").append(div);
		  
		  $(".blink_font").click(function(){
			  $.messager.alert('提示','暂无数据','info');
		  });
		  $(".blink_font1").click(function(){
			  $.messager.alert('提示','暂无数据','info');
		  });
		  $(".blink_font2").click(function(){
			  $.messager.alert('提示','暂无数据','info');
		  });
		  $(".blink_font3").click(function(){
			  $.messager.alert('提示','暂无数据','info');
		  });
		}
		
		
	}
	
	
})

