function writeAdultPop(layerid){
	document.write("<div id=\""+layerid+"\" style=\"display:none;position:absolute; width:401px; height:239px; z-index:9999; left: 71px; top: 58px\"> ");
	document.write("  <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" background=\"http://www.hanjinmall.co.kr/shopping/image/temp/adult_auth.jpg\">");
	document.write("    <tr> ");
	document.write("      <td height=\"146\">&nbsp;</td>");
	document.write("    </tr>");
	document.write("    <tr> ");
	document.write("      <td height=\"52\"> ");
	document.write("        <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
	document.write("          <tr> ");
	document.write("            <td width=\"120\">&nbsp;</td>");
	document.write("            <td align=\"center\" width=\"44\"> ");
	document.write("              <input type=\"text\" name=\"byear0\" id=\"byear0\" style=\"width:35px; height:48px; border:0px; font-size:40px; font-weight:bold; color:#460019; text-align:center; background:none; font-family:arial;\" maxlength=1 value=\"1\" onKeyup=\"goNextInput(this);\" onBlur=\"checkVal(this);\">");
	document.write("            </td>");
	document.write("            <td width=\"28\">&nbsp; </td>");
	document.write("            <td align=\"center\" width=\"44\"> ");
	document.write("              <input type=\"text\" name=\"byear1\" id=\"byear1\" style=\"width:35px; height:48px; border:0px; font-size:40px; font-weight:bold; color:#460019; text-align:center; background:none; font-family:arial;\" maxlength=1 value=\"9\" onKeyup=\"goNextInput(this);\" onBlur=\"checkVal(this);\">");
	document.write("            </td>");
	document.write("            <td width=\"28\">&nbsp; </td>");
	document.write("            <td align=\"center\" width=\"44\"> ");
	document.write("              <input type=\"text\" name=\"byear2\" id=\"byear2\" style=\"width:35px; height:48px; border:0px; font-size:40px; font-weight:bold; color:#460019; text-align:center; background:none; font-family:arial;\" maxlength=1 onKeyup=\"goNextInput(this);\" onFocus=\"initVal(this);\" onBlur=\"checkVal(this);\">");
	document.write("            </td>");
	document.write("            <td width=\"28\">&nbsp;</td>");
	document.write("            <td align=\"center\" width=\"44\"> ");
	document.write("              <input type=\"text\" name=\"byear3\"  id=\"byear3\"style=\"width:35px; height:48px; border:0px; font-size:40px; font-weight:bold; color:#460019; text-align:center; background:none; font-family:arial;\" maxlength=1 onKeyUp= \"if(window.event.keyCode==13)checkAudult();\" onFocus=\"initVal(this);\" onBlur=\"checkVal(this);\">");
	document.write("            </td>");
	document.write("            <td>&nbsp;</td>");
	document.write("          </tr>");
	document.write("        </table>");
	document.write("      </td>");
	document.write("    </tr>");
	document.write("    <tr> ");
	document.write("      <td height=\"102\"> ");
	document.write("        <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" height=\"102\">");
	document.write("          <tr> ");
	document.write("            <td width=\"153\">&nbsp;</td>");
	document.write("            <td><img src=\"http://www.hanjinmall.co.kr/shopping/image/temp/enter_bttn.jpg\" width=\"94\" height=\"33\" onClick=\"checkAudult();\" style=\"cursor:hand;\"></td>");
	document.write("            <td width=\"9\">&nbsp;</td>");
	document.write("            <td><img src=\"http://www.hanjinmall.co.kr/shopping/image/temp/back_bttn.jpg\" width=\"96\" height=\"33\" onClick=\"history.back(1);\" style=\"cursor:hand;\"></td>");
	document.write("            <td width=\"150\">&nbsp;</td>");
	document.write("          </tr>");
	document.write("        </table>");
	document.write("      </td>");
	document.write("    </tr>");
	document.write("  </table>");
	document.write("</div>");
	document.write("<div id=\""+layerid+"_back\" style=\"display:none;position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#333;FILTER:alpha(opacity=80);z-index:9998;\">");
	document.write("</div>");
}

function initVal(obj){
	if(obj.value) obj.value="";
}

function goNextInput(obj){
	if(obj.value.length==1){
		if(obj.name=="byear0") document.getElementById("byear1").focus();
		if(obj.name=="byear1") document.getElementById("byear2").focus();
		if(obj.name=="byear2") document.getElementById("byear3").focus();
	}
}

function checkAudult(){
	var iYear = 0;
	var sYear = "";
	var byear = new Array(4);

	for(var i=0;i<4;i++){
		byear[i] = document.getElementById("byear"+i);
		if(byear[i].value == ""){
			alert("Ãâ»ý³âµµ¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
			byear[i].focus();
			return;
		}
		if(!checkIsNum(byear[i].value)){
			alert("¼ýÀÚ¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
			byear[i].focus();
			return;
		}
		sYear = sYear+byear[i].value;
	}
	iYear = parseInt(sYear,10);
	var dt = new Date();
	var cYear = parseInt(dt.getFullYear().toString(),10);

	if(cYear-iYear<19){
		alert("¸¸ 19¼¼ ÀÌÇÏ´Â ÀÌ¿ë ºÒ°¡´É ÇÕ´Ï´Ù.");
		history.go(-1);
	}else{
		// ¼ºÀÎÀÎÁõ ¹Þ´Â´Ù.
		var url = "/shopping/login/FO_SetAdultSession.jsp";
		$.ajax({
			url : url,
			cache : false,
			success : function(data, textStatus){
				hideLayer('adult');
			}
		});	
	}

}

function checkIsNum(val){
	var re = new RegExp("^\\d+$");
	return re.test(val);
}

function checkVal(obj){
	if(obj.value!="" && !checkIsNum(obj.value)){
		alert("¼ýÀÚ¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.");
		obj.value="";
		obj.focus();
		return;
	}
}

function showLayer(layerid){
	var layer = document.getElementById(layerid);
	to_top = document.documentElement.offsetHeight/2 - layer.style.height.replace("px","")/2;
	to_left = document.documentElement.offsetWidth/2 - layer.style.width.replace("px","")/2;
	layer.style.top = to_top;
	layer.style.left= to_left;
	
	layer.style.display="";
	document.getElementById(layerid+"_back").style.display="";
	document.body.style.overflow = "hidden";
}

function hideLayer(layerid){
	var layer = document.getElementById(layerid);
	layer.style.display="none";
	document.getElementById(layerid+"_back").style.display="none";
	document.body.style.overflow = "";
}

