






var cpt_val = false;  
var cpt_layer = null; 
var esX, esY;        
var zIdx    = 100;    

var is_ie = (navigator.userAgent.indexOf("MSIE") != -1) ? true :false;


function capture(obj_id, evt) {
	var evt = evt ? evt : event;

	cpt_layer = document.getElementById(obj_id);
	zIdx++;
	cpt_layer.style.zIndex = zIdx;
	cpt_val = true;
	
	if(document.body && document.body.setCapture) {
		
		document.body.setCapture();
   }

	if(is_ie) {
		esX = evt.offsetX;
		esY = evt.offsetY;
	}
	else {
		esX = evt.clientX - (cpt_layer.offsetLeft ? cpt_layer.offsetLeft : 0);
		esY = evt.clientY - (cpt_layer.offsetTop  ? cpt_layer.offsetTop  : 0) ;
	}

	evt.cancelBubble = true;
   return false;
}


function drag_layer(evt) {
	var evt = evt ? evt : event;
	if(cpt_val == true) {
		if(cpt_layer != null) {
			if(is_ie) {
				cpt_layer.style.pixelLeft = evt.x + document.body.scrollLeft - esX;
				cpt_layer.style.pixelTop  = evt.y + document.body.scrollTop  - esY;
			}
			else {
				cpt_layer.style.left = evt.clientX - esX;
				cpt_layer.style.top  = evt.clientY - esY;
			}
			evt.cancelBubble = true;
			return false;
		}
	}
}


function release() {
	cpt_val = false;
	cpt_layer = null;
   if (document.body && document.body.releaseCapture) {
	
		document.body.releaseCapture();
    }
}


function close_layer(obj_id) {
	cpt_layer = document.getElementById(obj_id);
	cpt_layer.style.display = "none";
}

document.onmousemove = drag_layer;
document.onmouseup   = release;




function open_window( filename, option, name )
{
	if( !name )
	{
		name = 'new'
	}


        win = window.open( filename, name, option );

        return win
}

function window_open( page, name, top, left, width, height )
{
	option = "'toolbar=no," +
		"location=no," +
		"directories=no," +
		"status=no," +
		"menubar=no," +
		"scrollbars=yes," +
		"resizable=yes," +
		"width=" + width + "," +
		"height=" + height + "," +
		"top=" + top + "," +
		"left=" + left + "'"

        window.open( page, name, option );
}

function window_open2( page, name, top, left, width, height )
{
	option = "'toolbar=no," +
		"location=no," +
		"directories=no," +
		"status=no," +
		"menubar=no," +
		"scrollbars=no," +
		"resizable=no," +
		"width=" + width + "," +
		"height=" + height + "," +
		"top=" + top + "," +
		"left=" + left + "'"

        window.open( page, name, option );
}

function window_open3( page, name, top, left, width, height )
{
	option = "'toolbar=no," +
		"location=no," +
		"directories=no," +
		"status=no," +
		"menubar=no," +
		"scrollbars=yes," +
		"resizable=no," +
		"width=" + width + "," +
		"height=" + height + "," +
		"top=" + top + "," +
		"left=" + left + "'"

        window.open( page, name, option );
}

function open_poll_pop( mode, no )
{
	page = '/front/php/poll_r.php?mode=' + mode + '&no=' + no;
	window_open( page, 'poll', 100, 300, 466, 382 );
}

/*Left menu 반투명 레이어 구현*/
function Layer_overload(LayerName,Status) 
{
    if (navigator.appName == "Netscape")
    {
		LayerN = document.getElementById(LayerName).style;
		if (Status == 'show') LayerN.visibility = 'visible';
		if (Status == 'hide') LayerN.visibility = 'hidden';
    }	
    else
    {
		LayerN = document.all[LayerName].style;
		if (Status == 'show') LayerN.visibility = 'visible';
		if (Status == 'hide') LayerN.visibility = 'hidden';
    }
}

