/// ½ºÆ®¸µ °´Ã¼¿¡ ¸Þ¼Òµå Ãß°¡ ///
String.prototype.trim = function(str) {
	str = this != window ? this : str;

	return str.replace(/^\s+/g,'').replace(/\s+$/g,'');
}

String.prototype.hasFinalConsonant = function(str) {
	str = this != window ? this : str;

	var strTemp = str.substr(str.length-1);

	return ((strTemp.charCodeAt(0)-16)%28!=0);
}

String.prototype.bytes = function(str) {
	str = this != window ? this : str;
	var len = 0; //bug. ÀÌ ÇÑÁÙ¶§¹®¿¡ °í»ýÀ».. ³Ö¾îÁÖ¼¼¿ä. -_-;;

	for(j=0; j<str.length; j++) {
		var chr = str.charAt(j);
		len += (chr.charCodeAt() > 128) ? 2 : 1
	}

	return len;
}
// ´ë¼Ò¹®ÀÚ ±¸º°ÇÏÁö ¾Ê°í ´Ü¾î À§Ä¡ Ã£±â
String.prototype.ipos = function (needle, offset) {
	var offset = (typeof offset == "number")?offset:0;

	return str.toLowerCase().indexOf(needle.toLowerCase(), offset);
}

// ´ë¼Ò¹®ÀÚ ±¸º°ÇÏÁö ¾Ê°í µÚ¿¡¼­ºÎÅÍ ´Ü¾îÀ§Ä¡ Ã£±â
String.prototype.ripos = function (needle, offset) {
	var offset = (typeof offset == "number")?offset:0;

	return str.toLowerCase().lastIndexOf(needle.toLowerCase(), offset);
}

// ¹®ÀÚ¿­À» ¹è¿­·Î
String.prototype.toArray = function () {
	var len = this.length;
	var arr = new Array;

	for (var i=0; i<len; i++) arr[i] = this.charAt(i);

	return arr;
}
//¹®ÀÚ¿­À» ÀüºÎ replaceÇÏ±â
String.prototype.replaceAll = function(str1, str2)
{
	var temp_str = "";

	if((this.trim().length>0) && (str1 != str2)){
		temp_str = this.trim();
		while (temp_str.indexOf(str1) > -1){
			temp_str = temp_str.replace(str1, str2);
		}
	}
	return temp_str;
}


/// ¿¡·¯¸Þ½ÃÁö Æ÷¸ä Á¤ÀÇ ///
var NO_BLANK = "{name+Àº´Â} ÇÊ¼ö Ç×¸ñÀÔ´Ï´Ù";
var NOT_VALID = "{name+ÀÌ°¡} ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù";
//var NO_BLANK = "{name+Àº´Â} required column";
//var NOT_VALID = "{name+Àº´Â} invalid";
var TOO_LONG = "{name}ÀÇ ±æÀÌ°¡ ÃÊ°úµÇ¾ú½À´Ï´Ù (ÃÖ´ë {maxbyte}¹ÙÀÌÆ®)";

function procJsExp(objException){
	var strMsg = "";
	
	strMsg += "Ã³¸® °úÁ¤¿¡¼­ ¿À·ù°¡ ¹ß»ý ÇÏ¿´½À´Ï´Ù.\n\n";
	strMsg += "¿À·ù °³Ã¼: " + objException + "\n";
	strMsg += "¿À·ù ¹øÈ£: " + objException.number + "\n";
	strMsg += "¿À·ù ¼³¸í:\n    " + objException.description + "\n";
	
	alert(strMsg);
	
	if(eval(event)){
		event.returnValue = false;
	}
	return false;
}

function josa(str,tail) {
	return (str.hasFinalConsonant()) ? tail.substring(0,1) : tail.substring(1,2);
}

function isValidEmail(el,value) {
	var value = value ? value : el.value;
	var pattern = /^[_a-zA-Z0-9-\.]+@[\.a-zA-Z0-9-]+\.[a-zA-Z]+$/;
	return (pattern.test(value)) ? true : doError(el,NOT_VALID);
}

function doError(el,type,action) {
	var pattern = /{([a-zA-Z0-9_]+)\+?([°¡-Èþ]{2})?}/;
	var name = (hname = el.getAttribute("HNAME")) ? hname : el.getAttribute("NAME");
	pattern.exec(type);
	var tail = (RegExp.$2) ? josa(eval(RegExp.$1),RegExp.$2) : "";
	//var tail = " is";
	//alert(type.replace(pattern, eval(RegExp.$1) + tail));
	alert(type.replace(pattern, eval(RegExp.$1) + tail) + "!!");
	//alert(type.replace(pattern,"\"" + eval(RegExp.$1) + "\"" + tail));
	if (action == "sel") {
		el.select();
	} else if (action == "del")	{
		el.value = "";
	}
	el.focus();

	return false;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	obj.visibility=v; }
}
MM_reloadPage(true);

function ff_OnPopup(PARAM_URL, PARAM_NAME, PARAM_WIDTH, PARAM_HEIGHT) {
	Options = "scrollbars=no, status=no, resizable=no, width=" + PARAM_WIDTH + ", height=" + PARAM_HEIGHT;

	window.open(PARAM_URL, PARAM_NAME, Options);
}
function ff_OnPopup2(PARAM_URL, PARAM_NAME, PARAM_WIDTH, PARAM_HEIGHT) {
	Options = "scrollbars=yes, status=yes, resizable=no, width=" + PARAM_WIDTH + ", height=" + PARAM_HEIGHT;

	window.open(PARAM_URL, PARAM_NAME, Options);
}

