

/*

 * 전체 신호제어기를 메모리에 저장해서 등록함(Bean 으로 등록하면 됨)

 */

var _mapSignal = new HashMap();



var _circleSize = 25;    //서클사이즈

var _circleStroke = 4;   //서클두께

var _imgW = 55;         //보행자이미지 가로

var _imgH = 55;         //보행자이미지 세로

var _lightBlinkImgSrc = 'images/lightBlink_55.gif';

var _pedeImgSrc = 'images/walking_55.png'; //보행자이미지

var _imgOffSetW = 27; //보행자 이미지 가로중심점

var _imgOffsetH = 27; //보행자 이미지 세로중심점



var listDrawSignal = [];

var signalALineArr = [];

var signalBLineArr = [];

var signalBackCircleArr = [];

var signalInfoId = null;

var sigInfowindow = null;



var signalArr = [];

var sigDataArr = [];

var aRingPhaseValArr = [];

var bRingPhaseValArr = [];

var aRingPhaseArr = [];

var bRingPhaseArr = [];

var aRingLinkVtxArr = [];

var bRingLinkVtxArr = [];

var linkLineArr = [];



var getPhaseTimeId = null;



//팝업변수

var sigMap;

var _mapSignalPoP = new HashMap();

var listDrawSignalPoP = [];



var signalLineArrPoP = [];

var signalCircleArrPoP = [];

var signalInfoIdPoP = null;

var sigInfowindowPoP = null;

var getPhaseTimeIdPoP = null;



var signalArrPoP = [];

var aRingPhaseValArrPoP = [];

var bRingPhaseValArrPoP = [];

var aRingPhaseArrPoP = [];

var bRingPhaseArrPoP = [];



var mapCircleMeta;

var sigPopFlag = true;

var _XCoord = '126.978087';

var _YCoord = '37.564684';

var popMapPhaseArr = [];

var getSigPopMobId = null;

var sigPopMobId = false;

var clickEventId = true;



var _CommOnOffFlag;

var _IntSigCycleCnt;

var _IntSigCycleLen;



var _SigPopMobFirst = null;



function mapSigZoomBound() {

	var intSig = $("#intSig").attr("class");

	if(intSig.indexOf("road_on") !== -1)

	{

		if(sigInfowindow != null) sigInfowindow.close();

		

		emptySignalArr(signalBackCircleArr);

		emptySignalArr(signalALineArr);

		emptySignalArr(signalBLineArr);

		

		signalBackCircleArr = [];

		signalALineArr      = [];

		signalBLineArr      = [];

		

		level = map.getLevel();

		if(level < 6)

		{

			if(level == 0)

			{

				_circleSize = 20;    //원지름

				_circleStroke = 14;   //원두께

				_imgW = 335;

				_imgH = 335;

				_lightBlinkImgSrc = 'images/lightBlink_175.gif';

				_pedeImgSrc = 'images/walking_175.png';

				_imgOffSetW = 168;

				_imgOffsetH = 168;

			}

			else if(level == 1)

			{

				_circleSize = 20;    //원지름

				_circleStroke = 10;   //원두께

				_imgW = 175;

				_imgH = 175;

				_lightBlinkImgSrc = 'images/lightBlink_175.gif';

				_pedeImgSrc = 'images/walking_175.png';

				_imgOffSetW = 86;

				_imgOffsetH = 86;

			}

			else if(level == 2)

			{

				_circleSize = 20;

				_circleStroke = 6;

				_imgW = 90;

				_imgH = 90;

				_lightBlinkImgSrc = 'images/lightBlink_90.gif';

				_pedeImgSrc = 'images/walking_90.png';

				_imgOffSetW = 45;

				_imgOffsetH = 45;

			}

			else if(level == 3)

			{

				_circleSize = 25;

				_circleStroke = 4;

				_imgW = 55;

				_imgH = 55;

				_lightBlinkImgSrc = 'images/lightBlink_55.gif';

				_pedeImgSrc = 'images/walking_55.png';

				_imgOffSetW = 27;

				_imgOffsetH = 27;

			}

			else if(level == 4)

			{

				_circleSize = 30;

				_circleStroke = 3;

				_imgW = 33;

				_imgH = 33;

				_lightBlinkImgSrc = 'images/lightBlink_33.gif';

				_pedeImgSrc = 'images/walking_33.png';

				_imgOffSetW = 17;

				_imgOffsetH = 17;

			}

			

			getSignalInfo();

		}

		else 

		{

			if(signalArr != null)

			{

				signalArr.forEach(function(el) {

					el.mapCircle.setMap(null);

				});

				

				signalArr = 0;

				signalArr = [];

			}

			

			if(getPhaseTimeId != null) clearTimeout(getPhaseTimeId);

		}

	}

	

}



function mapSigMoveBound() 

{

	if (UserAgent.match(/iPhone|iPod|Android|Windows CE|BlackBerry|Symbian|Windows Phone|webOS|Opera Mini|Opera Mobi|POLARIS|IEMobile|lgtelecom|nokia|SonyEricsson/i) != null || UserAgent.match(/LG|SAMSUNG|Samsung/) != null)

	{

		

	}

	else

	{

		if(sigInfowindow != null) sigInfowindow.close();

		var intSig = $("#intSig").attr("class");

		if(intSig.indexOf("road_on") !== -1)

		{

			if(level < 6)

			{

				getSignalInfo();

			}

		}

	}

	

}



function emptySignalArr(arr) {

	if(arr != null) 

	{

		arr.forEach(function(el) {

			el.setMap(null);

		});

		arr = 0;

	}

}



function getSignalInfo() {

	if(getPhaseTimeId != null) clearTimeout(getPhaseTimeId);

	

	var option = {

			url		 : 'main/getSignalInfo.do',

			param	 : {

				minX : map.getBounds().getSouthWest().getLng(),

				minY : map.getBounds().getSouthWest().getLat(),

				maxX : map.getBounds().getNorthEast().getLng(),

				maxY : map.getBounds().getNorthEast().getLat()

			},

			callback : getSignalInfoCallback

	}

	// ajax로 요청

	callService(option);

	

	if(this.level < 6)

	{

		getPhaseTimeId = setTimeout('getSignalInfo()',1000 * 5);

	}

	else

	{

		if(getPhaseTimeId != null) clearTimeout(getPhaseTimeId);

	}



}



