var mcMsg = "";
var station_no;
var station_code;
var linecode;
var line_no; // 호선 정보
var updown; //상행 하행 구분
var curr_name , next_name , prev_name , destination_name; //현재역 ,다음역 , 이전역명 , 종착역명
var curr_distance = 0 ;
var skip_station_name;	
var lineArr = new Array(); //  노선도 좌표
var shortArr = new Array(); // 구간 운행 운행 하지 않는 구간 좌표도
var Departure_code, Destination_code; //출발역 , 종착역 코드
var Departure, Destination; //출발역 , 종착역 명
var doorSide = 0; //0 : 없음 , 1:오른쪽 , 2:왼쪽 , 3: 양쪽
var interchange = "";
var isDoorOpenVisible = false; //STB의 IP가 홀수일경우 왼쪽 , 짝수일경우 오른쪽 판단하여 현재 열리는 문에 위치한 STB에만 정보 송신
var tmpIsDoorOpenVisible = false; //M4 반복시  isDoorOpenVisible 값이 불규칙하게 들어오는 bug. JSLEE 
var curr_pos; //현재역 이미지 좌표
var doorTxtblinkCnt = 0;
var stationChangeCount = 0;
var mapChangeCount = 0;
var currMapDisplay = 0; //현재 보여지고 있는 MAP 0:없음 , 1:전체노선도맵 , 2:단일노선도맵 , 3:역명맵
var map4RepeatCount = 0; //M4의 반복 횟수 카운트 //JSLEE
var map3RepeatCount = 0; //M3의 언어설정을 위한 mapChangeCount 임시 저장 변수.//JSLEE
var intervalID = null;
var intervalID2 = null;
var intervalID3 = null;
var prev_name_arr = null;
var curr_name_arr = null;
var next_name_arr = null;
var nowTimer = null;
var interLineNo = new Object();
var interTimer = null;
var doorTextInterval = null;
var interBlinkStat = null;
var timeID = null;
var rdCnt = null;
var depStationNo ,desStationNo;
var isDepature = false;
var dispType = getDisplayType();
var lanIntervalTime = 4000;
var mapChangeIntervalTime = 9000;
var headInfo = null; //차량 Head Car 정보
var tailInfo = null; //차량 Tail Car 정보
var funcPaCnt = 0; //Function PA Msg 처음 시작 위치 결정
var doorOpenViewArr = [
                       				"Please exit this side",
                       				"ఈ వైపు నిష్క్రమించడానికి దయచేసి",
                       				"اس طرف سے باہر نکلیں کریں",
                       				"इस पक्ष से बाहर निकलने करें"
                       			 ];
function log(msg){
	AndroidFunction.DebugOut(33, "train.js : " + msg);
}
function error(msg){
	AndroidFunction.DebugOut(31, "train.js : " + msg);
}

//funcPaCnt 증가
function incFuncPaCnt(){
	funcPaCnt += 1;
	funcPaCnt = funcPaCnt%4;
}

function trainValueReset(){
	mcMsg = "";
	station_no = null;
	station_code = null;
	linecode = null;
	line_no = null; // 호선 정보
	updown = null; //상행 하행 구분
	curr_name = null , next_name = null , prev_name = null , destination_name = null; //현재역 ,다음역 , 이전역명 , 종착역명
	curr_distance = 0 ;
	lineArr = new Array(); //  노선도 좌표
	shortArr = new Array(); // 구간 운행 운행 하지 않는 구간 좌표도
	Departure_code = null, Destination_code = null; //출발역 , 종착역 코드
	Departure = null, Destination = null; //출발역 , 종착역 명
	doorSide = 0; //0 : 없음 , 1:오른쪽 , 2:왼쪽 , 3: 양쪽
	interchange = "";
	isDoorOpenVisible = false; //STB의 IP가 홀수일경우 왼쪽 , 짝수일경우 오른쪽 판단하여 현재 열리는 문에 위치한 STB에만 정보 송신
	curr_pos = null; //현재역 이미지 좌표
	doorTxtblinkCnt = 0;
	stationChangeCount = 0;
	mapChangeCount = 0;
	currMapDisplay = 0; //현재 보여지고 있는 MAP 0:없음 , 1:전체노선도맵 , 2:단일노선도맵 , 3:역명맵
	intervalID = null;
	intervalID2 = null;
	intervalID3 = null;
	prev_name_arr = null;
	curr_name_arr = null;
	next_name_arr = null;
	nowTimer = null;
	interLineNo = new Object();
	interTimer = null;
	interBlinkStat = null;
	timeID = null;
	rdCnt = null;
	depStationNo = null ,desStationNo = null;
	isDepature = false;
	headInfo = null; //차량 Head Car 정보
	tailInfo = null; //차량 Tail Car 정보
}

//자막 현시 , 맵 변경 시간을 가져온다
function getIntervalTime(type){
	//type 1:msg(stationName) , 2:map 
	var languagePath = "sdcard/metro/main/lanTime.conf";
	var mapPath = "sdcard/metro/main/mapTime.conf";
	if(1 == type){
		if(AndroidFunction.FileExist(languagePath)){
			var val = AndroidFunction.Cat(languagePath);
			if("0" == val || "" == val || "null" == val){
				return 4000;
			}else{
				return val;
			}
		}else{
			return 4000;
		}
	}else if(2 == type){
		if(AndroidFunction.FileExist(mapPath)){
			var val = AndroidFunction.Cat(mapPath);
			if("0" == val || "" == val || "null" == val){
				return 9000;
			}else{
				return val;
			}
		}else{
			return 9000;
		}
	}
}

//우상단에 표시되는 시간 형태 가져온다
function getTimeType(){
	var timePath = "sdcard/metro/main/dispTime.conf";
	if(AndroidFunction.FileExist(timePath)){
		var val = AndroidFunction.Cat(timePath);
		if("0" == val || "" == val || "null" == val){
			return 0;
		}else{
			return val;
		}
	}else{
		return 0;
	}
}
//포인터 깜박거림 효과
function point_blink(){
	///img/curr_dot1.png
	var obj = document.getElementById("curr_dot");
	if(obj.style.display == "none"){
		obj.style.display="block";
	}else{
		obj.style.display="none";
	}
}
//현재역 마킹
function setCurrStation(no){
	var parentNode = document.getElementById("mainDiv");
	if(no == 0){
		var curr_pos_arr = curr_pos.total.split(",");
	}else{
		var curr_pos_arr = curr_pos.detail.split(",");
	}
	
	var currSpan = document.createElement("span");
	
	currSpan.id = "curr_dot";
	currSpan.className ="curr_dot"+no;
	
	currSpan.style.left = curr_pos_arr[0]+"px";
	currSpan.style.top = curr_pos_arr[1]+"px";
	
	parentNode.appendChild(currSpan);
}

//지나온역 마킹
function setPrevStation(no){
	var parentNode = document.getElementById("mainDiv");
	var lineLength = 0;
	
	if(updown == "<") lineLength = lineArr.length-1;
	else lineLength = lineArr.length;
	
	for(var i = 0;i<lineLength;i++){
		//if(updown == ">" && i == 0) continue;
		if(updown == ">" && i == 0 ) continue;
		
		var prevSpan = document.createElement("span");
		prevSpan.Name ="prev_dot";
		prevSpan.className ="prev_dot"+no;
		
		if(no == 1){
			var prev_pos_arr = lineArr[i].total.split(",");
		}else{
			var prev_pos_arr = lineArr[i].detail.split(",");
		}
		prevSpan.style.left = prev_pos_arr[0]+"px";
		prevSpan.style.top = prev_pos_arr[1]+"px";
		
		parentNode.appendChild(prevSpan);
	}
}

//구간운행 정보를 설정한다
function setShortLoop(no){
	var parentNode = document.getElementById("mainDiv");
	var leng = shortArr.length;
	
	for( var i = 0 ; i < leng ; i++ ){
		var prevSpan = document.createElement("span");
		prevSpan.Name ="prev_dot";
		prevSpan.className = "short_dot"+no;
		
		if(no == 1){
			var prev_pos_arr = shortArr[i].total.split(",");
		}else{
			var prev_pos_arr = shortArr[i].detail.split(",");
		}
		prevSpan.style.left = prev_pos_arr[0]+"px";
		prevSpan.style.top = prev_pos_arr[1]+"px";
		
		parentNode.appendChild(prevSpan);
	}
}

//맵현시중 방향 화살표를 현시한다.
function moveArrowBlink(){
	var obj = document.getElementById("moveArrow");
	if(obj.style.display == "none"){
		obj.style.display="block";
	}else{
		obj.style.display="none";
	}
}

//맵현시중 방향 화살표를 제거한다.
function clearMoveArrorBlink(){
	clearInterval(intervalID3); 
	intervalID3= null;
	document.getElementById("moveArrow").style.top = "312px";
	document.getElementById("moveArrow").style.top = "313px";
	document.getElementById("moveArrow").style.display="none";
	document.getElementById("moveArrow").style.top = "312px";
	document.getElementById("moveArrow").style.top = "313px";
}

//노선도 마킹 초기화
function clearPointMark(type){
	//type - A:전체노선도 , B:상세노선도 , C:전후노선도
	clearInterval(intervalID); 
	intervalID= null;
	clearTimeout(timeID);
	timeID= null;
	
	var parentTag = document.getElementById("mainDiv");
	var childTag = parentTag.getElementsByTagName("span");
	
	//while(list.hasChildNodes()) list.removeChild(list.firstChild);
	
	
	try {
		for( var i = childTag.length ; i > 0 ; i-- ){
			parentTag.removeChild(childTag[i-1]);
		}
	} catch (e) {
		log("clearPointMark() : removeChild failed don't have span child");
	}
	
	/*for( var i = 0 ; i < childTag.length ; i++ ){
		if(parentTag.getElementsByTagName("span").length > 0 ) parentTag.removeChild(parentTag.lastChild);
	}*/
	
	
	if(type == 'A'){
		setDetailLine();
		AndroidFunction.DebugOut(33,"Now Map show type = Detail Line Map");
	}else if(type == 'B'){
		//setStationName();
		setMoveStationName();
		AndroidFunction.DebugOut(33,"Now Map show type = Station Name");
	}else if(type == 'C'){
		document.getElementById("leftName").innerHTML = "";
		document.getElementById("rightName").innerHTML = "";
	}else if(type == 'D'){
		setAllLine();
		AndroidFunction.DebugOut(33,"Now Map show type = All Line Name");
	}
	
}

