function getCvibInfo() {
	if(_CvibTimeId != null) clearTimeout(_CvibTimeId);
	_CvibObjArr = [];
	
	var regionCdArr = [];
	var regionNmArr = [];
	var intNoArr    = [];
	var intNmArr    = [];
	var latArr      = [];
	var lngArr      = [];
	
	if(signalArr.length > 0)
	{
		signalArr.forEach(function(el) {
			if(el.networkType == 1 || el.networkType == 2)
			{
				regionCdArr.push(el.regionCd);
				regionNmArr.push(el.regionNm);
				intNoArr.push(el.intNo);
				intNmArr.push(el.intNm);
				latArr.push(el.Lat);
				lngArr.push(el.Lng);
			}
		});
		
		//console.log('regionCd : ' + regionCdArr[0] + ' , intNo : ' + intNoArr[0]);
		
		if(regionCdArr.length > 0 && intNoArr.length > 0)
		{
			var bottomCvibInfoList = '';
			
			$.ajax({
				type:"POST",
				url:'getCvibInfo.do',
				data:'regionCd=' +regionCdArr+
				     '&intNo=' + intNoArr,
				success: function(data) {
					if(data.length > 0 )
					{
						data.forEach(function(el,idx) {
							_CvibObjArr.push(new CvibInfo(el.REGION_CD, regionNmArr[idx], el.INT_NO, intNmArr[idx], latArr[idx], lngArr[idx],
									el.COLLECT_TIME,el.OPR_TRANS,el.OPR_IND,el.OPR_TURNOFF,el.OPR_BLINK,el.OPR_MANUAL,
									el.ERR_BUS,el.ERR_DB,el.ERR_SCU,el.ERR_CENTER,el.ERR_CONT,el.CYCLE_COUNTER,
									el.DATA_COUNT,el.INT_TIME,el.LIGHT_STS1,el.LIGHT_STS2,el.LIGHT_STS3,el.LIGHT_STS4,
									el.LIGHT_STS5,el.LIGHT_STS6,el.LIGHT_STS7,el.LIGHT_STS8));
						});
					}
					else
					{
						$('#iframeBottomList').contents().find('#cvibBottomInfo').empty();
						_CvibObjArr.forEach(function(el) {
							el.emptyCvibCircleImg();
							el.emptyCvibInfoImg();
						});
						
						_CvibObjArr = [];
					}
					
					//신호를 그린다..
					if(_Level == 0 || _Level == 1)
					{
						_CvibObjArr.forEach(function(el) {
							el.drawCircle();
							el.drawCvibInfo(true);
						});
					}
					
					//하단 cvib리스트 표출
					_CvibObjArr.forEach(function(el) {
						bottomCvibInfoList += '<tr>'+
							'<td style="width:5%">'+el.regionNm+'</td>'+
							'<td style="width:5%"><a href="javascript:goPanToInt(\''+el.intNm+'\','+el.centerPos.Lng+','+el.centerPos.Lat+')">'+el.intNo+'</a></td>'+
							'<td style="width:15%"><a href="javascript:goPanToInt(\''+el.intNm+'\','+el.centerPos.Lng+','+el.centerPos.Lat+')">'+el.intNm+'</a></td>'+
							'<td style="width:10%">'+el.collectTime+'</td>'+
							'<td style="width:3%">'+el.oprTrans+'</td>'+
							'<td style="width:3%">'+el.oprInd+'</td>'+
							'<td style="width:3%">'+el.oprTurnoff+'</td>'+
							'<td style="width:3%">'+el.oprBlink+'</td>'+
							'<td style="width:3%">'+el.oprManual+'</td>'+
							'<td style="width:7%">'+el.errBus+'</td>'+
							'<td style="width:7%">'+el.errDb+'</td>'+
							'<td style="width:7%">'+el.errScu+'</td>'+
							'<td style="width:7%">'+el.errCenter+'</td>'+
							'<td style="width:7%">'+el.errCont+'</td>'+
							'<td style="width:7%">'+el.cycleCounter+'</td>'+
							'<td style="width:8%">'+el.intTime+'</td>'+
						'</tr>';
					});
					$('#iframeBottomList').contents().find('#cvibBottomInfo').empty().html(bottomCvibInfoList);
					
				},
				error: function(e) {
					
				}
			});
		}
		else
		{
			$('#iframeBottomList').contents().find('#cvibBottomInfo').empty();
		}
		
	}
	else
	{
		$('#iframeBottomList').contents().find('#cvibBottomInfo').empty();
	}
	
	_CvibTimeId = setTimeout('getCvibInfo()', 1000 * 1);
}

function CvibInfo(regionCd, regionNm, intNo, intNm, lat, lng, collectTime, oprTrans, oprInd, oprTurnoff, oprBlink, oprManual,
				errBus, errDb, errScu, errCenter, errCont, cycleCounter, dataCount, intTime, 
				lightSts1, lightSts2, lightSts3, lightSts4, lightSts5, lightSts6, lightSts7, lightSts8) {
	this.initialize(regionCd, regionNm, intNo, intNm, lat, lng, collectTime, oprTrans, oprInd, oprTurnoff, oprBlink, oprManual,
				errBus, errDb, errScu, errCenter, errCont, cycleCounter, dataCount, intTime, 
				lightSts1, lightSts2, lightSts3, lightSts4, lightSts5, lightSts6, lightSts7, lightSts8);
}