function getSignalInfoCallback(json) {

	

	//신호표시 바깥원을 지운다..

	_mapSignal.clear();

	if(signalArr != null)

	{

		signalArr.forEach(function(el) {

			el.mapCircle.setMap(null);

		});

		

		signalArr = 0;

		signalArr = [];

	}

	

	//신호 페이즈정보 삭제..

	emptySignalArr(signalBackCircleArr);

	emptySignalArr(signalALineArr);

	emptySignalArr(signalBLineArr);

	

	signalArr = [];

	signalBackCircleArr = [];

	signalALineArr      = [];

	signalBLineArr      = [];

	

	aRingPhaseValArr = [];

	bRingPhaseValArr = [];

	aRingPhaseArr    = [];

	bRingPhaseArr    = [];

	sigDataArr       = [];

	

	_ALineCenterArr = 0;

	_BLineCenterArr = 0;

	_ALineCenterArr = [];

	_BLineCenterArr = [];

	if($("#intSig").attr("class").indexOf("road_on") === -1){
		return;
	}

	var obj = json.data.list;

	if(obj.length > 0 )

	{

		for(var ii = 0; ii < obj.length; ii++)

		{

			var regionCd = obj[ii].REGION_CD;

			var regionNm = obj[ii].REGION_NM;

			var intNo    = obj[ii].INT_NO;

			var intNm    = obj[ii].INT_NM;

			var xCoord   = obj[ii].X_COORD;

			var yCoord   = obj[ii].Y_COORD;

			

			var aRing0 = obj[ii].A_RING_1_PHASE_CONF_CD;

			var aRing1 = obj[ii].A_RING_2_PHASE_CONF_CD;

			var aRing2 = obj[ii].A_RING_3_PHASE_CONF_CD;

			var aRing3 = obj[ii].A_RING_4_PHASE_CONF_CD;

			var aRing4 = obj[ii].A_RING_5_PHASE_CONF_CD;

			var aRing5 = obj[ii].A_RING_6_PHASE_CONF_CD;

			var aRing6 = obj[ii].A_RING_7_PHASE_CONF_CD;

			var aRing7 = obj[ii].A_RING_8_PHASE_CONF_CD;

			var bRing0 = obj[ii].B_RING_1_PHASE_CONF_CD;

			var bRing1 = obj[ii].B_RING_2_PHASE_CONF_CD;

			var bRing2 = obj[ii].B_RING_3_PHASE_CONF_CD;

			var bRing3 = obj[ii].B_RING_4_PHASE_CONF_CD;

			var bRing4 = obj[ii].B_RING_5_PHASE_CONF_CD;

			var bRing5 = obj[ii].B_RING_6_PHASE_CONF_CD;

			var bRing6 = obj[ii].B_RING_7_PHASE_CONF_CD;

			var bRing7 = obj[ii].B_RING_8_PHASE_CONF_CD;

			

			var collctDtime = obj[ii].COLLCT_DTIME;                   //수집일시

			var commOnOffFlag = obj[ii].COMM_ON_OFF_FLAG;             //통신ON/OFF여부

			var contrlrOperModeCd = obj[ii].CONTRLR_OPER_MODE_CD;     //제어기운영모드코드

			var aRingPhaseVal = obj[ii].A_RING_PHASE_VAL;             //A링 현시값

			var bRingPhaseVal = obj[ii].B_RING_PHASE_VAL;             //B링 현시값

			var siglightTurnoffFlag = obj[ii].SIGLIGHT_TURNOFF_FLAG;  //신호등소등여부   

			var siglightBlinkFlag = obj[ii].SIGLIGHT_BLINK_FLAG;      //신호등점멸여부

			var contrlrManualFlag = obj[ii].CONTRLR_MANUAL_FLAG;      //제어기수동여부

			var contrlrTmdiffContrlFlag = obj[ii].CONTRLR_TMDIFF_CONTRL_FLAG;

			var intSigCycleCnt = obj[ii].INT_SIG_CYCLE_CNT;           //교차로 신호주기 카운트

			var intSigCycleLen = obj[ii].INT_SIG_CYCLE_LEN;           //교차로 신호주기 값

			var groupNo = obj[ii].GROUP_NO;

			var mapNo = obj[ii].MAP_NO;

			var cdNo = regionCd+intNo;

			

			//제어기 상태 색상변경..

			var strokeColor = '#0000FF';

			var fillColor;

			

			if(contrlrManualFlag == 1) fillColor = '#03fdee'; //수동

			else fillColor = '#ffffff';



			if(contrlrOperModeCd == 1 || contrlrOperModeCd == 2) //오프라인

			{

				if(contrlrOperModeCd == 2)

				{

					strokeColor = '#FF0000';

					fillColor = '#666666';

				}

				//시차제 인경우

				if(contrlrTmdiffContrlFlag == 1) strokeColor = '#FF00FF'; //핑크

			}

			else if(contrlrOperModeCd == 4 || contrlrOperModeCd == 5) //온라인

			{

				if(contrlrOperModeCd == 4)

				{

					strokeColor = '#FF0000'; //red

				}



				//시차제 인경우

				if(contrlrTmdiffContrlFlag == 1) strokeColor = '#FF00FF'; //핑크

			}

			

			var signal = findSignal(cdNo);

			if(_mapSignal.containsKey(cdNo) == false) 

			{

				signal = new Signal(yCoord, xCoord, strokeColor, fillColor, regionCd, regionNm, intNo, intNm, groupNo, mapNo, commOnOffFlag, intSigCycleCnt, intSigCycleLen);

				addSignal(cdNo,signal);

			}

			else

			{

				signal.mapCircle.setOptions({

					strokeColor: strokeColor,

					fillColor: fillColor

				});

			}

			//페이즈 구분을 해주자...

			signalArr.push(signal);

			if(level < 5)

			{

				aRingPhaseValArr.push(aRingPhaseVal);

				bRingPhaseValArr.push(bRingPhaseVal);

				aRingPhaseArr.push(new ringPhaseData(aRing0,aRing1,aRing2,aRing3,aRing4,aRing5,aRing6,aRing7));

				bRingPhaseArr.push(new ringPhaseData(bRing0,bRing1,bRing2,bRing3,bRing4,bRing5,bRing6,bRing7));

				sigDataArr.push(new sigMetaData(regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,collctDtime,commOnOffFlag,contrlrOperModeCd,siglightTurnoffFlag,siglightBlinkFlag,contrlrManualFlag,groupNo,mapNo));

			}

		}

			

		if(level < 5) setRingPhase();

	}

}



function setRingPhase()

{

	if(sigPopMobId == false)

	{

		if(sigInfowindow != null) sigInfowindow.close();

		if(getSigPopMobId != null) clearInterval(getSigPopMobId);

	}

		

	var aRingDeg;

	var bRingDeg;

	

	var aRingLinkVtx;

	var bRingLinkVtx;

	

	for(var ii = 0; ii < signalArr.length; ii++)

	{

		var regionCd       = sigDataArr[ii].regionCd;

		var regionNm       = sigDataArr[ii].regionNm;

		var intNo          = sigDataArr[ii].intNo;

		var intNm          = sigDataArr[ii].intNm;

		var intSigCycleCnt = sigDataArr[ii].intSigCycleCnt;

		var intSigCycleLen = sigDataArr[ii].intSigCycleLen; 

		var commOnOffFlag   = sigDataArr[ii].commOnOffFlag;

		var siglightTurnoffVal = sigDataArr[ii].siglightTurnoffFlag;

		var siglightBlinkVal = sigDataArr[ii].siglightBlinkFlag;

		var contrlrManualVal = sigDataArr[ii].contrlrManualFlag;

		var groupNo = sigDataArr[ii].groupNo;

		var mapNo = sigDataArr[ii].mapNo;

		var aRingVal;

		var bRingVal;

		

		if(commOnOffFlag == 1) signalArr[ii].setPhase('commOff',null,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo);

		else if(siglightTurnoffVal == 1) signalArr[ii].setPhase('siglightTurnoff',null,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo);

		else if(siglightBlinkVal == 1) signalArr[ii].setPhase('siglightBlink',null,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo);

		else

		{

			aRingVal = aRingPhaseValArr[ii];

			bRingVal = bRingPhaseValArr[ii];

			

			if(aRingVal == 0) aRingDeg = aRingPhaseArr[ii].ring0;

			else if(aRingVal == 1) aRingDeg = aRingPhaseArr[ii].ring1;

			else if(aRingVal == 2) aRingDeg = aRingPhaseArr[ii].ring2;

			else if(aRingVal == 3) aRingDeg = aRingPhaseArr[ii].ring3;

			else if(aRingVal == 4) aRingDeg = aRingPhaseArr[ii].ring4;

			else if(aRingVal == 5) aRingDeg = aRingPhaseArr[ii].ring5;

			else if(aRingVal == 6) aRingDeg = aRingPhaseArr[ii].ring6;

			else if(aRingVal == 7) aRingDeg = aRingPhaseArr[ii].ring7;

			else aRingDeg = '';

			

			if(bRingVal == 0) bRingDeg = bRingPhaseArr[ii].ring0;

			else if(bRingVal == 1) bRingDeg = bRingPhaseArr[ii].ring1;

			else if(bRingVal == 2) bRingDeg = bRingPhaseArr[ii].ring2;

			else if(bRingVal == 3) bRingDeg = bRingPhaseArr[ii].ring3;

			else if(bRingVal == 4) bRingDeg = bRingPhaseArr[ii].ring4;

			else if(bRingVal == 5) bRingDeg = bRingPhaseArr[ii].ring5;

			else if(bRingVal == 6) bRingDeg = bRingPhaseArr[ii].ring6;

			else if(bRingVal == 7) bRingDeg = bRingPhaseArr[ii].ring7;

			else bRingDeg = '';

			

			signalArr[ii].setPhase(aRingDeg, bRingDeg, regionCd, regionNm, intNo, intNm, intSigCycleCnt, intSigCycleLen, commOnOffFlag, groupNo, mapNo);

		}

	}

	

}