function ff_OnPopup3(PARAM_URL, PARAM_NAME, PARAM_WIDTH, PARAM_HEIGHT) {
	Options = "scrollbars=yes, status=yes, resizable=yes, width=" + PARAM_WIDTH + ", height=" + PARAM_HEIGHT;

	window.open(PARAM_URL, PARAM_NAME, Options);
}

function ff_OnPopup4(PARAM_URL, PARAM_NAME, PARAM_WIDTH, PARAM_HEIGHT) {
	Options = "scrollbars=no, status=no, resizable=no, width=" + PARAM_WIDTH + ", height=" + PARAM_HEIGHT;

	window.open(PARAM_URL, PARAM_NAME, Options);

}

function ff_OnPopup5(PARAM_URL, PARAM_NAME, PARAM_WIDTH, PARAM_HEIGHT) {
	Options = "scrollbars=no, status=no, resizable=no, width=" + PARAM_WIDTH + ", height=" + PARAM_HEIGHT;

	window.popup(PARAM_URL, PARAM_NAME, Options);
}

function setRouteMapWin(intBusID){
    ff_OnPopup3('/maps/main_route.asp?m=8&num='+intBusID, 'al_BusMap', '1015', '695');
	//ff_OnPopup3('/main_bus_etc.asp?num='+intBusID, 'al_BusMap', '1015', '695');
}

function setLineInfo(id, num) {
	var ctlMap = parent.top.map.document.getElementById("IntraMap2DXMTIS");
	ctlMap.FindBusPath(num, id);
}

//°Ô½ÃÆÇÀÇ ÆäÀÌÁö¸¦ ¿¬´Ù.
function setMainMenu(strUrl) {
	var ctlLogoImg = document.getElementById("imgLogo");

	//window.location.href(strUrl, 'AlgogaMain');
	window.location.href(strUrl);
	if(ctlLogoImg){
		ctlLogoImg.focus();
	}
}
function echo(strMassage){
	document.write(strMassage);
}
function gisFix() {
	var ctlMap = document.getElementById("IntraMap2DXMTIS");
	var strData;

	try{
		ctlMap.ResetMap();
		strData = ctlMap.getDisplayScale();

		//if (strData > 1) {
			//alert("Áöµµ¸¦ Á»´õ È®´ëÇÏ½Ê½Ã¿ä!");
		//} else {
			ctlMap.ResetMap();
			ff_OnPopup('/gisfix/gisfix.htm','firstuse', '300', '280');
			ctlMap.SetUserClickMode();
		//}
	}catch(e){
		procJsExp(e);
	}
}
function SetInitial(){
	top.window.moveTo(0,0);
	top.window.focus();
}

