//¼ýÀÚ°¡ ¾Æ´Ñ°æ¿ì´Â ºñ¿ì°í ´Ù½Ã ½ÃÀÛ
function numCheck() {
	val=event.srcElement.value;
	str=" "+"0123456789";
	for(i=0;i<val.length;i++) {
		if(str.indexOf(val.substring(i,i+1))<=0) {
			alert("¼ýÀÚ¸¸ÀÔ·ÂÇÏ¼¼¿ä");
			event.srcElement.value="";
			event.srcElement.focus();
			return;
		}
	}
}

//¼ýÀÚ°¡ ¾Æ´Ñ°æ¿ì´Â ºñ¿ì°í ´Ù½Ã ½ÃÀÛ
function phoneCheck() {
	val=event.srcElement.value;
	str=" -0123456789";
	for(i=0;i<val.length;i++) {
		if(str.indexOf(val.substring(i,i+1))<=0) {
			alert("Àß¸øµÈ ÀüÈ­¹øÈ£ÀÔ´Ï´Ù.");
			event.srcElement.value="";
			event.srcElement.focus();
			return;
		}
	}
}

//ºñÈ°¼ºÈ­..
function checkCheckBox(form,val,obj1, obj2) {
	val=event.srcElement.checked;
	if(obj1=="COPYRIGHT") {
		if(val) {
			eval("form."+obj1+".style.background='#FFFFFF'");
			if(obj2!="") eval("form."+obj2+".style.background='#FFFFFF'");
		}
		else {
			eval("form."+obj1+".style.background='#EEEEEE'");
			if(obj2!="") eval("form."+obj2+".style.background='#EEEEEE'");
		}
	}
	else {
		if(val) {
			eval("form."+obj1+".style.background='#EEEEEE'");
			if(obj2!="") eval("form."+obj2+".style.background='#EEEEEE'");
		}
		else {
			eval("form."+obj1+".style.background='#FFFFFF'");
			if(obj2!="") eval("form."+obj2+".style.background='#FFFFFF'");
		}
	}
	return;
}

//Æ÷Ä¿½º ¸ø¿À°Ô..
function checkBlur(val) {
	if(val) event.srcElement.blur();
	return;
}

function imgPreView(layerId) {
	if(event.srcElement.value.match(/(.jpg|.jpeg|.gif|.png)$/))	{
		document.images[layerId].src = event.srcElement.value;
		document.images[layerId].style.display = "";
	}
	else document.images[layerId].style.display = "none";
}

function imgPreView2(layerId) {

	if(event.srcElement.value.match(/(.jpg|.jpeg|.gif|.png)$/))	{
			if(layerId!=""){
				eval("document.all."+layerId+".style.backgroundImage ='url('+event.srcElement.value+')'");
				eval("document.all."+layerId+"2.style.backgroundImage ='url('+event.srcElement.value+')'");				
			}
	}
	else document.images[layerId].style.display = "none";
}

function checkAll(form, chk) {
	if (chk == true) {
		for (var i=0; i<form.length;i++) {
			if (form[i].type == "checkbox" && form[i].checked == false) {
				form[i].checked = true;
			}
		}
	}
	else {
		for (var i=0; i<form.length;i++) {
			if (form[i].type == "checkbox" && form[i].checked == true) {
				form[i].checked = false;
			}
		}
	}
}

function zipWin(formName, zip1, zip2, addr1, addr2) {
	window.open("/shopuser/join/zipSearch.html?formName="+formName+"&zip1="+zip1+"&zip2="+zip2+"&addr1="+addr1+"&addr2="+addr2,"","top=200,left=200,width=400, height=220");
}



function multiId(formName,rev){
	if(rev==""){
		alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
		return;
	}else{
		id_url = '/shopuser/join/multiId.html?formName='+formName+'&id=' + rev;
		window.open(id_url,'',"top=100,left=450,width=400, height=252");
	}
}

function checkId(field) {
	len=field.length;
	a=new Array(12);
	str1="abcdefghijklmnopqrstuvwxyz";
	str2="ABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%+_&*1234567890";
	str=""+str1+str2;

 	if((len>=4) && (len<=12)) {
		for(i=0;i<len;i++) {
			a[i]=field.substring(i,i+1);
			if (i==0) {
				if(str1.indexOf(a[i])>=0)  // Ã¹¹®ÀÚ ¿µ¹®¼Ò¹®ÀÚ °Ë»ç
					continue;
				else {
					alert("Ã¹¹®ÀÚ´Â ¿µ¼Ò¹®ÀÚ¿©¾ß ÇÕ´Ï´Ù.");
					return false;			// Ã¹¹®ÀÚ ¿µ¼Ò¹®ÀÚ°¡ ¾Æ´Ï¸é False ¹ÝÈ¯
				}
			}
			else if (str.indexOf(a[i])<0)  {  //ÇÑ±Û°Ë»ç str¿¡ ¾ø´Â ¹®ÀÚ¿­ °Ë»ç
				alert(a[i]+"¹®ÀÚ´Â ÀÔ·ÂÇÏ½Ç¼ö ¾ø½À´Ï´Ù.");
				return false;
			}
		}
	}
	else {
		alert("¾ÆÀÌµð´Â 4ÀÚÀÌ»ó 12ÀÚ ÀÌÇÏ¶ó¾ß ÇÕ´Ï´Ù.")
		event.srcElement.value="";
		event.srcElement.focus();
		return false;
	}

	return true;
}


