var activeButton=null;
function browser_type()
{
	var ua,s,i;
	this.isIE=false;
	this.isNS=false;
	this.version=null;
	ua=navigator.userAgent;
	s="MSIE";
	
	if((i=ua.indexOf(s))>=0){
	this.isIE=true;
	this.version=parseFloat(ua.substr(i+s.length));
	return;
	}
	s="Netscape6/";
	if((i=ua.indexOf(s))>=0){
	this.isNS=true;
	this.version=parseFloat(ua.substr(i+s.length));
	return;
	}
	s="Gecko";
	if((i=ua.indexOf(s))>=0){
	this.isNS=true;
	this.version=6.1;return;
	}
}

var browser_type=new browser_type();


function FindTable(obj)
{
	return obj.tagName == "TABLE" ? obj:FindTable(obj.parentElement);
}

function calculat_x(el)
{
	return el.offsetLeft+(el.offsetParent?calculat_x(el.offsetParent):0);
}

function calculat_y(el)
{
	return el.offsetTop+(el.offsetParent?calculat_y(el.offsetParent):0);
}

function PreloadImg()
{ 
  var img_list = PreloadImg.arguments;
  if (document.preloadlist == null)     document.preloadlist = new Array();
  var top = document.preloadlist.length;
  
  for (var i=0; i < img_list.length; i++) 
  {
    document.preloadlist[top+i]     = new Image;
    if(img_list[i+1] != undefined)    document.preloadlist[top+i].src = img_list[i+1];
  } 
}

var rBanner,maxH,lBanner;
var bTop;
var bBottom;
var topMenu;
var inSet=0;
var inSet_l=0;
function FindChildTable(obj)
{
	return obj.tagName == "TABLE" ? obj:FindTable(obj.childElement);
}

function InitBannerMove()
{	
	var topElem = document.body.firstChild;	
		
	var bottomLine = document.getElementById('BottomLine');
	topMenu = document.getElementById('TopMenu');
	rBanner = document.getElementById('rBanner');
	//lBanner = document.getElementById('lBanner');
	var rBanner_default = document.getElementById('rBanner_default');
	var cList = GetCookie_vi("viewItems");
	
	if(cList != "" && cList != undefined && cList != "undefined" && cList != null)
	{
		rBanner_default.style.visibility="hidden";		
		vi_ShowItems(cList);		
	} 
	else
	{
		rBanner.style.visibility="hidden";
		rBanner = rBanner_default;
	}
	
	if(topElem && bottomLine && topMenu && rBanner)
	{
		bTop = topElem.offsetHeight + 5;
		bBottom = bottomLine.offsetTop;
		
		
		rBanner.style.top = bTop; //document.body.scrollTop * 1;	
		rBanner.style.left = topMenu.offsetLeft+ topMenu.offsetWidth-inSet;	
		rBanner.style.visibility = "visible";
		//lBanner.style.top = bTop;
		//lBanner.style.left = topMenu.offsetLeft- lBanner.offsetWidth-inSet_l;		
		
		maxH = bBottom - bTop - (rBanner.offsetHeight + 50);
		window.onresize=ResetBannerMove;
		
		moveRightEdge();
	}
}
	
function ResetBannerMove()
{
	rBanner.style.left = topMenu.offsetLeft+ topMenu.offsetWidth-inSet;
	//lBanner.style.left = topMenu.offsetLeft- lBanner.offsetWidth-inSet_l;	
}

function moveRightEdge() 
{
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
	
	yMenuFrom   = parseInt (rBanner.style.top, 10);
	yMenuTo     = document.body.scrollTop + 100;
	if(yMenuTo > maxH) yMenuTo = maxH;
	if(yMenuTo < bTop) yMenuTo = bTop;
	if(yMenuTo > bBottom) yMenuTo = bBottom;
	
	timeoutNextCheck = 200;

	if (yMenuFrom != yMenuTo) 
	{
		yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 15);
		if (yMenuTo < yMenuFrom)	yOffset = -yOffset;
		 
		rBanner.style.top = parseInt (rBanner.style.top, 10) + yOffset;
		//lBanner.style.top = parseInt (lBanner.style.top, 10) + yOffset;
		timeoutNextCheck = 1;
	}
	setTimeout ("moveRightEdge()", timeoutNextCheck);
}
//-------------------¿À´Ãº»»óÇ° ¸®½ºÆ®-------------------------//