function setMenuMove(strMenuCode){
	switch (strMenuCode) {
		case "link":       //°ü·Ã»çÀÌÆ®
				setMainMenu('/etc/linkedsite.asp');
			break;
		case "admin":      
				alert("ÁØºñÁß ÀÔ´Ï´Ù.");
			break;
		case "sitemap":     //»çÀÌÆ®¸Ê
				setMainMenu('/etc/sitemap.asp');
				//ff_OnPopup3('/etc/sitemap.asp', 'al_BusMap', '1120', '790');
			break;
		case "sitemap2":    //»çÀÌÆ®¸Ê(¸ÊÆäÀÌÁö)
				//setMainMenu('/etc/sitemap.asp');
				ff_OnPopup3('/etc/sitemap.asp', 'al_BusMap', '1200', '820');
			break;
		case "mapappdown":   //Áöµµ°¡¾Èº¸ÀÌ½Ê´Ï±î
				document.location.replace("/ActiveX download/AI_download.asp");
				//ff_OnPopup('/ActiveX download/AI_download.asp', 'mapappdown', '1', '1');
			break;
		case "firstuse":    //Ã³À½ÀÌ½Ê´Ï±î.ÀÌ¿ë¾È³»(¸ÊÆäÀÌÁö)
				setMainMenu('/help/index.asp');

			break;		
		case "board":		//°Ô½ÃÆÇ
				setMainMenu('/board/busline/list.asp');
				//ff_OnPopup2('/board/busline/list.asp','board', '627', '580');
				//ff_OnPopup3('/board/busline/list.asp', 'al_BusMap', '1120', '790');
			break;
		case "board2":      //°Ô½ÃÆÇ(¸ÊÆäÀÌÁö)
				ff_OnPopup3('/board/busline/list.asp', 'al_BusMap', '1200', '820');
			break;
		case "transitinfo": //È¯½ÂÁÖÂ÷ÀåÁ¤±â±Ç
				setMainMenu('/etc/transit_info.asp');
			break;
		case "transitinfo2": //È¯½ÂÁÖÂ÷Àå-ÀÌ¸§À¸·ÎÃ£±â
				ff_OnPopup3('/maps/main_route.asp?m=6', 'al_BusMap', '1200', '820');
			break;
		case "transitinfo3": //È¯½ÂÁÖÂ÷Àå-³ë¼±À¸·ÎÃ£±â
				ff_OnPopup3('/maps/main_route.asp?m=9', 'al_BusMap', '1200', '820');
			break;
		case "fastway":		//ºü¸¥±æ Á¤º¸
				ff_OnPopup3('/maps/main_route.asp?m=1', 'al_BusMap', '1200', '820'); //À±Áö¼÷ »çÀÌÁî ¼öÁ¤
			break;
		case "businfo":     //½Ã³»¹ö½ºÁ¤º¸¸ÞÀÎ
				ff_OnPopup3('/maps/main_route.asp?m=2', 'al_BusMap', '1200', '820');
			break;
		case "businfo2":    //½Ã³»¹ö½ºÁ¤º¸-¹ö½º¹øÈ£·ÎÃ£±â
				ff_OnPopup3('/intrabus/main_bus1.asp', 'al_BusMap', '1200', '820');
			break;
		case "businfo2":    //½Ã³»¹ö½ºÁ¤º¸-¿îÇàÁö¿ªÀ¸·ÎÃ£±â
				ff_OnPopup3('/intrabus/main_bus2.asp', 'al_BusMap', '1200', '820');
			break;
		case "busstopinfo":	 //Á¤·ùÀåÁ¤º¸-ÀÌ¸§À¸·ÎÃ£±â
				ff_OnPopup3('/maps/main_route.asp?m=3', 'al_BusMap', '1200', '820');
			break;
		case "busstopinfo2": //Á¤·ùÀåÁ¤º¸-Áö¿ªÀ¸·ÎÃ£±â
				ff_OnPopup3('/maps/main_stop1.asp', 'al_BusMap', '1200', '820');
			break;
		case "mobile":       //¾Ë°í°¡¸ð¹ÙÀÏ
				setMainMenu('/etc/mobileservice.asp'); 
			break;
		case "findmap":      //ÁöµµÃ£±â
				setMainMenu('/etc/mapfind.asp'); 
			break;
		case "widebus":      //±¤¿ª¹ö½º
				setMainMenu('/etc/extbus_route.asp'); 
			break;
		case "subwayline":   //ÁöÇÏÃ¶³ë¼±µµ
				setMainMenu('/etc/subway_line.asp'); 
			break;
		case "toll":         //ÁöÇÏÃ¶¿ª°£Á¶È¸
				ff_OnPopup('/toll.asp', 'toll', '251', '380');
			break;
		case "subway":       //ÀüÃ¶/ÁöÇÏÃ¶Á¤º¸-ÀÌ¸§À¸·ÎÃ£±â //090630 ¿¬°è
				ff_OnPopup3('http://www.seoulsubway.co.kr/station/linemap.action', 'al_BusMap', '1120', '790');
			break;
		case "subway2":      //ÀüÃ¶/ÁöÇÏÃ¶Á¤º¸-³ë¼±À¸·ÎÃ£±â
				ff_OnPopup3('http://www.seoulsubway.co.kr/station/linemap.action', 'al_BusMap', '1120', '790');
			break;
		case "extbus2":       //½Ã¿Ü/°í¼Ó¹ö½º(¸ÊÆäÀÌÁö)
				//setMainMenu('/extbus/extbus.asp'); 
				ff_OnPopup3('/extbus/extbus.asp', 'al_BusMap', '1120', '790');
			break;
		case "extbus":       //½Ã¿Ü/°í¼Ó¹ö½º
				setMainMenu('/extbus/extbus.asp'); 
			break;

		case "ktxopr":       //Ã¶µµ/°í¼ÓÃ¶µµ-¿îÇàÁ¤º¸
				setMainMenu('/ktx/ktx3.asp'); 
			break;
		case "ktxline":      //Ã¶µµ/°í¼ÓÃ¶µµ-°í¼ÓÃ¶µµ³ë¼±Á¤º¸
				setMainMenu('/ktx/ktx1.asp'); 
			break;
		case "ktxopr2":       //Ã¶µµ/°í¼ÓÃ¶µµ-¿îÇàÁ¤º¸(¸ÊÆäÀÌÁö)
				ff_OnPopup5('/ktx/ktx3.asp', 'al_BusMap', '1120', '790');
			break;
		case "ktxline2":      //Ã¶µµ/°í¼ÓÃ¶µµ-°í¼ÓÃ¶µµ³ë¼±Á¤º¸(¸ÊÆäÀÌÁö)
				ff_OnPopup3('/ktx/ktx1.asp', 'al_BusMap', '1120', '790'); 
			break;	
		case "ktxlink":      //Ã¶µµ/°í¼ÓÃ¶µµ-°í¼ÓÃ¶µµ¿ª¿¬°è±³Åë
				ff_OnPopup3('/maps/main_route.asp?m=5', 'al_BusMap', '1120', '790');
			break;
		case "newslist":     //´º½ºÁ¤º¸
				ff_OnPopup2('/board/news/list.asp', 'newslist', '626', '540');
			break;
		default:             //¸ÊÆäÀÌÁöÇ¥Ãâ
				ff_OnPopup3('/', 'al_BusMap', '1120', '790');
			break;
	}
}


/* ´º½ºÆ¼Ä¿ START */
function swapMarqueeText(){
	imarquee = (imarquee + 1) % NewsTitles.length;
	this.setInnerHTML(NewsTitles[imarquee]);
	return false;
}
/* ´º½ºÆ¼Ä¿ ´º½ºÆ¼Ä¿ END */

