// Top Menu
function initNavigation(seq) {
	nav = document.getElementById("topmenu");
	nav.menu = new Array();
	nav.current = null;
	nav.menuseq = 0;
	navLen = nav.childNodes.length;
	
	allA = nav.getElementsByTagName("a")
	for(k = 0; k < allA.length; k++) {
		allA.item(k).onmouseover = allA.item(k).onfocus = function () {
			nav.isOver = true;
		}
		allA.item(k).onmouseout = allA.item(k).onblur = function () {
			nav.isOver = false;
			setTimeout(function () {
				if (nav.isOver == false) {
					if (nav.menu[seq])
						nav.menu[seq].onmouseover();
					else if(nav.current) {
						menuImg = nav.current.childNodes.item(0);
						menuImg.src = menuImg.src.replace("_on.gif", ".gif");
						if (nav.current.submenu)
							nav.current.submenu.style.display = "none";
						nav.current = null;
					}
				}
			}, 500);
		}
	}

	for (i = 0; i < navLen; i++) {
		navItem = nav.childNodes.item(i);
		if (navItem.tagName != "LI")
			continue;

		navAnchor = navItem.getElementsByTagName("a").item(0);
		navAnchor.submenu = navItem.getElementsByTagName("ul").item(0);
		
		navAnchor.onmouseover = navAnchor.onfocus = function () {
			if (nav.current) {
				menuImg = nav.current.childNodes.item(0);
				menuImg.src = menuImg.src.replace("_on.gif", ".gif");
				if (nav.current.submenu)
					nav.current.submenu.style.display = "none";
				nav.current = null;
			}
			if (nav.current != this) {
				menuImg = this.childNodes.item(0);
				menuImg.src = menuImg.src.replace(".gif", "_on.gif");
				if (this.submenu)
					this.submenu.style.display = "block";
				nav.current = this;
			}
			nav.isOver = true;
		}
		nav.menuseq++;
		nav.menu[nav.menuseq] = navAnchor;
	}
	if (nav.menu[seq])
		nav.menu[seq].onmouseover();
}

