function imagebox(file) { window.open('/util/viewer.asp?file='+file,'imagebox','width=500,height=400,resizable=no,scrollbars=yes'); }
function wbox(url) { window.open(url,'wbox','width=600,height=200,resizable=no,scrollbars=yes'); }
function event(file) { window.open('/gonggoo/event.asp','gonggoo_event','width=400,height=460,resizable=no,scrollbars=no'); }
function obox(url) { window.open(url,'wbox','width=100,height=100,resizable=no,scrollbars=no'); }
//
function ofix(sn, wn, w, h) { window.open(sn, wn,"WIDTH="+w+",HEIGHT="+h+",resizable=no,scrollbars=no"); }
function onofix(sn, wn, w, h) { window.open(sn, wn,"WIDTH="+w+",HEIGHT="+h+",resizable=yes,scrollbars=yes"); }
function ofix_loc(sn, wn, w, h, l, t) { window.open(sn, wn,"WIDTH="+w+",HEIGHT="+h+",LEFT="+l+",TOP="+t+",resizable=no,scrollbars=no"); }

function Layers() { 
   var i, visStr, args, theObj;
   args = Layers.arguments;
   for (i=0; i<(args.length-2); i+=3) {
      visStr   = args[i+2];
      if (navigator.appName == 'Netscape' && document.layers != null) {
         theObj = eval(args[i]);
         if (theObj) theObj.visibility = visStr;
      } else if (document.all != null) {
         if (visStr == 'show') visStr = 'visible';
         if (visStr == 'hide') visStr = 'hidden';
         theObj = eval(args[i+1]);
         if (theObj) theObj.style.visibility = visStr;
      }
   }
}


