
//-------------------------------
 // ÁÖ¹Î¹øÈ£ À¯È¿¼º Ã¼Å©(¿¬»ê¿¡ ÀÇÇÑ.)
 //------------------------------- 
 function validateCalJumin(j1,j2){
  jumin = j1+j2;
  
  result = false;
  jumin_hap = 0;
  calNum = "234567892345";  

  if( jumin.charAt(6) == 1 || jumin.charAt(6) == 2 ){ 
   for (i=0;i<12;i++) jumin_hap = jumin_hap + jumin.charAt(i)*(calNum.charAt(i));
   
   fixValue = (11-(jumin_hap % 11))%10;   
         
   if (jumin.charAt(12) == fixValue) result=true;
  }
  return result;
 }      
 
 //-------------------------------
 // isEmail
 //-------------------------------
 function isEmail(s) {
  if (s.indexOf(" ") != -1)
   return false;
  else if (s.indexOf("@") == -1)
   return false;
  else if (s.indexOf("@") == 0)
   return false;
  else if (s.indexOf("@") == (s.length-1))
   return false;
   
  arrayString = s.split("@");
 
  if (arrayString[1].indexOf(".") == -1)
   return false;
  else if (arrayString[1].indexOf(".") == 0)
   return false;
  else if (arrayString[1].charAt(arrayString[1].length-1) == ".") {
   return false;
  }
  return true;
 } 
 
 //-------------------------------
 // Left Trim
 //-------------------------------
 function LTrim(s) {
  while (1) {
   if ( s.substring(0, 1) != " " ) {
    break;
   }
   s = s.substring(1, s.length);
  }
  return s;
 }
 
 //-------------------------------
 // Right Trim
 //-------------------------------
 function RTrim(s) {
  while (1) {
   if ( s.substring(s.length - 1, s.length) != " " ) {
    break;
   }
   s = s.substring(0, s.length - 1);
  }
  return s;
 }
 
 //-------------------------------
 // Trim
 //-------------------------------
 function Trim(s) {
  tmpstr = LTrim(s);
  return RTrim(tmpstr);
 }
  
 //-------------------------------
 // ¼ýÀÚ, ¿µ¹®ÀÚ(_,-Á¦¿Ü) ¸¸ °¡´É.
 //------------------------------- 
 function isWord(sWord) {
  valid = true;
  exStr = /[^A-Za-z0-9]/; // regular expression excluding non-word characters
  
  if (sWord.match(exStr)) valid = false;
  return valid;
 } 
 
 //-------------------------------
 // ¼ýÀÚ
 //------------------------------- 
 function isInteger(sWord) {

  if (sWord.length > 0) {
   for (i=0; i<sWord.length; i++) {
    if (sWord.charAt(i) < '0' || sWord.charAt(i) > '9') { return false; }
   }
   return true;
  } else { return false; }
 }  

 //----------------------------------------------
 // ÇÃ·¡½¬ °ü·Ã
 //----------------------------------------------
 function changeEmbed(arg1, arg2, arg3)
 {
   document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'");
   document.write("        codebase='https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='"+arg2+"' height='"+arg3+"'>");
   document.write("<param name='movie' value='"+arg1+"'>");
   document.write("<param name='quality' value='high'>");
   document.write("<embed src='"+arg1+"' quality='high' pluginspage='https://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+arg2+"' height='"+arg3+"'></embed>");
   document.write("</object>");
 }


//-----------------------------------------------
//ÁÖ¼Ò°Ë»öÃ¢
//-----------------------------------------------
function zipinput()
{
	var gourl;
	gourl="/admin/common/zipcode.asp";
	
	window.open(gourl,"zipcode","width=350,height=350,scrollbars=YES");
}

//-----------------------------------------------
//¾ÆÀÌµð/ÆÐ½º¿öµå Ã£±â
//-----------------------------------------------
function search_idpw()
{
	window.open("/member/search_idpw.asp","searchidpw","width=417,height=410,scrollbars=no");
}

//-----------------------------------------------
//°áÁ¦ ÆË¾÷
//-----------------------------------------------
//ÀÌºÏ¸Ó´ÏÃæÀü
function ebookcha()
{
	window.name="windowpay";
	window.open("https://www.ebook21.com/order/ebook_money.asp","ebookcha","width=500,height=550,scrollbars=NO");
}

//ÀÏ¹Ý°áÁ¦Ã¢
function nowby(idx,bymode)
{
	var gourl;
	window.name="windowpay";
	gourl="https://www.ebook21.com/order/paypop.asp?id="+idx+"&bymode="+bymode;
	if(bymode == "gift") window.open(gourl,"paypop","width=500,height=700,scrollbars=NO");
	else window.open(gourl,"paypop","width=500,height=550,scrollbars=NO");
}

//-----------------------------------------------
//°áÁ¦ ÆË¾÷ - Å×½ºÆ®
//-----------------------------------------------
function nowby2(idx,bymode)
{
	var gourl;
	
	gourl="/order/paypop2.asp?id="+idx+"&bymode="+bymode;
	window.open(gourl,"paypop","width=500,height=670,scrollbars=NO");
}

//----------------------------------------------
//µµ¼­ ´Ù¿î·Îµå 
//----------------------------------------------
function down_file(idx,item_id,tidx)
{
	window.open("","file_down","width=495,height=305,scrollbars=NO");
	
	document.ttdown.id.value=idx;
	document.ttdown.item_id.value=item_id;
	document.ttdown.item_kind.value=tidx;
	document.ttdown.target="file_down";
	document.ttdown.action="/ebook/ebook_down.asp";
	document.ttdown.submit();
}


//----------------------------------------------
//µµ¼­ ¹Ù·Îº¸±â - À¥¹æ½Ä º¸±â
//----------------------------------------------
function DayView(idx,item_id,tidx)
{
	window.open("","file_view","width=190,height=150,scrollbars=NO, top=0 left=0");
	
	document.ttdown.id.value=idx;
	document.ttdown.item_id.value=item_id;
	document.ttdown.item_kind.value=tidx;
	document.ttdown.target="file_view";
	document.ttdown.action="/ebook/ebook_view.asp";
	document.ttdown.submit();
}

//----------------------------------------------
//µµ¼­ ¹Ù·Îº¸±â - ¹«·áº¸±â
//----------------------------------------------
function nomoney_View(idx,item_id,tidx)
{
	window.open("","file_view","width=190,height=150,scrollbars=NO, top=0 left=0");
	
	document.ttdown.id.value=idx;
	document.ttdown.item_id.value=item_id;
	document.ttdown.item_kind.value=tidx;
	document.ttdown.target="file_view";
	document.ttdown.action="/ebook/nomoney.asp";
	document.ttdown.submit();
}

//----------------------------------------------
//µµ¼­ ¹Ù·Îº¸±â - ¹Ì¸®º¸±â
//----------------------------------------------
function preView(idx)
{
	window.open("","file_view","width=190,height=150,scrollbars=NO, top=0 left=0");
	
	document.ttdown.id.value=idx;
	document.ttdown.target="file_view";
	document.ttdown.action="/ebook/preview.asp";
	document.ttdown.submit();
}

//----------------------------------------------
//ÄíÆù»ç¿ëµî·Ï ÆË¾÷ ¶ç¿ì±â
//----------------------------------------------
function gift_pop()
{
	window.open("/event/gift_num.asp","comgift","width=417,height=250");	
}

//----------------------------------------------
//È¸¿ø°¡ÀÔ½Ã ·Î±×ÀÎÃ¤Å©
//----------------------------------------------
function main_log(form,url)
{
	if(Trim(form.user_id.value)=="")
	{
		alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
		form.user_id.focus();
		return;
	}
	
	if(Trim(form.user_pw.value)=="")
	{
		alert("ÆÐ½º¿öµå¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
		form.user_pw.focus();
		return;
	}
	
	var gourl;
	gourl="/index.asp";
	form.action="/member/login_end.asp?reurl="+gourl;
	form.submit();
}

function idkeychk()
{
	if (event.keyCode==13)
	{
		if (Trim(document.main_login.user_id.value)!="")
		{
			document.main_login.user_pw.focus();
		}
	}
}

function pwkeychk()
{
	if (event.keyCode==13)
	{
		if (Trim(document.main_login.user_pw.value)!="")
		{
			main_log(document.main_login);
		}
	}
}

/*** ·¹ÀÌ¾î ÆË¾÷Ã¢ ¶ç¿ì±â ***/
function popupLayer(s,w,h)
	{
		if (!w) w = 600;
		if (!h) h = 400;

		var pixelBorder = 3;
		var titleHeight = 12;
		w += pixelBorder * 2;
		h += pixelBorder * 2 + titleHeight;

		var bodyW = document.body.clientWidth;
		var bodyH = document.body.clientHeight;

		var posX = (bodyW - w) / 2;
		var posY = (bodyH - h) / 2;

		hiddenSelectBox('hidden');

		/*** ¹é±×¶ó¿îµå ·¹ÀÌ¾î ***/
		var obj = document.createElement("div");
		with (obj.style){
			position = "absolute";
			left = 0;
			top = 0;
			width = "100%";
			height = document.body.scrollHeight;
			backgroundColor = "#000000";
			filter = "Alpha(Opacity=50)";
			opacity = "0.5";
		}
		obj.id = "objPopupLayerBg";
		document.body.appendChild(obj);

		/*** ³»¿ëÇÁ·¹ÀÓ ·¹ÀÌ¾î ***/
		var obj = document.createElement("div");
		with (obj.style){
			position = "absolute";
			left = posX + document.body.scrollLeft;
			top = posY + document.body.scrollTop;
			width = w;
			height = h;
			backgroundColor = "#FFFFFF";
			border = "3px solid #000000";
		}
		obj.id = "objPopupLayer";
		document.body.appendChild(obj);

		/*** Å¸ÀÌÆ²¹Ù ·¹ÀÌ¾î ***/
		var bottom = document.createElement("div");
		with (bottom.style){
			position = "absolute";
			width = w - pixelBorder * 2;
			height = titleHeight;
			left = 0;
			top = h - titleHeight - pixelBorder * 3;
			padding = "2px 0 0 0";
			textAlign = "right";
			backgroundColor = "#000000";
			color = "#ffffff";
			font = "bold 11px tahoma";
		}
		bottom.innerHTML = "<a href='javascript:closeLayer()'><font color='FFFFFF'><b>close</b></font></a>&nbsp;&nbsp;&nbsp;";
		obj.appendChild(bottom);

		/*** ¾ÆÀÌÇÁ·¹ÀÓ ***/
		var ifrm = document.createElement("iframe");
		with (ifrm.style){
			width = w - 6;
			height = h - pixelBorder * 2 - titleHeight - 3;
			//border = "3 solid #000000";
		}
		ifrm.frameBorder = 0;
		ifrm.src = s;
		//ifrm.className = "scroll";
		obj.appendChild(ifrm);
	}
	function closeLayer()
	{
		hiddenSelectBox('visible');
		_ID('objPopupLayer').parentNode.removeChild( _ID('objPopupLayer') );
		_ID('objPopupLayerBg').parentNode.removeChild( _ID('objPopupLayerBg') );
	}

	function hiddenSelectBox(mode)
	{
		var obj = document.getElementsByTagName('select');
		for (i=0;i<obj.length;i++){
			obj[i].style.visibility = mode;
		}
	}
	function _ID(obj){return document.getElementById(obj)}