//showHideLayers
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// Tab Content
function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tabbtn")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);

		thismenu.onclick = thismenu.onclick = thismenu.onfocus = thismenu.onkeypress = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
				} else {
					currentmenu.className = currentmenu.className.replace(" over", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
			} else {
				this.className += " over";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}


//Flash
function flashWrite( id, flashUri, vWidth, vHeight ) {
   var _obj_ = "";

   _obj_ = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" align="middle">';
	_obj_ += '<param name="movie" value="' + flashUri + '" />';
   _obj_ += '<param name="quality" value="high" />';
   _obj_ += '<param name="wmode" value="transparent" />    ';
	_obj_ += '<param name="menu" value="false" />    ';
   _obj_ += '<param name="bgcolor" value="#ffffff" />        ';
   _obj_ += '<embed src="' + flashUri + '" quality="high" wmode="transparent" bgcolor="#ffffff" width="' + vWidth +'" height="' + vHeight + '" id="' + id + '" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>    ';
   _obj_ += '</object>';
   document.writeln( _obj_ );
}


//openBrWindow
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/*########popup zone########*/
var img_content=new Array();
		var lyId = "", iconId = "";
		var timeId, timeId2;
		var popImgIdx = 1;
		var popImgMax = 12;    /* ÆË¾÷Á¸ °¹¼ö¿¡ µû¶ó Á¶Á¤ */
		
		function popupView(num, at)
		{
			clearInterval(timeId2);
			
			if(at == 's'){
				clearInterval(timeId);
			}
		
			for(i=1; i < popImgMax+1; i++){
				lyId = "pdiv" + i;
				iconId = "pop_Icon" + i;
		
				if(i == num){
					eval("document.getElementById('"+lyId+"').style.display = '';");
					eval("document.getElementById('"+iconId+"').src = '/kor/images/main_banner_n"+num+"_on.gif';");
				}
				else{
					eval("document.getElementById('"+lyId+"').style.display = 'none';");
					eval("document.getElementById('"+iconId+"').src = '/kor/images/main_banner_n"+i+"_off.gif';");
				}
			}		
		}		
		
		function fn_autoLoop(){
			popupView(popImgIdx, 'g')
		
			if(popImgIdx < popImgMax)
				popImgIdx = popImgIdx+1;
			else
				popImgIdx = 1;
		
			timeId = setTimeout("fn_autoLoop()",7000);
		}
	function fn_outWait(){
		timeId2 = setTimeout("fn_autoLoop()",7000);
	}
	


var zoomStat=100;
function funcZoom(param){
    if(navigator.userAgent.toLowerCase().indexOf("msie")!=-1) {
        var zoomUnit=20;
        var zoomMax=300;
        var zoomMin=60;

        if(param=="in") {
            zoomStat = zoomStat + zoomUnit;
        } else {
            zoomStat = zoomStat - zoomUnit;
        }

        if(zoomStat > zoomMax) {
            zoomStat = zoomMax;
        }

        if(zoomStat < zoomMin) {
            zoomStat = zoomMin;
        }
        
		document.getElementById('wrapper_all').style.zoom = zoomStat+"%";
    } else {
        alert("ÀÌ ºê¶ó¿ìÀú¿¡¼­´Â Áö¿øÇÏÁö ¾Ê½À´Ï´Ù.");
    }
}

function funcZoomNomal() {
	document.getElementById('wrapper_all').style.zoom = "100%";
}
function onOpenMiniHome() {
	MM_openBrWindow("http://www1.guro.go.kr/gaea/index.php?ch=minihomeMain","popup","width=941,height=530");
}

// ½ºÅ©·Ñ µû¶ó´Ù´Ï´Â ·¹ÀÌ¾î
  var stmnGAP1 = 0; // ÆäÀÌÁö Çì´õºÎºÐÀÇ ¿©¹é
  var qKind = "" ; 
  var stmnGAP2 = 50; // ½ºÅ©·Ñ½Ã ºê¶ó¿ìÀú »ó´Ü°ú ¾à°£ ¶ç¿ò. ÇÊ¿ä¾øÀ¸¸é 0À¸·Î ¼¼ÆÃ
  var stmnBASE = 0; // ½ºÅ©·Ñ¸Þ´º ÃÊ±â ½ÃÀÛÀ§Ä¡ (¾Æ¹«·¸°Ô³ª ÇØµµ »ó°üÀº ¾øÁö¸¸ stmnGAP1°ú ¾à°£ Â÷ÀÌ¸¦ ÁÖ´Â°Ô º¸±â ÁÁÀ½)
  var stmnActivateSpeed = 500; // ¿òÁ÷ÀÓÀ» °¨ÁöÇÏ´Â ¼Óµµ (¼ýÀÚ°¡ Å¬¼ö·Ï ´Ê°Ô ¾Ë¾ÆÂ÷¸²)
  var stmnScrollSpeed = 10; // ½ºÅ©·ÑµÇ´Â ¼Óµµ (Å¬¼ö·Ï ´Ê°Ô ¿òÁ÷ÀÓ)


  function RefreshStaticMenu() {
    var stmnStartPoint, stmnEndPoint, stmnRefreshTimer;
	
	if ( qKind == "sub" ) 
	    stmnStartPoint = parseInt(document.getElementById("divMenu").style.top, 10);
	else if (qKind == "main")
		stmnStartPoint = parseInt(document.getElementById("main_divMenu").style.top, 10);
    
	stmnEndPoint = document.documentElement.scrollTop + stmnGAP2;
    if (stmnEndPoint < stmnGAP1) { stmnEndPoint = stmnGAP1; }

    stmnRefreshTimer = stmnActivateSpeed;
    if ( stmnStartPoint != stmnEndPoint ) {
      stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 15 );
	  if ( qKind == "sub" ) 
	      document.getElementById("divMenu").style.top = (parseInt(document.getElementById("divMenu").style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount )) + "px";
	  else if (qKind == "main")
	      document.getElementById("main_divMenu").style.top = (parseInt(document.getElementById("main_divMenu").style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount )) + "px";
      stmnRefreshTimer = stmnScrollSpeed;
    }
    stmnTimer = setTimeout ("RefreshStaticMenu();", stmnRefreshTimer);
  }

  function InitializeStaticMenu() {
	if ( qKind == "sub" ) 
		document.getElementById("divMenu").style.top = (document.documentElement.scrollTop + stmnBASE) + "px";
	 else if (qKind == "main")
		document.getElementById("main_divMenu").style.top = (document.documentElement.scrollTop + stmnBASE) + "px";

    RefreshStaticMenu();
  }

  function StartStaticMenu(stmnGAP2Plus) {
	  
	   var domainArry = ["anyang","ceo","child","commerce","edu","food","forum","garibongdev","gh","green","gurofest","handicap","health","old","woman","kor"];
  var subTop = [5,130,-27,137,20,19,258,196,42,20,38,30,24,0,87,88];
  var mainTop = [5,130,-27,137,0,19,122,196,42,20,38,30,24,0,87,88];
  var loca  = location.href ; 
  var nTopCnt = 0 ; 
  var nTop = 0 ;
 
  for ( var i = 0 ; i < domainArry.length ; i++ )  {
	 if ( loca.indexOf(domainArry[i]) != -1 ) {
		 nTopCnt = i;
		 break;
	 }
  }
  
  if ( loca.indexOf("page.jsp") != -1 || loca.indexOf("sub_main.jsp") != -1 )  {
	
	  qKind = "sub";
	  nTop = subTop[nTopCnt] ;
  } else {	  
	  nTop = mainTop[nTopCnt] ;
	  qKind = "main"
  } 
    stmnGAP2 = nTop;
	stmnGAP2 = stmnGAP2 +stmnGAP2Plus ;
	
	if ( qKind == "sub" ) 
		document.getElementById("divMenu").style.top = stmnGAP2 + "px";
	 else if (qKind == "main")
		document.getElementById("main_divMenu").style.top = stmnGAP2 + "px";

    RefreshStaticMenu();
  }