/*Left menu구현*/
var old='';

function menu(name)
{
	submenu=eval("submenu_"+name+".style");
	if(old!=submenu)
	{
		if(old!='')
		{
			old.display='none';
		}
		submenu.display='block';
		old=submenu;
	}
	else
	{
		submenu.display='none';
		old='';
	}
}


function Layer_rollover(img_name,img_url)
{
	var menu;	
	//tmp = new String( "document."+img_name );
	menu=eval("document."+img_name);		
	menu.src = img_url;
	return;
}

function image_zoom( product_no, main_cate_no, display_group )
{
	//href = '/front/php/image_zoom.php?img='+image+'&product_no='+document.frm.product_no.value;
	href = '/front/php/image_zoom.php?product_no='+product_no+'&main_cate_no='+main_cate_no+'&display_group='+display_group;
	option = 'toolbar=no,scrollbars=no,resizable=yes,width=800,height=640,left=0,top=0';
	win_name = 'image'

	window.open( href, win_name, option );
}

/* 장바구니 삭제버튼 구현 */
function select_delete2(basket_type,chk_id){
    var fobj = document.forms.item("frm"+basket_type);
    var checked_length = 0;
    var k =0;
    var tmp;
    fobj.checked_product.value = chk_id;

    if(confirm('해당 상품을 삭제하시겠습니까?')) {
		fobj.command.value = 'select_delete' ;
		fobj.submit();
    }
}

/* 파일찾기버튼 이미지 구현 */
var lastform = -1;

function initFileButton()
{
	for (var i = 0; i < document.all.length; i++)
	{
		var control = document.all[i];
		
		if (control.tagName == "FORM")
		{
			lastform = i;
		}
		else if (control.getAttribute("filebutton"))
		{
			if (lastform >= 0)
				control.setAttribute("fileform", "document.all["+lastform+"]."+control.getAttribute("filebutton"));
		}
		else if (control.tagName == "DIV" && control.getAttribute("filename"))
		{
			var layertext = "";
			
			control.id = control.getAttribute("filename")+"_layer"+parseInt(Math.random() * 1000000000000000);

			layertext += "<input type='file' name='"+control.getAttribute("filename")+"' layerid='"+control.id+"'";
			layertext += " style='width:50px; height:50px; border:1px; cursor:default;'";
			
			if (control.getAttribute("displaytext"))
				layertext += " onchange='onChangeFile(this, this.form."+control.getAttribute("displaytext")+");'";
				
			layertext += ">";

			control.style.position = "absolute";
			control.style.left = 0;
			control.style.top = 0;
			control.style.width = 6;
			control.style.height = 6;
			control.style.overflow = "hidden";
			control.style.filter = "alpha(opacity=0)";
			control.style.clip = "rect(5, 9, 9, 5)";

			control.innerHTML = layertext;
		}
	}
}

function document.onmousemove()
{
	var eobj = window.event.srcElement;
	
	if (eobj.getAttribute("fileform"))
	{
		eval("var file = "+eobj.getAttribute("fileform")+";");
		var form = file.form;
		
		eval("var layer = "+file.getAttribute("layerid")+";");
		
		layer.style.left = event.x - 7 + document.body.scrollLeft;
		layer.style.top = event.y - 7 + document.body.scrollTop;
	}
}

function onChangeFile(file, text)
{
	text.value = file.value;
}

/* 배경음악관련 */
function music(n) { 
  var music = window.parent.topFrame.document.getElementById('music'); 
  if(n == "stop")  music.stop(); 
  if(n == "play")  music.play(); 
  if(n == "pause") { 
    if (music.playstate == 2) music.pause(); 
    else { 
      if (music.playstate == 1) 
        music.play(); 
    } 
  } 
  if(n == "pre") music.previous(); 
  if(n == "next") music.next(); 
}


/* 매거진 관련 */
if (document.all) {
   layerview='document.all'
   styleview='.style.'
}
else if (document.layers) {
   layerview='document.layers'
   styleview='.'
} 