function findSignal(Id) {

	return _mapSignal.get(Id);

};



function addSignal(Id, Obj) {

	_mapSignal.put(Id, Obj);

	return _mapSignal.size();

};



Number.prototype.toRadians = function() { 

	return this * 0.017453293; 

};

Number.prototype.toDegrees = function() { 

	return this * 57.29577951; 

};



function SCoord(Lat, Lng) {

	this.Lat = parseFloat(Lat);

	this.Lng = parseFloat(Lng);

};



/*

 * 실제 신호 Phase를 그리는 Class

 */

function SignalDraw(ringA, ringB, lat, lng, regionCd, regionNm, intNo, intNm, intSigCycleCnt, intSigCycleLen, commOnOffFlag, groupNo, mapNo) {

	this.initialize(ringA, ringB, lat, lng, regionCd, regionNm, intNo, intNm, intSigCycleCnt, intSigCycleLen, commOnOffFlag, groupNo, mapNo);

};



SignalDraw.prototype = {

		ringA : null,

	    ringB : null,

	    Lat : 0,

		Lng : 0,

		regionCd : null,

		regionNm : null,

		intNo : null,

		intNm : null,

		intSigCycleCnt : 0,

		intSigCycleLen : 0,

		commOnOffFlag : null,

		groupNo : 0,

		mapNo : 0,



		posA : null,

		posB : null,

		

		typeA : 0,

		typeB : 0,

		mapCircle : null,

		mapRingA : null,

		mapRingB : null,

		

		listCoordA : null,

		listCoordB : null,

		

	    initialize : function(ringA, ringB, lat, lng, regionCd, regionNm, intNo, intNm, intSigCycleCnt, intSigCycleLen, commOnOffFlag, groupNo, mapNo) {

	    	this.ringA = ringA;

	    	this.ringB = ringB;

	    	this.Lat = lat;

	    	this.Lng = lng;

	    	this.regionCd = regionCd;

	    	this.regionNm = regionNm;

	    	this.intNo = intNo;

	    	this.intNm = intNm;

	    	this.intSigCycleCnt = (intSigCycleCnt == null) ? '0' : intSigCycleCnt;

	    	this.intSigCycleLen = (intSigCycleLen == null) ? '0' : intSigCycleLen;

	    	this.commOnOffFlag = commOnOffFlag;

	    	this.groupNo = groupNo;

	    	this.mapNo = mapNo;

	    	

	    	this.posA = new SCoord(lat, lng);

	    	this.posB = new SCoord(lat, lng);

	    	

			this.mapRingA = null;

	    	this.mapRingB = null;

	    	

	    	this.listCoordA = new Array();

			this.listCoordB = new Array();

			

			this.typeA = this.checkRingType(this.ringA);

			this.typeB = this.checkRingType(this.ringB);

			

			if (this.typeA == 0 && this.typeB == 0) {

				return;	

			}



			var degAI = 0; var degAO = 0; var degBI = 0; var degBO = 0; 

			

			// 진입, 진출 Degree 각도를 얻는다.

			if (this.typeA == 1 || this.typeA == 2 || this.typeA == 3) {

				degAI = Number(this.ringA.substring(1,4));

				degAO = Number(this.ringA.substring(4,7));

				

				if(this.typeA == 1 || this.typeA == 2)

				{

					if (degAI >= 360) degAI = degAI - 360;

					if (degAO >= 360) degAO = degAO - 360;

				}

				else if(this.typeA == 3)

				{

					if(regionCd == 'L01')

					{

						degAO = degAI + 180;

						if (degAI >= 360) degAI = degAI - 360;

						if (degAO >= 360) degAO = degAO - 360;

					}

					else

					{

						if(degAO != 0)

						{

							return this.drawPedestrians();

						}

						else

						{

							degAI += 90;

							degAO = degAI + 180;

							if(degAI > 360) degAI = degAI - 360;

							if(degAO > 360) degAO = degAO - 360;

						}

					}

				}

				

			}

			

			if (this.typeB == 1 || this.typeB == 2 || this.typeB == 3) {

				degBI = Number(this.ringB.substring(1,4));

				degBO = Number(this.ringB.substring(4,7));

				

				if(this.typeB == 1 || this.typeB == 2)

				{

					if (degBI >= 360) degBI = degBI - 360;

					if (degBO >= 360) degBO = degBO - 360;

				}

				else if(this.typeB == 3)

				{

					if(regionCd == 'L01')

					{

						degBO = degBI + 180;

						if (degBI >= 360) degBI = degBI - 360;

						if (degBO >= 360) degBO = degBO - 360;

					}

					else

					{

						if(degBO != 0)

						{

							return this.drawPedestrians();

						}

						else

						{

							degBI += 90;

							degBO = degBI + 180;

							if(degBI > 360) degBI = degBI - 360;

							if(degBO > 360) degBO = degBO - 360;

						}

					}

				}

				

			}

			

			if (((this.typeA == 1 || this.typeA == 2 || this.typeA == 3) && this.typeB == 0) || ((this.typeB == 1 || this.typeB == 2 || this.typeB == 3) && this.typeA == 0)) {

				if (this.typeA == 3) {

					degAI = 0;

					degAO = 180;

				}

				if (this.typeB == 3) {

					degBI = 0;

					degBO = 180;

				}

				

				return this.createMap(degAI, degAO, degBI, degBO);

			}



			var a;

			var gapAngle;

			

			// ARing

			if (this.typeA == 1 || this.typeA == 2) {

				if(this.typeA == 1)

				{

					//직진

					gapAngle = 270;

				}

				else 

				{

					//좌회전

					gapAngle = 90;

				}

				

				a = degAI + gapAngle;

				if (a >= 360) a = a - 360;

				

				this.moveCenterPos(this.posA, a, false);

			}

			else if (this.typeA == 3) 

			{

				var diff = degAI;

				if (diff > 180) {

					diff = diff - 180;

					gapAngle = 90;

				}else{

					gapAngle = 270;

				}

				

				a = diff + gapAngle;

				if (a >= 360) a = a - 360;

				

				//보행자

				this.moveCenterPos(this.posA, a, true);

			}

			else if (this.typeA == 4 || this.typeA == 5 || this.typeA == 6 || this.typeA == 7) {

				return this.createErrMap(this.typeA);

			}

			

			// BRing

			if (this.typeB == 1 || this.typeB == 2) {

				if(this.typeB == 1)

				{

					//직진

					gapAngle = 270;

				}

				else 

				{

					//좌회전

					gapAngle = 90;

				}

				

				a = degBI + gapAngle;

				if (a >= 360) a = a - 360;

				

				this.moveCenterPos(this.posB, a, false);

			}

			else if (this.typeB == 3) {

				var diff = degBI;

				if (diff > 180) {

					diff = diff - 180;

					gapAngle = 90;

				}else{

					gapAngle = 270;

				}

				

				a = diff + gapAngle;

				if (a >= 360) a = a - 360;

				

				//보행자

				this.moveCenterPos(this.posB, a, true);

			}

			

			return this.createMap(degAI, degAO, degBI, degBO);

    },



    moveCenterPos : function(pos, deg, pedestriansA) {

    	this.level = map.getLevel();

		var distance;

		if(this.level == 0) distance = 0.005;

		if(this.level == 1) distance = 0.005;

		if(this.level == 2) distance = 0.005;

		if(this.level == 3) distance = 0.007;

		if(this.level == 4) distance = 0.007;

		if (pedestriansA) {

			/*

			 * 보행자 신호인 경우 중심 좌표에서 진행방향으로 4미터 떨어진 곳을 중심으로 잡고

			 * (진입각-90)도 각으로 점선을 그려준다

			 */

			distance = 0.009;

		}



		var rad = deg.toRadians();

		var deltaLat = distance * Math.cos(rad);

		var deltaLng = distance * Math.sin(rad);

		

		deltaLat = (deltaLat * 360) / 40000;

		deltaLng = (deltaLng * 360) / 40000;

		pos.Lat = pos.Lat + deltaLat;

		pos.Lng = pos.Lng + deltaLng;

	},

    

	checkRingType : function(ring) {

		

    	if (ring == null) 

    		return 0;	//유효하지 않은 유형

    	

    	var type = ring.substring(0,1);

		if (type == "S") return 1;	//직진

		if (type == "L") return 2;  //좌회전

		if (type == "P") return 3;	//보행자

		

		if (ring == "commOff") return 4;         //통신이상

		if (ring == "siglightTurnoff") return 5; //신호등소등여부

		if (ring == "siglightBlink") return 6;   //신호등점멸여부

		if (ring == "contrlrManual") return 7;   //제어기수동여부

		

		return 0;	//알수없음

    },



    draw : function(map) {

		if (this.mapRingA != null) this.mapRingA.setMap(map);

		if (this.mapRingB != null) this.mapRingB.setMap(map);

    },



    createMap : function(degAI, degAO, degBI, degBO) {

    	//백그라운드 서클생성

    	//this.createCircle();

    	

		//console.log("*. AI: " + degAI + ", AO: " + degAO + ", BI: " + degBI + ", BO: " + degBO) ;

    	

    	var lineLengthA;            //A라인길이

    	var strokeWeightA;          //A라인두께

		var endArrawA = true;       //A라인화살표유무

		var strokeStyleA = 'solid'; //A라인 라인종류 

		var colorA = '#0000FF';     //A라인 색상

		

		var lineLengthB;            //B라인길이

		var strokeWeightB;          //B라인두께

		var endArrawB = true;       //B라인화살표유무

		var strokeStyleB = 'solid'; //B라인 라인종류

		var colorB = '#0000FF';     //B라인 색상

		

		var level = map.getLevel();

		

		if (this.typeA != 0) {

			if(this.typeA == 3) //보행자

			{

				if(level == 4)

				{

					lineLengthA = 0.02;

					strokeWeightA = 3;

				}

				else if(level == 3)

				{

					lineLengthA = 0.016;

					strokeWeightA = 4;

				}

				else if(level == 2)

				{

					lineLengthA = 0.012;

					strokeWeightA = 6;

				}

				else if(level == 1)

				{

					lineLengthA = 0.008;

					strokeWeightA = 8;

				}

				else if(level == 0)

				{

					lineLengthA = 0.008;

					strokeWeightA = 10;

				}

				endArrawA = false;

				strokeStyleA = 'shortdot';

				colorA = '#000000';

			}

			else

			{

				if(level == 4)

				{

					lineLengthA = 0.011;

					strokeWeightA = 2;

				}

				else if(level == 3)

				{

					lineLengthA = 0.011;

					strokeWeightA = 3;

				}

				else if(level == 2)

				{

					lineLengthA = 0.009;

					strokeWeightA = 5;

				}

				else if(level == 1)

				{

					lineLengthA = 0.009;

					strokeWeightA = 9;

				}

				else if(level == 0)

				{

					lineLengthA = 0.009;

					strokeWeightA = 12;

				}

				endArrawA = true;

				strokeStyleA = 'solid';

				colorA = '#0000FF';

			}

			

			this.listCoordA.push(new SCoord(lineLengthA * Math.cos(degAI.toRadians()), lineLengthA * Math.sin(degAI.toRadians())));

			this.listCoordA.push(new SCoord(this.posA.Lat, this.posA.Lng));

			this.listCoordA.push(new SCoord(lineLengthA * Math.cos(degAO.toRadians()), lineLengthA * Math.sin(degAO.toRadians())));

		}

		

		if (this.typeB != 0) {

			if(this.typeB == 3) //보행자

			{

				if(level == 4)

				{

					lineLengthB = 0.02;

					strokeWeightB = 3;

				}

				else if(level == 3)

				{

					lineLengthB = 0.016;

					strokeWeightB = 4;

				}

				else if(level == 2)

				{

					lineLengthB = 0.012;

					strokeWeightB = 6;

				}

				else if(level == 1)

				{

					lineLengthB = 0.008;

					strokeWeightB = 8;

				}

				else if(level == 0)

				{

					lineLengthB = 0.008;

					strokeWeightB = 10;

				}

				endArrawB = false;

				strokeStyleB = 'shortdot';

				colorB = '#000000';

			}

			else

			{

				if(level == 4)

				{

					lineLengthB = 0.011;

					strokeWeightB = 2;

				}

				else if(level == 3)

				{

					lineLengthB = 0.011;

					strokeWeightB = 3;

				}

				else if(level == 2)

				{

					lineLengthB = 0.009;

					strokeWeightB = 5;

				}

				else if(level == 1)

				{

					lineLengthB = 0.009;

					strokeWeightB = 9;

				}

				else if(level == 0)

				{

					lineLengthB = 0.009;

					strokeWeightB = 12;

				}

				endArrawB = true;

				strokeStyleB = 'solid';

				colorB = '#0000FF';

			}

			

			this.listCoordB.push(new SCoord(lineLengthB * Math.cos(degBI.toRadians()), (lineLengthB) * Math.sin(degBI.toRadians())));

			this.listCoordB.push(new SCoord(this.posB.Lat, this.posB.Lng));

			this.listCoordB.push(new SCoord(lineLengthB * Math.cos(degBO.toRadians()), (lineLengthB) * Math.sin(degBO.toRadians())));

		}

		

		for(var ii = 0; ii < 3; ii++) {

			if (ii == 1) continue;	//중심좌표는 보정이 필요없음.

			

	    	if (this.typeA != 0) {

		    	this.listCoordA[ii].Lat = (this.listCoordA[ii].Lat * 360) / 40000;	//delta lat

		    	this.listCoordA[ii].Lng = (this.listCoordA[ii].Lng * 360) / 40000;	//delta lng

		    	this.listCoordA[ii].Lat = this.posA.Lat + this.listCoordA[ii].Lat;

		    	this.listCoordA[ii].Lng = this.posA.Lng + this.listCoordA[ii].Lng;

	    	}

	    	if (this.typeB != 0) {

		    	this.listCoordB[ii].Lat = (this.listCoordB[ii].Lat * 360) / 40000;	//delta lat

		    	this.listCoordB[ii].Lng = (this.listCoordB[ii].Lng * 360) / 40000;	//delta lng

		    	this.listCoordB[ii].Lat = this.posB.Lat + this.listCoordB[ii].Lat;

		    	this.listCoordB[ii].Lng = this.posB.Lng + this.listCoordB[ii].Lng;

	    	}

		}

		

		if (this.typeA != 0) {

			this.mapRingA = new kakao.maps.Polyline({

		          path: [

		              new kakao.maps.LatLng(this.listCoordA[0].Lat, this.listCoordA[0].Lng),

		              new kakao.maps.LatLng(this.listCoordA[1].Lat, this.listCoordA[1].Lng),

		              new kakao.maps.LatLng(this.listCoordA[2].Lat, this.listCoordA[2].Lng)

		          ],

		          strokeWeight: strokeWeightA,

		          strokeColor: colorA,

		          strokeOpacity: 1,

		          strokeStyle: strokeStyleA,

		          endArrow: endArrawA,

		          zIndex: 10

		    });

			

			this.mapRingA.setMap(map);

			signalALineArr.push(this.mapRingA);

    	}

    	

    	if (this.typeB != 0) {

			this.mapRingB = new kakao.maps.Polyline({

	          path: [

	              new kakao.maps.LatLng(this.listCoordB[0].Lat, this.listCoordB[0].Lng),

	              new kakao.maps.LatLng(this.listCoordB[1].Lat, this.listCoordB[1].Lng),

	              new kakao.maps.LatLng(this.listCoordB[2].Lat, this.listCoordB[2].Lng)

	          ],

	          strokeWeight: strokeWeightB,

	          strokeColor: colorB,

	          strokeOpacity: 1,

	          strokeStyle: strokeStyleB,

	          endArrow: endArrawB,

	          zIndex: 10

			});

			

			this.mapRingB.setMap(map);

			signalBLineArr.push(this.mapRingB);

		}

		

    },

    

    createErrMap : function(type){

    	var lat = this.Lat;

    	var lng = this.Lng;

    	var regionCd = this.regionCd;

    	var regionNm = this.regionNm;

    	var intNo = this.intNo;

    	var intNm = this.intNm;

    	var intSigCycleCnt = this.intSigCycleCnt;

    	var intSigCycleLen = this.intSigCycleLen;

    	var collctDtime = this.collctDtime;

    	var commOnOffFlag = this.commOnOffFlag;

    	var contrlrOperModeCd = this.contrlrOperModeCd;

    	var groupNo = this.groupNo;

    	var mapNo = this.mapNo;

    	var eventVal = null;

    	

    	if(type == 6) this.mapCircle = this.siglightBlinkImg();

    	else 

    	{

    		var fillColor = '#FF0000';

    		var strokeColor = '#FF0000';

    		

    		if(type == 5) 

        	{

        		fillColor = '#000000';

        		strokeColor = '#000000';

        	} 

        	else if(type == 7)

        	{

        		fillColor = '#00ffff';

        		strokeColor = '#00ffff';

        	}

        	

        	this.mapCircle = new kakao.maps.Circle({

    		    center : new kakao.maps.LatLng(lat, lng),

    		    radius: _circleSize,

    		    strokeWeight: _circleStroke,

    		    strokeColor: strokeColor,

    		    strokeOpacity: 1,

    		    strokeStyle: 'solid',

    		    fillColor: fillColor,

    		    fillOpacity: 1,

    		    zIndex: 20

    		});

        	

        	this.mapCircle.setMap(map);

    	}

    	

    	var mapCircle = this.mapCircle;

    	

    	this.showSigPop(mapCircle, lat,lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo);

    	

    	signalALineArr.push(mapCircle);

    },

    

    drawPedestrians : function(){

    	var lat = this.Lat;

    	var lng = this.Lng;

    	var regionCd = this.regionCd;

    	var regionNm = this.regionNm;

    	var intNo = this.intNo;

    	var intNm = this.intNm;

    	var intSigCycleCnt = this.intSigCycleCnt;

    	var intSigCycleLen = this.intSigCycleLen;

    	var collctDtime = this.collctDtime;

    	var commOnOffFlag = this.commOnOffFlag;

    	var contrlrOperModeCd = this.contrlrOperModeCd;

    	var groupNo = this.groupNo;

    	var mapNo = this.mapNo;

    	

    	var position = new kakao.maps.LatLng(this.Lat, this.Lng);

    	var src = _pedeImgSrc;

    	var size = new kakao.maps.Size(_imgW,_imgH),

    	           options = {

    					offset : new kakao.maps.Point(_imgOffSetW,_imgOffsetH)

    				};

    	

    	var markerImage = new kakao.maps.MarkerImage(src, size, options);

    	this.mapCircle = new kakao.maps.Marker({

    		position : position,

    		image : markerImage

    	});

    	

    	this.mapCircle.setMap(map);

    	

    	var mapCircle = this.mapCircle;

    	

    	this.showSigPop(mapCircle, lat,lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo);

    	

    	signalALineArr.push(mapCircle);

    },

    

    createCircle : function(){

    	var lat = this.Lat;

    	var lng = this.Lng;

    	var regionCd = this.regionCd;

    	var regionNm = this.regionNm;

    	var intNo = this.intNo;

    	var intNm = this.intNm;

    	var intSigCycleCnt = this.intSigCycleCnt;

    	var intSigCycleLen = this.intSigCycleLen;

    	var collctDtime = this.collctDtime;

    	var commOnOffFlag = this.commOnOffFlag;

    	var contrlrOperModeCd = this.contrlrOperModeCd;

    	var groupNo = this.groupNo;

    	var mapNo = this.mapNo;

    	

    	_CommOnOffFlag = commOnOffFlag;

    	_IntSigCycleCnt = intSigCycleCnt;

    	_IntSigCycleLen = intSigCycleLen;

    	

    	this.mapCircle = new kakao.maps.Circle({

		    center : new kakao.maps.LatLng(lat, lng),

		    radius: _circleSize,

		    strokeWeight: _circleStroke,

		    strokeColor: '#fff',

		    strokeOpacity: 0,

		    strokeStyle: 'solid',

		    fillColor: '#fff',

		    fillOpacity: 0.1,

		    zIndex: 20

		});

		

		this.mapCircle.setMap(map);

		

		var mapCircle = this.mapCircle;

		

		this.showSigPop(mapCircle, lat,lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo);

		

		signalBackCircleArr.push(this.mapCircle);

    },

    

    showSigPop : function(obj,lat,lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo) {

    	kakao.maps.event.addListener(obj, 'click', function(e) {

			var UserAgent = window.navigator.userAgent;

			if (UserAgent.match(/iPhone|iPod|Android|Windows CE|BlackBerry|Symbian|Windows Phone|webOS|Opera Mini|Opera Mobi|POLARIS|IEMobile|lgtelecom|nokia|SonyEricsson/i) != null || UserAgent.match(/LG|SAMSUNG|Samsung/) != null)

			{

				if(getSigPopMobId != null) clearInterval(getSigPopMobId);

				

				if(_SigPopMobFirst == intNm)

				{

					if(clickEventId == false) 

					{

						clickEventId = true;

						sigPopMobId = false;

						if(sigInfowindow != null) sigInfowindow.close();

					}

					else

					{

						clickEventId = false;

						sigPopMobId = true;

						getSigPop(lat,lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo,obj);

						getSigPopMobId = setInterval('getSigPop("'+lat+'","'+lng+'","'+regionCd+'","'+regionNm+'","'+intNo+'","'+intNm+'","'+intSigCycleCnt+'","'+intSigCycleLen+'","'+commOnOffFlag+'","'+groupNo+'","'+mapNo+'","'+obj+'")',1000*5);

					}

				}

				else

				{

					clickEventId = false;

					sigPopMobId = true;

					getSigPop(lat,lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo,obj);

					getSigPopMobId = setInterval('getSigPop("'+lat+'","'+lng+'","'+regionCd+'","'+regionNm+'","'+intNo+'","'+intNm+'","'+intSigCycleCnt+'","'+intSigCycleLen+'","'+commOnOffFlag+'","'+groupNo+'","'+mapNo+'","'+obj+'")',1000*5);

				}

				

				_SigPopMobFirst = intNm;

			}

		});

		

		kakao.maps.event.addListener(obj, 'mouseover', function() {

			sigPopFlag = false;

			getSigPop(lat,lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo,obj);

		});

		

		kakao.maps.event.addListener(obj, 'mouseout', function() {

			sigPopFlag = true;

			sigInfowindow.close();

		});

    },

    

    siglightBlinkImg : function()

    {

    	var lat = this.Lat;

    	var lng = this.Lng;

    	var icon = new kakao.maps.MarkerImage(

    			_lightBlinkImgSrc,

			    new kakao.maps.Size(_imgW,_imgH),

			    {

			        offset: new kakao.maps.Point(_imgOffSetW,_imgOffsetH),

			        alt: "점멸"

			    }

			);

		

		this.mapCircle = new kakao.maps.Marker({

					    position: new kakao.maps.LatLng(lat, lng),

					    image: icon,

					    zIndex: 10

					});

		

		this.mapCircle.setMap(map);

		

		return this.mapCircle;

    },

    

    createLinkMap : function(){

    	

    }

    

};