function OpenCertDetails() {
	thewindow = window.open('https://www.thawte.com/cgi/server/certdetails.exe?code=KRAVAN1', 'anew', config='height=400,width=450,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
}

function memoLengthCheck(form,maxlen) {
	var t;
	var msglen;
	msglen = 0;

	l = form.memo.value.length;
	for(k=0;k<l;k++){
	    if (msglen > maxlen ) {
			form.memo.focus();
			alert("ÀÔ·Â °¡´ÉÇÑ ±ÛÀÚ¼ö¸¦ ÃÊ°úÇß½À´Ï´Ù.");
			return false;
	    }
	    t = form.memo.value.charAt(k);
	    if (escape(t).length > 4) msglen += 2;
	    else msglen++;
	}
}


// ¼ýÀÚ format
function unFormat(obj) {
    var temp = "";
    var n = String(obj.value);
    var len = n.length;
    var pos = 0;
    var ch = '';

    while (pos < len) {
        ch = n.charAt(pos);
        if ((ch >= '0') && (ch <= '9')) temp = temp + ch;
        pos = pos + 1;
    }
    obj.value = temp;
    return true;
}

function numFormat(obj)
{
    unFormat(obj);
    var str = Number(obj.value) + "";
    if( str=='NaN' ){
        alert("¼ýÀÚ·Î¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
        obj.focus();
        return;
    }
    var leng = str.length;
    var size = 3;
    var cnt = Math.floor(leng / size);
    var pos = leng % size;
    var result = "";

    for( var i = cnt ; i > 0 ; i-- ){
        result = "," + str.substr(pos+(i-1)*size, size) + result ;
    }

    if( pos == 0) {
        obj.value = result.substring(1);
    }else{
        obj.value = str.substr(0,pos) + result;
    }
    return;
}


function unFormatUSD(obj) {
//	alert("unformat obj:["+obj+"]");
	var temp = "";
	var n = String(obj.value);
	var len = n.length;
	var pos = 0;
  	var ch = '';
  	
	while (pos < len) {
		ch = n.charAt(pos);
		if ((ch >= '0') && (ch <= '9')) temp = temp + ch;
		if(pos == len-3) temp = temp + ".";
		pos = pos + 1;
	}
	obj.value = temp;
	return true;
}

function numFormatUSD(obj)
{	
	//ÀÔ·ÂÇÊµå¿¡ 3ÀÚ¸® ±¸ºÐÀÚ(,)°¡ ÀÖÀ¸¸é ¾ø¾Ø´Ù.
	var temp = "";
	var nn = String(obj.value);
	var llen = nn.length;
	var ppos = 0;
  	var cch = '';
  	
	while (ppos < llen) {
		cch = nn.charAt(ppos);
		if ( (cch >= '0') && (cch <= '9') ) { temp=temp+cch; }
		if ( ( ppos == llen-3) && (cch == '.' )) { temp = temp + cch; }
		
		ppos = ppos + 1;
	}
	
	obj.value = temp;
	/////////////
	
	if(obj.value == "")
		obj.value = "0";
	
	var usdvar = parseFloat(obj.value);
	obj.value = usdvar*100;

	var fullstr = Number(obj.value) + "";
	if( fullstr=='NaN' ){
		alert("¼ýÀÚ·Î¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
		obj.value ="0"
		return;
	}
	
	var fullleng = fullstr.length;
	var str = fullstr.substr(0, fullleng-2);
	
	var leng = str.length; 
	var size = 3;
	var cnt = Math.floor(leng / size);
	var pos = leng % size;
	var result = "";
	
	for( var i = cnt ; i > 0 ; i-- ){
		result = "," + str.substr(pos+(i-1)*size, size) + result ;
	}

	if( pos == 0) {
		if(leng == 0)
		{
			obj.value = fullstr.substr(fullleng-2, 2);
		} else
		{		
			obj.value = result.substring(1) + "."+fullstr.substr(fullleng-2, 2);
		}	
	}else{
		obj.value = str.substr(0,pos) + result + "."+ fullstr.substr(fullleng-2, 2);
	}
	return;
}

// ·¹ÀÌ¾î¸¦ Ã¢ Áß°£À¸·Î ¸ÂÃß±â
function CenterPoint(mypoint, myvalue) {
	var widthX, widthY, mywidthX, myheightY;

	if ( mypoint == 'X' ) {
		mywidthX = parseInt ( myvalue / 2 );
		widthX = parseInt ( (document.body.clientWidth-mywidthX) / 2 - mywidthX );
		return ( widthX );
	} else if ( mypoint == 'Y' ) {
		mywidthY = parseInt ( myvalue / 2 );
		widthY = document.body.scrollTop + ( document.body.clientHeight / 2 ) - mywidthY;  
		return ( widthY );
	}
}

function _clickLayer(url,width,height) {
	var Xpoint, Ypoint;

	Xpoint = parseInt ( (document.body.clientWidth-(width / 2)) / 2 - width / 2 );
	Ypoint = document.body.scrollTop + ( document.body.clientHeight / 2 ) - height/2 ;

	document.getElementById('PopupLayer').style.visibility = 'hidden';
	document.getElementById('PopupLayer').style.left   = Xpoint;
	document.getElementById('PopupLayer').style.top    = Ypoint;
	document.getElementById('PopupFrame').location=url;
	document.getElementById('PopupFrame').resizeTo(width,height);
	document.getElementById('PopupLayer').style.visibility = 'visible';

}

function clickalertLayer(url,width,height) {
	var Xpoint, Ypoint;

	Xpoint = parseInt ( (document.body.clientWidth-(width / 2)) / 2 - width / 2 );
	Ypoint = 280;

	document.getElementById('alertLayer').style.visibility = 'hidden';
	document.getElementById('alertLayer').style.left   = Xpoint;
	document.getElementById('alertLayer').style.top    = Ypoint;
	document.getElementById('alertFrame').location=url;
	
	var iframeWin = window.frames['alertFrame'];
	
	var iframeEl = window.document.getElementById? window.document.getElementById('alertFrame'): document.all? document.all['alertFrame']: null;
	
	if ( iframeEl && iframeWin )
	{
	  iframeEl.style.height = height + 'px';
	  iframeEl.style.width = width + 'px';
	}
	else
	{ // firefox
	  window.document.getElementById('alertFrame').style.height = height + 'px';
	}
		
	//alertFrame.resizeTo(width,height);
	document.getElementById('alertLayer').style.visibility = 'visible';
}

function moveSubMenu( mainMenu, subMenu ) 
{
    // ¼­ºê ¸Þ´º¸¦ º¸ÀÌÁö ¾Êµµ·Ï ÇÔ
    subMenu.style.top = -400; 
    subMenu.style.visibility = "hidden"; 

    //highlightMenu( mainMenu );
    if(subMenu.id != "9") {
    	
    	if(subMenu.id == "sub1") {
    		subMenu.style.top = 135;
    		subMenu.style.left = (document.body.clientWidth-910)/2+200;
    	} else {
    		subMenu.style.top = 135 + 'px';;
    		subMenu.style.left = (document.body.clientWidth-910)/2+680 + 'px';;  
   		}
  		subMenu.style.visibility = "visible";  		
   	}
}
function moveSubMenuOut( mainMenu, subMenu ) 
{
    // ¼­ºê ¸Þ´º¸¦ º¸ÀÌÁö ¾Êµµ·Ï ÇÔ
    //subMenu.style.top = -400; 
    subMenu.style.visibility = "hidden";  		
}

function highlightMenu( menuItem )
{
    menuItem.style.backgroundColor = "#cbcbcb";
    menuItem.style.color = "white";
}

function normalMenu( menuItem )
{
    menuItem.style.backgroundColor = "";
    menuItem.style.color = "";
}

function menuAction( menuId, menuflag ) 
{
		if(menuflag == 0) {
    	document.getElementById(menuId).style.visibility = "hidden";  	
    } else if(menuflag == 1) {
    	document.getElementById(menuId).style.left = (document.body.clientWidth-1000)/2+125;
    	document.getElementById(menuId).style.visibility = "visible";  
    } else {
    	document.getElementById(menuId).style.visibility = "hidden";
    }	 		
}

function outline_box(obj,val) {
	if (document.all||document.getElementById) {
		if(val == 1) {
			obj.style.border = 1;
			obj.style.borderColor = '#FF0000';
		} else if(val == 0){
			obj.style.border = 0;
			obj.style.borderColor = '#cbcbcb';
		}
	}
}

function clickwishLayer(url,width,height) {
	var Xpoint, Ypoint;

	Xpoint = parseInt ( document.body.clientWidth / 2 - width / 2 );
	Ypoint = 245;
	if('<?=$ck_uid?>' == '160268') {
		alert(url);
	}
	wishLayer.style.visibility = 'hidden';
	wishLayer.style.left   = Xpoint;
	wishLayer.style.top    = Ypoint;
	wishFrame.location=url;
	
	var iframeWin = window.frames['wishFrame'];
	
	var iframeEl = window.document.getElementById? window.document.getElementById('wishFrame'): document.all? document.all['wishFrame']: null;
	
	if ( iframeEl && iframeWin )
	{
	  iframeEl.style.height = height + 'px';
	  iframeEl.style.width = width + 'px';
	}
	else
	{ // firefox
	  window.document.getElementById('wishFrame').style.height = height + 'px';
	}
  	
	//wishFrame.resizeTo(width,height);
	parent.document.getElementById('wishLayer').style.visibility = 'visible';/*.display = 'block'; /*style*/
}

function goCat(num) {
	if(num == 803) {
		document.location.href = '/shopping/pa/default.asp?code=' + num ;
	} else {
		document.location.href = '/shopping/default.asp?code=' + num ;
	}
}
function goPage(part, btype, code, mode, num) {
	//$part,$BTYPE,$code,'s_recommend',$num
	//code=$code&mode=s_recommend&num=$num&part=$part&BTYPE=$BTYPE
	document.location.href = '/iboard_memo.asp?code=' + code + '&mode=' + mode + '&num=' + num + '&part=' + part + '&BTYPE=' + btype ;
}

function ChangeTab(tabid, tabobj)
{
  var tabseq = 1;
  var obj;
  while (obj = document.getElementById(tabobj + tabseq)) {
    if (tabseq == tabid) {
      obj.style.display = 'block';
    } else {
      obj.style.display = 'none';
    }
    tabseq++;
  }
}	

function clickLayer(url,width,height) {
	var Xpoint, Ypoint;
	
	Xpoint = parseInt ( document.body.clientWidth / 2 - width / 2 );
	Ypoint = parseInt (document.body.scrollTop + ( document.body.clientHeight / 2 ) - height/2 ) ;

	PopupLayer.style.visibility = 'hidden';
	PopupLayer.style.left   = Xpoint;
	PopupLayer.style.top    = Ypoint;
	PopupFrame.location=url;

	var iframeWin = window.frames['PopupFrame'];
	
	var iframeEl = window.document.getElementById? window.document.getElementById('PopupFrame'): document.all? document.all['PopupFrame']: null;
	
	if ( iframeEl && iframeWin )
	{
	  var docHt = height ; //getDocHeight(iframeWin.document);
	  var docWt = width ; //getDocHeight(iframeWin.document);
	
	  if (docHt != iframeEl.style.height) iframeEl.style.height = docHt + 'px';
	  if (docWt != iframeEl.style.height) iframeEl.style.width = docWt + 'px';
	}
	else
	{ // firefox
	  var docHt = window.document.getElementById('PopupFrame').contentDocument.height + 15;
	  window.document.getElementById('PopupFrame').style.height = height + 'px';
	}	
	//alert('aa');
	//PopupFrame.resizeTo(width,height);

	parent.document.getElementById('PopupLayer').style.visibility = 'visible';
}

// ±â¾÷ÀºÇà¾È½ÉÀÌÃ¼ ÀÎÁõ¸¶Å© Àû¿ë ½ÃÀÛ
function onPopAuthMark(key)
{
   window.open('','AUTHMARK_POPUP','height=615, width=630, status=yes, toolbar=no, menubar=no, location=no');
   document.AUTHMARK_FORM.authmarkinfo.value = key;
   document.AUTHMARK_FORM.action='http://mybank.ibk.co.kr/ibs/jsp/guest/esc/esc1030/esc103020/CESC302020_i.jsp';
   document.AUTHMARK_FORM.target='AUTHMARK_POPUP';
   document.AUTHMARK_FORM.submit();
}

function value_check(ck) {
	for(var i = 0; i < ck.value.length; i++) {
         var chr = ck.value.substr(i,1);
         if(chr < '0' || chr > '9'){
            alert("¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù ´Ù½Ã ÀÔ·ÂÇÏ¼¼¿ä!");

  		  ck.value=1;
  		  ck.focus();
         }
 	}
 	return;
}


//ÀÔ·ÂÇÑ °ªÀÌ ¼ýÀÚÀÎÁö Ã¼Å©ÇÑ´Ù.
function IsNumber(formname) {
   var form = eval("document.form." + formname);

   for(var i = 0; i < form.value.length; i++) {
       var chr = form.value.substr(i,1);
       if(!(chr >= '0' && chr <= '9')) {
          return false;
       }
   }
   return true;
}


function value_add(form)
{
	if(!IsNumber(form.prod_num.name))
	{
		alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ½Ç¼ö ÀÖ½À´Ï´Ù..");
		form.prod_num.focus();
		form.prod_num.select();
		return;
	}
	form.prod_num.value = Number(form.prod_num.value) + 1;
}

function value_minus(form)
{
	if(!IsNumber(form.prod_num.name))
	{
		alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ½Ç¼ö ÀÖ½À´Ï´Ù..");
		form.prod_num.focus();
		form.prod_num.select();
		return;
	}

	if(form.prod_num.value == 1)
	{
		form.prod_num.value = 1;
	}
	else
	{
		form.prod_num.value = Number(form.prod_num.value) - 1;
	}
}


function frm_up_qty(frm,max){
	old_qty = parseInt(frm.value);
	if( old_qty < (max -1) ) frm.value = old_qty + 1;
	else frm.value = max - 1;
	return;
}

function frm_down_qty(frm){
	old_qty = parseInt(frm.value);
	if( old_qty > 1 ){
		frm.value = old_qty - 1;
	}
	return;
}


function toggleTab(tabid, tabobj)
{
  var tabseq = 1;
  var obj;
  if (obj = document.getElementById(tabobj + tabid)) {
    if (obj.style.display == 'block') {
      obj.style.display = 'none';
      if(objtext = document.getElementById(tabobj + "_text")) {
      	objtext.innerHTML = "ÆîÄ¡±â";
      }
    } else {
      obj.style.display = 'block';
      if(objtext = document.getElementById(tabobj + "_text")) {
      	objtext.innerHTML = "¼û±â±â";
      }      
    }
  }
}

function goOption() {
	var chk_cnt = 0;
	var tname = "";
	var optionForm = document.forms[2];
	
	if(optionForm.length == 0) {
		//alert(optionForms.length);
  	return;
  }

  for(i=0; i<optionForm.elements.length; i++) {
  	element = optionForm.elements[i];
		var itemType = element.type == 'text' ? 'ÀÔ·ÂÇ×¸ñ' : '¼±ÅÃÇ×¸ñ';
  	if(element.name.substring(0,8) == "opt_sel_" && element.value == "" && element.style.display != "none") {
  		
  		alert(itemType+'À» È®ÀÎÇÏ¼¼¿ä');//¼±ÅÃÇ×¸ñÀ» È®ÀÎÇÏ¼¼¿ä
  		element.focus();
  		break;
  		return;
  	}
  	
  }
}

//ÆË¾÷À©µµ¿ì, ½ºÅ©¸° Áß¾Ó¿¡ À§Ä¡, ´ÙÁß ¿ÀÇÂ ¹æÁö
var winname_1;
var openF = 0;
function popup(fileName, intWidth, intHeight, intLeft, intTop, vScrollbars, vResizable, vStatus){
  today = new Date();
  winName = today.getTime();

  var fileName, intWidth, intHeight;
  var screenWidth = window.screen.width; //screen.availwidth;
  var screenHeight = window.screen.height; //screen.availheight;

  if(intWidth >= screenWidth){ //½ºÅ©¸° »óÅ×¿¡ µû¶ó ½ºÅ©·Ñ¹Ù ÀÚµ¿Ç¥½Ã
          intWidth = screenWidth - 40;
          vScrollbars = 1;
  }
  if(intHeight >= screenHeight){ //½ºÅ©¸° »óÅ×¿¡ µû¶ó ½ºÅ©·Ñ¹Ù ÀÚµ¿Ç¥½Ã
          intHeight = screenHeight - 40;
          intWidth = intWidth + 20;
          vScrollbars = 1;
  }

  if(intLeft == 'auto' || intTop == 'auto'){ //½ºÅ©¸° Áß¾Ó¿¡ À§Ä¡ ½ÃÅ°±â
          var intLeft = (screenWidth - intWidth) / 2;
          var intTop = (screenHeight - intHeight) / 2;
  }
  //if(navigator.userAgent.indexOf("Firefox") > 0) intTop -= 10;
  var features = eval("'width=" + intWidth + ",height=" + intHeight + ",left=" + intLeft + ",top=" + intTop + ",scrollbars=" + vScrollbars + ",resizable=" + vResizable + ",status=" + vStatus + "'");
  if(openF == 1){
          if(winname_1.closed){
                  winname_1 = window.open(fileName,winName,features);
          }else{
                  winname_1.close();
                  winname_1 = window.open(fileName,winName,features);
          }
  }else{
          winname_1 = window.open(fileName,winName,features);
          openF = 1;
  }
  winname_1.focus();
}  

function addComma(n) {
 var reg = /(^[+-]?\d+)(\d{3})/;
 n += '';

 while (reg.test(n)) {
  n = n.replace(reg, '$1' + ',' + '$2');
 }

 return n;
}

function trim(str){
   //Á¤±Ô Ç¥Çö½ÄÀ» »ç¿ëÇÏ¿© È­ÀÌÆ®½ºÆäÀÌ½º¸¦ ºó¹®ÀÚ·Î ÀüÈ¯
   str = str.replace(/^\s*/,'').replace(/\s*$/, ''); 
   return str; //º¯È¯ÇÑ ½ºÆ®¸µÀ» ¸®ÅÏ.
}
