/* 
Gicamp Corp, Web Standardization Team (http://www.gicamp.co.kr/) crazyweb
-----------------------------------------------------------------------------
COMMON JavaScript
-----------------------------------------------------------------------------
*/
//<![CDATA[
//* Popup_g-Fair */
function PopNewOpen(id) {
	document.getElementById('new_2012').style.display='block'; // 보이기
}
function PopNewClose(id) {
	document.getElementById('new_2012').style.display='none'; // 숨김:
}
//]]>
//<![CDATA[
//* Popup_g-Fair */
function gfairOpen(id) {
	document.getElementById('gfair2011').style.display='block'; // 보이기
}
function gfairClose(id) {
	document.getElementById('gfair2011').style.display='none'; // 숨김:
}
//]]>
//<![CDATA[
//* SearchPopupLayer */
function searchpopOpen(id) {
	document.getElementById('searchpop').style.visibility='visible'; // 보이기
}
function searchpopClose(id) {
	document.getElementById('searchpop').style.visibility='hidden'; // 숨김:
}
//]]>
//<![CDATA[
//* AD PopupLayer */
function adpopOpen(id) {
	document.getElementById('adfirst').style.visibility='visible'; // 보이기
}
function adpopClose(id) {
	document.getElementById('adfirst').style.visibility='hidden'; // 숨김:
}
//]]>
//<![CDATA[
//* LNB Navigation */
function activeLNB(id) {
	for(num=1; num<=6; num++) document.getElementById('Lm'+num).style.visibility='hidden'; //
	document.getElementById(id).style.visibility='visible'; //해당 ID만 보임
}
function onblueLNB(id) {
	document.getElementById(id).style.visibility='hidden'; //
}
//]]>
//* ADselect */
function ADselect(id) {
 
 
	for(num=1; num<=6; num++) document.getElementById('Ad'+num).style.visibility='hidden'; //
	document.getElementById(id).style.visibility='visible'; //해당 ID만 보임
	document.getElementById('s'+id).style.backgroundImage ="/img/main/bg_adselect_list_on.gif"; //해당 ID만 보임

	//adpopClose('adfirst');
}
function onblueAD(id) {
	//document.getElementById(id).style.visibility='hidden'; //
}
//]]>
//<![CDATA[
//* Images Mouse Rollover and restore */
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];}
}
//]]>
//<![CDATA[
//*  Anchor Tab Menu*/
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[
//* Rolling Banner */
function fnRolMove_Type1() {
	this.GoodsSetTime = null;
	this.BannerCurrent = 0;
	this.DateNum = 3;
	
	this.Start = function() {
		this.Obj = document.getElementById(this.BoxName);
		this.ObjBox = document.getElementById(this.DivName);

		this.ObjUl = this.ObjBox.getElementsByTagName("ul")[0];
		this.ObjLi = this.ObjUl.getElementsByTagName("li");
		
		// 배너 갯수를 파악하는 부분
		this.ObjLiNum = this.ObjLi.length;
		
		// 배너 부분의 총 넓이를 파악하는 부분
		this.TotalWidth = this.DateWidth * this.ObjLiNum;

		this.ObjBox.style.width = this.TotalWidth + "px";
		
		if ( this.ObjLiNum % this.DateNum == 0 ) {
			this.BannerEnd = this.TotalWidth - ( this.DateWidth * this.DateNum );
		} else {
			this.BannerEnd = this.TotalWidth - this.DateWidth;
		}
		
		// 배너를 쌓고 있는 부분의 박스에 Css를 입히기
		this._Style();
		// Javascript 작동시 다음, 이전 버튼을 삽입하기
		this._ControlAdd();
	
		// 다음, 이전 버튼을 클릭시 이동해야 할 위치 계산하기
		this.BannerPrevLeft = this.BannerEnd;
		this.BannerNextLeft = this.DateWidth * this.DateNum ;

		this.PrevBtnLinkImg.Num = this.BannerPrevLeft;
		this.PrevBtnLinkImg.onclick = function() {
			eval(this.fnName + "._moveFrame(" + this.Num + ",'prev')" );
			return false;
		}
		
		this.NextBtnLinkImg.Num = this.BannerNextLeft;
		this.NextBtnLinkImg.onclick = function() {
			eval(this.fnName + "._moveFrame(" + this.Num + ",'next')" );
			return false;
		}
	}
	
	this._ControlAdd = function() {
		this.NewControl = document.createElement('div');
		this.NewControl.id = "BannerListCon1";
		this.Obj.appendChild(this.NewControl);
		
		//this.PrevBtnLink = document.createElement('a');
		//this.PrevBtnLink.fnName = this.fnName;
		//this.PrevBtnLink.href = "#";
		//this.NewControl.appendChild(this.PrevBtnLink);
		
		this.PrevBtnLinkImg = document.createElement('img');
		this.PrevBtnLinkImg.fnName = this.fnName;
		this.PrevBtnLinkImg.className = "prev1";
		this.PrevBtnLinkImg.src = "/img/common/btn_banner_prev.gif";
		this.PrevBtnLinkImg.alt = "이전";
		this.NewControl.appendChild(this.PrevBtnLinkImg);

		
		//this.NextBtnLink = document.createElement('a');
		//this.NextBtnLink.fnName = this.fnName;
		//this.NextBtnLink.href = "#";
		//this.NewControl.appendChild(this.NextBtnLink);
		
		this.NextBtnLinkImg = document.createElement('img');
		this.NextBtnLinkImg.fnName = this.fnName;
		this.NextBtnLinkImg.className = "next1";
		this.NextBtnLinkImg.src = "/img/common/btn_banner_next.gif";
		this.NextBtnLinkImg.alt = "다음";
		this.NewControl.appendChild(this.NextBtnLinkImg);

	}
	
	this._Style = function() {
		this.BoxStyle = this.ObjBox.parentNode;
		this.BoxStyle.className = "BannerListStyle1";
		this.BoxUlStyle = this.ObjBox.getElementsByTagName("ul")[0];
		this.BoxUlStyle.className = "BannerUlStyle1";
	}
	
	// 다음, 이전 버튼을 클릭시 배너를 이동 처리를 하는 부분
	this._moveFrame = function(val,fnmove) {
		clearTimeout(this.GoodsSetTime);

		if ( Math.abs(val - this.BannerCurrent) > 5 ) {
			this.BannerCurrent = this.BannerCurrent + ( val - this.BannerCurrent ) * this.Speed;
		} else {
			this.BannerCurrent = val;
		}
		
		this.ObjUl.style.left = ( -1 * this.BannerCurrent ) + "px";
		
		if ( this.BannerCurrent != val ) {
			this.GoodsSetTime = setTimeout(this.fnName + "._moveFrame(" + val + ",'" + fnmove + "')",10);
		} else {
			this.CurrentPicNum = this.BannerCurrent / this.DateWidth;
			
			this.BannerPrevLeft = this.BannerCurrent - ( this.DateWidth * this.DateNum );
			this.BannerNextLeft = this.BannerCurrent + ( this.DateWidth * this.DateNum );
			
			if ( this.BannerCurrent == 0 ) {
				this.BannerPrevLeft = this.BannerEnd;
			} else if ( this.BannerCurrent == this.TotalWidth - ( this.DateWidth * this.DateNum ) ) {
				this.BannerNextLeft = 0;
			}
			this.PrevBtnLinkImg.Num = this.BannerPrevLeft;
			this.PrevBtnLinkImg.onclick = function() {
				eval(this.fnName + "._moveFrame(" + this.Num + ",'prev')" );
				return false;
			}
			
			this.NextBtnLinkImg.Num = this.BannerNextLeft;
			this.NextBtnLinkImg.onclick = function() {
				eval(this.fnName + "._moveFrame(" + this.Num + ",'next')" );
				return false;
			}
		}
	}
}
//type2
function fnRolMove_Type2() {
	this.GoodsSetTime = null;
	this.BannerCurrent = 0;
	this.DateNum = 3;
	
	this.Start = function() {
		this.Obj = document.getElementById(this.BoxName);
		this.ObjBox = document.getElementById(this.DivName);

		this.ObjUl = this.ObjBox.getElementsByTagName("ul")[0];
		this.ObjLi = this.ObjUl.getElementsByTagName("li");
		
		// 배너 갯수를 파악하는 부분
		this.ObjLiNum = this.ObjLi.length;
		
		// 배너 부분의 총 넓이를 파악하는 부분
		this.TotalWidth = this.DateWidth * this.ObjLiNum;

		this.ObjBox.style.width = this.TotalWidth + "px";
		
		if ( this.ObjLiNum % this.DateNum == 0 ) {
			this.BannerEnd = this.TotalWidth - ( this.DateWidth * this.DateNum );
		} else {
			this.BannerEnd = this.TotalWidth - this.DateWidth;
		}
		
		// 배너를 쌓고 있는 부분의 박스에 Css를 입히기
		this._Style();
		// Javascript 작동시 다음, 이전 버튼을 삽입하기
		this._ControlAdd();
	
		// 다음, 이전 버튼을 클릭시 이동해야 할 위치 계산하기
		this.BannerPrevLeft = this.BannerEnd;
		this.BannerNextLeft = this.DateWidth * this.DateNum ;

		this.PrevBtnLinkImg.Num = this.BannerPrevLeft;
		this.PrevBtnLinkImg.onclick = function() {
			eval(this.fnName + "._moveFrame(" + this.Num + ",'prev')" );
			return false;
		}
		
		this.NextBtnLinkImg.Num = this.BannerNextLeft;
		this.NextBtnLinkImg.onclick = function() {
			eval(this.fnName + "._moveFrame(" + this.Num + ",'next')" );
			return false;
		}
	}
	
	this._ControlAdd = function() {
		this.NewControl = document.createElement('div');
		this.NewControl.id = "BannerListCon2";
		this.Obj.appendChild(this.NewControl);
		
		//this.PrevBtnLink = document.createElement('a');
		//this.PrevBtnLink.fnName = this.fnName;
		//this.PrevBtnLink.href = "#";
		//this.NewControl.appendChild(this.PrevBtnLink);
		
		this.PrevBtnLinkImg = document.createElement('img');
		this.PrevBtnLinkImg.fnName = this.fnName;
		this.PrevBtnLinkImg.className = "prev2";
		this.PrevBtnLinkImg.src = "/img/common/btn_banner_prev.gif";
		this.PrevBtnLinkImg.alt = "이전";
		this.NewControl.appendChild(this.PrevBtnLinkImg);

		
		//this.NextBtnLink = document.createElement('a');
		//this.NextBtnLink.fnName = this.fnName;
		//this.NextBtnLink.href = "#";
		//this.NewControl.appendChild(this.NextBtnLink);
		
		this.NextBtnLinkImg = document.createElement('img');
		this.NextBtnLinkImg.fnName = this.fnName;
		this.NextBtnLinkImg.className = "next2";
		this.NextBtnLinkImg.src = "/img/common/btn_banner_next.gif";
		this.NextBtnLinkImg.alt = "다음";
		this.NewControl.appendChild(this.NextBtnLinkImg);

	}
	
	this._Style = function() {
		this.BoxStyle = this.ObjBox.parentNode;
		this.BoxStyle.className = "BannerListStyle2";
		this.BoxUlStyle = this.ObjBox.getElementsByTagName("ul")[0];
		this.BoxUlStyle.className = "BannerUlStyle2";
	}
	
	// 다음, 이전 버튼을 클릭시 배너를 이동 처리를 하는 부분
	this._moveFrame = function(val,fnmove) {
		clearTimeout(this.GoodsSetTime);

		if ( Math.abs(val - this.BannerCurrent) > 5 ) {
			this.BannerCurrent = this.BannerCurrent + ( val - this.BannerCurrent ) * this.Speed;
		} else {
			this.BannerCurrent = val;
		}
		
		this.ObjUl.style.left = ( -1 * this.BannerCurrent ) + "px";
		
		if ( this.BannerCurrent != val ) {
			this.GoodsSetTime = setTimeout(this.fnName + "._moveFrame(" + val + ",'" + fnmove + "')",10);
		} else {
			this.CurrentPicNum = this.BannerCurrent / this.DateWidth;
			
			this.BannerPrevLeft = this.BannerCurrent - ( this.DateWidth * this.DateNum );
			this.BannerNextLeft = this.BannerCurrent + ( this.DateWidth * this.DateNum );
			
			if ( this.BannerCurrent == 0 ) {
				this.BannerPrevLeft = this.BannerEnd;
			} else if ( this.BannerCurrent == this.TotalWidth - ( this.DateWidth * this.DateNum ) ) {
				this.BannerNextLeft = 0;
			}
			this.PrevBtnLinkImg.Num = this.BannerPrevLeft;
			this.PrevBtnLinkImg.onclick = function() {
				eval(this.fnName + "._moveFrame(" + this.Num + ",'prev')" );
				return false;
			}
			
			this.NextBtnLinkImg.Num = this.BannerNextLeft;
			this.NextBtnLinkImg.onclick = function() {
				eval(this.fnName + "._moveFrame(" + this.Num + ",'next')" );
				return false;
			}
		}
	}
}
//]]>

function onInfoShow(n) {
	for(i=1;i<=6;i++) {
		if(document.getElementById('infotab'+i+'_list') != null) {
			if(n == i) {
				document.getElementById('infotab'+i+'_list').style.visibility = 'visible';	
				if(document.getElementById('infotab'+i) != null) {
					var re = new RegExp('_off');
					document.getElementById('infotab'+i).className = document.getElementById('infotab'+i).className.replace(re,'_on');
				}
			}else{
				document.getElementById('infotab'+i+'_list').style.visibility = 'hidden';
				if(document.getElementById('infotab'+i) != null) {
					var re = new RegExp('_on');
					document.getElementById('infotab'+i).className = document.getElementById('infotab'+i).className.replace(re,'_off');
				}
			}
		}
	}		
}
//]]>