function GetCookie_vi(name)
{  	
 	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)  			 
			return GetCookieVal_vi (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}

function GetCookieVal_vi(offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}

function SetCookie_vi(name, value) 
{  
	var argv = SetCookie_vi.arguments;  
	var argc = SetCookie_vi.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	
	//var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	var path = "/"; //allows the tree to remain open across pages with diff names & paths
	
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function ExpireCookie (name) 
{  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie_vi (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function vi_insViewItems(iCode,iPath,is_reload)
{	
	var insCode = iPath+"/"+iCode+"";
	
	var cList = vi_mkIcodeString(insCode);
	//4k ³ÑÀ¸¸é ÀÚµ¿ÃÊ±âÈ­
	SetCookie_vi("viewItems", cList);	
	if(is_reload==true)
	{
		vi_ShowItems(cList);
	}
}

function vi_mkIcodeString(iCode)
{
	var cList = GetCookie_vi("viewItems");
	if(cList == "" || cList == undefined || cList == "undefined" || cList == null)
	{
		cList = iCode;
	} 
	else if(!vi_chkDup(iCode,cList))
	{
		cList =  iCode + "|" + cList;
	}
	return cList;
}

function vi_chkDup(icode,cList)
{
	icode = String(icode);
	icode = icode.replace(/[\/]/g,"\\/"); 	
	codeEx1 = eval("/^"+icode+"\\|/");
    codeEx2 = eval("/\\|"+icode+"\\|/");
	codeEx3 = eval("/\\|"+icode+"$/");
	codeEx4 = eval("/^"+icode+"$/");
	
	if(codeEx1.test(cList)){ return true; };
	if(codeEx2.test(cList)){ return true; };
    if(codeEx3.test(cList)){ return true; };
    if(codeEx4.test(cList)){ return true; };
	return false;
}

function vi_ShowItems(cList)
{	
	var instr;
	var rBanner = document.all.rBanner;
	var items = document.all.nowViewItems;
	var itemCount = document.all.nowViewItemCount;
	items.innerHTML = "";
	
	if(cList != "" && cList != undefined && cList != "undefined" && cList != null)
	{
		rBanner.arrItm = cList.split("|");
		rBanner.curTop = 0;
		instr = vi_mkInnerHtml(rBanner.curTop,rBanner.arrItm)				
		items.innerHTML = instr ;
		
		if(itemCount != "" && itemCount != undefined && itemCount != "undefined" && itemCount != null)
		{
			if(rBanner.arrItm != "" && rBanner.arrItm != undefined && rBanner.arrItm != "undefined" && rBanner.arrItm != null)
																					itemCount.innerText=rBanner.arrItm.length+"°³";
		}
	
		if(instr != "" && rBanner.style.visibility == "hidden")
		{
			rBanner.style.visibility = "visible";
		}
	}	
}

function vi_ItemUp()
{
	var rBanner = document.all.rBanner;
	var items = document.all.nowViewItems;
	var iCnt = rBanner.arrItm.length;
	
	if (iCnt == 0)
	{
		alert("¿­¾îº¸½Å »óÇ° ¸®½ºÆ®°¡ ¾ø½À´Ï´Ù.");
		return;
	}
	
	if (rBanner.curTop <= 0)
	{
		alert("¿­¾îº¸½Å »óÇ° ¸®½ºÆ®ÀÇ ¸Ç Ã³À½ÀÔ´Ï´Ù.");
		return;
	}
	
	rBanner.curTop--;
	items.innerHTML = vi_mkInnerHtml(rBanner.curTop,rBanner.arrItm);
}


function vi_ItemDown()
{
	var rBanner = document.all.rBanner;
	var items = document.all.nowViewItems;
	var iCnt = rBanner.arrItm.length;
	
	if (iCnt == 0)
	{
		alert("¿­¾îº¸½Å »óÇ° ¸®½ºÆ®°¡ ¾ø½À´Ï´Ù.");
		return;
	}
	
	if (rBanner.curTop+4 >= iCnt)
	{
		alert("¿­¾îº¸½Å »óÇ° ¸®½ºÆ®ÀÇ ¸Ç ¸¶Áö¸·ÀÔ´Ï´Ù.");
		return;
	}
	
	rBanner.curTop++;	
	items.innerHTML = vi_mkInnerHtml(rBanner.curTop,rBanner.arrItm);
	
}

function vi_mkInnerHtml(curTop,arrItems)
{
	var instr="";
	var iCode;
	for(i=curTop;i < curTop + 4;i++)
	{
		if(arrItems[i] != "" && arrItems[i] != undefined && arrItems[i] != "undefined" && arrItems[i] != null)			
		{
			arrTmp = arrItems[i].split("_");
			iCode = arrTmp[0].replace(/^(\/[0-9|\/]+)\/([0-9]+)$/,"$2");	
				
			instr += "<img onClick=\"GoItem('"+iCode+"');\"  style='cursor:hand;margin-top:7px;border:1px #CCCCCC solid;' src='/_images"+arrTmp[0]+"_60_1.jpg' border='0' ONERROR=\"this.onerror=null;this.src='/image/blank_60.gif'\" width='50' Height='50'><BR>";
		}
	}
	return instr;
}

function vi_ItemCount()
{
	//alert(rBanner.arrItm.length);
	document.write(rBanner.arrItm.length);
}
//-------------------¿À´Ãº»»óÇ° ¸®½ºÆ®-------------------------//
function LogOut()
{
	location.href="/pub/etc/logOut.aspx"
}
function LogOutN()
{
	parent.location.href="/pub/etc/logOut.aspx"
}
function LogInPop(act)
{	
	act = (act==undefined || act=="" ? "login" : act);	
	var url = "/pub/etc/loginPop.aspx";
	
	if(act == "login")
	{
		url="/pub/etc/LoginPop.aspx";
	}
	else if(act == "findID")
	{
		url="/pub/etc/FindID.aspx";
	}
	else if(act == "findPass")
	{
		url="/pub/etc/FindPass.aspx";
	}
	
	OpenWindow_noscroll(url,'loginpop','445','360');
}


function popevent(no)
{
	if(no=1)
	{
		OpenWindow_noscroll('/html/event03_pop.html','eventpop','400','400');
	}
}
function PopRowPr()
{		
	OpenWindow_noscroll('/html/notice_row.html','rowp','500','600');
}
function SelectCob(belem,tID) 
{	
	var obj=document.getElementById(tID);	
	if(obj.style.display == 'none') 
	{
		var x = calculat_x(belem);
		var y = calculat_y(belem)+belem.offsetHeight -1;
		obj.style.left=x;
		obj.style.top=y;
		//obj.style.width=belem.offsetWidth;
		obj.style.display = 'block';
	}
	else 
	{
		obj.style.display = 'none';
	}
}

function ST_Type(cType)
{
	var cText = cType.innerText;	
	var tCell=document.getElementById("TopSearchType");	
	tCell.innerText=cType.innerText;
	
	var obj=document.getElementById("topSelecterItem");
	obj.style.display = 'none';
}

function GoTopSearch()
{
	var tCell=document.getElementById("TopSearchType");	
	var qText =document.getElementById("TopSearchText");
	if(qText.value=="") return;
	var tUrl;
	switch(tCell.innerText)
	{
		case "³ó°¡°Ë»ö":
			tUrl="/search/cp.aspx";
			break;
		case "¼­Æ÷ÅÍ":
			tUrl="/search/helper.aspx";
			break;
		case "Ä¿¹Â´ÏÆ¼":
			tUrl="/search/com.aspx";
			break;
		default:
			tUrl="/search/item.aspx";
			break;
	}
	tUrl=tUrl+"?inQ="+qText.value;
	location.href=tUrl;
}

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];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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; }
}


