var $ = document.getElementById;

function goParent( myurl ) {
	parent.location = myurl;
}

	//Æ¯¼ö¹®ÀÚ ¹× ÇÑ±ÛÀÔ·Â ¹æÁö È®ÀÎ
	function FuncString(chkfield){
			var checkOK = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
			var checkStr = chkfield;
			var allValid = true;
			var allNum = "";
			checkStr = checkStr.toUpperCase();
			for (i = 0;  i < checkStr.length;  i++)
			{
			  ch = checkStr.charAt(i);
			  for (j = 0;  j < checkOK.length;  j++)
				if (ch == checkOK.charAt(j))
					break;
					if (j == checkOK.length)
					{
						allValid = false;
						break;
					}
			}
		if (allValid == false) return false;
		if (allValid == true) return true;
	}

	//ÀÌ¸ÞÀÏ ¹®ÀÚ¿­ È®ÀÎ
	function FuncEmailString(chkfield){
			var checkOK = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@._-";
			var checkStr = chkfield;
			var allValid = true;
			var allNum = "";
			checkStr = checkStr.toUpperCase();
			for (i = 0;  i < checkStr.length;  i++)
			{
			  ch = checkStr.charAt(i);
			  for (j = 0;  j < checkOK.length;  j++)
				if (ch == checkOK.charAt(j))
					break;
					if (j == checkOK.length)
					{
						allValid = false;
						break;
					}
			}
		if (allValid == false) return false;
		if (allValid == true) return true;
	}


	//ÀÌ¸ÞÀÏ Çü½Ä È®ÀÎ ---------------------------------------------------
	function FuncEmailChk(p_obj,p_name){
		if(p_obj.value == ""){
			alert(p_name + " ºó¹®ÀÚ È¤Àº °ø¹éÀ» ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.");
			p_obj.focus();
			return false;

		}else{
			var str = p_obj.value;
			if (FuncEmailString(str)) {
				for(var i=0;i<str.length;i++){
					if (str.substring(i+1,i+2) =="@"){
						var str_1 = "y";
					}

					if (str_1 == "y" && str.substring(i,i+1) =='.'){
						return true;
					}

				}
				alert("ÀÌ¸ÞÀÏ Çü½Ä¿¡ ¸ÂÁö ¾Ê½À´Ï´Ù.");
				p_obj.focus();
				return false;


			}else{
				alert("ÀÌ¸ÞÀÏÀº ÇÑ±ÛÀ» ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.");
				return false;
			}

		}

	}


	//¼ýÀÚ¿­ ÀÔ·ÂÈ®ÀÎ ---------------------------------------------------
	function FuncCheckNumeric(p_obj, p_name) {
		var tempVal = "";
		var tocheck = "";
		tempVal = p_obj.value;

		splitData = tempVal.toString().split(".");

		if (splitData.length > 2) {
			alert("¼öÄ¡ µ¥ÀÌÅÍÇü½ÄÀÌ Àß¸øµÇ¾ú½À´Ï´Ù.");
			p_obj.value = "";
			p_obj.focus();
			return false;
		} else {
			for (s = 0; s < splitData.length; s++) {
				tocheck = splitData[s];
				for (var j = 0; j < tocheck.length; j++) {
					if (tocheck.substring(j, j + 1) != "0" &&
					tocheck.substring(j, j + 1) != "1" &&
					tocheck.substring(j, j + 1) != "2" &&
					tocheck.substring(j, j + 1) != "3" &&
					tocheck.substring(j, j + 1) != "4" &&
					tocheck.substring(j, j + 1) != "5" &&
					tocheck.substring(j, j + 1) != "6" &&
					tocheck.substring(j, j + 1) != "7" &&
					tocheck.substring(j, j + 1) != "8" &&
					tocheck.substring(j, j + 1) != "9") {
						alert(p_name + " ¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.");
						p_obj.value = "";
						p_obj.focus();
						return false;
					}
				}
			}

		}

		return true;

	}

	//¼ýÀÚ¿­ ÀÔ·ÂÈ®ÀÎ Æ÷Ä¿½ºÀÌµ¿ ¾øÀ½ ---------------------------------------------------
	function FuncCheckNumericNotFocus(p_obj, p_name) {
		var tempVal = "";
		var tocheck = "";
		tempVal = p_obj.value;

		splitData = tempVal.toString().split(".");

		if (splitData.length > 2) {
			alert("¼öÄ¡ µ¥ÀÌÅÍÇü½ÄÀÌ Àß¸øµÇ¾ú½À´Ï´Ù.");
			p_obj.value = "";
			p_obj.focus();
			return false;
		} else {
			for (s = 0; s < splitData.length; s++) {
				tocheck = splitData[s];
				for (var j = 0; j < tocheck.length; j++) {
					if (tocheck.substring(j, j + 1) != "0" &&
					tocheck.substring(j, j + 1) != "1" &&
					tocheck.substring(j, j + 1) != "2" &&
					tocheck.substring(j, j + 1) != "3" &&
					tocheck.substring(j, j + 1) != "4" &&
					tocheck.substring(j, j + 1) != "5" &&
					tocheck.substring(j, j + 1) != "6" &&
					tocheck.substring(j, j + 1) != "7" &&
					tocheck.substring(j, j + 1) != "8" &&
					tocheck.substring(j, j + 1) != "9") {
						alert(p_name + " ¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.");
						p_obj.value = "";
						p_obj.focus();
						return false;
					}
				}
			}

		}

		return true;

	}

	//³¯Â¥À¯Çü °Ë»ö
	function FuncCheckDate(p_obj,p_name){
		var tocheck = p_obj.value;
		var tempdate = "";
		var resultdate = "";

		for (var j = 0 ; j < tocheck.length; j++) {
			if (tocheck.substring(j, j + 1) == "0" ||
			tocheck.substring(j, j + 1) == "1" ||
			tocheck.substring(j, j + 1) == "2" ||
			tocheck.substring(j, j + 1) == "3" ||
			tocheck.substring(j, j + 1) == "4" ||
			tocheck.substring(j, j + 1) == "5" ||
			tocheck.substring(j, j + 1) == "6" ||
			tocheck.substring(j, j + 1) == "7" ||
			tocheck.substring(j, j + 1) == "8" ||
			tocheck.substring(j, j + 1) == "9") {

				tempdate += (tocheck.substring(j, j + 1)).toString();
			}
		}

		if (tempdate.length != 8){
			alert(p_name + "ÀÇ ³¯Â¥ Çü½ÄÀÌ Àß¸øµÇ¾ú½À´Ï´Ù.");
			p_obj.value = "";
			p_obj.focus();
			return false;
		}else{
			resultdate = tempdate.substr(0,4).toString() + '-' +  tempdate.substr(4,2).toString() + '-' + tempdate.substr(6,2).toString();
			var checkdate = new Date((resultdate.toString()).replace("-","/"));
			if (parseInt(tempdate.substr(0,4)) != parseInt(checkdate.getYear())){
				alert(p_name + "Àº À¯È¿ÇÏÁö ¾ÊÀº ³¯Â¥ÀÔ´Ï´Ù.1");
				p_obj.value = "";
				p_obj.focus();
				return false;
			}
			if (parseInt(tempdate.substr(4,2).replace("0","")) != parseInt(checkdate.getMonth())+1){
				//alert(p_name + "Àº À¯È¿ÇÏÁö ¾ÊÀº ³¯Â¥ÀÔ´Ï´Ù.2");
				//p_obj.value = "";
				//p_obj.focus();
				return true;
			}

			if (parseInt(tempdate.substr(6,2).replace("0","")) != parseInt(checkdate.getDate())){
				//alert(p_name + "Àº À¯È¿ÇÏÁö ¾ÊÀº ³¯Â¥ÀÔ´Ï´Ù.3");
				//p_obj.value = "";
				//p_obj.focus();
				return true;
			}
			p_obj.value = resultdate;
			return true;
		}
	}


	//ºó¹®ÀÚ¿­ °Ë»ö ---------------------------------------------------
	function FuncNullchk(p_obj,p_name){
		var p_string = eval(p_obj).value;
		var p_realString = "";

		for (var j = 0; j < p_string.length; j++) {

			if (p_string.substring(j, j + 1) != " ") {

				p_realString += (p_string.substring(j, j + 1)).toString();
			}
		}


		if (p_realString.length < 1) {
			alert(p_name + " ºó¹®ÀÚ È¤Àº °ø¹éÀ» ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.");
			eval(p_obj).focus();
			return false;
		}
		return true;
	}

	//ºó¹®ÀÚ¿­ °Ë»ö ---------------------------------------------------
	function FuncNullchkNotFocus(p_obj, p_name) {
		var p_string = eval(p_obj).value;
		var p_realString = "";

		for (var j = 0; j < p_string.length; j++) {

			if (p_string.substring(j, j + 1) != " ") {

				p_realString += (p_string.substring(j, j + 1)).toString();
			}
		}


		if (p_realString.length < 1) {
			alert(p_name + " ºó¹®ÀÚ È¤Àº °ø¹éÀ» ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.");
			return false;
		}
		return true;
	}

	//ÀüÈ­¹øÈ£ Ã¼Å© ---------------------------------------------------
	function FuncTelCheck(p_obj,p_name){
			var chkval ;
			if(!FuncNullchk(eval(p_obj + "1"),p_name)){
				return false;
			}else{
				if(!FuncCheckNumeric(eval(p_obj + "1"),p_name)){
					return false;
				}

			}

			if(!FuncNullchk(eval(p_obj + "2"),p_name)){
				return false;
			}else{
				if(!FuncCheckNumeric(eval(p_obj + "2"),p_name)){
					return false;
				}

			}

			if(!FuncNullchk(eval(p_obj + "3"),p_name)){
				return false;
			}else{
				if(!FuncCheckNumeric(eval(p_obj + "3"),p_name)){
					return false;
				}
			}
			return true;
	}


	//¶óÀÎ ½ºÅ©·Ñ Ã³¸®
	function funcColor(p_obj,p_num){
		if(p_num == "1"){
			if(p_obj.style.background){
				if (p_obj.style.background == "#f0e7dd") {
					p_obj.style.background = "#e1d1bd";
				}
			}else{
				p_obj.style.background = "#e1d1bd";
			}

		}else{
			if(p_obj.style.background == "#e1d1bd"){
				p_obj.style.background = "#f0e7dd";
			}
		}

	}

	//¶óÀÎ ½ºÅ©·Ñ Ã³¸®
	function funcColorOrder(p_obj, p_num) {
		if (p_num == "1") {
			if (p_obj.style.background) {
				if (p_obj.style.background == "#e0e0e0") {
					p_obj.style.background = "#e1d1bd";
				}
			} else {
				p_obj.style.background = "#e1d1bd";
			}

		} else {
			if (p_obj.style.background == "#e1d1bd") {
				p_obj.style.background = "#e0e0e0";
			}
		}

	}

	//¶óÀÎ ½ºÅ©·Ñ Ã³¸®1
	function funcColorReceive(p_obj,p_num,p_color){
		if(p_num == "1"){
			p_obj.style.background = p_color;

		}else{
			p_obj.style.background = p_color;
		}

	}

	//¼±ÅÃ¶óÀÎ Ç¥½Ã
	function FuncSetColor(p_frm,p_num){
		if(p_frm.clicknum.value != ""){
			eval("strline" + p_frm.clicknum.value).style.background = "#f3f3f3";
		}
		eval("strline" + p_num).style.background = "#ffd700";
		p_frm.clicknum.value = p_num;

	}

	//±Ý¾× À¯ÇüÀ¸·Î º¯°æ
	function FuncCurrency(p_value){

		var Moneys = p_value.toString();
		var currency = ""; 
		for(cc=0;cc < Moneys.length; cc++){ 
				currency += Moneys.substring(cc,cc+1);		 
				if(((Moneys.length - cc-1)%3) == 0 && (Moneys.length-cc-1) > 0 ) 
				currency += ","; 
		} 

		return currency;
	}

	//ÀÚ¸® ´ÜÀ§ ¸ÂÃß±â
	function FuncRound(p_value, p_num){
		var strvalue = 0;
		if (p_value >= Math.pow(10,p_num)){
			strvalue = p_value % Math.pow(10,p_num);
			if (parseInt(strvalue) > 0){
				return Math.ceil(p_value / Math.pow(10,p_num)) * Math.pow(10,p_num);
			}else{
				return p_value;
			}
		}else{
				return p_value;
		}


	}

	//¸Þ´º ·¹ÀÌ¾î ·Ñ¿À¹ö
	function FuncLayer(p_value, p_obj) {
		eval(p_obj).style.visibility = p_value;
	}


	//¸ÅÀå ÀÌµ¿Ã³¸®
	function FuncGoShop(P_type, P_mcd, P_ca) {
		var Site_Url = "";

		switch (P_type) {
			case "A":
				Site_Url = "/Shop/Main.asp?mcd=" + P_mcd;
				break;
			case "L":
				Site_Url = "/Shop/ShopLarge.asp?mcd=" + P_mcd;
				break;
			case "M":
				Site_Url = "/Shop/ShopMiddle.asp?mcd=" + P_mcd;
				break;
			case "S":
				Site_Url = "/Shop/ShopSmall.asp?mcd=" + P_mcd;
				break;
		}

		if (P_ca != "") { 
			Site_Url = Site_Url + '&ca=' + P_ca;
		}

		window.location.href = Site_Url;
	}


	//°øÁö»çÇ× ÀÌµ¿Ã³¸®
	function FuncNotice(p_num) {
		var Site_Url = "";

		switch (p_num) {
			case 1:
				Site_Url = "/CustomerCenter/NoticeList.asp?type=" + 1;
				break;
			case 2: ;
				Site_Url = "/CustomerCenter/NoticeList.asp?type=" + 3;
				break;
		}

		window.location.href = Site_Url;
	}

	// »óÇ°Âò Ã³¸®
	function FuncWishSelect(p_mcd, p_ca, p_itemcd) {
		iframewish.location.href = '/Mypage/iframeBizWishList.asp?txttype=1&mcd=' + p_mcd + '&ca=' + p_ca + '&itemcd=' + p_itemcd ;
	}
	function FuncWishDel(p_idx) {
		iframewish.location.href = '/Mypage/iframeBizWishList.asp?txttype=2&idxnum=' + p_idx ;
	}

	function FuncNoWish() {
		if (!confirm("È¸¿ø Àü¿ë ±â´ÉÀÔ´Ï´Ù.\n\n·Î±×ÀÎ ÆäÀÌÁö·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î?")) {
			return;
		} else {
			top.location.href = "/Join/Login.asp";
		}
	}


	function FuncsearchInput(p_frm) {
		if (!p_frm.searchword.value) {
			alert("°Ë»öÇÏ°íÀÚ ÇÏ´Â ´Ü¾î¸¦ ÀÔ·ÂÇÏ½Ê½Ã¿À.");
			// ÀÎÄÚµù Ã³¸®
			p_frm.searchword.focus();
			return false;
		}
		
	}

	function FuncSetSearchword(p_word) {
		topsearchform.searchword.value = p_word;
		topsearchform.submit();
	}

	//** ´ÙÀ½°´Ã¼·Î ÀÌµ¿ **
	function FuncSetNext(p_obj, p_length, p_nextobj) {
		var value1 = eval(p_obj).value;
		if (!FuncCheckNumeric(eval(p_obj), "ÀÔ·ÂÀº ")) {
			return;
		}
		if (value1.length == p_length) {
			eval(p_nextobj).focus();
		}
	}


	function FuncViewBigImage(p_mediumcd, p_categorycd, p_itemcd) {
		window.open("/include/popup/ViewBigImage.asp?mcd=" + p_mediumcd + "&ca=" + p_categorycd + "&itemcd=" + p_itemcd, "bigimage", "toolbars=no,status=no,width=450,height=460");
	}

	function FuncDivShowHide(p_obj){
		if ($(p_obj).style.visibility == "visible")
		{
			$(p_obj).style.visibility = "hidden";
		}else{
			$(p_obj).style.visibility = "visible";
		}
	}


	function FuncDivShow(p_obj){
		$(p_obj).style.visibility = "visible";
	}
	function FuncDivHide(p_obj){
		$(p_obj).style.visibility = "hidden";
	}

	function FuncSpanShow(p_obj){
		p_obj.style.display = "block";
	}
	function FuncSpanHide(p_obj){
		p_obj.style.display = "none";
	}

	function FuncInitText(p_obj, p_val){

		if (p_obj.value=="")
		{
			p_obj.value=p_val;
		}else{
			if (p_obj.value==p_val)
			{
				p_obj.value="";
			}
		}
	}

	function getCookie( name ) {
		var nameOfCookie = name + "="; 
		var x = 0; 

		while ( x <= document.cookie.length ) {
			var y = (x+nameOfCookie.length); 
			if ( document.cookie.substring( x, y ) == nameOfCookie ) {
				if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) endOfCookie = document.cookie.length; 

				return unescape( document.cookie.substring( y, endOfCookie ) );
			}

			x = document.cookie.indexOf( " ", x ) + 1;

			if ( x == 0 ) break;
		}
	}

	function setCookie( name, value, expiredays ) {
 		var todayDate = new Date();
		todayDate.setDate( todayDate.getDate() + expiredays );
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
	}

	function Num_Comma(str) {
		s = new String(str); 

		s=s.replace(/\D/g,"");

		if (s.substr(0,1)==0 ) {
			s = s.substr(0);
		}

		l=s.length-3;
		while(l>0) {
			s=s.substr(0,l)+","+s.substr(l);
			l-=3;
		}
		 return s;  
	}

	function FuncDownload(p_type, p_filename,p_filepath, p_obj){
		$(p_obj).location="/iniclude/popup/FileDownload.asp?txttype=" + p_type + "&filename=" + p_filename + "&filepath=" + p_filepath;
	}

	function FuncIframeHeight(p_obj){
		var h = document.body.scrollHeight;
		parent.$(p_obj).style.height=h;
	}

	function FuncSearchDate(p_num) {
		showModalDialog('/include/popup/CalendarFrame.asp?num=' + p_num, window, 'resizable: no; help: no; status: no; scroll: no; ');
	}


	function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function setShowSpan(name, seq){
	leng = eval("document.all." + name + ".length");
	if(leng + "" == "undefined"){
		eval("document.all." + name + ".style.display = 'inline';");
	}else{
		for(i=0;i<leng;i++){
			eval("document.all." + name + "[" + i + "].style.display = 'none';");
		}
		eval("document.all." + name + "[" + seq + "].style.display = 'inline';");
	}

}


//¸®ºä ÆË¾÷
function FuncSetReview(p_orderidxnum) {
	window.open('/include/popup/FrmProductReview.asp?orderidxnum=' + p_orderidxnum,'productreview','toolbars=no, status=no, width=1, height=1');
}

function isNull( myobj, strmsg ) {
	if ( myobj.value == "" ) {
		alert( strmsg + " ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À." );
		myobj.focus();
		return true;
	} else {
		return false;
	}
}