function checkPass(form,field1,field2) {
	if(field1 != field2) {
		alert("ºñ¹Ð¹øÈ£°¡ Æ²¸³´Ï´Ù.");
		form.pass1.value="";
		form.pass2.value="";
		form.pass1.focus();
		return false;
	}
	if (field1.length<4 || field1.length>10) {
		if(field1.length==0) {
			alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
			form.pass1.focus();
			return false;
		}
		else {
			alert("ÆÐ½º¿öµå´Â 4ÀÚ¿¡¼­ 10ÀÚ¸®±îÁö ÀÔ´Ï´Ù.");
			form.pass1.value="";
			form.pass2.value="";
			form.pass1.focus();
			return false;
		}
	}
	return true;
}

function checkEmail(field) {
	if(field.length>0) {
		if( ( field.indexOf(".")<0 ) ||( field.indexOf("@")<0) ) {
				alert("Àß¸øµÈ ¸ÞÀÏÁÖ¼ÒÀÔ´Ï´Ù.");
				event.srcElement.value="";
				event.srcElement.focus();
				return;
		}
	}
}


// ¾Æ½ºÅ°ÄÚµå°ªÀ» ÀÌ¿ëÇÑ ÇÑ±Û¸¸ ÀÔ·Â¹Þ±â
function hanCheck(str){
	if(str.length>0) {
		var len;
        len = str.length;
        for (i=0;i<len;i++) {
			if (str.charCodeAt(i) < 128 ) {
				alert('ÀÌ Ç×¸ñ¿¡´Â ÇÑ±Û¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.');
				event.srcElement.value="";
				event.srcElement.focus();
				return;
			}
		}
	}
}

function checkJumin(form, jumin1, jumin2) {
	var jumin=""+jumin1+jumin2;
	var str=" "+"0123456789";

	var len1=jumin1.length;  //¾ÕÀÚ¸®±æÀÌ
	var len2=jumin2.length;  //µÞÀÚ¸®±æÀÌ
	var len=len1+len2;

	var gender=jumin2.substring(0,1);
	var genderInt=parseInt(gender);  //¼ºº°´ÜÀ§ ÃßÃâ

	var year=jumin1.substring(0,2);
	var yearInt=parseInt(year); //³â´ÜÀ§ ÃßÃâ

	var month=jumin1.substring(2,4);
	month1=month.substring(0,1);
	if(month1==0) month=jumin1.substring(3,4);
	else month=jumin1.substring(2,4);
	var monthInt=parseInt(month); //¿ù´ÜÀ§ ÃßÃâ
	// ÀÏÃ¼Å©
	var day=jumin1.substring(4,6)
	var dayInt=parseInt(day);  //ÀÏ´ÜÀ§ ÃßÃâ

	var lastNum=jumin.substring(12,13);  // ³¡ÀÚ¸®

	//¼ºº°Ã¼Å©
	if(genderInt==1 || genderInt==2) yearInt+=1900;
	else if(genderInt==3 || genderInt==4) yearInt+=2000;
	else {
		alert("Àß¸øµÈ ÁÖ¹Î¹øÈ£ÀÔ´Ï´Ù.");
		form.jumin1.value="";
		form.jumin2.value="";
		form.jumin1.focus();
		return false;
	}

	if(yearInt<=1950) {
		alert("Àß¸øµÈ ÁÖ¹Î¹øÈ£ÀÔ´Ï´Ù.");
		form.jumin1.value="";
		form.jumin2.value="";
		form.jumin1.focus();
		return false;
	}

	if(dayInt>31) {
		alert("Àß¸øµÈ ÁÖ¹Î¹øÈ£ÀÔ´Ï´Ù.");
		form.jumin1.value="";
		form.jumin2.value="";
		form.jumin1.focus();
		return false;
	}

	// ¿ùÃ¼Å© ¹×, 30,31ÀÏ´Þ ³¯Â¥ Ã¼Å©
	if(monthInt>=13) {
		alert("Àß¸øµÈ ÁÖ¹Î¹øÈ£ÀÔ´Ï´Ù.");
		form.jumin1.value="";
		form.jumin2.value="";
		form.jumin1.focus();
		return false;
	}
	else {
		if(monthInt<=7) {
			if(((monthInt%2)==0) && (dayInt>30)) {
				alert("Àß¸øµÈ ÁÖ¹Î¹øÈ£ÀÔ´Ï´Ù.");
				form.jumin1.value="";
				form.jumin2.value="";
				form.jumin1.focus();
				return false;
			}
		}
		else {
			if(((monthInt%2)==1) && (dayInt>30)) {
				alert("Àß¸øµÈ ÁÖ¹Î¹øÈ£ÀÔ´Ï´Ù.");
				form.jumin1.value="";
				form.jumin2.value="";
				form.jumin1.focus();
				return false;
			}
		}
	}

	// ±æÀÌÃ¼Å©
	if(len!=13) {
		alert("Àß¸øµÈ ÁÖ¹Î¹øÈ£ÀÔ´Ï´Ù.");
		form.jumin1.value="";
		form.jumin2.value="";
		form.jumin1.focus();
		return false;
	}

	//ÁÖ¹Î¹øÈ£ ¾Ë°í¸®Áò Ã¼Å©
	var i = new Array(13);
	var hap=0;
	for(i=0;i<jumin.length-1;i++) {
		if(i<8) j=i+2;
		else j=i+2-8;

		if(str.indexOf(jumin.substring(i,i+1))<=0) {
//			alert(jumin.substring(i,i+1)+":::"+i);
			alert("¼ýÀÚ¸¸ÀÔ·ÂÇÏ¼¼¿ä");
			form.jumin1.value="";
			form.jumin2.value="";
			form.jumin1.focus();
			return false;
		}
		else hap+=jumin.substring(i,i+1)*(j);
	}

	okNum=11-(hap%11);
	if (okNum>9) okNum=okNum % 10;
	if(lastNum!=okNum) {
		alert("Àß¸øµÈ ÁÖ¹Î¹øÈ£ÀÔ´Ï´Ù.");
		form.jumin1.value="";
		form.jumin2.value="";
		form.jumin1.focus();
		return false;
	}
	
	return true;
}

