/*
	Cidow
	common javascript modify by sh 20100208
*/
/* images preload */


/* gnb */
function activeGNB(id) {
	for(num=1; num<=5; num++) document.getElementById('gm'+num).style.display='none';
	document.getElementById(id).style.display='block';
}

function activeGNBover(id) {
	for(num=1; num<=5; num++) document.getElementById('over'+num).className='over'+num;
	document.getElementById(id).className="overbg";
}

/* fnlClass */
function fnlClass(elId, tagName) {
	var el = document.getElementById(elId).getElementsByTagName(tagName);
	el[0].className="first";
	el[el.length-1].className="last";
}

/*
	Tab Contents(ÅÇ¸Þ´º)
*/
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 == "tab")
			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 = 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();
}

/*
	Tab Contents(½½¶óÀÌµå_ÅÇ)
*/
function initTabMenu2(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 == "tab2")
			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 = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
			}
			this.targetEl.style.display = "";
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

/* tabContents */
function tabContents(tabContainerID, tagName) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName(tagName);
	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 = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = 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(" selected", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(/.gif$/, "_on.gif");
			} else {
				this.className += " selected";
			}
			this.container.current = this;
			return false;
		};
		if (!thismenu.container.first) thismenu.container.first = thismenu;
	}
	if (tabContainer.first)	tabContainer.first.onclick();
}

/* rolloverimg */
function rollOverImg(elId, tagName) {
	var el = document.getElementById(elId).getElementsByTagName(tagName);
	for (var i=0; i<el.length; i++) {
		  if( el[i].src.indexOf("_on.gif") == -1 && el[i].src.indexOf(".gif") != -1 ) {
				el[i].onmouseover = changeOver;
				el[i].onmouseout = changeOut;
		}
	}
}

function changeOver() {
	this.src=this.src.replace(/.gif$/, "_on.gif");
}
function changeOut() {
  this.src=this.src.replace(/_on.gif$/, ".gif");
}

/*  image map */
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_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; }
}

/* board rollOverBg */
function rollOverBg(elId, tagName) {
	var el = document.getElementById(elId).getElementsByTagName(tagName);
	for (var i=0; i<el.length; i++) {
				el[i].onmouseover = overBg;
				if(i%2 == 0){
					el[i].onmouseout = outBg;
				}else if(i%2 !== 0){
					el[i].onmouseout = outBg2;
				}
	}
}
function overBg() {
	this.className = "overcolor";
}
function outBg() {
    this.className = " ";
}
function outBg2() {
    this.className = "overcolor ";
}


			//============ ÆäÀÌÁö Ã³¸® ½ºÅ©¸³Æ® ½ÃÀÛ ==========================
			var cur_point = 5;
			var fpoint = 0;
			var epoint = 0;

			function goPrev(totcnt, galid){

				if (epoint < 6 ){
					alert('Ã³À½ ÀÌ¹ÌÁöÀÔ´Ï´Ù.');
					return;
				}

				for (i=0; i < totcnt; i++){
					document.getElementById(galid + i).style.display="none";
				}
				cur_point = cur_point - 5;
				fpoint = cur_point - 5;
				epoint = cur_point;

				for (i = fpoint ; i < epoint; i++){
					document.getElementById(galid + i).style.display="inline";
				}
			}

			function goNext(totcnt, galid){

				if( cur_point >= totcnt){
					alert('¸¶Áö¸· ÀÌ¹ÌÁöÀÔ´Ï´Ù.');
					return;
				}

				for (i=0; i < totcnt; i++){
					document.getElementById(galid + i).style.display="none";
				}
				fpoint = cur_point;
				epoint = cur_point + 5;

				if( epoint > totcnt){
					fpoint = cur_point;
					epoint = totcnt;
				}

				for (i = fpoint ; i < epoint; i++){
					document.getElementById(galid + i).style.display="inline";
				}
				cur_point = cur_point + 5;
			}

			//============ ÀÌ¹ÌÁö ·Ñ¿À¹ö Ã³¸® ½ºÆ®¸³Æ® ========================
			function showbigImage(image_name){
				document.getElementById("big_image").src = image_name;
			}