/*

 * 신호제어기 정보

 */

function Signal(yCoord, xCoord, strokeColor, fillColor, regionCd, regionNm, intNo, intNm, groupNo, mapNo, commOnOffFlag, intSigCycleCnt, intSigCycleLen)

{

	this.initialize(yCoord, xCoord, strokeColor, fillColor, regionCd, regionNm, intNo, intNm, groupNo, mapNo, commOnOffFlag, intSigCycleCnt, intSigCycleLen);

};



Signal.prototype = {

	Lat  : 0,

	Lng  : 0,



	drawSignal     : null,	/* 현재 표출될 SignalDraw class */

	listDrawSignal : null, 	/* 표출현시 목록을 저장할 list array: 최초 한번만 좌표를 계산하도록 하기 위함, 성능에 따라 map 사용 가능 */

	

	mapCircle : null,

	

	initialize : function(Lat, Lng, strokeColor, fillColor, regionCd, regionNm, intNo, intNm, groupNo, mapNo, commOnOffFlag, intSigCycleCnt, intSigCycleLen) {

		this.Lat  = Lat;

		this.Lng  = Lng;

		

		if(level < 5)

		{

			this.mapCircle = new kakao.maps.Circle({

			    center : new kakao.maps.LatLng(this.Lat, this.Lng),

			    radius: _circleSize,

			    strokeWeight: _circleStroke,

			    strokeColor: strokeColor,

			    strokeOpacity: 1,

			    strokeStyle: 'solid',

			    fillColor: fillColor,

			    fillOpacity: 0.5,

			    zIndex: 10

			});

		}

		else if(level == 5)

		{

			var icon = new kakao.maps.MarkerImage(

					'images/TrafficLight25.png',

				    new kakao.maps.Size(25, 25),

				    {

				        offset: new kakao.maps.Point(12, 10),

				        alt: "신호현시"

				    }

				);

			

			this.mapCircle = new kakao.maps.Marker({

						    position: new kakao.maps.LatLng(Lat, Lng),

						    image: icon,

						    zIndex: 10

						});

		}

		

		this.mapCircle.setMap(map);

		

		kakao.maps.event.addListener(this.mapCircle, 'click', function() {

			var UserAgent = window.navigator.userAgent;

			if (UserAgent.match(/iPhone|iPod|Android|Windows CE|BlackBerry|Symbian|Windows Phone|webOS|Opera Mini|Opera Mobi|POLARIS|IEMobile|lgtelecom|nokia|SonyEricsson/i) != null || UserAgent.match(/LG|SAMSUNG|Samsung/) != null)

			{

				if(getSigPopMobId != null) clearInterval(getSigPopMobId);

				

				if(_SigPopMobFirst == intNm)

				{

					if(clickEventId == false) 

					{

						clickEventId = true;

						sigPopMobId = false;

						if(sigInfowindow != null) sigInfowindow.close();

					}

					else

					{

						clickEventId = false;

						sigPopMobId = true;

						getSigPop(Lat,Lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo,this.mapCircle);

						getSigPopMobId = setInterval('getSigPop("'+Lat+'","'+Lng+'","'+regionCd+'","'+regionNm+'","'+intNo+'","'+intNm+'","'+intSigCycleCnt+'","'+intSigCycleLen+'","'+commOnOffFlag+'","'+groupNo+'","'+mapNo+'","'+this.mapCircle+'")',1000*5);

					}

				}

				else

				{

					clickEventId = false;

					sigPopMobId = true;

					getSigPop(Lat,Lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo,this.mapCircle);

					getSigPopMobId = setInterval('getSigPop("'+Lat+'","'+Lng+'","'+regionCd+'","'+regionNm+'","'+intNo+'","'+intNm+'","'+intSigCycleCnt+'","'+intSigCycleLen+'","'+commOnOffFlag+'","'+groupNo+'","'+mapNo+'","'+this.mapCircle+'")',1000*5);

				}

				

				_SigPopMobFirst = intNm;

			}

		});

		

		kakao.maps.event.addListener(this.mapCircle, 'mouseover', function() {

			sigPopFlag = false;

			getSigPop(Lat,Lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo,this.mapCircle);

		});

		

		kakao.maps.event.addListener(this.mapCircle, 'mouseout', function() {

			sigPopFlag = true;

			sigInfowindow.close();

		});

	},

	

	/*

	 * 신호제어기 정보를 돌려줌

	 */

	getInfo : function() {

    	return this.Id + ', ' + this.Lat + '. ' + this.Lng + ", " + this.listDrawSignal.length + ", " + this.drawSignal;

	},



	/*

	 * 신호제어기 내의 Phase 가 존재하는 지를 검사

	 */

	find : function(ringA, ringB) {

		for(var ii = 0; ii < this.listDrawSignal.length; ii++) {

			if (this.listDrawSignal[ii].ringA == ringA && 

				this.listDrawSignal[ii].ringB == ringB) {

				return this.listDrawSignal[ii];

			}

		}

		return null;

	},



	/*

	 * 현재 Phase 정보를 설장함. 설정한 것에 따라 this.APhase, this.BPhase 정보가 설정됨

	 */

	setPhase : function(ARing, BRing, regionCd, regionNm, intNo, intNm, intSigCycleCnt, intSigCycleLen, commOnOffFlag, groupNo, mapNo) {

		//신호라인 삭제

		if(this.drawSignal != null) this.empty(map);

		this.drawSignal = new SignalDraw(ARing, BRing, this.Lat, this.Lng, regionCd, regionNm, intNo, intNm, intSigCycleCnt, intSigCycleLen, commOnOffFlag, groupNo, mapNo);

	},

	

	draw : function(map) {



		if (this.mapCircle  != null) this.mapCircle.setMap(map);

		if (this.drawSignal != null) this.drawSignal.draw(map);

		//if (this.mapCenter  != null) this.mapCenter.setMap(map);

	},



	empty : function(map) {

		if(this.drawSignal.mapRingA != null) this.drawSignal.mapRingA.setMap(null);

		if(this.drawSignal.mapRingB != null) this.drawSignal.mapRingB.setMap(null);

		if(this.drawSignal.mapCircle != null) this.drawSignal.mapCircle.setMap(null);

	}

};