CvibInfo.prototype = {

	initialize : function(regionCd, regionNm, intNo, intNm, lat, lng, collectTime, oprTrans, oprInd, oprTurnoff, oprBlink, oprManual,
				errBus, errDb, errScu, errCenter, errCont, cycleCounter, dataCount, intTime, 
				lightSts1, lightSts2, lightSts3, lightSts4, lightSts5, lightSts6, lightSts7, lightSts8) {
		this.regionCd = regionCd;
		this.regionNm = regionNm;
		this.intNo = intNo;
		this.intNm = intNm;
		this.collectTime = collectTime;
		this.oprTrans = oprTrans;
		this.oprInd   = oprInd;
		this.oprTurnoff = oprTurnoff;
		this.oprBlink = oprBlink;
		this.oprManual = oprManual;
		this.errBus = errBus;
		this.errDb = errDb;
		this.errScu = errScu;
		this.errCenter = errCenter;
		this.errCont = errCont;
		this.cycleCounter = cycleCounter;
		this.dataCount = dataCount;
		this.intTime = intTime;
		this.lightPosArr = [0,90,180,270,45,135,225,315];
		this.lightStsArr = [lightSts1,lightSts2,lightSts3,lightSts4,lightSts5,lightSts6,lightSts7,lightSts8];
		this.centerPos   = {'Lat':parseFloat(lat), 'Lng':parseFloat(lng)};
	},

	drawCircle : function () {
		this.emptyCvibCircleImg();
		var cvibCircle = new kakao.maps.Circle({
		    center : new kakao.maps.LatLng(this.centerPos.Lat, this.centerPos.Lng),
		    radius: 30,
		    strokeWeight: 1,
		    strokeColor: '#000000',
		    strokeStyle: 'solid',
		    zIndex: 10,
		    map:map
		});

		_CvibCircleImgArr.push(cvibCircle);

	},

	drawCvibInfo : function(clickable) {
		this.emptyCvibInfoImg();
		_CvibInfoImgArr = [];
		/**
			Map 매칭 방안에 따른 방향 코드-신호등정보(미지정(0), 북(1), 동(2), 남(3), 서(4), 북동(5), 남동(6), 남서(7), 북서(8))'
			출력형태 : 미지정(0), 직진(1), 좌회전(2), 보행(3), 자전거(4), 우회전(5), 버스(6), 유턴(7)'
			신호등상태: 소등(0), 적색점등(1), 황색점등(2), 녹색점등(3), 적색점멸(4), 황색점멸(5), 녹색점멸(6)'
		**/
		
		for(var ii = 0; ii < this.lightPosArr.length; ii++)
		{
			if(typeof this.lightStsArr[ii] == 'undefined' || this.lightStsArr[ii].substring(0,3) == '9_9') continue;

			var distanceX = 0.03;
			if((this.lightPosArr[ii] > 0 && this.lightPosArr[ii] < 180) ||
				(this.lightPosArr[ii] > 180 && this.lightPosArr[ii] < 360)) distanceX += 0.0075;

			var sigPos = this.moveCenterPos(this.centerPos,this.lightPosArr[ii],distanceX);

			var position = new kakao.maps.LatLng(sigPos.lat, sigPos.lng);
			var overlayId = 'cvib_' + this.intNo + '_' + this.lightPosArr[ii];

			var lightImg = this.lightStsArr[ii].substring(0,3);

			var content = '<div style="width:80px;height:27px;background-image:url(\'/images/cvib/CvibLight_'+lightImg+'.gif\')"'+
			               ' onclick="cvibInfoDetail('+clickable+',\''+this.regionCd+'\',\''+this.intNo+'\')" id="'+overlayId+'"></div>';
	    	var cvibOverlay = new kakao.maps.CustomOverlay({
	            content: content,
	            position: position,
	            map: map
	        });

	    	$('#'+overlayId).parent().css({'transform': 'rotate('+this.lightPosArr[ii]+'deg)'});

	        _CvibInfoImgArr.push(cvibOverlay);
		}

	},

	moveCenterPos : function(pos, deg, distanceX) {
		var distanceY = 0.03;

		var rad = deg.toRadians();
		var deltaLat = distanceY * Math.cos(rad);
		var deltaLng = distanceX * Math.sin(rad);

		deltaLat = (deltaLat * 360) / 40000;
		deltaLng = (deltaLng * 360) / 40000;
		var lat = pos.Lat + deltaLat;
		var lng = pos.Lng + deltaLng;
		
		return {'lat':lat,'lng':lng};
	},
	
	emptyCvibCircleImg : function() {
		_CvibCircleImgArr.forEach(function(el) {
			el.setMap(null);
		});
	},
	
	emptyCvibInfoImg : function() {
		_CvibInfoImgArr.forEach(function(el) {
			el.setMap(null);
		});
	}
	
}

function cvibInfoDetail(clickable,regionCd,intNo) {
	if(clickable)
	{
		var url = 'cvibInfoDetail.do?regionCd='+regionCd+'&intNo='+intNo;
		var options = 'scrollbars=no,toolbar=no,location=no,resizable=no,status=no,menubar=no,width=1300px,height=645px,left=0,top=0';
		_CvibInfoDetailPop = window.open(url,'cvibChild',options);
	}
}