//main tab news
function LayerChg(chk, id){
	var objList = null;
	var objImg = null;

	if(chk == "ar"){
		for(i=0; i<5; i++){
			objList = "ArList"+(i+1);
			objImg = "ArImg"+(i+1);
			if(objList == id){
				document.getElementById(objList).style.display = "block";
				document.getElementById(objImg).src = "/kor/images/main_top_tab_0"+(i+1)+"_on.gif";
			}else{
				document.getElementById(objList).style.display = "none";
				document.getElementById(objImg).src = "/kor/images/main_top_tab_0"+(i+1)+".gif";
			}
		}
	}
	if(chk == "svc"){
		for(i=0; i<5; i++){
			objList = "SvcList"+(i+1);
			objImg = "SvcImg"+(i+1);
			if(objList == id){
				document.getElementById(objList).style.display = "block";
				document.getElementById(objImg).src = "/kor/images/main_top_tab_0"+(i+1)+"_on.gif";
			}else{
				document.getElementById(objList).style.display = "none";
				document.getElementById(objImg).src = "/kor/images/main_top_tab_0"+(i+1)+".gif";
			}
		}
	}
	if(chk == "ns"){
		if(id == "NsList1"){
			document.getElementById("NsList1").style.display = "block";
			document.getElementById("NsImg1").src = "/kor/images/main_top_tab_01_on.gif";
			document.getElementById("NsList2").style.display = "none";
			document.getElementById("NsImg2").src = "/kor/images/main_top_tab_02.gif";
			document.getElementById("NsList3").style.display = "none";
			document.getElementById("NsImg3").src = "/kor/images/main_top_tab_03.gif";			
		}
		if(id == "NsList2"){
			document.getElementById("NsList1").style.display = "none";
			document.getElementById("NsImg1").src = "/kor/images/main_top_tab_0.gif";
			document.getElementById("NsList2").style.display = "block";
			document.getElementById("NsImg2").src = "/kor/images/main_top_tab_02_on.gif";
			document.getElementById("NsList3").style.display = "none";
			document.getElementById("NsImg3").src = "/kor/images/main_top_tab_03.gif";		
		}
		if(id == "NsList3"){
			document.getElementById("NsList1").style.display = "none";
			document.getElementById("NsImg1").src = "/kor/images/main_top_tab_01.gif";
			document.getElementById("NsList2").style.display = "none";
			document.getElementById("NsImg2").src = "/kor/images/main_top_tab_02.gif";
			document.getElementById("NsList3").style.display = "block"
			document.getElementById("NsImg3").src = "/kor/images/main_top_tab_03_on.gif";	
		}		
		
	}

	TopMenuClose();
}