function getSigPop(lat,lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo,icon) {

	var str = "";

	str += "<div class='sigPop_box'>";

	str += "<table cellspacing='0' cellpadding='0' border='0' summary='신호 위치정보' class='pop_table'>";

	str += "<caption>신호 위치정보</caption>";

	str += "<colgroup>";

	str += "<col style='width:25%;'>";

	str += "<col style='width:25%'>";

	str += "<col style='width:24%;'>";

	str += "<col style='width:26%'>";

	str += "</colgroup>";

	str += "<thead>";

	str += "<tr>";

	str += "<th colspan='4'><img src='images/icon01.gif' alt='타이틀 블릿'/><strong>["+regionNm+"] "+intNm+"("+intNo+")</strong></th>";

	str += "</tr>";

	str += "</thead>";

	str += "<tbody>";

	str += "<tr>";

	str += "<td><span>그룹번호&nbsp;&nbsp; :</span></td>";

	str += "<td>"+groupNo+"</td>";

	str += "<td><span>통신여부&nbsp;&nbsp; :</span></td>";

	str += "<td>"+commOnOffFlagFnc(commOnOffFlag)+"</td>";

	str += "</tr>";

	str += "<tr>";

	str += "<td><span>주기카운트 :</span></td>"; 

	str += "<td>"+intSigCycleCnt+" 초</td>";

	str += "<td><span style='margin-left:0px'>주&nbsp;&nbsp;기&nbsp;&nbsp;&nbsp;&nbsp; :</span></td>";

	str += "<td>"+ intSigCycleLen +" 초</td>";

	str += "</tr>";

	str += "</tbody>";

	str += "<tfoot>";

	str += "</tfoot>";

	str += "</table>";

	str += '<table class="pop_table_phase">';

	str += '<tr>							';

	str += '	<td>현시</td>				';

	str += '	<td class="pa_1">1</td>		';

	str += '	<td class="pa_2">2</td>		';

	str += '	<td class="pa_3">3</td>		';

	str += '	<td class="pa_4">4</td>		';

	str += '	<td class="pa_5">5</td>		';

	str += '	<td class="pa_6">6</td>		';

	str += '</tr>							';

	str += '<tr>';

	str += '	<td>A링</td>';

	str += '	<td id="pAMap0"></td>';

	str += '	<td id="pAMap1"></td>';

	str += '	<td id="pAMap2"></td>';

	str += '	<td id="pAMap3"></td>';

	str += '	<td id="pAMap4"></td>';

	str += '	<td id="pAMap5"></td>';

	str += '</tr>';

	str += '<tr class="aProgress">';

	str += '	<td>주기</td>';

	str += '	<td id="aRing1Phase"></td>';

	str += '	<td id="aRing2Phase"></td>';

	str += '	<td id="aRing3Phase"></td>';

	str += '	<td id="aRing4Phase"></td>';

	str += '	<td id="aRing5Phase"></td>';

	str += '	<td id="aRing6Phase"></td>';

	str += '</tr>';

	str += '<tr>';

	str += '	<td>B링</td>';

	str += '	<td id="pBMap0"></td>';

	str += '	<td id="pBMap1"></td>';

	str += '	<td id="pBMap2"></td>';

	str += '	<td id="pBMap3"></td>';

	str += '	<td id="pBMap4"></td>';

	str += '	<td id="pBMap5"></td>';

	str += '</tr>';

	str += '<tr class="bProgress">';

	str += '	<td>주기</td>';

	str += '	<td id="bRing1Phase"></td>';

	str += '	<td id="bRing2Phase"></td>';

	str += '	<td id="bRing3Phase"></td>';

	str += '	<td id="bRing4Phase"></td>';

	str += '	<td id="bRing5Phase"></td>';

	str += '	<td id="bRing6Phase"></td>';

	str += '</tr>';

	str += '</table>';

	str += "<div class='arrow_sig' style='margin-left:-75px;'><img alt='' src='images/arrow_tooltip.png'></div>";

	str += "</div>";

	

	var tempMap = map;

	var position = new kakao.maps.LatLng(lat,lng);

	

	if(sigInfowindow != null) sigInfowindow.close();

	

	sigInfowindow = new kakao.maps.InfoWindow({

  	    position : position, 

        content	: str,

        removable: false,

        zIndex	: 100,

        map:tempMap

    });

	

	 var pop_box = $('.sigPop_box').parent().parent();

	 var pop_top = pop_box.css('top');

	 var pop_top_ex = pop_top.split('px');

	 var top = 0;

	 var level = map.getLevel();

	 

	 if(level == 1) top = 55;

	 else if(level == 2) top = 45;

	 else if(level == 3) top = 35;

	 else if(level == 4) top = 25;

	 else top = 15;

	 

	 pop_box.css('top',(pop_top_ex[0]-top)+'px');

	 

	 //페이즈정보 

	 getSigInfoPhaseDetail(regionCd,intNo,mapNo);

}