//문열림 방향 텍스트를 제거한다.
function clearDoorTxtblink(){
	clearInterval(intervalID); 
	intervalID= null;
	clearTimeout(timeID);
	timeID= null;
	//hideNowTime();
	clearStationChange();
	clearInterLine();
	isDoorOpenVisible = false;
	//resetVariable();
	lineArr = new Array(); //  노선도 좌표
	shortArr = new Array();
	doorTxtblinkCnt = 0;
	currMapDisplay = 0;
	interLineNo = new Object();
	interLineNo.prev = "";
	interLineNo.curr = "";
	interLineNo.next = "";
	document.getElementById("MsgBox4").style.display = "none";
	document.getElementById("mainDiv").style.display="none";
	document.getElementById("MsgBox4").innerHTML = "";
	document.getElementById("MsgBox2").innerHTML = "";
	document.getElementById("prevName").innerHTML = "";
	document.getElementById("currName").innerHTML = "";
	document.getElementById("nextName").innerHTML = "";
	document.getElementById("leftName").innerHTML = "";
	document.getElementById("rightName").innerHTML = "";
}

function clearStationChange(){
	clearInterval(intervalID2); 
	intervalID2= null;
	mapChangeCount = 0;
	stationChangeCount = 0;
}

//기본 운행  정보 입력
function setBasicInfo(dep,des, head, tail){
	//설정된 intervalTime 적용
	lanIntervalTime = getIntervalTime(1);
	mapChangeIntervalTime = getIntervalTime(2);
	headInfo = head;
	tailInfo = tail;
	if( tailInfo.Car1 == 1 && headInfo.OppositeCar == 1 ) isDoorOpenVisible = !isDoorOpenVisible;
	
	if("RD" == dispType){
		rdCnt = getRdType();
		rdCnt = rdCnt.split("#");
	}
	
	Departure_code = dep; 
	Destination_code = des; 
	for(var i = 0 ;i< lineCode.line.length;i++ ){
		if(lineCode.line[i].destination == des && lineCode.line[i].departure == dep){
			linecode = lineCode.line[i].code;
			break;
		}/*else if( dep >= lineCode.line[i].departure && des <= lineCode.line[i].destination ){
			linecode = lineCode.line[i].code;
			break;
		}*/
	}
	
	if( undefined == linecode ) { // 만약 linecode가 없다면
		var isDepStation = false; // 출발역이 있는지 체크하는 변수
		var isDesStation = false; // 종착영이 있는지 체크하는 변수
		var tmpDepNo = "";
		var tmpDesNo = "";
		
		for( var i = 1 ; i < 4 ; i++ ){ // 호선별로 for문을 돌린다. 현재는 3호선까지 있기에 1~3까지 for문 loop
			var lineNumber = "line"+i; // eval을 사용하기 위하여 line1 ~ line3 의 정보가 입력된다.
			for( var j = 0 ; j < eval(lineNumber).station.length ; j++ ){ // 해당 호선의 역들의 개수 만큼 for loop
				if( dep == eval(lineNumber).station[j].code ){ // 출발역이 해당 호선의 역정보에 포함 되어있는가?
					tmpDepNo = eval(lineNumber).station[j].no;
					isDepStation = true; // 만약 포함되어있다면 출발역이 있다고 체크함
				}else if( des == eval(lineNumber).station[j].code ){ // 종착역이 해당 호선의 역정보에 포함 되어있는가?
					tmpDesNo = eval(lineNumber).station[j].no;
					isDesStation = true; // 만약 포함되어있다면 종착역이 있다고 체크함
				}
			}
			if( isDepStation && isDesStation ){ // 해당 호선에 출발역과 종착역이 모두 있는가?
				if(tmpDepNo > tmpDesNo){
					updown = ">"; //하행
				}else if(tmpDepNo < tmpDesNo){
					updown = "<"; //상행
				}
				if( updown == "<"){ // 출발역과 종착역이 모두 있고 상행선이라면
					linecode = (i*2)-1; // 라인코드는 1,3,5 가 되어야 한다.
					// linecode 가 1이면 1호선 상행, 3이면 2호선 상행, 5이면 3호선 상행
				}else{ // 출발역과 종착역이 모두 있고 하행선이라면
					linecode = (i*2); // 라인코드는 2,4,6 이어야 한다.
					//linecode 가 2이면 1호선 하행, 4이면 2호선 하행, 6이면 3호선 하행
				}
				break;
			}else{ // 해당 호선에 출발역과 종착역 두개를 포함하지 않는다면
				isDepStation = false; // 다음호선의 정보를 set하기 위하여 출발역체크 변수 초기화
				isDesStation = false; // 다음호선의 정보를 set하기 위하여 종착역체크 변수 초기화
			}
		}
		if( !isDepStation || !isDesStation ){
			AndroidFunction.DebugOut(31, "linecode invalid value pageReload()");
			location.reload();
			return;
		}
	}else{
		if(linecode%2 == 0){
			updown = ">"; //하행
		}else{
			updown = "<"; //상행
		}
	}
	
	//현재 호선 정보 추출
	for(var i = 0 ;i< lineCode.line.length;i++ ){
		if ( lineCode.line[i].code == linecode ) {
			//AndroidFunction.DebugOut(1,"126 i = " + i);
			line_no = lineCode.line[i].no;
			AndroidFunction.DebugOut(1,"128 line_no = " + line_no);
			break;
		}
	}
	
	//AndroidFunction.DebugOut(1,"133 line_no = " + line_no);
	//출발 , 종착역 코드로 역명 셋팅
	checkLineNo(356);
	var data = "line"+line_no;
	for(var i = 0 ;i< eval(data).station.length;i++ ){
		if(eval(data).station[i].code == Departure_code){
			Departure = eval(data).station[i].name;
			depStationNo = eval(data).station[i].no;
		}else if(eval(data).station[i].code == Destination_code){
			Destination = eval(data).station[i].name;
			desStationNo = eval(data).station[i].no;
			destination_name = (Destination != undefined) ? [Destination.english,Destination.telugu,Destination.urdu,Destination.hindi] : "";
		}
	}
}

function getDesArrName(des){
	
	var desArrName = null;
	var tmpDes = null;
	for ( var i = 1; i <= 3; i++) {
		var data = "line"+i;
		for(var j = 0 ;j< eval(data).station.length;j++ ){
			if(eval(data).station[j].code == des){
				tmpDes = eval(data).station[j].name;
				desArrName = (tmpDes != undefined) ? [tmpDes.english,tmpDes.telugu,tmpDes.urdu,tmpDes.hindi] : "";
				break;
			}
		}
	}
	return desArrName;
}

function checkLineNo(txtLine){
	
	if(undefined == line_no) {
		AndroidFunction.DebugOut(31, "line_no invalid value pageReload()" + txtLine + "line");
		openWindow1();
	}
	
	if(isNaN(line_no)){
		AndroidFunction.DebugOut(31, "line_no invalid value pageReload()" + txtLine + "line");
		openWindow1();
	}
}

function openWindow1(){
	var cmd = null;
	cmd = AndroidFunction.JSONs(null, "open.to", "window1");
	cmd = AndroidFunction.JSONs(cmd, "open.request", "false");
	cmd = AndroidFunction.JSONs(cmd, "open.value", "file:///android_asset/setup/intro.html");
	cmd = AndroidFunction.JSONs(cmd, "open.data.x", "0");
	cmd = AndroidFunction.JSONs(cmd, "open.data.y", "645");
	cmd = AndroidFunction.JSONs(cmd, "open.data.w", "1366");
	cmd = AndroidFunction.JSONs(cmd, "open.data.h", "120");
	AndroidFunction.JsonRun(cmd);
}
//호선 정보 추출(통합완료 검토후 삭제요망)
function getLineNo(){
	for(var i = 0 ;i< lineCode.line.length;i++ ){
		if(lineCode.line[i].code == linecode){
			line_no = lineCode.line[i].no;
			break;
		}
	}
}
//skip station 자막 
function setSkipStationCode(SkipStationCode){
	var data = "line"+line_no;
	for(var i = 0 ;i< eval(data).station.length;i++ ){
		if(eval(data).station[i].code == SkipStationCode){			
			skip_station_name = eval(data).station[i].name;			
		}
	}
}
//현재역 정보 입력
function setStationcode(val,doorOpenDir, doorSideVal ){
	checkLineNo(396);
	var data = "line"+line_no;
	//기존 door.side
//	if( doorOpenDir == 0 ){
//		doorSide = doorSideVal;
//	}else{
//		doorSide = doorOpenDir;
//	}
	doorSide = doorSideVal;
	
	for(var i = 0 ;i< eval(data).station.length;i++ ){
		if(eval(data).station[i].code == val){
			curr_name = eval(data).station[i].name;
			station_no = eval(data).station[i].no;
			station_code = val;
			if( i != 0 ){
				curr_distance = eval(data).station[i-1].distance;
			}
			interLineNo.curr = eval(data).station[i].interchange;
			curr_pos = eval(data).station[i].imgpos;
			getStationsName();
		}
	}
	
	if(undefined == station_no || undefined == line_no || undefined == curr_pos) {
		AndroidFunction.DebugOut(33, "station_no or line_no or curr_pos invalid value pageReload()");
		openWindow1();
	}
	setDoorSide();
}

function setDoorSide(){
	var stbIp = AndroidFunction.IPv4();
	var splitIp = stbIp.split("."); //3번째 IP는 호차번호
	var restValue = splitIp[3]%2; //홀수왼쪽문 , 짝수 오른쪽문
	
	//doorSide 값이 없을경우 기본으로 오른쪽 셋팅
	if(isNaN(doorSide)){
		console.log(" invalid door side value default LEFT set");
		doorSide = 2;
	}
	
	//호차번호가 6일경우 문열림 방향은 반대
	if('4' <= splitIp[2] && '6' >= splitIp[2] ){
		if('1' == doorSide){
		//right
			if(restValue != 0) isDoorOpenVisible = true;
			else isDoorOpenVisible = false;
		}else if('2' == doorSide){
		//left	
			if(restValue == 0) isDoorOpenVisible = true;
			else isDoorOpenVisible = false;
		}else  if('3' == doorSide){
		//both
			isDoorOpenVisible = true;
		}
	}else if('1' <= splitIp[2] && '3' >= splitIp[2] ){
		if('1' == doorSide){
		//right
			if(restValue == 0) isDoorOpenVisible = true;
			else isDoorOpenVisible = false;
		}else if('2' == doorSide){
		//left	
			if(restValue != 0) isDoorOpenVisible = true;
			else isDoorOpenVisible = false;
		}else  if('3' == doorSide){
		//both
			isDoorOpenVisible = true;
		}
	}
	
	// 하행 운행 중 문열림 방향이 오른쪽 또는 왼쪽이라면 방향을 다시 바꿔준다.
	if( ( doorSide == 1 || doorSide == 2 ) && updown == ">" ){
		//isDoorOpenVisible = !isDoorOpenVisible;
	}
	//역방향 운행일경우 문열림 방향을 다시 바꿔준다.
	if( tailInfo.Car1 == 1 && headInfo.OppositeCar == 1 ) isDoorOpenVisible = !isDoorOpenVisible;
}



