// JavaScript Document

/* Image RollOver */
function imgSwap(el){
	var imgContainer = document.getElementById(el);
	var imgAnchor = imgContainer.getElementsByTagName("a");
	for(var i=0; i<imgAnchor.length; i++){
		if(imgAnchor.item(i).className == "roll")
			imglist = imgAnchor.item(i);
		else
			continue;
		imglist.container = imgContainer;
		imglist.imgEl = imglist.getElementsByTagName("img").item(0);
		imglist.onmouseover = imglist.onblur = function imgSwapEvent(){
			current = this.container.current;
			if(current == this) return false;
			if(current){
				current.imgEl.src = current.imgEl.src.replace("_on.gif", ".gif");
				if(current.imgEl){
					current.imgEl.src = current.imgEl.src.replace("_on.gif", ".gif");
				}
			}
			if(this.imgEl){
				this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
			} else {
				this.imgEl.src = this.imgEl.src.replace("_on.gif", ".gif");
			}
			this.container.current = this;
			return false;
		}
		if(!imglist.container.first)
			imglist.container.first = imglist;
	}
	if(imgContainer.first)
		imgContainer.first.onmouseover();
}

/* toggle Menu */
function toggleInit(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 == "toggle")
			thismenu = tabAnchor.item(i);
		else
			continue;
	
		thismenu.container = tabContainer;
		thismenu.targetEl = thismenu.parentNode.getElementsByTagName("ul")[0];
		//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.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(" on", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;
	
			return false;
		};
	
		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
	}	


function swapView(){
	cView = document.getElementById("contentView");
	cClose = document.getElementById("contentClose");
	viewAnchor = cView.getElementsByTagName("a").item(0);
	closeAnchor = cClose.getElementsByTagName("a").item(0);
	cClose.parentNode.parentNode.style.display = "none";
	
	viewAnchor.onclick = viewAnchor.onfocus = function(){
		cClose.parentNode.parentNode.style.display = "block";
		cView.parentNode.style.display = "none";
	}
	closeAnchor.onclick = closeAnchor.onfocus = function(){
		cClose.parentNode.parentNode.style.display = "none";
		cView.parentNode.style.display = "block";
	}
}


// JavaScript Document

function inithistory(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 == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;
	
		thismenu.container = tabContainer;
		thismenu.targetEl = thismenu.parentNode.getElementsByTagName("div")[0];
		// 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.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(" on", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;
	
			return false;
		};
	
		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
	}	

function aa(){
	var seltab = arguments[0];
	if(seltab == null || typeof arguments[0] == typeof _UNDEFINED){ seltab = 1;}
	var curobj = document.getElementById('townCafe');
	var child_div_obj = curobj.getElementsByTagName('div');
	for(i=0; i<child_div_obj.length; i++){
		if('towncafe'+seltab == child_div_obj[i].id) child_div_obj[i].style.display = 'block';
		else child_div_obj[i].style.display = 'none';
	}
	var imgobj = document.getElementById('townImg');
	imgobj.setAttribute('src','../images/05_future/townCafe'+seltab+'.gif');
}


function fnYear(val){
	var yyyy = new Array('2005','2006','2007','2008','2009','2010');
	for(var i=0; i < yyyy.length ; i++){
		if(val == yyyy[i]){
			document.getElementById(val).style.display="";
		}else{
			document.getElementById(yyyy[i]).style.display="none";
		}
	}
}

function fnYearFuture(val){
	var yyyy = new Array('2003','2004','2005','2006','2007','2008','2009','2010_01','2010_02','2010_03','2010_04','2010_05','2010_06','2010_07');
	for(var i=0; i < yyyy.length ; i++){
		if(val == yyyy[i]){
			document.getElementById(val).style.display="";
		}else{
			document.getElementById(yyyy[i]).style.display="none";
		}
	}
}

// 메인, 서브 탭 스크립트
function initTab(el){

	target = $(el+"> li > a");
	target.eq(0).addClass("on");
	target.parent().find("div").hide();
	target.parent().find("div").eq(0).show();
	target.bind("mouseover", initTabListener).bind("focus", initTabListener);
}

function initTabListener(el){
	target.removeClass("on");
	target.parent().find("div").hide();
	$(this).addClass("on");
	$(this).parent().find("div").show();
}

// 메인에서 target focus
function targetView(){
	var target = $(".helperList > li > a");
	if(target){
		
		for(i=0; i<target.length; i++){
			currentTarget = location.href;
			var strSplit = currentTarget.split("=");
			var currentAnchor = strSplit[strSplit.length-1];
			
			if(currentAnchor == $(".helperList > li > a").eq(i).attr("href").split("#")[1]){
				target.eq(i).attr("href", "#"+currentAnchor).focus();	
			}
		}
	}
	else{
		return false;
	}
}
 
// 군청안내
function mapView(){
	listAnchor = $("#hiList > li > a");
	mapAnchor = $("#map_hall > p > a");
	for(i=0; i<listAnchor.length; i++){
		container = $(listAnchor).eq(i).attr("href");
		$(container).hide();
	}
	containerFirst = $(listAnchor).eq(0).attr("href");
	$(containerFirst).show();
	
	listAnchor.children().eq(0).attr("src", listAnchor.children().eq(0).attr("src").replace(".gif", "on.gif"));
	mapAnchor.children().eq(0).attr("src", mapAnchor.children().eq(0).attr("src").replace(".gif", "_on.gif"));
	listAnchor.bind("click", mapListener).bind("focus", mapListener);
}

function mapListener(el){
	for(var i=0; i<listAnchor.length; i++){
		targetContainer = $("#hiList > li > a").eq(i).attr("href");
		$(targetContainer).hide();
		listAnchor.children().eq(i).attr("src", listAnchor.children().eq(i).attr("src").replace("on.gif", ".gif"));
		mapAnchor.children().eq(i).attr("src", mapAnchor.children().eq(i).attr("src").replace("_on.gif", ".gif"));
	}
	for(var i=0; i<mapAnchor.length; i++){
		targetMap = mapAnchor.eq(i).attr("href");
		if($(this).attr("href") == targetMap){
			mapAnchor.children().eq(i).attr("src", mapAnchor.children().eq(i).attr("src").replace(".gif", "_on.gif"));
		}
	}
	$(this).children().attr("src", $(this).children().attr("src").replace(".gif", "on.gif"));
	target = $(this).attr("href");
	$(target).show();
}