function getSigPopMob(lat,lng,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,commOnOffFlag,groupNo,mapNo,icon) {

	var str = "";

	str += "<img src='images/close_btn.gif' onclick='closeMobInfo()' style='position:absolute;top:15px;right:15px;z-index:20'/>";

	str += "<div class='sigPop_box'>";

	str += "<table cellspacing='0' cellpadding='0' border='0' summary='신호 위치정보' class='pop_table'>";

	str += "<caption>신호 위치정보</caption>";

	str += "<colgroup>";

	str += "<col style='width:25%;'>";

	str += "<col style='width:25%'>";

	str += "<col style='width:24%;'>";

	str += "<col style='width:26%'>";

	str += "</colgroup>";

	str += "<thead>";

	str += "<tr>";

	str += "<th colspan='4'><img src='images/icon01.gif' alt='타이틀 블릿'/><strong>["+regionNm+"] "+intNm+"("+intNo+")</strong></th>";

	str += "</tr>";

	str += "</thead>";

	str += "<tbody>";

	str += "<tr>";

	str += "<td><span>그룹번호&nbsp;&nbsp; :</span></td>";

	str += "<td>"+groupNo+"</td>";

	str += "<td><span>통신여부&nbsp;&nbsp; :</span></td>";

	str += "<td>"+commOnOffFlagFnc(_CommOnOffFlag)+"</td>";

	str += "</tr>";

	str += "<tr>";

	str += "<td><span>주기카운트 :</span></td>"; 

	str += "<td>"+_IntSigCycleCnt+" 초</td>";

	str += "<td><span style='margin-left:0px'>주&nbsp;&nbsp;기&nbsp;&nbsp;&nbsp;&nbsp; :</span></td>";

	str += "<td>"+ _IntSigCycleLen +" 초</td>";

	str += "</tr>";

	str += "</tbody>";

	str += "<tfoot>";

	str += "</tfoot>";

	str += "</table>";

	str += '<table class="pop_table_phase">';

	str += '<tr>							';

	str += '	<td>현시</td>				';

	str += '	<td class="pa_1">1</td>		';

	str += '	<td class="pa_2">2</td>		';

	str += '	<td class="pa_3">3</td>		';

	str += '	<td class="pa_4">4</td>		';

	str += '	<td class="pa_5">5</td>		';

	str += '	<td class="pa_6">6</td>		';

	str += '</tr>							';

	str += '<tr>';

	str += '	<td>A링</td>';

	str += '	<td id="pAMap0"></td>';

	str += '	<td id="pAMap1"></td>';

	str += '	<td id="pAMap2"></td>';

	str += '	<td id="pAMap3"></td>';

	str += '	<td id="pAMap4"></td>';

	str += '	<td id="pAMap5"></td>';

	str += '</tr>';

	str += '<tr class="aProgress">';

	str += '	<td>주기</td>';

	str += '	<td id="aRing1Phase"></td>';

	str += '	<td id="aRing2Phase"></td>';

	str += '	<td id="aRing3Phase"></td>';

	str += '	<td id="aRing4Phase"></td>';

	str += '	<td id="aRing5Phase"></td>';

	str += '	<td id="aRing6Phase"></td>';

	str += '</tr>';

	str += '<tr>';

	str += '	<td>B링</td>';

	str += '	<td id="pBMap0"></td>';

	str += '	<td id="pBMap1"></td>';

	str += '	<td id="pBMap2"></td>';

	str += '	<td id="pBMap3"></td>';

	str += '	<td id="pBMap4"></td>';

	str += '	<td id="pBMap5"></td>';

	str += '</tr>';

	str += '<tr class="bProgress">';

	str += '	<td>주기</td>';

	str += '	<td id="bRing1Phase"></td>';

	str += '	<td id="bRing2Phase"></td>';

	str += '	<td id="bRing3Phase"></td>';

	str += '	<td id="bRing4Phase"></td>';

	str += '	<td id="bRing5Phase"></td>';

	str += '	<td id="bRing6Phase"></td>';

	str += '</tr>';

	str += '</table>';

	str += "</div>";

	

	$('.mobInfoWin').empty().html(str);

	 

	 //페이즈정보 

	 getSigInfoPhaseDetail(regionCd,intNo,mapNo);

}