function getStationsName()
{	
	
	checkLineNo(470);
	var tmpStr1,tmpStr2;
	var tmpDis1 , tmpDis2;
	var tmpInter1, tmpInter2 = "";
	var data = "line"+line_no;

	for(var i = 0 ;i< eval(data).station.length;i++ ){
		if(eval(data).station[i].no == (station_no-0)+1){
			tmpStr1 = eval(data).station[i].name;
			tmpDis1 = eval(data).station[i].distance;
			tmpInter1 = eval(data).station[i].interchange;
		}else if(eval(data).station[i].no == station_no-1){
			tmpStr2 = eval(data).station[i].name;
			tmpDis2 = eval(data).station[i].distance;
			tmpInter2 = eval(data).station[i].interchange;
		}else{
			continue;
		}
	}
	
	if(updown == "<"){
		prev_name = tmpStr2;
		prev_distance = "";
		next_name = tmpStr1;
		interLineNo.next = tmpInter1;
		interLineNo.prev = tmpInter2;
	}else if(updown == ">"){
		prev_name = tmpStr1;
		prev_distance = "";
		next_name =  tmpStr2;
		interLineNo.next = tmpInter2;
		interLineNo.prev = tmpInter1;
	}
}

//노선도 좌표 추출
function getLinePos(){
	checkLineNo(507);
	var data1 = "line"+line_no;
	var data2 = "line"+line_no+".station[i].no"+updown+"="+station_no;
	AndroidFunction.DebugOut(33, "station_no : " + station_no);
	var cnt = 0;
	var cnt2 = 0;
	for(var i = 0 ; i<eval(data1).station.length;i++ ){
		if( isShortLoop(i) ){
			shortArr[cnt2] = eval(data1).station[i].imgpos;
			cnt2++;
		}else if(eval(data2)){
			lineArr[cnt] = eval(data1).station[i].imgpos;
			cnt++;
		}
	}
}