function wishInsert(code) {
	window.open("/shopuser/mypage/wishlistInsert.html?code="+code,"","top=10000,left=10000,width=100, height=100");
	return;
}

function wishInsert2(form,code,iname) {
	form.target=iname;
	form.action="/shopuser/mypage/wishlistInsert_new.html";
	form.code.value=code;
	form.submit();
	return;
}

function cartInsert(code, kind) {
	window.open("/shopuser/goods/simpleCartInsert.html?code="+code+"&kind="+kind,"","top=10000,left=10000,width=100, height=100");
	return;
}

function cartInsert2(code, kind) {
	window.open("/shopuser/goods/simpleCartInsert2.html?code="+code+"&kind="+kind,"","top=10000,left=10000,width=100, height=100");
	return;
}

function buyInsert(code, kind) {
	window.open("/shopuser/goods/simpleByInsert.html?code="+code+"&kind="+kind,"","top=10000,left=10000,width=10, height=10");
	return;
}

function compareGood(form) {
	var num=0;
	for(i=0;i<form.length;i++) if(form.elements[i].checked) num+=1;

	if(num==0) {
		alert("»óÇ°ºñ±³ÇÒ »óÇ°ÀÌ ¾ø½À´Ï´Ù.");
		return false;
	}
	else if(num<=1 || num>=4) {
		alert("»óÇ°ºñ±³´Â 2, 3°³¸¸ °¡´ÉÇÕ´Ï´Ù.");
		return false;
	}
	else {
		window.open("","compare","top=100,left=100,width=766, height=600, scrollbars=yes, resizable=1");
		form.target="compare";
		form.action="/shopuser/goods/compareVew.html";
		return true;
	}
}

function compareGood2(form) {
	var num=0;
	for(i=0;i<form.length;i++) if(form.elements[i].checked) num+=1;

	if(num==0) {
		alert("»óÇ°ºñ±³ÇÒ »óÇ°ÀÌ ¾ø½À´Ï´Ù.");
		return false;
	}
	else if(num<=1 || num>=4) {
		alert("»óÇ°ºñ±³´Â 2, 3°³¸¸ °¡´ÉÇÕ´Ï´Ù.");
		return false;
	}
	else {
		var codeArr= new Array("a");
		SLB('/shopuser/goods/compareVew_new.html','iframe', 766, 600, true, false);
		//window.open("","compare","top=100,left=100,width=766, height=600, scrollbars=yes, resizable=1");
		//form.target="SLB_iframe";
		//form.action="/shopuser/goods/compareVew.html";
		//form.submit();
		//return true;
	}
}