function getSigInfoPhaseDetail(regionCd,intNo,mapNo) {

	var option = {

			url		 : 'main/getSigInfoPhaseDetail.do',

			param	 : {

				regionCd : regionCd,

				intNo : intNo,

				mapNo : mapNo

			},

			callback : sigPhaseDetailListCallback

	}

	// ajax로 요청

	callService(option);

}



function sigPhaseDetailListCallback(json) {

	var data = json.data.list;

	var regionCd = data[0].REGION_CD;

	var intNo = data[0].INT_NO;

	var phaseVal = Number(data[0].A_RING_PHASE_VAL) + 1;

	$('.pa_'+phaseVal).css('background-color','yellow');

	var aRing1Phase = data[0].A_RING_1_PHASE_CONF_CD;

	var aRing2Phase = data[0].A_RING_2_PHASE_CONF_CD;

	var aRing3Phase = data[0].A_RING_3_PHASE_CONF_CD;

	var aRing4Phase = data[0].A_RING_4_PHASE_CONF_CD;

	var aRing5Phase = data[0].A_RING_5_PHASE_CONF_CD;

	var aRing6Phase = data[0].A_RING_6_PHASE_CONF_CD;

	var bRing1Phase = data[0].B_RING_1_PHASE_CONF_CD;

	var bRing2Phase = data[0].B_RING_2_PHASE_CONF_CD;

	var bRing3Phase = data[0].B_RING_3_PHASE_CONF_CD;

	var bRing4Phase = data[0].B_RING_4_PHASE_CONF_CD;

	var bRing5Phase = data[0].B_RING_5_PHASE_CONF_CD;

	var bRing6Phase = data[0].B_RING_6_PHASE_CONF_CD;

	

	$('#aRing1Phase').text((typeof data[0].A_RING_1_PHASE_VAL == 'undefined' || data[0].A_RING_1_PHASE_VAL == 9999) ? '정보없음' : data[0].A_RING_1_PHASE_VAL);

	$('#aRing2Phase').text((typeof data[0].A_RING_2_PHASE_VAL == 'undefined' || data[0].A_RING_2_PHASE_VAL == 9999) ? '정보없음' : data[0].A_RING_2_PHASE_VAL);

	$('#aRing3Phase').text((typeof data[0].A_RING_3_PHASE_VAL == 'undefined' || data[0].A_RING_3_PHASE_VAL == 9999) ? '정보없음' : data[0].A_RING_3_PHASE_VAL);

	$('#aRing4Phase').text((typeof data[0].A_RING_4_PHASE_VAL == 'undefined' || data[0].A_RING_4_PHASE_VAL == 9999) ? '정보없음' : data[0].A_RING_4_PHASE_VAL);

	$('#aRing5Phase').text((typeof data[0].A_RING_5_PHASE_VAL == 'undefined' || data[0].A_RING_5_PHASE_VAL == 9999) ? '정보없음' : data[0].A_RING_5_PHASE_VAL);

	$('#aRing6Phase').text((typeof data[0].A_RING_6_PHASE_VAL == 'undefined' || data[0].A_RING_6_PHASE_VAL == 9999) ? '정보없음' : data[0].A_RING_6_PHASE_VAL);



	$('#bRing1Phase').text((typeof data[0].B_RING_1_PHASE_VAL == 'undefined' || data[0].B_RING_1_PHASE_VAL == 9999) ? '정보없음' : data[0].B_RING_1_PHASE_VAL);

	$('#bRing2Phase').text((typeof data[0].B_RING_2_PHASE_VAL == 'undefined' || data[0].B_RING_2_PHASE_VAL == 9999) ? '정보없음' : data[0].B_RING_2_PHASE_VAL);

	$('#bRing3Phase').text((typeof data[0].B_RING_3_PHASE_VAL == 'undefined' || data[0].B_RING_3_PHASE_VAL == 9999) ? '정보없음' : data[0].B_RING_3_PHASE_VAL);

	$('#bRing4Phase').text((typeof data[0].B_RING_4_PHASE_VAL == 'undefined' || data[0].B_RING_4_PHASE_VAL == 9999) ? '정보없음' : data[0].B_RING_4_PHASE_VAL);

	$('#bRing5Phase').text((typeof data[0].B_RING_5_PHASE_VAL == 'undefined' || data[0].B_RING_5_PHASE_VAL == 9999) ? '정보없음' : data[0].B_RING_5_PHASE_VAL);

	$('#bRing6Phase').text((typeof data[0].B_RING_6_PHASE_VAL == 'undefined' || data[0].B_RING_6_PHASE_VAL == 9999) ? '정보없음' : data[0].B_RING_6_PHASE_VAL);

	

	

	aRingPhaseData = new ringPhaseData(aRing1Phase,aRing2Phase,aRing3Phase,aRing4Phase,aRing5Phase,aRing6Phase);

	bRingPhaseData = new ringPhaseData(bRing1Phase,bRing2Phase,bRing3Phase,bRing4Phase,bRing5Phase,bRing6Phase);

	

	var aRingPhaseCnt = 0;

	if(aRing1Phase) aRingPhaseCnt = 1;

	if(aRing2Phase) aRingPhaseCnt = 2;

	if(aRing3Phase) aRingPhaseCnt = 3;

	if(aRing4Phase) aRingPhaseCnt = 4;

	if(aRing5Phase) aRingPhaseCnt = 5;

	if(aRing6Phase) aRingPhaseCnt = 6;

	

	for(var ii = 0; ii < aRingPhaseCnt; ii++)

	{

		listCoord = [];

		makePMap('pAMap'+ii);

		if(ii == 0) if(aRingPhaseData.ring0 != null) drawPhaseLine(regionCd,aRingPhaseData.ring0, _YCoord, _XCoord);

		if(ii == 1) if(aRingPhaseData.ring1 != null) drawPhaseLine(regionCd,aRingPhaseData.ring1, _YCoord, _XCoord);

		if(ii == 2) if(aRingPhaseData.ring2 != null) drawPhaseLine(regionCd,aRingPhaseData.ring2, _YCoord, _XCoord);

		if(ii == 3) if(aRingPhaseData.ring3 != null) drawPhaseLine(regionCd,aRingPhaseData.ring3, _YCoord, _XCoord);

		if(ii == 4) if(aRingPhaseData.ring4 != null) drawPhaseLine(regionCd,aRingPhaseData.ring4, _YCoord, _XCoord);

		if(ii == 5) if(aRingPhaseData.ring5 != null) drawPhaseLine(regionCd,aRingPhaseData.ring5, _YCoord, _XCoord);

	}

	

    var bRingPhaseCnt = 0;

	if(bRing1Phase) bRingPhaseCnt = 1;

	if(bRing2Phase) bRingPhaseCnt = 2;

	if(bRing3Phase) bRingPhaseCnt = 3;

	if(bRing4Phase) bRingPhaseCnt = 4;

	if(bRing5Phase) bRingPhaseCnt = 5;

	if(bRing6Phase) bRingPhaseCnt = 6;

	

	for(var jj = 0; jj < bRingPhaseCnt; jj++)

	{

		listCoord = [];

		makePMap('pBMap'+jj);

		if(jj == 0) if(bRingPhaseData.ring0 != null) drawPhaseLine(regionCd,bRingPhaseData.ring0, _YCoord, _XCoord);

		if(jj == 1) if(bRingPhaseData.ring1 != null) drawPhaseLine(regionCd,bRingPhaseData.ring1, _YCoord, _XCoord);

		if(jj == 2) if(bRingPhaseData.ring2 != null) drawPhaseLine(regionCd,bRingPhaseData.ring2, _YCoord, _XCoord);

		if(jj == 3) if(bRingPhaseData.ring3 != null) drawPhaseLine(regionCd,bRingPhaseData.ring3, _YCoord, _XCoord);

		if(jj == 4) if(bRingPhaseData.ring4 != null) drawPhaseLine(regionCd,bRingPhaseData.ring4, _YCoord, _XCoord);

		if(jj == 5) if(bRingPhaseData.ring5 != null) drawPhaseLine(regionCd,bRingPhaseData.ring5, _YCoord, _XCoord);

	}

	

	//kakao로고 삭제

	for(var mm = 0; mm < 6; mm++)

	{

		$('#pAMap'+mm+' div:nth-child(2)').css('z-index',0);

		$('#pBMap'+mm+' div:nth-child(2)').css('z-index',0);

	}

}