//메세지 호출
function getMsg(idx , param1 , param2 , isException , isFunc){
	//console.log("param1 train.js 618 ");
	lanIntervalTime = getIntervalTime(1);
	if("RD" == dispType){
		rdCnt = getRdType();
		rdCnt = rdCnt.split("#");
	}else if("PID" == dispType){
		var pidCnt = getPidType();
		pidCnt = pidCnt.split("#");
	}
	
 console.log("rdCnt===>"+rdCnt);
	//English
	var next_station_E =  (next_name != undefined) ? next_name.english : "";
	var prev_station_E =  (prev_name != undefined) ? prev_name.english : "";

	if(isDepature){
		var curr_station_E =  (curr_name != undefined) ? prev_name.english : "";
		isDepature = false;
	}else{
		var curr_station_E =  (curr_name != undefined) ? curr_name.english : "";
	}
	
	var dep_station_E =  (Departure != undefined) ? Departure.english : "";
	var des_station_E =  (Destination != undefined) ? Destination.english : "";
	var skip_station_E = (skip_station_name != undefined) ? skip_station_name.english : "";
	var inter_station_E="";
	var doorDirection_E = "";
	
	//Hindi
	var next_station_H =  (next_name != undefined) ? next_name.hindi : "";
	var prev_station_H =  (prev_name != undefined) ? prev_name.hindi : "";
	var curr_station_H =  (curr_name != undefined) ? curr_name.hindi : "";
	var dep_station_H =  (Departure != undefined) ? Departure.hindi : "";
	var des_station_H =  (Destination != undefined) ? Destination.hindi : "";
	var skip_station_H = (skip_station_name != undefined) ? skip_station_name.hindi : "";
	var inter_station_H="";
	var doorDirection_H = "";
	
	//Telugu
	var next_station_T =  (next_name != undefined) ? next_name.telugu : "";
	var prev_station_T =  (prev_name != undefined) ? prev_name.telugu : "";
	var curr_station_T =  (curr_name != undefined) ? curr_name.telugu : "";
	var dep_station_T =  (Departure != undefined) ? Departure.telugu : "";
	var des_station_T =  (Destination != undefined) ? Destination.telugu : "";
	var skip_station_T = (skip_station_name != undefined) ? skip_station_name.telugu : "";
	var inter_station_T="";
	var doorDirection_T = "";
	
	//Urdu
	var next_station_U =  (next_name != undefined) ? next_name.urdu : "";
	var prev_station_U =  (prev_name != undefined) ? prev_name.urdu : "";
	var curr_station_U =  (curr_name != undefined) ? curr_name.urdu : "";
	var dep_station_U =  (Departure != undefined) ? Departure.urdu : "";
	var des_station_U =  (Destination != undefined) ? Destination.urdu : "";
	var skip_station_U = (skip_station_name != undefined) ? skip_station_name.urdu : "";
	var inter_station_U="";
	var doorDirection_U = "";
	
	
	var msgArr = new Array();
	
	switch (parseInt(interLineNo.curr)) {
	case 1:
		inter_station_E = "Red";
		inter_station_H = "लाल";
		inter_station_T = "రెడ్";
		inter_station_U = "سرخ";
		break;
	case 2:
		inter_station_E = "Green";
		inter_station_H = "ग्रीन";
		inter_station_T = "గ్రీన్";
		inter_station_U = "گرین";
		break;
	case 3:
		inter_station_E = "Blue";
		inter_station_H = "ब्लू";
		inter_station_T = "బ్లూ";
		inter_station_U = "بلیو";
		break;
	}
	
	switch (parseInt(doorSide)) {
	case 1:
		doorDirection_E = "Right";
		doorDirection_H = "सही";
		doorDirection_T = "సరియైన";
		doorDirection_U = "ٹھیک ہے";
		break;
	case 2:
		doorDirection_E = "Left";
		doorDirection_H = "बाएं";
		doorDirection_T = "ఎడమ";
		doorDirection_U = "بائیں بازو کی";
		break;
	case 3:
		doorDirection_E = "Both";
		doorDirection_H = "दोनों";
		doorDirection_T = "ఇద్దరు";
		doorDirection_U = "دونوں";
		break;
	}
	
	var jData = new Object();
	jData.msg = new Array();
	var map = null;
	var defaultString = "";

	for(var i=0 ; i<PSE.MSG.length;i++ ){
		if(PSE.MSG[i].id == idx){
			AndroidFunction.DebugOut(33,"train.js : PSE.MSG["+i+"].id = " + idx);
			//lanMsg = eval("PSE.MSG["+i+"]."+lan);
			defaultString = PSE.MSG[i].param1;
			for(var j=0;j<PSE.MSG[i].content.length;j++){
				//var map = new Map();
				map = new Map();
				//var txtArr  =  PSE.MSG[i].content[j].txt;
				var txtArr  =  (PSE.MSG[i].content[j].txt).slice(0);

				var curr_station_tmp = "";
				var next_station_tmp = "";
				var dep_station_tmp = "";
				var des_station_tmp = "";
				var doorDirection_tmp = "";
				var inter_station_tmp = "";
				var prev_station_tmp = "";
				var skip_station_tmp = "";
				
				if("english" == PSE.MSG[i].content[j].lan){
					curr_station_tmp = curr_station_E;
					//next_station_tmp = next_station_E;
					dep_station_tmp = dep_station_E;
					des_station_tmp =des_station_E;
					doorDirection_tmp = doorDirection_E;
					inter_station_tmp = inter_station_E;
					prev_station_tmp = prev_station_E;
					skip_station_tmp = skip_station_E;
				}else if("telugu" == PSE.MSG[i].content[j].lan){
					curr_station_tmp = curr_station_T;
					//next_station_tmp = next_station_T;
					dep_station_tmp = dep_station_T;
					des_station_tmp =des_station_T;
					doorDirection_tmp = doorDirection_T;
					inter_station_tmp = inter_station_T;
					prev_station_tmp = prev_station_T;
					skip_station_tmp = skip_station_T;
				}else if("urdu" == PSE.MSG[i].content[j].lan){
					curr_station_tmp = curr_station_U;
					//next_station_tmp = next_station_U;
					dep_station_tmp = dep_station_U;
					des_station_tmp =des_station_U;
					doorDirection_tmp = doorDirection_U;
					inter_station_tmp = inter_station_U;
					prev_station_tmp = prev_station_U;
					skip_station_tmp = skip_station_U;
				}else if("hindi" == PSE.MSG[i].content[j].lan){
					curr_station_tmp = curr_station_H;
					//next_station_tmp = next_station_H;
					dep_station_tmp = dep_station_H;
					des_station_tmp =des_station_H;
					doorDirection_tmp = doorDirection_H;
					inter_station_tmp = inter_station_H;
					prev_station_tmp = prev_station_H;
					skip_station_tmp = skip_station_H;
				}else{
					curr_station_tmp = curr_station_E;
					//next_station_tmp = next_station_E;
					dep_station_tmp = dep_station_E;
					des_station_tmp =des_station_E;
					doorDirection_tmp = doorDirection_E;
					inter_station_tmp = inter_station_E;
					prev_station_tmp = prev_station_E;
					skip_station_tmp = skip_station_E;
				}

				for( var y = 0 ; y < txtArr.length ; y++ ){
					if(txtArr[y].indexOf("[Departure]") > -1){
						txtArr[y] = txtArr[y].replace("[Departure]",dep_station_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Departure]",dep_station_tmp))
					}
					if(txtArr[y].indexOf("[Destination]") > -1){
						txtArr[y] = txtArr[y].replace("[Destination]",des_station_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Destination]",des_station_tmp));
					}
					if(txtArr[y].indexOf("[Direction]") > -1){
						txtArr[y] = txtArr[y].replace("[Direction]",doorDirection_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Direction]",doorDirection_tmp));
					}
					if(txtArr[y].indexOf("[Line Color]") > -1){
						txtArr[y] = txtArr[y].replace("[Line Color]",inter_station_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Line Color]",inter_station_tmp));
					}
					//1:Depature , 2:Current , 3:Next , 4:Destiination
					if(0 == param1 || "" == param1){
						if("Current" == defaultString){
							txtArr[y] = txtArr[y].replace("[Param1]",curr_station_tmp);
							//txtTmpArr.push(txtArr[y].replace("[Param1]",curr_station_tmp));
						}
						if("Next" == defaultString){
							txtArr[y] = txtArr[y].replace("[Param1]",curr_station_tmp);
							//txtTmpArr.push(txtArr[y].replace("[Param1]",curr_station_tmp));
						}
						if("Destination" == defaultString){
							txtArr[y] = txtArr[y].replace("[Param1]",des_station_tmp);
							//txtTmpArr.push(txtArr[y].replace("[Param1]",des_station_tmp));
						}
						if("Others" == defaultString){
							txtArr[y] = txtArr[y].replace("[Param1]",prev_station_tmp);
							txtArr[y] = txtArr[y].replace("[Param1-1]",curr_station_tmp);
						}
					}
					if(1 == param1){
						txtArr[y] = txtArr[y].replace("[Param1]",dep_station_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Param1]",dep_station_tmp));
					}
					if(2 == param1){
						txtArr[y] = txtArr[y].replace("[Param1]",curr_station_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Param1]",curr_station_tmp));
					}
					if(3 == param1){
						txtArr[y] = txtArr[y].replace("[Param1]",curr_station_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Param1]",curr_station_tmp));
					}
					if(4 == param1){
						txtArr[y] = txtArr[y].replace("[Param1]",des_station_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Param1]",des_station_tmp));
					}
					if(5 == param1 && 0 == param2){
						if("Others" == defaultString){							
							txtArr[y] = txtArr[y].replace("[Param1]",skip_station_tmp);
						}
					}
					if(txtArr[y].indexOf("<br/>") > 0){
						txtArr[y] = txtArr[y].replace("<br/>"," ");
						//txtTmpArr.push(txtArr[y].replace("[Line Color]",inter_station_tmp));
					}
					
					
					/*if(1 == param2){
						txtArr[y] = txtArr[y].replace("[Param2]",dep_station_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Param2]",dep_station_tmp));
					}
					if(2 == param2){
						txtArr[y] = txtArr[y].replace("[Param2]",curr_station_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Param2]",curr_station_tmp));
					}
					if(3 == param2){
						txtArr[y] = txtArr[y].replace("[Param2]",curr_station_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Param2]",curr_station_tmp));
					}
					if(4 == param2){
						txtArr[y] = txtArr[y].replace("[Param2]",des_station_tmp);
						//txtTmpArr.push(txtArr[y].replace("[Param2]",des_station_tmp));
					}*/
				}

				map.put("txt", txtArr);
				map.put("dir", PSE.MSG[i].content[j].dir);
				map.put("size", PSE.MSG[i].content[j].size);
				map.put("color", PSE.MSG[i].content[j].color);
				msgArr[j] = map;
			}
		}
	}
	
	if("PID" == dispType && msgArr.length > 0 ){
		//가장 많은 라인의 언어를 찾는다
		var txtLineArr = new Array();
		txtLineArr[0] = msgArr[0].get("txt").length;
		txtLineArr[1] = msgArr[1].get("txt").length;
		txtLineArr[2] = msgArr[2].get("txt").length;
		txtLineArr[3] = msgArr[3].get("txt").length;
		txtLineArr.sort(function(a,b){return b-a});	
		var maxLine = parseInt(txtLineArr[0]);
		var tmpCnt = funcPaCnt;
		var data = new Object();
		var tmpTxt = msgArr[pidCnt[(tmpCnt+0)%4]].get("txt");
		data.txt = tmpTxt;
		data.dir = msgArr[pidCnt[(tmpCnt+0)%4]].get("dir");
		data.size = msgArr[pidCnt[(tmpCnt+0)%4]].get("size")
		data.color =  msgArr[pidCnt[(tmpCnt+0)%4]].get("color")
		//data.disp = (maxLine * 3000) / tmpTxt.length;
		data.disp = (maxLine * parseInt(lanIntervalTime)) / tmpTxt.length;
		jData.msg.push(data);
		
		var data1 = new Object();
		var tmpTxt = msgArr[pidCnt[(tmpCnt+1)%4]].get("txt");
		data1.txt = tmpTxt;
		data1.dir = msgArr[pidCnt[(tmpCnt+1)%4]].get("dir");
		data1.size = msgArr[pidCnt[(tmpCnt+1)%4]].get("size")
		data1.color =  msgArr[pidCnt[(tmpCnt+1)%4]].get("color")
		//data1.disp = (maxLine * 3000) / tmpTxt.length;
		data1.disp = (maxLine * parseInt(lanIntervalTime)) / tmpTxt.length;
		jData.msg.push(data1);
		
		var data2 = new Object();
		var tmpTxt = msgArr[pidCnt[(tmpCnt+2)%4]].get("txt");
		data2.txt = tmpTxt;
		data2.dir = msgArr[pidCnt[(tmpCnt+2)%4]].get("dir");
		data2.size = msgArr[pidCnt[(tmpCnt+2)%4]].get("size")
		data2.color =  msgArr[pidCnt[(tmpCnt+2)%4]].get("color")
		//data2.disp = (maxLine * 3000) / tmpTxt.length;
		data2.disp = (maxLine * parseInt(lanIntervalTime)) / tmpTxt.length;
		jData.msg.push(data2);
		
		var data3 = new Object();
		var tmpTxt = msgArr[pidCnt[(tmpCnt+3)%4]].get("txt");
		data3.txt = tmpTxt;
		data3.dir = msgArr[pidCnt[(tmpCnt+3)%4]].get("dir");
		data3.size = msgArr[pidCnt[(tmpCnt+3)%4]].get("size")
		data3.color =  msgArr[pidCnt[(tmpCnt+3)%4]].get("color")
		//data2.disp = (maxLine * 3000) / tmpTxt.length;
		data3.disp = (maxLine * parseInt(lanIntervalTime)) / tmpTxt.length;
		jData.msg.push(data3);
		
		/*data.txt = msgArr[0].get("txt");
		data.dir = msgArr[0].get("dir");
		data.size = msgArr[0].get("size")
		data.color =  msgArr[0].get("color")*/
		
	}else if("RD" == dispType && msgArr.length > 0 ){
		
		if(idx == 49 || idx == 22){
		
			var data = new Object();
			data.txt = msgArr[rdCnt[mapChangeCount%4]].get("txt");
			data.dir = msgArr[mapChangeCount%4].get("dir");
			data.size = msgArr[mapChangeCount%4].get("size")
			data.color =  msgArr[mapChangeCount%4].get("color")
			jData.msg.push(data);
		}else if(idx != 2 && idx != 3 && idx != 4){//M4에 자막. msgId 5 에 동작.
			//20141310 한터 요청으로 1,2,3 이외의 메세지일경우 PID와 같이 3개 언어 번갈아가며 현시
			//언어는 기존 4개에서 마지막 언어를 제외한 3개
			
			//가장 많은 라인의 언어를 찾는다
			//JSLEE S : M4에서 msgArr 가 E, H, T, U 순으로 들어와서 재배열 해줌. 언어설정대로 동작하게 하기 위해서.
			var tempArr = msgArr.slice(0);//배열 객체를 복사
			msgArr[0] = tempArr[0];			
			msgArr[1] = tempArr[2];
			msgArr[2] = tempArr[3];
			msgArr[3] = tempArr[1];
			//JSLEE E
			
			var txtLineArr = new Array();
			txtLineArr[0] = msgArr[0].get("txt").length;
			txtLineArr[1] = msgArr[1].get("txt").length;
			txtLineArr[2] = msgArr[2].get("txt").length;
			txtLineArr[3] = msgArr[3].get("txt").length;
			
			
			txtLineArr.sort(function(a,b){return b-a});	
			var maxLine = parseInt(txtLineArr[0]);
			var tmpCnt = funcPaCnt;
			
			var data = new Object();
			var tmpTxt = msgArr[rdCnt[(tmpCnt+0)%4]].get("txt");
			data.txt = tmpTxt;
			data.dir = msgArr[rdCnt[(tmpCnt+0)%4]].get("dir");
			data.size = msgArr[rdCnt[(tmpCnt+0)%4]].get("size")
			data.color =  msgArr[rdCnt[(tmpCnt+0)%4]].get("color")
			//data.disp = (maxLine * 3000) / tmpTxt.length;
			data.disp = (maxLine * parseInt(lanIntervalTime)) / tmpTxt.length;
			jData.msg.push(data);
			
			var data1 = new Object();
			var tmpTxt = msgArr[rdCnt[(tmpCnt+1)%4]].get("txt");
			data1.txt = tmpTxt;
			data1.dir = msgArr[rdCnt[(tmpCnt+1)%4]].get("dir");
			data1.size = msgArr[rdCnt[(tmpCnt+1)%4]].get("size")
			data1.color =  msgArr[rdCnt[(tmpCnt+1)%4]].get("color")
			//data1.disp = (maxLine * 3000) / tmpTxt.length;
			data1.disp = (maxLine * parseInt(lanIntervalTime)) / tmpTxt.length;
			jData.msg.push(data1);
			
			var data2 = new Object();
			var tmpTxt = msgArr[rdCnt[(tmpCnt+2)%4]].get("txt");
			data2.txt = tmpTxt;
			data2.dir = msgArr[rdCnt[(tmpCnt+2)%4]].get("dir");
			data2.size = msgArr[rdCnt[(tmpCnt+2)%4]].get("size")
			data2.color =  msgArr[rdCnt[(tmpCnt+2)%4]].get("color")
			//data2.disp = (maxLine * 3000) / tmpTxt.length;
			data2.disp = (maxLine * parseInt(lanIntervalTime)) / tmpTxt.length;
			jData.msg.push(data2);
			
			var data3 = new Object();
			var tmpTxt = msgArr[rdCnt[(tmpCnt+3)%4]].get("txt");
			data3.txt = tmpTxt;
			data3.dir = msgArr[rdCnt[(tmpCnt+3)%4]].get("dir");
			data3.size = msgArr[rdCnt[(tmpCnt+3)%4]].get("size")
			data3.color =  msgArr[rdCnt[(tmpCnt+3)%4]].get("color")
			//data2.disp = (maxLine * 3000) / tmpTxt.length;
			data3.disp = (maxLine * parseInt(lanIntervalTime)) / tmpTxt.length;
			jData.msg.push(data3);
			
			
		}else if(isFunc){
			
			var data = new Object();
			data.txt = msgArr[rdCnt[mapChangeCount%4]].get("txt");
			data.dir = msgArr[mapChangeCount%4].get("dir");
			data.size = msgArr[mapChangeCount%4].get("size")
			data.color =  msgArr[mapChangeCount%4].get("color")
			jData.msg.push(data);
		}else{
			//보통 M1, M2 에서 msgId 2,3,4 에 동작 
			var data = new Object();
			data.txt = msgArr[rdCnt[0]].get("txt");
			data.dir = msgArr[rdCnt[0]].get("dir");
			data.size = msgArr[rdCnt[0]].get("size");
			data.color =  msgArr[rdCnt[0]].get("color");
			//if(isException) data.disp = ((mapChangeIntervalTime / 2) / msgArr[rdCnt[0]].get("txt").length) - 30;
			if(isException) data.disp = (mapChangeIntervalTime  / msgArr[rdCnt[0]].get("txt").length) - 10;
			jData.msg.push(data);
			
			var data1 = new Object();
			data1.txt = msgArr[rdCnt[1]].get("txt");
			data1.dir = msgArr[rdCnt[1]].get("dir");
			data1.size = msgArr[rdCnt[1]].get("size");
			data1.color =  msgArr[rdCnt[1]].get("color");
			//if(isException) data1.disp = ((mapChangeIntervalTime / 2) / msgArr[rdCnt[1]].get("txt").length) - 30;
			if(isException) data1.disp = (mapChangeIntervalTime / msgArr[rdCnt[1]].get("txt").length) - 10;
			jData.msg.push(data1);
			
			var data2 = new Object();
			data2.txt = msgArr[rdCnt[2]].get("txt");
			data2.dir = msgArr[rdCnt[2]].get("dir");
			data2.size = msgArr[rdCnt[2]].get("size");
			data2.color =  msgArr[rdCnt[2]].get("color");
			//if(isException) data2.disp = ((mapChangeIntervalTime / 2) / msgArr[rdCnt[2]].get("txt").length) - 30;
			if(isException) data2.disp = (mapChangeIntervalTime / msgArr[rdCnt[2]].get("txt").length) - 10;
			jData.msg.push(data2);
			
			var data3 = new Object();
			data3.txt = msgArr[rdCnt[3]].get("txt");
			data3.dir = msgArr[rdCnt[3]].get("dir");
			data3.size = msgArr[rdCnt[3]].get("size");
			data3.color =  msgArr[rdCnt[3]].get("color");
			//if(isException) data3.disp = ((mapChangeIntervalTime / 2) / msgArr[rdCnt[3]].get("txt").length) - 30;
			if(isException) data3.disp = (mapChangeIntervalTime / msgArr[rdCnt[3]].get("txt").length) - 10;
			jData.msg.push(data3);
		}
	}

	return JSON.stringify(jData);
}