function show(){
   eval(layerview+'["Magazine"]'+styleview+'visibility="visible"') 
}
function hide(){
   eval(layerview+'["Magazine"]'+styleview+'visibility="hidden"') 
}

/* 움직이는 배너_우측 */

//var stmnLEFT = 0; // 스크롤메뉴의 좌측 위치
var stmnGAP1 = 0; // 페이지 위쪽 여백
var stmnGAP2 = -400; // 스크롤시 브라우저 상단과 약간 띄움. 필요없으면 0으로 조정하세요
var stmnBASE = 0; // 스크롤메뉴 초기 시작위치
var stmnActivateSpeed = 150; // 움직임을 감지하는 속도 (숫자가 클수록 느리다)
var stmnScrollSpeed = 10; // 스크롤되는 속도 (클수록 느림)
var stmnTimer;
function RefreshStaticMenu()
{
  var stmnStartPoint, stmnEndPoint, stmnRefreshTimer;
  stmnStartPoint = parseInt(STATICMENU.style.top, 10);
  stmnEndPoint = document.body.scrollTop + stmnGAP2;
  if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1;
  stmnRefreshTimer = stmnActivateSpeed;
  if ( stmnStartPoint != stmnEndPoint ) {
    stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 15 );
    STATICMENU.style.top = parseInt(STATICMENU.style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount );
    stmnRefreshTimer = stmnScrollSpeed;
  }
  stmnTimer = setTimeout ("RefreshStaticMenu();", stmnRefreshTimer);
}

function InitializeStaticMenu()
{
  //STATICMENU.style.left = stmnLEFT;
  STATICMENU.style.top = document.body.scrollTop + stmnBASE;
  RefreshStaticMenu();
}

/* 메인 탭 이미지 변환 관련 */
var tabScroll = 1;
var tabChk,tabLast

// 카테고리별 이벤트 배너 탭 전환 //
function switchMainIndexTab(tNo)
{
	var frm = document.all;
	// 선택된 항목 표시
	document.getElementById('tabBtn' + tNo).src="http://file.zeroback.cafe24.com/Design/skin_2/main_best/main_best" + tNo + "_btn_o.gif";
	document.getElementById('todayTab' + tNo).filters.blendTrans.Apply();
	document.getElementById('todayTab' + tNo).style.zIndex="20";
	document.getElementById('todayTab' + tNo).style.visibility = "visible";
	document.getElementById('todayTab' + tNo).filters.blendTrans.Play();
	// 버튼 리셋
	for(i=1; i<=9; i++) {
		var tmp = "0"+i;
		if(tNo != tmp) {
			document.getElementById('tabBtn0' + i).src="http://file.zeroback.cafe24.com/Design/skin_2/main_best/main_best0" + i + "_btn.gif";
		}
	}
	// 이전항목 처리
	tabChk = "N";
	tabLast = tNo;
	hiddenTab();
}
// 이벤트 배너 숨김처리(1초 후 실행)
function hiddenTab()
{
	var frm = document.all;
	// 레이어 리셋
	if(tabChk=="Y")	{
		for(i=1;i<=9;i++) {
			var tmp = "0"+i;
			if(tabLast!=tmp)	{
				document.getElementById('todayTab0' + i).style.visibility = 'hidden';
			}
			document.getElementById('todayTab0' + i).style.zIndex="10";
		}
		clearTimeout(tabTimeOut2);
	}
	else
	{	
		tabChk="Y";
		tabTimeOut2 = setTimeout(hiddenTab,3);
	}
}
// 이벤트 배너 탭 자동 전환 시작 //
function startMainIndexTab()
{
	if(tabScroll > 9)
		tabScroll = 1;
	switchMainIndexTab('0'+tabScroll);
	tabScroll++;
	tabTimeOut = setTimeout(startMainIndexTab, 5000);
}