function ShowPopupLayer(tName,xOffset,yOffset)
{
	xOffset = xOffset + document.body.scrollLeft + 10;
	yOffset = yOffset + document.body.scrollTop + 10;
	var lefter = event.clientX + xOffset;
	var topper = event.clientY + yOffset;	
	
	var elem = document.getElementById(tName);
	
	elem.style.left=lefter;
	elem.style.top=topper;
	elem.style.display='';
	elem.style.zIndex = 100;
}
function HidePopupLayer(tName)
{
	var elem = document.getElementById(tName);
	elem.style.display='none';	
}

function GoList(cID)
{
	document.location.href="/pub/item/list.aspx?cID="+cID;
}
function GoListOpen(cID)
{
	document.location.href="/pub/open/list.aspx?cID="+cID;
}

function GoItem(iCode,cID)
{
	if(cID==undefined)
	{
		document.location.href="/pub/item/detail.aspx?iCode="+iCode;
	}
	else
	{
		document.location.href="/pub/item/detail.aspx?iCode="+iCode+"&cID="+cID;
	}
}

function GoItemN(iCode,cID)
{
	var url;
	if(cID==undefined)
	{
		url="/pub/item/detail.aspx?iCode="+iCode;
	}
	else
	{
		url="/pub/item/detail.aspx?iCode="+iCode+"&cID="+cID;
	}	
	window.open(url);
}