/* ÆäÀÌÁö ·Îµå½Ã ½ÇÇàµÇ´Â Function START */
function hidestatus(){
	window.status=''
	setTimeout("hidestatus();", 100);
	return true
}
window.onload = function (){
	var ctl = document.getElementById("tdSpaceCell");
	var ctl2 = document.getElementById("ddlHelpMenu");
	var ctl3 = document.getElementById("linkedsite_item");
	var ctlTemp;

	// hide status massage at browser bottom
	setTimeout("hidestatus();", 500);
	// hide context menu
	document.oncontextmenu = function(){return false};


	if(eval(ctl)){ // ÁÂÃø¸Þ´º ÇÏ´Ü °ø¹é¼¿ ³ôÀÌ ´ÃÀÌ±â
		if((document.body.clientHeight-664)>10) {
			ctl.setAttribute("style", "height:"+(document.body.clientHeight-664)+"px;", 0);
			ctl.style.height=(document.body.clientHeight-664);
		}else{
			ctl.setAttribute("style", "height:10px;", 0);
			ctl.style.height = 10;
		}
		window.name = "AlgogaMain";
	}
	if(eval(ctl2)){ctl2.onchange = setHelpItem;} // µµ¿ò¸» ¸Þ´º¿¡¼­ SelectBox¿¡ ´ëÇÑ onchange event
	if(eval(ctl3)){ // °ü·Ã»çÀÌÆ® ¸Þ´º¿¡¼­ ¸µÅ©ÀÇ Å¸°ÙÀ» »õÃ¢À¸·Î ¼³Á¤
		ctlTemp = ctl3.getElementsByTagName("a");
		if(ctlTemp){
			if(ctlTemp.length){
				for (var i=0;i<ctlTemp.length;i++){ctlTemp[i].setAttribute("target", "_blank");}
			}else{
				ctlTemp.setAttribute("target", "_blank");
			}
		}
	}
	// ¸ÞÀÎ ¸Þ´º
	MM_preloadImages('/image/menu1_over.gif','/image/menu2_over.gif','/image/menu3_over.gif','/image/menu4_over.gif','/image/menu5_over.gif','/image/menu6_over.gif','/image/menu7_over.gif');
	// ¸Ê ¸ÞÀÎ ¸Þ´º
	MM_preloadImages('/image/map/menu1.gif','/image/map/menu2_over.gif','/image/map/menu3_over.gif','/image/map/menu4_over.gif','/image/map/menu5_over.gif','/image/map/menu6_over.gif','/image/map/menu7_over.gif');
	// ¸Ê ±â´É ¹öÆ°(È®´ë,Ãà¼Ò)µî..
	MM_preloadImages('/image/map/maptool1_over.gif','/image/map/maptool2_over.gif','/image/map/maptool3_over.gif','/image/map/maptool4_over.gif','/image/map/maptool5_over.gif','/image/map/maptool6_over.gif','/image/map/maptool7_over.gif','/image/map/maptool8_over.gif','/image/map/maptool9_over.gif','/image/map/maptool10_over.gif','/image/map/maptool11_over.gif');
	MM_preloadImages('/image/map/maptool1_2.gif','/image/map/maptool2_2.gif','/image/map/maptool3_2.gif','/image/map/maptool4_2.gif','/image/map/maptool5_2.gif','/image/map/maptool6_2.gif','/image/map/maptool7_2.gif','/image/map/maptool8_2.gif','/image/map/maptool9_2.gif');
	// °Ô½ÃÆÇ Ä«Å×°í¸®
	MM_preloadImages('/image/board/tab1_1.gif','/image/board/tab2_1.gif','/image/board/tab3_1.gif','/image/board/tab4_1.gif','/image/board/tab5_1.gif','/image/board/tab6_1.gif','/image/board/tab7_1.gif');
}
/* ÆäÀÌÁö ·Îµå½Ã ½ÇÇàµÇ´Â Function END */

function getArrival(){
	var departure = document.getElementById("departure");
	iArrival.location.replace('/inc/arrivaltra_combo.asp?departure=' + departure.value);
}

function setOperateList(){

	var ctlFrm = document.getElementById("form1");
	var ctlRtn = document.frames('iResult');
	
	if(ctlFrm.departure.value.trim().bytes()<1){
		alert("Ãâ¹ßÁö¸¦ ¼±ÅÃÇØÁÖ¼¼¿ä.");
		ctlFrm.departure.focus();
	}else if(iArrival.arrival.value.trim().bytes()<1){
		alert("µµÂøÁö¸¦ ¼±ÅÃÇØÁÖ¼¼¿ä.");
		iArrival.arrival.value.focus();
	}else{
		ctlFrm.action = './subtra_r.asp?departure='+ctlFrm.departure.value+'&arrival='+iArrival.arrival.value+'&tClass='+ctlFrm.tClass.value;
		ctlFrm.submit();
	}
}

function ClearResult() {
	parent.main.document.IntraMap2DXMTIS.Resetmap();
}
function setExternalBusList(){
	var ctlFrm = document.getElementById("form1");
	var ctlRtn = document.frames('iResult');
	
	if(ctlFrm.terminal.value.trim().bytes()<1){
		doError(ctlFrm.terminal, "½Ã¿Ü¹ö½º ÅÍ¹Ì³ÎÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.")
	}else{
		ctlFrm.action = "./subexb_1_r.asp";
		ctlFrm.target = "iResult";
		ctlFrm.submit();
	}
}