function setAllLine(){
	
	AndroidFunction.DebugOut(33,"setAllLine start, Now Map show type = All Line Map");
	//stationChangeCount = 0;
	//mapChangeCount = 0
	mapChangeCount += 1;
	currMapDisplay = 1;
	
	if("RD" == dispType && rdCnt == null){
		rdCnt = getRdType();
		rdCnt = rdCnt.split("#");
	}
	
	if(rdCnt == null){
		error("getRdType() fail app restart");
		
		var cmd = null;
		cmd = AndroidFunction.JSONs(null, "restart.to", "Launcher");
		cmd = AndroidFunction.JSONs(cmd, "restart.request", "false");
		cmd = AndroidFunction.JSONs(cmd, "restart.value", "1000");
		AndroidFunction.JsonRun(cmd);
	}
	
	//stationNameChange();
	/*if( intervalID2 == null ){
		intervalID2 = setInterval("stationNameChange()",mapChangeIntervalTime / 2);
	}*/
	var mainImg = document.getElementById("mainImg");
	switch (line_no) {
	case 1:
		//mainImg.src = eval("lineImgAll_A_"+rdCnt[mapChangeCount%4]+".src");
		mainImg.src = eval("lineImgAll_A_"+rdCnt[(mapChangeCount-1)%10]+".src");//JSLEE
		//imgObj.src = lineImgAll_A.src; 
		break;
	case 2:
		//mainImg.src = eval("lineImgAll_B_"+rdCnt[mapChangeCount%4]+".src");
		mainImg.src = eval("lineImgAll_B_"+rdCnt[(mapChangeCount-1)%10]+".src");//JSLEE
		//imgObj.src = lineImgAll_B.src;
		break;
	case 3:
		//mainImg.src =  eval("lineImgAll_C_"+rdCnt[mapChangeCount]+".src");
		mainImg.src =  eval("lineImgAll_C_"+rdCnt[(mapChangeCount-1)%10]+".src");//JSLEE
		//imgObj.src = lineImgAll_C.src;
		break;	
	default:
		break;
	}
	//resolveAfterTxt();
	
	/*var timeType = getTimeType(); 
	AndroidFunction.DebugOut(33," train.js timeType : " + timeType); 
	showNowTime(timeType);
	nowTimer = setInterval("showNowTime('"+timeType+"')", 3000);*/
	
	getLinePos();
	//setCurrStation(0);
	//setShortLoop(1);
	//setPrevStation(1);
	setTimeout("setCurrStation(0)", 45);
	setTimeout("setShortLoop(1)", 50);
	setTimeout("setPrevStation(1)", 55);
	intervalID = setInterval("point_blink()",1100);
	timeID = setTimeout("clearPointMark('A')",mapChangeIntervalTime);
	AndroidFunction.DebugOut(33,"setAllLine exit");
	
}

function setDetailLine(){
	if(currMapDisplay == 4) return;
	//map3 문열림 방향 blink작업중
	clearInterval(doorTextInterval); 
	document.getElementById("MsgBox4").innerHTML = "";
	document.getElementById("MsgBox4").style.display = "none"
	clearMoveArrorBlink();
	clearInterLine();
	document.getElementById("leftName").innerHTML = "";
	document.getElementById("rightName").innerHTML = "";
	//currMapDisplay = 2;
	mapChangeCount +=1;
	if("RD" == dispType && rdCnt == null){
		rdCnt = getRdType();
		rdCnt = rdCnt.split("#");
	}
	
	if(rdCnt == null){
		error("getRdType() fail app restart");
		var cmd = null;
		cmd = AndroidFunction.JSONs(null, "restart.to", "Launcher");
		cmd = AndroidFunction.JSONs(cmd, "restart.request", "false");
		cmd = AndroidFunction.JSONs(cmd, "restart.value", "1000");
		AndroidFunction.JsonRun(cmd);
	}
	
	//상세 노선도 이미지 교체
	var mainImg = document.getElementById("mainImg");		
	
	switch (line_no) {
	case 1:
		//if(updown == "<") mainImg.src =  eval("lineImg1_A_"+rdCnt[mapChangeCount%4]+".src"); 
		//else mainImg.src =  eval("lineImg1_B_"+rdCnt[mapChangeCount%4]+".src");
		if(updown == "<") mainImg.src =  eval("lineImg1_A_"+rdCnt[(mapChangeCount-1)%10]+".src"); 
		else mainImg.src =  eval("lineImg1_B_"+rdCnt[(mapChangeCount-1)%10]+".src");
		break;
	case 2:
		//if(updown == "<") mainImg.src =  eval("lineImg2_A_"+rdCnt[mapChangeCount%4]+".src"); 
		//else mainImg.src =  eval("lineImg2_B_"+rdCnt[mapChangeCount%4]+".src");
		if(updown == "<") mainImg.src =  eval("lineImg2_A_"+rdCnt[(mapChangeCount-1)%10]+".src"); 
		else mainImg.src =  eval("lineImg2_B_"+rdCnt[(mapChangeCount-1)%10]+".src");
		break;
	case 3:
		//if(updown == "<") mainImg.src =  eval("lineImg3_A_"+rdCnt[mapChangeCount%4]+".src"); 
		//else mainImg.src =  eval("lineImg3_B_"+rdCnt[mapChangeCount%4]+".src");
		if(updown == "<") mainImg.src =  eval("lineImg3_A_"+rdCnt[(mapChangeCount-1)%10]+".src"); 
		else mainImg.src =  eval("lineImg3_B_"+rdCnt[(mapChangeCount-1)%10]+".src");
		break;	
	}
	//resolveAfterTxt();
	
	getLinePos();
	//setPrevStation(2);
	setTimeout("setPrevStation(2)", 45);//mainImg 로드완료되기 전 점들이 표시되어 잔상이 표시되는 것 같아 보인다. 약간 지연을 주어 이미지로드 후 역진행점들 표시되도록 의도인듯 
	setTimeout("setCurrStation(1)", 50);
	setTimeout("setShortLoop(2)",55);
	intervalID = setInterval("point_blink()",1100);
	//JSLEE S
	//timeID = setTimeout("clearPointMark('B')",mapChangeIntervalTime);
	if(mapChangeCount > 3)
		timeID = setTimeout("clearPointMark('B')",mapChangeIntervalTime);// -> M3
	else
		timeID = setTimeout("clearPointMark('D')",mapChangeIntervalTime);// -> M1
	//JSLEE E
}

function setMoveStationName(){
	clearMoveArrorBlink();//JSLEE M4가운데 화살표 남아있는문제
	clearInterval(doorTextInterval); //doorText
	if(currMapDisplay == 4) return;
	currMapDisplay = 3;
	stationChangeCount = 0;
	mapChangeCount += 1;
	if(mapChangeCount < 8)
		map3RepeatCount = mapChangeCount;
	else
		map3RepeatCount = 8;
	console.log("setMoveStationName M3 mapChangeCount : "+mapChangeCount+ ", map3RepeatCount : "+map3RepeatCount);
	/*if( intervalID2 == null ){
		intervalID2 = setInterval("stationNameChange()",lanIntervalTime);
	}else{
		clearInterval(intervalID2);
		intervalID2 = null;
		intervalID2 = setInterval("stationNameChange()",lanIntervalTime);
	}*/
	
	var mainImg = document.getElementById("mainImg");
	var leftName = document.getElementById("leftName");
	var rightName = document.getElementById("rightName");
	
	prev_name_arr = new Array();
	curr_name_arr = new Array();
	
	if(prev_name != undefined || prev_name != null || typeof(prev_name.english) != "undefined"){
		prev_name_arr.push(prev_name.english,prev_name.telugu,prev_name.urdu,prev_name.hindi);
	}else{
		prev_name_arr.push("","","","");
	}
	if(curr_name != undefined || curr_name != null || typeof(curr_name.english) != "undefined"){
		curr_name_arr.push(curr_name.english,curr_name.telugu,curr_name.urdu,curr_name.hindi);
	}else{
		curr_name_arr.push("","","","");
	}
	
	switch (line_no) {
	case 1:
		mainImg.src = moveStationImg_A.src; 
		break;
	case 2:
		mainImg.src = moveStationImg_B.src;
		break;
	case 3:
		mainImg.src = moveStationImg_C.src;
		break;	
	}
	
	var moveArrow = document.getElementById("moveArrow");
	moveArrow.style.display="block";
	//방향별 이동방향 화살표 반전 적용
	if(getMirrorType()){
		//moveArrow.style.background = "url("+eval(moveStationArrowL.src)+")";
		moveArrow.style.background = "url("+moveStationArrowL.src+")";
	}else{
		//moveArrow.style.background = "url("+eval(moveStationArrowR.src)+")";
		moveArrow.style.background = "url("+moveStationArrowR.src+")";
	}
	intervalID3 = setInterval("moveArrowBlink()",1111);
	
	//방향별 RD 이미지 반전 적용
	/*if(getMirrorType()){
		switch (line_no) {
		case 1:
			mainImg.src = moveStationImg_A_.src; 
			break;
		case 2:
			mainImg.src = moveStationImg_B_.src;
			break;
		case 3:
			mainImg.src = moveStationImg_C_.src;
			break;	
		}
	}else{
		switch (line_no) {
		case 1:
			mainImg.src = moveStationImg_A.src; 
			break;
		case 2:
			mainImg.src = moveStationImg_B.src;
			break;
		case 3:
			mainImg.src = moveStationImg_C.src;
			break;	
		}
	}*/
	
	leftName.style.display = "";
	rightName.style.display = "";
	
	stationNameChange();
	setInterLine();
	
	//map3 문열림 방향 blink작업중
	setDoorSide();
	if(isDoorOpenVisible){
		//document.getElementById("MsgBox4").innerHTML = doorOpenViewArr[rdCnt[mapChangeCount%4]];
		//document.getElementById("MsgBox4").innerHTML = doorOpenViewArr[rdCnt[(mapChangeCount-1)%10]];
		document.getElementById("MsgBox4").innerHTML = doorOpenViewArr[rdCnt[(map3RepeatCount-1)%10]];
		doorTextInterval = setInterval("doorTxtBlink()",1500);
	}
	
	//timeID = setTimeout("setDetailLine()",mapChangeIntervalTime);
	timeID = setTimeout("clearPointMark('B')", mapChangeIntervalTime);// -> M3 반복
}

