/* GiCamp Corp, Web Standardization (http://www.gicamp.co.kr/) | Author: Crazyweb 091120 */

//전체메뉴보기의 (보이기/숨김)설정
function AllmenuOpen(id) {
	document.getElementById('am').style.display='block'; // 보이기
}
function AllmenuClose(id) {
	document.getElementById('am').style.display='none'; // 숨김
}
function MypageOpen(id) {
	document.getElementById('mp').style.display='block'; // 보이기
}
function MypageClose(id) {
	document.getElementById('mp').style.display='none'; // 숨김
}
function SearchWhereOpen(id) {
	document.getElementById('sw').style.display='block'; // 보이기
}
function SearchWhereClose(id) {
	document.getElementById('sw').style.display='none'; // 숨김
}
function activeRegionOpen(id) {
	document.getElementById('RC').style.display='block'; // 보이기
}
function activeRegionClose(id) {
	document.getElementById('RC').style.display='none'; // 숨김
}
//이미지 마우스 롤오버 설정
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];}
}
/* Anchor Tab */
function TabContent(tabContainerID,triggers,self,img,showFirst) {
	this.tabContainerID = tabContainerID;
	this.trigger = triggers;
	this.selfClose = self;
	this.imgEnhance = img;
	this.showFirst = showFirst;
}

//Toggle.prototype
TabContent.prototype.init = function() {
	var tabContainer = document.getElementById(this.tabContainerID);
	var tabAnchor =tabContainer.getElementsByTagName("a");
	var selfClose = new Boolean(this.selfClose);
	var showFirst = new Boolean(this.showFirst);
	var i,j;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == this.trigger)
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		

		if(this.imgEnhance && this.imgEnhance == 1)
			thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function() {
			currentmenu = this.container.current;

			if (currentmenu == this) {
				if(selfClose && (selfClose.toString() == "true")) {
					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.container.current = null;
				} else {
					return false;
				}
			} else {
				if (currentmenu) {
					currentmenu.targetEl.style.display = "none";
					if (currentmenu.imgEl) {
						currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
						currentmenu.className = currentmenu.className.replace(" on", "");
					} else {
						currentmenu.className = currentmenu.className.replace(" on", "");
					}
				}
				this.targetEl.style.display = "block";
				if (this.imgEl) {
					this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
					this.className += " on";
				} else {
					this.className += " on";
				}
				
				this.container.current = this;
			}
			return false;
		};
		if (!thismenu.container.first) {
			thismenu.container.first = thismenu;
		}
	}
	if(showFirst && (showFirst.toString() == "true")) {
		if (tabContainer.first)
			tabContainer.first.onclick();
	}
};
//<![CDATA[
/* getElementsByClassName */
	function getElementsByClassName(chkName,parentNode) {
		var arr = new Array();
		if (parentNode == null) {
			var elems = document.getElementsByTagName("*");
		} else {
			var elems = parentNode.getElementsByTagName("*");
		}
		for ( var chk, i = 0; ( elem = elems[i] ); i++ ) {
			if ( elem.className == chkName ) {
				arr[arr.length] = elem;
			}
		}
		return arr;
	}
	function tabDisplay(tab,content,num,chk,over,type) {
		for (var i=0; i<content.length; i++) {
			tab[i].className = '';
			tab[num].className = chk;
			content[i].style.display = 'none';
			content[num].style.display = 'block';
		}
	}
	function tabAct(tab,content,num,chk,over,type) {
		tab[num].onclick = function() {
			tabDisplay(tab,content,num,chk);
			return false;
		}
		if (type == true) {
			tab[num].onmouseover = function() {
				if (this.className != chk) {
					this.className = over;
				}
			}
			tab[num].onmouseout = function() {
				if (this.className == over) {
					this.className = '';
				}
			}
		}
	}
	window.onload = tabMenu;
	function tabMenu() {
		var tabs = document.getElementById('tabmenu');
		if (tabs != null)
		{
			var tab = tabs.getElementsByTagName('a'); // 탭 요소
			var contents = document.getElementById('tabcontents');
			var content = getElementsByClassName('tabcontent',contents); // 컨텐츠 요소 class
			var chk = 'selected'; // 선택된 탭의 class
			var over = 'over'; // 롤오버된 탭의 class
			var type = true; // 롤오버의 true / false
			for (var i=0; i<tab.length; i++) {
				tabDisplay(tab,content,0,chk,over,true);
				tabAct(tab,content,i,chk,over,type);
			}
		}
	}
//]]>
//팝업존(2Depth 메뉴그룹)에 대한 마우스 또는 키보드 반응(보임/숨김)설정
/*
function activePopupZone(id) {
	for(num=1; num<=5; num++) document.getElementById('pz'+num).style.display='none'; //
	document.getElementById(id).style.display='block'; //해당 ID만 보임
}
*/
function activePopupZone(id,pnum) {
	for(num=1; num<=pnum; num++) document.getElementById('pz'+num).style.display='none'; //
	document.getElementById(id).style.display='block'; //해당 ID만 보임
}
//<![CDATA[
//* Select List region */
function Go_region()
{			
	var len = document.getElementById("regionlink").length;
	var str;
	for(var i=0;i<len;i++)
{
	if(document.getElementById("regionlink")[i].selected)
	{
		str = document.getElementById("regionlink")[i].value;
	}
}
	if(str != "")
	{
		window.open(str,"","");
}
	return false;
}
//]]>