//°Ë»ö
function onSearch(form) {

	document.charset = "euc-kr";

	var search_word = form.search_word.value;

	if ( form.st[0].checked ) {//ÅëÇÕ°Ë»ö 
		if(search_word == ""){
			alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä");
			form.search_word.focus();
			return false;
		}else{
			form.target = "_blank";
			form.q.value = search_word;
			form.action = "http://search.guro.go.kr/search.jsp?w=guro_tong&section=&s_d1=&e_d1=&outmax=&dsort=&pg=&q=" + form.q.value;
		}
	}else if( form.st[1].checked ) {//¾÷¹«¸í °Ë»ö 		
		if(search_word == ""){
			alert("¾÷¹«¸íÀ» ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä!");
			form.search_word.focus();				
			return false;
		} else {
			form.works.value = search_word;
			form.action = "/kor/page.jsp?code=gua010010000";	
			form.target="_self";
		}
	}else if( form.st[2].checked ) {//Á÷¿ø¸í °Ë»ö 
		if(search_word == ""){
			alert("Á÷¿ø¸íÀ» ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä!");
			form.search_word.focus();
			return false;
		} else {
			form.name.value = search_word;
			form.action = "/kor/page.jsp?code=gua010010000";
			form.target="_self";				
		}			
	}
	return true;
}

// Tab Content
function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tabbtn")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);

		thismenu.onclick = thismenu.onmouseover = thismenu.onfocus = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
				} else {
					currentmenu.className = currentmenu.className.replace(" over", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
			} else {
				this.className += " over";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

function ErrorMsg(msg,url,line) {
  var str = "Error: " + msg + " on line: " 
  + line + "\nURL: " + url  + "\nWeb: " 
  + navigator.appName + " " + navigator.appName 
  + " " + navigator.appVersion;
  //alert(str);
  return true;
}
window.onerror = ErrorMsg;

function ff_Open(x,y,z)
{

var url = "http://gis.seoul.go.kr/SeoulGis/LifeMap_gu.jsp?";
var OfficeName = encodeURIComponent("±¸·Î±¸");
var SisulName = encodeURIComponent(x);
var Dong_Info = encodeURIComponent(y);
var Bunji_Info = encodeURIComponent(z);
var San_Yn = 1;
var ImgDir = 1;
var SecTorYN = "Y";

url += "OfficeName=" + OfficeName + "&SisulName=" + SisulName + "&Dong_Info=" + Dong_Info + "&Bunji_Info=" + Bunji_Info + "&San_Yn=1&ImgDir=1&SecTorYN=Y&Mode=1" ;
window.open(url, 'SeoulGis', 'width=1100,height=600,status=yes,toolbar=no,menubar=no,location=no,directories=no');
//top.window.location = url;
}

function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
	{
		obj.addEventListener( type, fn, false );
	}
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}