function doorTxtBlink(){
	if(0 ==doorTxtblinkCnt){
		document.getElementById("MsgBox4").style.display = "none";
		doorTxtblinkCnt = 1;
	}else if(1 ==doorTxtblinkCnt){
		document.getElementById("MsgBox4").style.display = "block";
		doorTxtblinkCnt = 0;
	}
}

function setStationName(doorSideVal, stationCode)
{	
	if( currMapDisplay == 4 )return;
	
	if("RD" == dispType && rdCnt == null){
		rdCnt = getRdType();
		rdCnt = rdCnt.split("#");
	}
	
	mapChangeCount += 1;
	clearPointMark('C');
	clearMoveArrorBlink();
	currMapDisplay = 4;
	stationChangeCount = 0;
	
	/*if( intervalID2 == null ){
		intervalID2 = setInterval("stationNameChange()",lanIntervalTime);
	}else{
		clearInterval(intervalID2);
		intervalID2 = null;
		intervalID2 = setInterval("stationNameChange()",lanIntervalTime);
	}*/
	doorSide = doorSideVal;
	var mainImg = document.getElementById("mainImg");	

	leftName.innerHTML = "";
	rightName.innerHTML = "";
	
	if( Destination_code == stationCode ){
		//mainImg.src = stationMapImg_B.src;
		
		prev_name_arr = new Array();
		prev_name_arr.push(prev_name.english,prev_name.telugu,prev_name.urdu,prev_name.hindi);
		next_name_arr = new Array();
		next_name_arr.push("","","","");
		curr_name_arr = new Array();
		curr_name_arr.push(curr_name.english,curr_name.telugu,curr_name.urdu,curr_name.hindi);
		
		//방향별 RD 이미지 반전 적용
		if(getMirrorType()){
			mainImg.src = eval("stationMapImg"+line_no+"_B_.src");
		}else{
			mainImg.src = eval("stationMapImg"+line_no+"_B.src");
		}
	}else if( Departure_code == stationCode ){
		//출발역 이미지 show
		mapChangeCount = 0;
		isDepature = true;
		//20150421 출발역일경우 다음역 환승정보를 가져오고 있는 로직이 문제가 있어 삭제
		//var tmpInterNext = interLineNo.next;
		//interLineNo.next = interLineNo.curr;
		//interLineNo.curr = tmpInterNext;
		
		//20150421 출발역일경우마다 환승역을 체크하도록 추가 : STR
		var data = "line"+line_no;
		var tmpNo = 0;
		var tmpInter1 = ""
		var tmpInter2 = "";
		interLineNo = new Object();
		
		for(var i = 0 ;i< eval(data).station.length;i++ ){
			if(eval(data).station[i].code == stationCode){
				tmpNo = eval(data).station[i].no;
				interLineNo.curr = eval(data).station[i].interchange;
			}
		}
		
		for(var i = 0 ;i< eval(data).station.length;i++ ){
			if(eval(data).station[i].no == (tmpNo-0)+1){
				tmpInter1 = eval(data).station[i].interchange;
			}else if(eval(data).station[i].no == tmpNo-1){
				tmpInter2 = eval(data).station[i].interchange;
			}else{
				continue;
			}
		}
		
		if(updown == "<"){
			interLineNo.next = tmpInter1;
			interLineNo.prev = tmpInter2;
		}else if(updown == ">"){
			interLineNo.next = tmpInter2;
			interLineNo.prev = tmpInter1;
		}
		
		//20150421 출발역일경우마다 환승역을 체크하도록 추가 : END
		
		prev_name_arr = new Array();
		prev_name_arr.push("","","","");
		next_name_arr = new Array();
		next_name_arr.push(curr_name.english,curr_name.telugu,curr_name.urdu,curr_name.hindi);
		curr_name_arr = new Array();
		curr_name_arr.push(prev_name.english,prev_name.telugu,prev_name.urdu,prev_name.hindi);
		
		//방향별 RD 이미지 반전 적용
		if(getMirrorType()){
			mainImg.src = eval("stationMapImg"+line_no+"_C_.src");
		}else{
			mainImg.src = eval("stationMapImg"+line_no+"_C.src");
		}
		stationNameChange();
	}else{
		next_name_arr = new Array();
		if(next_name == undefined || next_name == null || typeof(next_name_arr.english) != "undefined"){
			next_name_arr.push("","","","");
		}else{
			next_name_arr.push(next_name.english,next_name.telugu,next_name.urdu,next_name.hindi);
		}
		
		//방향별 RD 이미지 반전 적용
		if(getMirrorType()){
			mainImg.src = eval("stationMapImg"+line_no+"_A_.src");
		}else{
			mainImg.src = eval("stationMapImg"+line_no+"_A.src");
		}
	}

	//setDoorSide();
	/*if( intervalID2 == null ){
		clearInterval(intervalID2);
		intervalID2 = null;
		AndroidFunction.DebugOut(33," train.js setStationName lanIntervalTime : " + lanIntervalTime);
		intervalID2 = setInterval("stationNameChange()",lanIntervalTime);
	}else{
		stationNameChange();
	}*/
	
	stationNameChange();
	
	setInterLine();	

	if(map4RepeatCount == 0)//M4 두번째 반복할때 isDoorOpenVisible 값이 불규칙하게 들어오는 bug 방어코드.
		tmpIsDoorOpenVisible = isDoorOpenVisible;
	console.log('m4 map4RepeatCount : '+map4RepeatCount+', isDoorOpenVisible : '+isDoorOpenVisible + ', tmpIsDoorOpenVisible : '+tmpIsDoorOpenVisible);
	//if(isDoorOpenVisible){
	if(tmpIsDoorOpenVisible){
		//document.getElementById("MsgBox4").innerHTML = doorOpenViewArr[rdCnt[mapChangeCount%4]];
		document.getElementById("MsgBox4").innerHTML = doorOpenViewArr[rdCnt[(rdCnt.length+map4RepeatCount%2-2)%10]];
	}
	
	//JSLEE S //M4 반복.	
	if(map4RepeatCount == 0){	
		map4RepeatCount += 1;
		currMapDisplay = 3;
		timeID = setTimeout("setStationName('"+doorSideVal+"', '"+stationCode+"')", mapChangeIntervalTime);		
	}	
	//JSLEE E
}

function setInterLine(){
	clearInterLine();
	var leftDiv = document.getElementById("lInter");
	var rightDiv = document.getElementById("rInter");
	var prevDiv = document.getElementById("prevInter");
	var currDiv = document.getElementById("currInter");
	var nextDiv = document.getElementById("nextInter");
	
	var prev = interLineNo.prev;
	var curr = interLineNo.curr;
	var next = interLineNo.next;
	
	if( currMapDisplay == 3 ){
		//interLineNo
		//방향별 RD 환승역 이미지 반전 적용
		if(getMirrorType()){
			if( prev != "" && prev != "undefined" && prev != undefined ){
				rightDiv.style.background = "url("+eval("moveTransfer"+prev+".src")+")";
				rightDiv.style.display = "block";
				interBlinkStat = "none";
			}
			if( curr != "" && curr != "undefined" && prev != undefined ){
				leftDiv.style.background = "url("+eval("moveTransfer"+curr+".src")+")";
				leftDiv.style.display = "block";
				interBlinkStat = "none";
			}
		}else{
			if( prev != "" && prev != "undefined" && prev != undefined ){
				leftDiv.style.background = "url("+eval("moveTransfer"+prev+".src")+")";
				leftDiv.style.display = "block";
				interBlinkStat = "none";
			}
			if( curr != "" && curr != "undefined" && prev != undefined ){
				rightDiv.style.background = "url("+eval("moveTransfer"+curr+".src")+")";
				rightDiv.style.display = "block";
				interBlinkStat = "none";
			}
		}
	}else if( currMapDisplay == 4 ){
		if( prev != "" || curr != "" || next != "" ){
			//2호선 0x1C 출발역일경우 예외처리			
			if(line_no == 2 && isDepature){
				//currDiv.style.background = "url("+eval("stationTransfer"+curr+".src")+")";
				currDiv.style.background = "url("+stationTransfer3.src+")";
				currDiv.style.display = interBlinkStat;
				interLineNo.curr = "3";
			}else{
				//방향별 RD 환승역 이미지 반전 적용
				if(getMirrorType()){
					if( prev != "" && prev != "undefined" && prev != undefined ){
						nextDiv.style.background = "url("+eval("interImgNextPrev"+prev+".src")+")";
						nextDiv.style.display = interBlinkStat;
					}
					if( curr != "" && curr != "undefined" && curr != undefined){
						currDiv.style.background = "url("+eval("stationTransfer"+curr+".src")+")";
						currDiv.style.display = interBlinkStat;
					}
					if( next != "" && next != "undefined" && next != undefined){
						prevDiv.style.background = "url("+eval("interImgNextPrev"+next+".src")+")";
						prevDiv.style.display = interBlinkStat;
					}
				}else{
					if( prev != "" && prev != "undefined" && prev != undefined ){
						prevDiv.style.background = "url("+eval("interImgNextPrev"+prev+".src")+")";
						prevDiv.style.display = interBlinkStat;
					}
					if( curr != "" && curr != "undefined" && curr != undefined){
						currDiv.style.background = "url("+eval("stationTransfer"+curr+".src")+")";
						currDiv.style.display = interBlinkStat;
					}
					if( next != "" && next != "undefined" && next != undefined){
						nextDiv.style.background = "url("+eval("interImgNextPrev"+next+".src")+")";
						nextDiv.style.display = interBlinkStat;
					}
				}
			}
			interBlinkStat = "none";
		}
	}
	interTimer = setInterval("blinkInterLine()",1000);
}