function makePMap(mapNum)

{

	var pLat = parseFloat(_YCoord);

	var pLng = parseFloat(_XCoord);



	var pMapContainer = document.getElementById(mapNum) // 지도를 표시할 div 

	var mapOption = {

		center: new kakao.maps.LatLng(pLat, pLng),

		level: 1

	};

	

	pMap = new kakao.maps.Map(pMapContainer, mapOption); // 지도생성

	

	var mapBack = new kakao.maps.Circle({

		center : new kakao.maps.LatLng(pLat, pLng),

	    radius: 30,

	    strokeStyle: 'solid',

	    fillColor: '#fff',

	    fillOpacity: 1,

	    zIndex: 5

	});

	

	mapBack.setMap(pMap);

}



function sigInfoWindowClose()

{

	if(sigInfowindow != null)

	{

		var sigPop = $('.pop_box').parent().parent().parent();

		sigPop.css('top','0px');

		

		sigInfowindow.close();

		_mapSignalPoP = new HashMap();

		signalArrPoP = [];

		if(getPhaseTimeIdPoP != null) clearTimeout(getPhaseTimeIdPoP);

	}

}



function commOnOffFlagFnc(val)

{

	var str = '정상';

	if(val == 1) str = '이상';

	return str;

}



function lightOnOffFlagFnc(val)

{

	var str = 'OFF';

	if(val == 1) str = 'ON';

	return str;

}



function contrlrOperModeCdFnc(val)

{

	var str = 'SCU모드';

	if(val == 1) str = '비감응 OFFLINE';

	else if(val == 2) str = '감응OFFLINE';

	else if(val == 4) str = '감응ONLINE';

	else if(val == 5) str = 'ONLINE';

	return str;

}



function closeMobInfo() 

{

	$('.mobInfoWin').empty();

}