function startMainIndexTab1(str)
{

	tabScroll = str;
	switchMainIndexTab('0'+tabScroll);
	tabScroll++;
	tabTimeOut = setTimeout(startMainIndexTab, 5000);
}
// 이벤트 배너 탭 정지 //
function endMainIndexTab()
{
	clearTimeout(tabTimeOut);
}

/* rolling news(a_7 포함) */
function hit_roll(div_id, banner_height, banner_delay, banner_speed, this_height, list_count) 
{
    var div_tag = document.getElementById(div_id);
    var table_tag, i, total_height;

    this_height++;
    total_height = banner_height * list_count;
    if(this_height < total_height) {
        if(this_height%banner_height == 0){
            div_tag.style.top = -this_height;
            setTimeout("hit_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", " + this_height + ", " + list_count + ");", banner_delay);
        } else{
            div_tag.style.top = -this_height;
            setTimeout("hit_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", " + this_height + ", " + list_count + ");", banner_speed);
        }
    } else {
        table_tag = div_tag.getElementsByTagName("table");
        div_tag.appendChild(table_tag[0]);
        div_tag.style.top = 0;
        setTimeout("hit_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", 0, " + list_count + ");", banner_delay);
    }

    return true;
}

/* FAQ BEST10 항목 보이기/숨기기 */
function showhide(index) {
   thisList = eval("list" + index + ".style");

   if(thisList.display != "none") {
      thisList.display = "none";
   } else {
      thisList.display = "block";
   }

}

/* 네에버체크아웃관련 */
function strTonum(price,rate) {
	var str = price;
	var str2 = str.slice(str.indexOf('￦')+1, str.indexOf('원'));

	var arrayData = str2.split(",");

	var str3 = arrayData[0] + arrayData[1];

	var num = Number(str3);
         if (num >= 50000) {
             var num2 = num * rate
         } else {
	    var num2 = (num + 2500) * rate;
         }

	var num3 = Math.round(num2 / 10) * 10;

	var num4 = number_format_custom(num3);

	document.write(num4 + "원");
}


function number_format_custom(numstr) { 
    numstr = SetComma(DelComma(numstr)); 
    return numstr; 
} 

// 숫자에 콤마를 찍는다. 
function SetComma(numstr) { 
    numstr = String(numstr); 
    var re0 = /^(-?d+)(d{3})($|..*$)/; 
    if (re0.test(numstr)) 
        return numstr.replace(re0, 
            function(str,p1,p2,p3) { 
                return SetComma(p1) + ',' + p2 + p3; 
            } 
        ); 
    else 
        return numstr; 
} 
String.prototype.SetComma = function () { 
    return SetComma(this); 
} 

// 문자를 숫자로 정리한다. 
function DelComma(numstr) { 
    numstr = String(numstr); 
    if (numstr == '') return '0'; 
    else if (numstr == '-') return '0'; 
    else if (numstr == '0-') return '-0'; 
    numstr = numstr.replace(/[^d.-]/g,''); 
    numstr = String(numstr.match(/^-?d*.?d*/)); 
    numstr = numstr.replace(/^(-?)(d*)(.*)/, 
        function(str,p1,p2,p3) { 
            p2 = (p2>0) ? String(p2.match(/[1-9]d*$/)) : '0'; 
        //    p2 = (p2>0) ? String(parseInt(p2,10)) : '0'; 
            return p1 + p2 + p3; 
        } 
    ); 
    return numstr; 
} 
String.prototype.DelComma = function () { 
    return DelComma(this); 
} 

// 소숫점 자릿수를 조정한다.(버림) 
function cutFloat(numstr, length) { 
    numstr = String(numstr); 
    eval('var re0 = /.*.d{'+ length +'}/;'); 
    if (re0.test(numstr)) 
        numstr = String(numstr.match(re0)); 
    return numstr; 
} 
String.prototype.cutFloat = function (length) { 
    return cutFloat(this,length); 
} 