function ShowCpInfo(cpCode)
{	
	try
	{
		var x = Number(document.body.clientWidth);
		var y = Number(document.body.clientHeight) + 100;
		var wWidth = 950;
		var wHeight = 650;
		x = (x/2)-wWidth/2;
		y = (y/2)- wHeight/2;
		
		x=1;
		y=1;
		wHeight = screen.availHeight-31;
		window.name = 'ultari';
		var url="/blog/main.aspx?bNo="+cpCode;	
		WinOpenFull(url,"blogDetail",wWidth,wHeight,x,y);	
	}
	catch(e)
	{
	}
}

function OpenBlogWindow(url)
{
	try
	{
		var wWidth = 950;
		var wHeight = screen.availHeight-31;		
		var x=1;
		var y=1;
		window.name = 'ultari';		
		WinOpenFull(url,"blogDetail",wWidth,wHeight,x,y);	
	}
	catch(e)
	{
	}
}
function SetWishSeller(cpCode)
{
	var url = "/pub/etc/insWishCpPop.aspx?act=intoWish&cCode="+cpCode;
	OpenWindow_noscroll(url,'WishPop','445','360');
}

var activeButton=null;
function RollOverImage(button,onImgSrc)
{
	
	if(activeButton!=button)
	{	
		if(!button.offSrc) button.offSrc=button.src;
		if(!button.onSrc) button.onSrc=onImgSrc;
		
		if(activeButton && activeButton!=button)
		{
			RollOutImage();
		}
		button.src = button.onSrc;	
		activeButton=button;
	}
	return false;
}


function RollOutImage()
{
	if(activeButton)
	{
		if(activeButton.offSrc) activeButton.src = activeButton.offSrc;
		activeButton=null;
	}
}
 
function ZoomItemImage(no,iCode,iPath)
{	
	var url = "/pub/item/ZoomItem.aspx?iCode="+iCode+"&iPath="+iPath+"&no="+no;
	OpenWindow_noscroll(url,"zoomwin",735,555);
}


function ZoomingImage(imgUrl)
{
	var newWin=window.open("/etc/zoomImage.aspx?img="+imgUrl,"Detail_view","width=20,height=10,scrollbars=0,resizable=0,left=50,top=50");
	if (newWin !=null)
	{
		newWin.opener=self;
	}
	newWin.focus();
}