function blinkInterLine(){
	var prev = interLineNo.prev;
	var curr = interLineNo.curr;
	var next = interLineNo.next;
	if( currMapDisplay == 3 ){
		if( prev != "" || curr != "" ){
			//방향별 RD 환승역 이미지 반전 적용
			if(getMirrorType()){
				if( prev != "" ){
					document.getElementById("rInter").style.display = interBlinkStat;
				}
				if( curr != "" ){
					document.getElementById("lInter").style.display = interBlinkStat;
				}
			}else{
				if( prev != "" ){
					document.getElementById("lInter").style.display = interBlinkStat;
				}
				if( curr != "" ){
					document.getElementById("rInter").style.display = interBlinkStat;
				}
			}
			interBlinkStat = interBlinkStat == "none" ? "block" : "none";
		}else{
			clearInterLine();
		}
	}else if( currMapDisplay == 4 ){
		if( prev != "" || curr != "" || next != "" ){
			//방향별 RD 환승역 이미지 반전 적용
			if(getMirrorType()){
				if( prev != "" ){
					document.getElementById("nextInter").style.display = interBlinkStat;
				}
				if( curr != "" ){
					document.getElementById("currInter").style.display = interBlinkStat;
				}
				if( next != "" ){
					document.getElementById("prevInter").style.display = interBlinkStat;
				}
			}else{
				if( prev != "" ){
					document.getElementById("prevInter").style.display = interBlinkStat;
				}
				if( curr != "" ){
					document.getElementById("currInter").style.display = interBlinkStat;
				}
				if( next != "" ){
					document.getElementById("nextInter").style.display = interBlinkStat;
				}
			}
			interBlinkStat = interBlinkStat == "none" ? "block" : "none";
			if( isDoorOpenVisible ){
				document.getElementById("MsgBox4").style.display = interBlinkStat;
			}
		}else{
			if( isDoorOpenVisible ){
				//if(0 ==doorTxtblinkCnt){
					//document.getElementById("MsgBox4").style.display = "none";
					//doorTxtblinkCnt = 1;
				//}else if(1 ==doorTxtblinkCnt){
					document.getElementById("MsgBox4").style.display = "block";
					//doorTxtblinkCnt = 0;
				//}
			}
		}
		
	}
}

function clearInterLine(){
	document.getElementById("lInter").style.background = "";
	document.getElementById("rInter").style.background = "";
	document.getElementById("lInter").style.display = "none";
	document.getElementById("rInter").style.display = "none";
	document.getElementById("prevInter").style.background = "";
	document.getElementById("currInter").style.background = "";
	document.getElementById("nextInter").style.background = "";
	document.getElementById("prevInter").style.display = "none";
	document.getElementById("currInter").style.display = "none";
	document.getElementById("nextInter").style.display = "none";
	interBlinkStat = "block";
	if( interTimer != null ){
		clearInterval(interTimer);
		interTimer = null;
	}
}

function stationNameChange(){
	
	if("RD" == dispType && rdCnt == null){
		rdCnt = getRdType();
		rdCnt = rdCnt.split("#");
	}
	
	if(rdCnt == null){
		error("getRdType() fail app restart");
		var cmd = null;
		cmd = AndroidFunction.JSONs(null, "restart.to", "Launcher");
		cmd = AndroidFunction.JSONs(cmd, "restart.request", "false");
		cmd = AndroidFunction.JSONs(cmd, "restart.value", "1000");
		AndroidFunction.JsonRun(cmd);
	}
	
	
	//resolveAfterTxt(rdCnt[mapChangeCount%4]);
	//resolveAfterTxt();
	
	var m3_fontSize_path = "/sdcard/metro/main/m3_fontSize.conf";
	var m4_side_fontSize_path = "/sdcard/metro/main/m4_side_fontSize.conf";
	var m4_center_fontSize_path = "/sdcard/metro/main/m4_center_fontSize.conf";
	var colorCode1_path = "/sdcard/metro/main/line1_fontColor.conf";
	var colorCode2_path = "/sdcard/metro/main/line2_fontColor.conf";
	var colorCode3_path = "/sdcard/metro/main/line3_fontColor.conf";
	
	var m3_fontSize = "45";
	var m4_side_fontSize = "26";
	var m4_center_fontSize = "55";
	/*var colorCode1 = "#FF0000";
	var colorCode2 = "#87CE00";
	var colorCode3 = "#0054FF";*/
	var colorCode1 = "#000000";
	var colorCode2 = "#000000";
	var colorCode3 = "#000000";
	
	if(AndroidFunction.FileExist(m3_fontSize_path)){
		var val = AndroidFunction.Cat(m3_fontSize_path);
		if("0" != val || "" != val || "null" != val){
			m3_fontSize = val;
		}
	}
	if(AndroidFunction.FileExist(m4_side_fontSize_path)){
		var val = AndroidFunction.Cat(m4_side_fontSize_path);
		if("0" != val || "" != val || "null" != val){
			m4_side_fontSize = val;
		}
	}
	if(AndroidFunction.FileExist(m4_center_fontSize_path)){
		var val = AndroidFunction.Cat(m4_center_fontSize_path);
		if("0" != val || "" != val || "null" != val){
			m4_center_fontSize = val;
		}
	}
	if(AndroidFunction.FileExist(colorCode1_path)){
		var val = AndroidFunction.Cat(colorCode1_path);
		if("0" != val || "" != val || "null" != val){
			colorCode1 = val;
		}
	}
	if(AndroidFunction.FileExist(colorCode2_path)){
		var val = AndroidFunction.Cat(colorCode2_path);
		if("0" != val || "" != val || "null" != val){
			colorCode2 = val;
		}
	}
	if(AndroidFunction.FileExist(colorCode3_path)){
		var val = AndroidFunction.Cat(colorCode3_path);
		if("0" != val || "" != val || "null" != val){
			colorCode3 = val;
		}
	}
	
	var colorCode = "#FFFFFF";
	if(line_no == 1){
		colorCode = colorCode1; 
	}else if(line_no == 2){
		colorCode = colorCode2;  
	}else if(line_no == 3){
		colorCode = colorCode3; 
	}
	
	if( currMapDisplay == 1 ){
		/*var mainImg = document.getElementById("mainImg");
		switch (line_no) {
		case 1:
			mainImg.src = eval("lineImgAll_A_"+rdCnt[mapChangeCount]+".src");
			//imgObj.src = lineImgAll_A.src; 
			break;
		case 2:
			mainImg.src = eval("lineImgAll_B_"+rdCnt[mapChangeCount]+".src");
			//imgObj.src = lineImgAll_B.src;
			break;
		case 3:
			mainImg.src =  eval("lineImgAll_C_"+rdCnt[mapChangeCount]+".src");
			//imgObj.src = lineImgAll_C.src;
			break;	
		default:
			break;
		}*/
		//mapChangeCount = 1;
	  }else if( currMapDisplay == 2 ){	
		 /* mapChangeCount = 3;
		var mainImg = document.getElementById("mainImg");
		switch (line_no) {
		case 1:
			if(updown == "<") mainImg.src =  eval("lineImg1_A_"+rdCnt[mapChangeCount]+".src"); 
			else mainImg.src =  eval("lineImg1_B_"+rdCnt[mapChangeCount]+".src"); 
			break;
		case 2:
			if(updown == "<") mainImg.src =  eval("lineImg2_A_"+rdCnt[mapChangeCount]+".src"); 
				else mainImg.src =  eval("lineImg2_B_"+rdCnt[mapChangeCount]+".src"); 
			break;
		case 3:
			if(updown == "<") mainImg.src =  eval("lineImg3_A_"+rdCnt[mapChangeCount]+".src"); 
			else mainImg.src =  eval("lineImg3_B_"+rdCnt[mapChangeCount]+".src"); 
			break;	
		}*/
	}else if( currMapDisplay == 3 ){
		console.log("currMapDisplay == 3 mapChangeCount : "+ mapChangeCount+", map3RepeatCount : "+ map3RepeatCount+", rdCnt[(map3RepeatCount-1)%10] : "+ rdCnt[(map3RepeatCount-1)%10]);
		//방향별 RD TEXT 반전 적용
		if(getMirrorType()){
			//if(leftName != undefined) leftName.innerHTML = '<span class="leftRightSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
			//if(rightName != undefined) rightName.innerHTML = '<span class="leftRightSpanA"  style="color:'+colorCode+';">'+prev_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
			if(leftName != undefined) leftName.innerHTML = '<span class="leftRightSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[(map3RepeatCount-1)%10]]+'</span>';//JSLEE
			if(rightName != undefined) rightName.innerHTML = '<span class="leftRightSpanA"  style="color:'+colorCode+';">'+prev_name_arr[rdCnt[(map3RepeatCount-1)%10]]+'</span>';//JSLEE
		}else{
			//if(leftName != undefined) leftName.innerHTML = '<span class="leftRightSpanA" style="color:'+colorCode+';">'+prev_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
			//if(rightName != undefined) rightName.innerHTML = '<span class="leftRightSpanA"  style="color:'+colorCode+';">'+curr_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
			if(leftName != undefined) leftName.innerHTML = '<span class="leftRightSpanA" style="color:'+colorCode+';">'+prev_name_arr[rdCnt[(map3RepeatCount-1)%10]]+'</span>';//JSLEE
			if(rightName != undefined) rightName.innerHTML = '<span class="leftRightSpanA"  style="color:'+colorCode+';">'+curr_name_arr[rdCnt[(map3RepeatCount-1)%10]]+'</span>';//JSLEE
		}
		
		leftName.style.fontSize = m3_fontSize + "pt";
		leftName.style.lineHeight = m3_fontSize + "pt";
		rightName.style.fontSize = m3_fontSize + "pt";
		rightName.style.lineHeight = m3_fontSize + "pt";
	}else if( currMapDisplay == 4 ){
		//방향별 RD TEXT 반전 적용
		if(getMirrorType()){
			if(prev_name_arr == null || prev_name_arr[rdCnt[stationChangeCount]] == null){				
				//if(next_name != undefined) prevName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+next_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				//if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				if(next_name != undefined) prevName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+next_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
				if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
			}else if(next_name_arr == null ||next_name_arr[rdCnt[stationChangeCount]] == null){				
				//if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				//if(prev_name != undefined) nextName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+prev_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
				if(prev_name != undefined) nextName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+prev_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
			}else{				
				//if(prev_name != undefined) nextName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+prev_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				//if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				//if(next_name != undefined) prevName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+next_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				if(prev_name != undefined) nextName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+prev_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
				if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
				if(next_name != undefined) prevName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+next_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
			}
		}else{
			if(prev_name_arr == null || prev_name_arr[rdCnt[stationChangeCount]] == null){				
				//if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				//if(next_name != undefined) nextName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+next_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
				if(next_name != undefined) nextName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+next_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
			}else if(next_name_arr == null || next_name_arr[rdCnt[stationChangeCount]] == null){				
				//if(prev_name != undefined) prevName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+prev_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				//if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				if(prev_name != undefined) prevName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+prev_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
				if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
			}else{
				//if(prev_name != undefined) prevName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+prev_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				//if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				//if(next_name != undefined) nextName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+next_name_arr[rdCnt[mapChangeCount%4]]+'</span>';
				if(prev_name != undefined) prevName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+prev_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
				if(curr_name != undefined) currName.innerHTML = '<span class="msgBoxSpanA" style="color:'+colorCode+';">'+curr_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
				if(next_name != undefined) nextName.innerHTML = '<span class="msgBoxSpanB" style="color:'+colorCode+';">'+next_name_arr[rdCnt[rdCnt.length+map4RepeatCount%2-2]]+'</span>';//JSLEE
			}
		}
				
		prevName.style.fontSize = m4_side_fontSize+"pt";
		prevName.style.lineHeight = m4_side_fontSize+"pt";
		nextName.style.fontSize = m4_side_fontSize+"pt";
		nextName.style.lineHeight = m4_side_fontSize+"pt";
		currName.style.fontSize = m4_center_fontSize+"pt";
		currName.style.lineHeight = m4_center_fontSize+"pt";
	}
	/*// 0 , 1  , 2 , 3
	//stationChangeCount = (stationChangeCount - 1) * (-1);
	if(stationChangeCount < 3){
		stationChangeCount += 1;  
	}else{
		stationChangeCount = 0;
	}*/
}