function bigImg(img, width, height) {
	window.open("/shopuser/goods/bigImage.html?img="+img,"","top=200,left=200,width="+width+", height="+height+", resizable=1");
}

function receptPrint(ordno) {
	window.open("/shopuser/mypage/recept.html?ordno="+ordno,"","top=100,left=100,width=638, height=600, scrollbars=yes, resizable=1");	
}
function receptPrint2(ordno) {
	window.open("/shopuser/mypage/recept2.html?ordno="+ordno,"","top=100,left=100,width=638, height=600, scrollbars=yes, resizable=1");	
}

function checkOut(ordno, checktype, type) {
	// Ä«µå°áÁ¦Ã¢À» ¾²´Â °æ¿ì
	if(checktype=="card" || checktype=="real") {	
		//Æ÷ÀÎÆ®°¡ ¾ø´Â °æ¿ì
		if(type=="normal") height=200;
		//Æ÷ÀÎÆ®°¡ ÀÖ´Â °æ¿ì
		else if(type=="point") height=410;
	}
	else if(checktype=="escrow") {
		//Æ÷ÀÎÆ®°¡ ¾ø´Â °æ¿ì
		if(type=="normal") height=230;
		//Æ÷ÀÎÆ®°¡ ÀÖ´Â °æ¿ì
		else if(type=="point") height=410;
	}
	else if(checktype=="bank") {
		//Æ÷ÀÎÆ®°¡ ¾ø´Â °æ¿ì
		if(type=="normal") height=290;
		//Æ÷ÀÎÆ®°¡ ÀÖ´Â °æ¿ì
		else if(type=="point") height=350;
	}

	window.open("checkForm.html?ordno="+ordno+"&checktype="+checktype, "check", "top=100, left=100, width=555, height="+height);
	return;		
}

function checkCancel(ordno, popuptype) {
	if(!confirm("ÁÖ¹®Ãë¼Ò°¡ µË´Ï´Ù. Á¤¸» Ãë¼Ò ÇÏ½Ã°Ú½À´Ï±î?")) {
		return;
	}
	//if(popuptype=="connecting") {
	//	window.open("cardCancelConnecting.html?ordno="+ordno, "check", "top=100, left=100, width=555, height=330");
	//	return;		
	//}
	//else if(popuptype=="exe") {
	if(popuptype=="exe" || popuptype=="connecting") {
		//window.open("cancelOrderExe.html?ordno="+ordno, "exe", "top=10000, left=10000, width=100, height=100");
		exe.location.href="cancelOrderExe.html?ordno="+ordno;
		return;		
	}
}

function etcgoodView(etcno) {
	window.open("/shopuser/goods/etcgoodView.html?etcno="+etcno,"","top=100,left=100,width=518, height=532");
}

function etcgoodView2(etcno,codeno) {
	window.open("/shopuser/goods/etcgoodView.html?etcno="+etcno+"&code="+codeno,"","top=100,left=100,width=518, height=532");
}

function goWrite(url, time, qrystring) {
	self.location=url+"?refer="+time+qrystring;
}

function getCookie(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) {
		  var end=document.cookie.indexOf(";",j);
		  if(end == -1) end=document.cookie.length;
		  return unescape(document.cookie.substring(j,end));
	  }

	  i=document.cookie.indexOf(" ",i) +1;
	  if(i==0) break;
  }
  return null;
}


function flash_Object(flashMovie) {
		document.write(flashMovie);
			
}


function addfavorites(gourl,urltitle){

var favoriteurl=gourl;
var favoritetitle=urltitle+" ¹Ù·Î°¡±â";

window.external.AddFavorite(favoriteurl,favoritetitle)
}

function mailpop(){
window.open("/shopuser/etc/formmail.html","","top=200,left=200,width=500, height=330");
}

//kcp ¿¡½ºÅ©·Î
function kcp_check()
{
	var status  = "width=500 height=450 menubar=no,scrollbars=no,resizable=no,status=no";
	var obj     = window.open('', 'kcp_pop', status);
	
	document.shop_check.method = "post";
	document.shop_check.target = "kcp_pop";
	document.shop_check.action = "http://admin.kcp.co.kr/Modules/escrow/kcp_pop.jsp";

	document.shop_check.submit();
}
//arsÆË¾÷
function arspop(){
	var leftValue = Math.floor((screen.width/2)-(240/2)); 
 	var topValue = Math.floor((screen.height/2)-(240/2)); 
	var openArsPop=window.open('/shopuser/etc/ars.html','openArs','toolbar=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, left='+leftValue+' ,top='+topValue+' ,width='+240+' ,height='+240);
	openArsPop.focus();
}