function setExpressBusList(){
	var ctlFrm = document.getElementById("form1");
	var ctlRtn = document.frames('iResult');
	
	if(ctlFrm.ex.value.trim().bytes()<1){
		doError(ctlFrm.ex, "°í¼Ó¹ö½º ÅÍ¹Ì³ÎÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.")
	}else{
		ctlFrm.action = "./subexb_2_r.asp";
		ctlFrm.target = "iResult";
		ctlFrm.submit();
	}
}


/* °Ô½ÃÆÇ START */
function gisFixList() {
	MM_openBrWindow('../../gisfix/board/list.asp','','width=626,height=590,scrollbars=yes');
}
function onVisited() {
	MM_openBrWindow('../../visited.asp','','width=270,height=380');
}
function downfile(){
	alert("??");
}

function getRegionList(){
	var f = document.forms[0];
	var nation = f.nation.value;
	iRegion.location.replace('mem_region_combo.asp?nation=' + nation);
}
function layerdel_view()
{
	layerdel.style.display="block";
	document.passform.password.focus();
}

function layerdel_hidden()
{
	layerdel.style.display="none";
}
/* ±Û¾²±â START */
function onBoardWriteSubmit() {
	var frm = document.getElementById("frmWrite");
	
	frm.email.setAttribute("hname", "¸ÞÀÏÁÖ¼Ò")

	try{
		if(frm.writer.value.trim().bytes()<1) {
			return doError(frm.writer, "ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä.");
		}else if(frm.email.value.trim().bytes()<1) {
			return doError(frm.email, "¸ÞÀÏÁÖ¼ÒÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		}else if(!isValidEmail(frm.email, frm.email.value)) {
			return false;
		}else if(frm.subject.value.trim().bytes()<1) {
			return doError(frm.subject, "Á¦¸ñÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		}else if(frm.contents.value.trim().bytes()<1) {
			alert("³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
			return false;
		}else if(frm.file.value.trim().bytes()>1) {
			return illegalFileFiltering(frm.file.value)
		}else if(frm.password.value.trim().bytes()<1) {
			return doError(frm.password, "ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		}else{
			document.getElementById("contents").value = document.getElementById("contents").value.replace(new RegExp('(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 'img'), '');
			return true;
		}
	}catch(e){
		procJsExp(e);
	}
	return false;
}
function illegalFileFiltering(path) {
	var imgExten = path.substring(path.lastIndexOf(".")+1,path.length);
	
	var imgExten_lower = imgExten.toLowerCase();
	
	if (imgExten_lower == 'jpg' || imgExten_lower == 'jpeg' || imgExten_lower == 'bmp' || imgExten_lower == 'gif' || imgExten_lower == 'hwp' || imgExten_lower == 'xls' || imgExten_lower == 'doc' )
	{
		return true;
	}
	else
	{
		alert('¹®¼­ / ÀÌ¹ÌÁö ÆÄÀÏ¸¸ Çã¿ë µË´Ï´Ù.');
			return false;
	}
}
/* ±Û¾²±â END */
/* °Ô½ÃÆÇ END */

/* µµ¿ò¸» START */
function setHelpItem(){
	var ctl = document.getElementById("ddlHelpMenu");
	if(ctl.value.trim().bytes()>0){
		window.location.href=ctl.value;
	}
}
/* µµ¿ò¸» END */

/* ¸Ê START */
/* ¸Ê ¸ÞÀÎ START */
function getGuList(){
	var f = document.forms[0];
	var sigun = f.sigun.value.split("^");
	iGu.location.replace('/inc/gu_move_combo.asp?sigun=' + sigun[0]);
	iDong.location.replace('/inc/dong_move_combo.asp?gu=');
}

function getDongList(){
	var f = document.forms[0];
	var gu = iGu.gu.value.split("^");
	iDong.location.replace('dong_move_combo.asp?gu=' + gu[0]);
}

function DisplayScales(ZoomFactor) {
	var centerpos = window.document.IntraMap2DXMTIS.GetViewCenter().split("^");

	window.document.IntraMap2DXMTIS.SetLocation(centerpos[0], centerpos[1], ZoomFactor);
}

function moveBusStop(busid) {
	parent.left.iResult2.location.href = './linelist.asp?busstopid='+busid;
}

function buttonCheck() {
	setTimeout("checkMode();", 500)
}

function checkMode() {
	var str = window.document.IntraMap2DXMTIS.GetMouseMode();
	//alert(str);
	if(str == "1") {
		//µå·¡±× ¸ðµå
		//document.Image15.src= "img/maptool10_2.gif";
		//document.Image5.src= "img/maptool4.gif";
		//document.Image11.src= "img/maptool7.gif";
	}
	else if(str == "2" ) {
		//ÀÌµ¿ ¸ðµå
		//document.Image15.src= "img/maptool10.gif";
		//document.Image5.src= "img/maptool4_2.gif";
		//document.Image11.src= "img/maptool7.gif";
	}
	
	/*
	else if(str == "3" ) {
		//°Å¸® ¸ðµå
		document.Image15.src= "img/maptool10.gif";
		document.Image8.src= "img/maptool4.gif";
		document.Image11.src= "img/maptool7_2.gif";
	}
	*/
}


function ff_MapMove() { // ½Ã±º ÀüÃ¼±Ç¿ª ¹Ù·Î°¡±â
	if((iGu.gu.value.trim() == "")&&(iDong.dong.value.trim() == "")) {
		var bound_xy = metro.sigun.value.split("^");
		window.document.IntraMap2DXMTIS.SetLocationBound(bound_xy[1], bound_xy[2], bound_xy[3], bound_xy[4]);
	} else if (iGu.gu.value.trim() != "") { // ±¸±Ç¿ª ¹Ù·Î°¡±â
		if(iDong.dong.value.trim() == "") {
			var bound_xy = iGu.gu.value.split("^");
			window.document.IntraMap2DXMTIS.SetLocationBound(bound_xy[1], bound_xy[2], bound_xy[3], bound_xy[4]);
		} else { // µ¿±Ç¿ª ¹Ù·Î°¡±â
			var bound_xy = iDong.dong.value.split("^");
			window.document.IntraMap2DXMTIS.SetLocationBound(bound_xy[1], bound_xy[2], bound_xy[3], bound_xy[4]);
		}
	}
}

function appzin() {
	window.document.IntraMap2DXMTIS.ZoomIn();
}

function appfull() {
	window.document.IntraMap2DXMTIS.ZoomFit();
}

function appzout() {
	window.document.IntraMap2DXMTIS.ZoomOut();
}

function appfresh() {
	window.document.IntraMap2DXMTIS.reSetMap();
}

function appdist() {
	window.document.IntraMap2DXMTIS.CalcDistanceMode();
}

function apparea() {
	window.document.IntraMap2DXMTIS.CalArea();
}

function apppan() {
	window.document.IntraMap2DXMTIS.Panning();
}

function appPrint() {
	var s = window.document.IntraMap2DXMTIS.PrintForm();
	
	prtForm = window.open("", "PrintWin", "resizable=yes, status=yse, scrollbars=yes, toolbar=no, menubar=no, width=800, height=650");
	prtForm.location.href="../inc/print.asp?img=" + s;
}

function appmailMapi() {
	window.document.IntraMap2DXMTIS.SendMailMapi();
}
function appselect() {
	window.document.IntraMap2DXMTIS.SelectObjectClick();
}
function appBack() {
	window.document.IntraMap2DXMTIS.MoveBack();
}
function appForward() {
	window.document.IntraMap2DXMTIS.MoveFoward();
}
function appIndexMap() {
	window.document.IntraMap2DXMTIS.IndexMapOnOff();
}
function app3DMap() {
	window.document.IntraMap2DXMTIS.Show3DMapOnOff();
}
function appZoomArea() {
	window.document.IntraMap2DXMTIS.ZoomArea();
}
/* ¸Ê ¸ÞÀÎ END */
/* ¸Ê ÁÂÃøÇÁ·¹ÀÓ START */
function restart() { //Ãâ¹ßÁö ¼±ÅÃ(Àç¼±ÅÃ)
	var ctlStartPointFrm = document.getElementById("divStartPointFrm");
	var ctlStartPointText = document.getElementById("divStartPointText");
	var ctlStartPointSelect = document.getElementById("divStartPointSelect");
	var ctlStartPointReset = document.getElementById("divStartPointReset");
	var ctlFrm = document.getElementById("frmSearch");

	parent.map.document.IntraMap2DXMTIS.Resetmap();

	ctlStartPointFrm.style.display = 'block';
	ctlStartPointSelect.style.display = 'block';
	ctlStartPointText.style.display = 'none';
	ctlStartPointReset.style.display = 'none';

	ctlFrm.start_x.value = "";
	ctlFrm.start_y.value = "";
	ex = Math.round(ctlFrm.arrival_x.value);
	ey = Math.round(ctlFrm.arrival_y.value);
}

function rearrival() { //µµÂøÁö ¼±ÅÃ(Àç¼±ÅÃ)
	var ctlArrivalPointFrm = document.getElementById("divArrivalPointFrm");
	var ctlArrivalPointText = document.getElementById("divArrivalPointText");
	var ctlArrivalPointSelect = document.getElementById("divArrivalPointSelect");
	var ctlArrivalPointReset = document.getElementById("divArrivalPointReset");
	var ctlFrm = document.getElementById("frmSearch");

	parent.map.document.IntraMap2DXMTIS.Resetmap();

	ctlArrivalPointFrm.style.display = 'block';
	ctlArrivalPointSelect.style.display = 'block';
	ctlArrivalPointText.style.display = 'none';
	ctlArrivalPointReset.style.display = 'none';

	ctlFrm.arrival_x.value = "";
	ctlFrm.arrival_y.value = "";
}

function Initial() {
	route.style.display = 'none'
	mtis.textfield1.focus();
}

function ClearResult() {
	parent.map.document.IntraMap2DXMTIS.Resetmap();
}

function selstart() { //Ãâ¹ßÁö ¼±ÅÃ
	//alert("ºü¸¥±æ °Ë»ö ¼­ºñ½º´Â Á¡°ËÁßÀÔ´Ï´Ù.\nÀÌ¿ë¿¡ ºÒÆíÀ» µå·Á ÁË¼ÛÇÕ´Ï´Ù.");
	//return;

	var ctlFrm = document.getElementById("frmSearch");

	if(ctlFrm.textfield1.value.trim().bytes()<1) {
		alert("Ãâ¹ßÁö¸íÀ» ÀÔ·ÂÇÏ¼¼¿ä!");
		ctlFrm.textfield1.focus();
	}else{
		ctlFrm.code.value = "1";
		ctlFrm.action = "./left_fastway_result.asp";
		ctlFrm.submit();
	}
}

function selarrival() { //¸ñÀûÁö ¼±ÅÃ
	//alert("ºü¸¥±æ °Ë»ö ¼­ºñ½º´Â Á¡°ËÁßÀÔ´Ï´Ù.\nÀÌ¿ë¿¡ ºÒÆíÀ» µå·Á ÁË¼ÛÇÕ´Ï´Ù."); ÁÖ¼®Ã³¸®ÇØÁÖ¼¼¿ä...^^
	//return;

	var ctlFrm = document.getElementById("frmSearch");

	if(ctlFrm.textfield2.value.trim().bytes()<1) {
		alert("µµÂøÁö¸íÀ» ÀÔ·ÂÇÏ¼¼¿ä!");
		ctlFrm.textfield2.focus();
	}else{
		ctlFrm.code.value = "2";
		ctlFrm.action = "./left_fastway_result.asp";
		ctlFrm.submit();
	}
}

function shortest() {
	//alert("ºü¸¥±æ °Ë»ö ¼­ºñ½º´Â Á¡°ËÁßÀÔ´Ï´Ù.\nÀÌ¿ë¿¡ ºÒÆíÀ» µå·Á ÁË¼ÛÇÕ´Ï´Ù.");
	//return;

	var ctlFrm = document.getElementById("frmSearch");
	var ctlResult = document.getElementById("iRouteResult");

	sx = Math.round(ctlFrm.start_x.value);
	sy = Math.round(ctlFrm.start_y.value);
	ex = Math.round(ctlFrm.arrival_x.value);
	ey = Math.round(ctlFrm.arrival_y.value);
	

       ctlFrm.sx.value = sx;
       ctlFrm.sy.value = sy;
       ctlFrm.ex.value = ex;
       ctlFrm.ey.value = ey; 

	var dist = (Math.abs(sx-ex))*(Math.abs(sx-ex)) + Math.abs((sy-ey))*Math.abs((sy-ey));

	try{
		if(ctlFrm.start_x.value.trim().bytes()<1) {
			alert("Ãâ¹ßÁö¸¦ ¼±ÅÃ ÇÏ¼¼¿ä.");
			ctlFrm.textfield1.focus();
		}else if(ctlFrm.arrival_x.value.trim().bytes()<1) {
			alert("µµÂøÁö¸¦ ¼±ÅÃÇÏ¼¼¿ä.");
			ctlFrm.textfield2.focus();
		}else if(dist< 500000) {
			alert("500m ÀÌÇÏ´Â µµº¸·Î ÀÌµ¿ÇÏ¼¼¿ä.");
		} else {
			//ctlFrm.action = "./MTISServer.asp";
			ctlFrm.action = "./MTISServer_frame.asp";
			ctlFrm.submit();
		}
	}catch(e){
		procJsExp(e);
	}
}

function StartClick(){ //¹öÆ°(Áöµµ¿¡¼­Ã£±â) Å¬¸¯ 
	//alert("ºü¸¥±æ °Ë»ö ¼­ºñ½º´Â Á¡°ËÁßÀÔ´Ï´Ù.\nÀÌ¿ë¿¡ ºÒÆíÀ» µå·Á ÁË¼ÛÇÕ´Ï´Ù.");
	//return;

	parent.map.document.IntraMap2DXMTIS.ZoomArea();
	parent.map.document.IntraMap2DXMTIS.SetStartFlagMode();
}

function EndClick(){ //¹öÆ°(Áöµµ¿¡¼­Ã£±â) Å¬¸¯ 
	//alert("ºü¸¥±æ °Ë»ö ¼­ºñ½º´Â Á¡°ËÁßÀÔ´Ï´Ù.\nÀÌ¿ë¿¡ ºÒÆíÀ» µå·Á ÁË¼ÛÇÕ´Ï´Ù.");
	//return;

	parent.map.document.IntraMap2DXMTIS.ZoomArea();
	parent.map.document.IntraMap2DXMTIS.SetEndFlagMode();
}

function MoveBack(){
	document.location.replace("./left_fastway.asp");
	ClearResult();
}
function procBusInfoSearch(){		//½Ã³»¹ö½º Á¤·ùÀå Á¤º¸
	var ctlFrm = document.getElementById("frmSearch");
	var ctlResult = document.getElementById("iRouteResult");
	var ctlMap = parent.map.document.getElementById("IntraMap2DXMTIS");
	try{
		if(ctlFrm.txtBusNo.value.trim().bytes()<1) {
			alert("°Ë»öÇÏ½Ç ¹ö½º ¹øÈ£¸¦ ÀÔ·Â ÇÏ¼¼¿ä.");
			ctlFrm.txtBusNo.focus();
		} else {
			//alert(ctlFrm.txtBusNo.value);
			ctlFrm.action = "./left_businfo_result.asp?key="+ctlFrm.txtBusNo.value;
			//ctlFrm.action = "left_businfo_frame.asp?key="+ctlFrm.txtBusNo.value+"&br_vol='0'";
			//ctlFrm.action = "left_businfo_frame.asp?key="+ctlFrm.txtBusNo.value;
			ctlFrm.submit();
			ctlMap.Resetmap();
			/*
			if (ctlFrm.txtNum.value.trim().bytes()<1) {
			    alert(ctlFrm.txtNum.value + " ctlFrm.num dont have value" );
			} else
			{
				ctlMap.FindBusPath(ctlFrm.txtNum.value);
			}*/
			
		}
	}catch(e){
		procJsExp(e);
	}
}
function procBusStopInfoSearch(){
	var ctlFrm = document.getElementById("frmSearch");
	var ctlMap = parent.map.document.getElementById("IntraMap2DXMTIS");
	
	try{
		if(ctlFrm.key.value.trim().bytes()<1) {
			alert("Á¤·ùÀå¸íÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
			ctlFrm.key.focus();
		} else {
			ctlMap.Resetmap();
			ctlFrm.action = "./left_busstopinfo_result.asp";
			ctlFrm.submit();
		}
	}catch(e){
		procJsExp(e);
	}
}
function getGuList(){
	var ctlFrm = document.getElementById("frmSearch");

	iGu.location.replace('../inc/gu_combo_idx.asp?sigun=' + ctlFrm.sigun.value);
	iDong.location.replace('../inc/dong_combo_idx.asp?gu=');
}
function getGuList2(){
	var ctlFrm = document.getElementById("metro");

	iGu.location.replace('../inc/gu_move_combo.asp?sigun=' + ctlFrm.sigun.value.split("^")[0]);
	iDong.location.replace('../inc/dong_move_combo.asp?gu=');
}


function getDongList(){
	var ctlFrm = document.getElementById("frmSearch");

	ctlFrm.gu.value = iGu.gu.value;
	iDong.document.location.replace('../inc/dong_combo_idx.asp?gu=' + ctlFrm.gu.value);
}
function getDongList2(){
	var gu = iGu.gu.value.split("^");
	iDong.location.replace('dong_move_combo.asp?gu=' + gu[0]);
}

function checkform(box,message){
	if(box.value == ''){
		alert(message);
		box.focus();
		return false;
	} else {
		return true;
	}
}

function procKTXConnectionInfo(loname, cenx, ceny) {
	var ctlFrm = document.getElementById("frmSearch");

	parent.map.document.IntraMap2DXMTIS.Resetmap();
	parent.map.document.IntraMap2DXMTIS.SetLocationObject(cenx, ceny, 0.9);

	ctlFrm.local.value = loname;
	ctlFrm.cenx.value = cenx;
	ctlFrm.ceny.value = ceny;
	ctlFrm.action = "./left_ktxconnection_result.asp";
	ctlFrm.submit();
}
/* ¸Ê ÁÂÃøÇÁ·¹ÀÓ END */
/* ¸Ê ÁÂÃøÇÁ·¹ÀÓ °á°ú ÆäÀÌÁö START */
function setLocationObject(x_p, y_p) {
	parent.top.map.document.IntraMap2DXMTIS.SetLocationObject(x_p, y_p, 0.9);
}

function setLocationObject2(x_p, y_p, o_name) {
	//parent.top.map.document.IntraMap2DXMTIS.SetLocationObject(x_p, y_p, 0.9);
	parent.top.map.document.IntraMap2DXMTIS.SetLocationObjectWithName(x_p, y_p, 0.9, o_name);
}

function SetLocationObject(x_p, y_p, busstopid) {
	top.parent.map.document.IntraMap2DXMTIS.SetLocationObject(x_p, y_p, 0.9);
	parent.iResult2.location.href = "./linelist.asp?busstopid="+busstopid;
}

function SetLocationObject2(x_p, y_p, busstopid, o_name) {
	//top.parent.map.document.IntraMap2DXMTIS.SetLocationObjectWithName(x_p, y_p, 0.9, o_name);
	parent.top.map.document.IntraMap2DXMTIS.SetLocationObjectWithName(x_p, y_p, 0.9, o_name);
	parent.iResult2.location.href = "./linelist.asp?busstopid="+busstopid;
}

function setLocationPoint(intMod, strLocInfo) {
	var ctlFrm               = parent.document.getElementById("frmSearch");

	var ctlStartPointFrm     = parent.document.getElementById("divStartPointFrm");
	var ctlStartPointText    = parent.document.getElementById("divStartPointText");
	var ctlStartPointSelect  = parent.document.getElementById("divStartPointSelect");
	var ctlStartPointReset   = parent.document.getElementById("divStartPointReset");
	
	var ctlArrivalPointFrm    = parent.document.getElementById("divArrivalPointFrm");
	var ctlArrivalPointText   = parent.document.getElementById("divArrivalPointText");
	var ctlArrivalPointSelect = parent.document.getElementById("divArrivalPointSelect");
	var ctlArrivalPointReset  = parent.document.getElementById("divArrivalPointReset");

	var strLocInfo2 = strLocInfo.split("-");
	var start       = strLocInfo2[0];
	var sx          = strLocInfo2[1];
	var sy          = strLocInfo2[2];
	
	if(intMod == 1) {
		ctlFrm.start_x.value = sx;
		ctlFrm.start_y.value = sy;
		
		ctlStartPointText.innerHTML = start;
		ctlStartPointFrm.style.display = 'none';
		ctlStartPointSelect.style.display = 'none';
		ctlStartPointText.style.display = 'block';
		ctlStartPointReset.style.display = 'block';
	} else {
		ctlFrm.arrival_x.value = sx;
		ctlFrm.arrival_y.value = sy;
		
		ctlArrivalPointText.innerHTML = start ;
		ctlArrivalPointFrm.style.display = 'none';
		ctlArrivalPointSelect.style.display = 'none';
		ctlArrivalPointText.style.display = 'block';
		ctlArrivalPointReset.style.display = 'block';
	}
	
	document.location.replace('about:blank');
}
/* ¸Ê ÁÂÃøÇÁ·¹ÀÓ °á°ú ÆäÀÌÁö END */
/* ¸Ê END */