function objToString (obj) {
    var str = '';
    for (var key in obj) {
        if (obj.hasOwnProperty(key)) {
        
            str += key + '=' + obj[key] + '\n';
            
        }
        
    }
    
    return str;
    
}

function resolveAfterTxt(){
	var doc = document.getElementById("MsgBox2");
	doc.innerHTML = (destination_name[rdCnt[mapChangeCount%4]]).replace("<br/>"," ");
	doc.style.top = (24 + (mapChangeCount%4))+"px";
	//doc.style.top = "3"+mapChangeCount%4+"px";
	/*setTimeout(function(){
		document.getElementById("MsgBox2").style.top = "30px";
	},10);*/
}

function resolveAfterTxt2(desArrName){//우측 상단 도착지 표시. 언어설정배열 0번째값동작.
	
	var typeCnt = null;
	if("RD" == dispType){
		typeCnt = getRdType();
		typeCnt = typeCnt.split("#");
	}else if("PID" == dispType){
		typeCnt = getPidType();
		typeCnt = typeCnt.split("#");
	}
	
		var doc = document.getElementById("MsgBox2");
		
		var desTmp = null;
		if(desArrName != "" && typeof(desArrName) != 'undefined') 
		{
			desTmp = (desArrName[typeCnt[0]]).replace("<br/>"," ");
		}else{
			desTmp = null;
		}
		
		if(doc.innerHTML != desTmp) doc.innerHTML = desTmp;

	//doc.style.top = (24 + (mapChangeCount%4))+"px";
	//doc.style.top = "3"+mapChangeCount%4+"px";
	/*setTimeout(function(){
		document.getElementById("MsgBox2").style.top = "30px";
	},10);*/
}


function getParseInt(val){
	return parseInt('val').toString(10);
}

function getParseStationCode(val){
	return "0x"+val;
	/*
	var lower = val.substr(0,2);
	var upper = val.substr(2,2);
	lower = lower.replace('00','0x');
	return lower + upper;*/
}

function getDisplayType(){
	var displayType = "";
	var stbIp = AndroidFunction.IPv4();
	var splitIp = stbIp.split("."); //3번째 IP는 호차번호
	if(176 <= splitIp[3] && 191 >= splitIp[3]){
		displayType = "PID";
	}else if(192 <= splitIp[3] && 207 >= splitIp[3]){
		displayType = "RD";
	}
	return displayType;
}

function getRdIndex(){
	var stbIp = AndroidFunction.IPv4();
	var splitIp = stbIp.split(".")[3];
	console.log('getRdIndex() splitIp : '+splitIp);
	return (splitIp - 193) + 1;
}

function getRdType(){
	var idx = getRdIndex();
	//0:English 1:Teleugu  2:Urdu  3:Hindi
	var resultType = "";
	/*if(idx == 1 || idx == 8){
		resultType = "0#1#3#2";
	}else if(idx == 2 || idx == 7){
		resultType = "2#0#1#3";
	}else if(idx == 3 || idx == 6){
		resultType = "1#3#2#0";
	}else if(idx == 4 || idx == 5){
		resultType = "3#2#0#1";
	}else{
		error("!!getRdType Select Fail , RdType = 0#1!!");
		resultType = "0#1#3#2";
	}*/
	
	/*
	 20151215 형철 추가
	 if(idx == 1 || idx == 6){
		resultType = "0#1#3#2"; //E , T , H , U
	}else if(idx == 2 || idx == 5){ 
		resultType = "3#2#0#1"; //H , U , E , T
	}else if(idx == 3 || idx == 8){
		resultType = "1#3#2#0"; // T , H , U , E
	}else if(idx == 4 || idx == 7){
		resultType = "2#0#1#3"; //U , E , T , H
	}else{
		error("!!getRdType Select Fail , RdType = 0#1#3#2");
		resultType = "0#1#3#2";
	}*/
	/* 0 E,
	   1 T
	   2 U
	   3 H
	 */
	if(idx == 1 || idx == 5){
		//	                                  M1 M2 M1 M2 M3 M3 M3 M3 M4 M4		
		resultType = "0#0#2#2#0#2#1#3#0#2"; //E, E, U, U, E, U, T, H, E, U //RD 1, 5		
	}else if(idx == 2 || idx == 6){ 
		resultType = "1#1#3#3#1#3#0#2#1#3"; //T, T, H, H, T, H, E, U, T, H //RD 2, 6
	}else if(idx == 3 || idx == 7){
		resultType = "3#3#1#1#3#1#2#0#3#1"; //H, H, T, T, H, T, U, E, H, T //RD 3, 7
	}else if(idx == 4 || idx == 8){
		resultType = "2#2#0#0#2#0#3#1#2#0"; //U, U, E, E, U, E, H, T, U, E //RD 4, 8
	}else{
		error("!!getRdType Select Fail , RdType = 0#1#3#2");
		resultType = "0#0#2#2#0#2#1#3#0#2"; //E, E, U, U, E, U, T, H, E, U
	}
	
	
	return resultType;
}

function getPidIndex(){
	var stbIp = AndroidFunction.IPv4();
	var splitIp = stbIp.split(".")[3];
	return (splitIp - 177) + 1;
}

function getPidType(){
	var idx = getPidIndex();
	
	//0:English 1:Teleugu  2:Urdu  3:Hindi
	var resultType = "";
	
	//Index별 순서
	/*if(idx == 1){
		resultType = "0#2#3"; //E,U,H 
	}else if(idx == 2){
		resultType = "1#0#2"; //T,E,U
	}else if(idx == 3){
		resultType = "3#1#0"; //H,T,E
	}else if(idx == 4){
		resultType = "2#3#1"; //U,H,T
	}else{
		error("!!getPidType Select Fail , RdType = 0#2#3");
		resultType = "0#2#3"; //E,U,H
	}*/
	
	//차량에 설치되는 실제 PID 순서 순서(1<->2 , 3<->4 위치가 바뀐다)
	/*if(idx == 1){
		resultType = "1#0#2"; //T,E,U
	}else if(idx == 2){
		resultType = "0#2#3"; //E,U,H 
	}else if(idx == 3){
		resultType = "2#3#1"; //U,H,T
	}else if(idx == 4){
		resultType = "3#1#0"; //H,T,E
	}else{
		error("!!getPidType Select Fail , RdType = 0#2#3");
		resultType = "0#2#3"; //E,U,H
	}*/
	
	//차량에 설치되는 실제 PID 순서 순서(1<->2 , 3<->4 위치가 바뀐다)
	if(idx == 1){
		resultType = "3#1#2#0"; //H,T,U,E 
	}else if(idx == 2){
		resultType = "0#3#1#2"; //E,H,T,U
	}else if(idx == 3){
		resultType = "2#0#3#1"; //U,E,H,T
	}else if(idx == 4){
		resultType = "1#2#0#3"; //T,U,E,H
	}else{
		error("!!getPidType Select Fail , RdType = 0#3#1#2");
		resultType = "0#3#1#2"; //E,H,T,U
	}
	return resultType;
}

function showNowTime(timeType){
	//1:24시간(HH:ss) , 2:12시간(a/p hh:ss) , 3:24시간(HH:mm:ss) , 4:12시간(a/p hh:mm:ss)
	var strDate = "";
	switch (parseInt(timeType)) {
	case 1:
		strDate = new Date().format("HH:mm");
		break;
	case 2:
		strDate = new Date().format("a/p hh:mm");
		break;
	case 3:
		strDate = new Date().format("HH:mm:ss");
		break;
	case 4:
		strDate = new Date().format("a/p hh:mm:ss");
		break;
	default:
		strDate = new Date().format("HH:mm");
		break;
	}
	document.getElementById("NowTime").innerHTML = strDate;
}

function hideNowTime(){
	if( null != nowTimer){
		clearInterval(nowTimer);
		nowTimer = null;
	}
	document.getElementById("NowTime").innerHTML = "";
}

function isShortLoop( idx ){
	checkLineNo(1644);
	var lineInfo = eval("line"+line_no).station;
	var defualtDepNo = lineInfo[0].no;
	var defualtDesNo = lineInfo[lineInfo.length-1].no;
	if( defualtDesNo != desStationNo || defualtDepNo != depStationNo ){
		var stationNo = eval("line"+line_no).station[idx].no; // 현재 들어온 인덱스 코드
		if( updown == ">" ){ //하행선일때
			if( stationNo <= defualtDesNo && stationNo > depStationNo ){
				return true;
			}else if( stationNo >= defualtDepNo && stationNo < desStationNo ){
				return true;
			}
		}else{
			if( stationNo >= defualtDepNo && stationNo < depStationNo ){
				return true;
			}else if( stationNo <= defualtDesNo && stationNo > desStationNo ){
				return true;
			}
		}
	}
	return false;
}

//이미지 방향 변경 여부
//정방향일경우 우측(짝수) Mirror True
//역방향 일경우 좌측(홀수) Mirror True
function getMirrorType(){
	var stbIp = AndroidFunction.IPv4();
	var splitIp = stbIp.split("."); //3번째 IP는 호차번호
	var remainingValue = splitIp[3]%2;
	var isResult = false;
	
	if( headInfo.Car1 == 1 && tailInfo.OppositeCar == 1 ){
		//정방향
		if(remainingValue == 0){
			isResult = true;
			log("getMirrorType : head car1 == 1 , even ip , return true");
		}
	}else if( tailInfo.Car1 == 1 && headInfo.OppositeCar == 1 ){
		//역방향
		if(remainingValue != 0){
			isResult = true;
			log("getMirrorType : tail car1 == 1 , odd ip , return true");
		}
	}else{
		error("getMirrorType : !!head car and tail car valued check!!!");
	}
	
	//호차번호가 6일경우 반대
	if(splitIp[2] == '6'){
		isResult = !isResult
	}
	return isResult;
}