
/*
±â´É : ÇÊµå¿¡ ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ¼ö ÀÖ´Â ÇÔ¼ö 
»ç¿ë¹ý : onkeyup="onlyNumber(this);"
*/
 
function onlyNumber(el) {
  el.value = el.value.replace(/\D/g,'');
}



/*
±â´É : ÆË¾÷Ã¢À» È­¸é Áß¾Ó¿¡ ¶ç¿ì´Â ÇÔ¼ö
»ç¿ë¹ý : openPopup('auth_write.asp','auth',667,500,'scrollbars=yes,width=667,height=500')
*/
function openPopup( url, name, width, height, features) {

    var left= ( screen.width   - width ) / 2;
    var top = ( screen.height   - height ) / 2;

    return window.open(url, name, features + ',left=' + left + ', top=' + top);
}


/*
±â´É : °øÅë Blank CheckÇÔ¼ö
»ç¿ë¹ý1 : setInputAlert(form1.field, fieldName);
°á°ú : "Please input PDC Code."
*/
function setInputAlert(field, fieldName) {	
	if(Trim(field.value) == "") {
		alert("Please input " + fieldName + ".");
		field.focus();
		return false;
	}

	return true;
}


/*
±â´É : °øÅë Blank CheckÇÔ¼ö
»ç¿ë¹ý1 : setInputAlert2(form1.field, fieldName);
°á°ú : "Please fill in "To" blank"
*/
function setInputAlert2(field, fieldName) {	
	if(Trim(field.value) == "") {
		alert("Please fill in \"" + fieldName + "\" blank.");
		field.focus();
		return false;
	}

	return true;
}


/*
±â´É : °øÅë Blank CheckÇÔ¼ö
»ç¿ë¹ý1 : setInputAlert3(form1.field, fieldName, 10);
°á°ú : "New Password should be 3 characters long."
*/
function setInputAlert3(field, fieldName, num) {	
	var fieldValue = Trim(field.value);
	if(fieldValue == "" || fieldValue.length < parseInt(num)) {
		alert(fieldName + " should be " + num + " characters long.");
		field.focus();
		return false;
	}

	return true;
}


/*
±â´É : °øÅë Blank CheckÇÔ¼ö
»ç¿ë¹ý1 : setInputAlert4(form1.field, fieldName, 3, 10);
°á°ú : "Your password should range between 3 ~ 7 characters."
*/
function setInputAlert4(field, fieldName, num1, num2) {	
	var fieldValue = Trim(field.value);
	if(fieldValue == "" || fieldValue.length < parseInt(num1) || fieldValue.length > parseInt(num2)) {
		alert(fieldName + " should range between " + num1 + " ~ " + num2 + " characters.");
		field.focus();
		return false;
	}

	return true;
}


/* 
±â´É : Check °ü·Ã Message
»ç¿ë¹ý 1 : setCheckAlert(document.form1.checkCount, "select box", "MIN", "1");
*/
function setCheckAlert(field, fieldName, type, num) {	
	if(type.toUpperCase() == "MAX") {
		alert("Please check " + fieldName + " at most " + num + " item");			
	} else if(type.toUpperCase() == "MIN") {
		alert("Please check " + fieldName + " at least " + num + " item");	
	}
	return;
}


function setFormatAlert(field, fieldName, formatName) {
	alert("You have an error.\n Format of " + fieldName + " is " + formatName + ".");
	field.focus();
	return;
}

/*
±â´É : Select °ü·Ã ÇÔ¼ö
»ç¿ë¹ý : if(!setSelectAlert(frm.div_name, "Code")) return;
*/ 
function setSelectAlert(field, fieldName) {	
	if(Trim(field.value) == "") {
		alert("Please select " + fieldName + ".");
		field.focus();
		return false;
	}

	return true;
}

function Trim( str ) {
		
	var resultStr = "";
		
	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);
	
	return resultStr;
} 


function TrimLeft( str ) {
	var resultStr = "";
	var i = len = 0;	
	if (str+"" == "undefined" || str == null) return null;	
	str += "";
	
	if (str.length == 0) resultStr = "";
	else {	
		len = str.length;					
  		while ((i <= len) && (str.charAt(i) == " "))i++;   	
  		resultStr = str.substring(i, len);
  	}

  	return resultStr;
} 


function TrimRight( str ) {
	var resultStr = "";
	var i = 0;	
	
	if (str+"" == "undefined" || str == null) return null;
	str += "";
		
	if (str.length == 0) resultStr = "";
	else {
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;
	  		resultStr = str.substring(0, i + 1);
	  	}
	  	
	  	return resultStr;  	
}


//compare list Ã¼Å©¹Ú½º ¼±ÅÃ ´ã±â 
function compareListbox() {

  var frm = document.listForm;
  var len = document.getElementsByName("pro_code").length;
  var pro_code_val ="";
  
  if (len > 1 ) {
    for(i=0;i<len;i++) {
      if(frm.pro_code[i].checked) {
        pro_code_val = pro_code_val + frm.pro_code[i].value + ",";
      }
    }
  } else if (len==1) {
    if(frm.pro_code.checked) {
      pro_code_val = frm.pro_code.value;
    }
  }
  
  if (pro_code_val=="") {
    alert("Please choose the item."); 
  } else {
   act.location.href="/util/comparelist.asp?pro_code="+pro_code_val;
  }

}


//wish list Ã¼Å©¹Ú½º ¼±ÅÃ ´ã±â
function wishListbox() {

  var frm = document.listForm;
  var len = document.getElementsByName("pro_code").length;
  var pro_code_val ="";
  
  if (len > 1 ) {
    for(i=0;i<len;i++) {
      if(frm.pro_code[i].checked) {
        pro_code_val = pro_code_val + frm.pro_code[i].value + ",";
      }
    }
  } else if (len==1) {
    if(frm.pro_code.checked) {
      pro_code_val = frm.pro_code.value;
    }
  }
  
  if (pro_code_val=="") {
    alert("Please choose the item."); 
  } else {
    location.href="/util/wishlist.asp?pro_code="+pro_code_val;
  }

}

//shopping cart Ã¼Å©¹Ú½º ¼±ÅÃ ´ã±â
function cartListbox() {

  var frm = document.listForm;
  var len = document.getElementsByName("pro_code").length;
  var pro_code_val ="";
  
  if (len > 1 ) {
    for(i=0;i<len;i++) {
      if(frm.pro_code[i].checked) {
        pro_code_val = pro_code_val + frm.pro_code[i].value + ",";
      }
    }
  } else if (len==1) {
    if(frm.pro_code.checked) {
      pro_code_val = frm.pro_code.value;
    }
  }
  
  if (pro_code_val=="") {
    alert("Please choose the item."); 
  } else {
    parent.act.location.href="/util/cartlist.asp?pro_code="+pro_code_val;
  }

}

function calcuWeight(val) {

  var frm = document.form1;
  var ea_val = frm.order_ea.value;
  
  if (ea_val=="") {
    ea_val = 0;
  }
  
  //¼Ò¼öÁ¡ ¼¼ÀÚ¸®¿¡¼­ ¹Ý¿Ã¸²
  frm.order_weight.value=Math.round(ea_val*val*100)/100;

}

function calcuWeight1(val,wgt) {

  var each_weight = 0;
  var total_qty = 0;
  var total_weight = 0;
  
  var chkbox = document.getElementsByName("chkYn");
  
  for(i=0;i<chkbox.length;i++) {
    
    var each_qty = eval("document.form1.pro_qty"+chkbox[i].value);
    if (chkbox.length=="1") {
    each_weight = document.form1.pro_weight;
    } else {
    each_weight = document.form1.pro_weight[i];
    }
    
    if (each_qty.value >= "0") {
      
      if (val=="ring") {
        each_weight.value = Math.round(each_qty.value * wgt *1.00 * 100)/100;
      } else {
        each_weight.value = Math.round(each_qty.value * chkbox[i].value.replace("_",".") * wgt *1.00 * 100)/100;
      }
    
    }
    
    if (chkbox[i].checked==true) {
      
      total_qty = total_qty + each_qty.value*1.00;
      total_weight = total_weight + each_weight.value*1.00;
      
    }
    
  }
  
  document.form1.order_ea.value = total_qty;
  document.form1.order_weight.value = Math.round(total_weight*100)/100;

}

function calcuWeight2(val) {

  var frm = document.form1;
  var ea_val = frm.order_ea.value;
  if (ea_val=="") {
    ea_val = 0;
  }
  
  //¼Ò¼öÁ¡ ¼¼ÀÚ¸®¿¡¼­ ¹Ý¿Ã¸²
  frm.order_weight.value=Math.round(ea_val*val*100)/100;

}

function shoppingOrder() {
//ÁÖ¹®ÇÏ±â

  var frm = document.form1;
  
  var option_a = document.getElementById("option1");
  var option_b = document.getElementById("option2");
  var option_c = document.getElementById("option3");
  var option_d = document.getElementById("option4");
  var option_e = document.getElementById("option5");
  var option_f = document.getElementById("option6");
  var option_g = document.getElementById("option7");
  var option_h = document.getElementById("option8");
  var option_i = document.getElementById("option9");
  
  if (frm.order_ea.value==""  || frm.order_ea.value=="0" ) {
    alert("Please enter a number that you want to purchase.");
    frm.order_ea.focus();
    return false; 
  }
  
  if (option_a) {
    if (option_a.value=="") {
      alert("Please select Birth Stone that you want to purchase.");
      return false;
    }
  }
  
  if (option_b) {
    if (option_b.value=="") {
      alert("Please enter Initial Name that you want to purchase.");
      return false;
    }  
  }
  
  if (option_c) {
    if (option_c.value=="") {
      alert("Please select Metal Type/Color that you want to purchase.");
      return false;
    }    
  }
  
  if (option_d) {
    if (option_d.value=="") {
      alert("Please select Diamond/No Diamond that you want to purchase.");
      return false;
    }    
  }
  
  if (option_f) {
    if (option_f.value=="") {
      alert("Please select Length that you want to purchase.");
      return false;
    }    
  }
  
  if (option_g) {
    if (option_g.value=="") {
      alert("Please select Initial that you want to purchase.");
      return false;
    }    
  }
  
  if (option_h) {
    if (option_h.value=="") {
      alert("Please select Ring size that you want to purchase.");
      return false;
    }    
  }
  
  if (option_i) {
    if (option_i.value=="") {
      alert("Please select Metal Color that you want to purchase.");
      return false;
    }    
  }
  
  frm.action="/util/shoppingorder.asp";
  frm.submit();
  //parent.act.location.href="/util/shoppingorder.asp?pro_code="+val+"&cart_ea="+frm.order_ea.value;
  
}

function logincheck() {
//ÁÖ¹®ÇÏ±â

  var frm = document.form1;
  
  var option_a = document.getElementById("option1");
  var option_b = document.getElementById("option2");
  var option_c = document.getElementById("option3");
  var option_d = document.getElementById("option4");
  var option_e = document.getElementById("option5");
  var option_f = document.getElementById("option6");
  var option_g = document.getElementById("option7");
  var option_h = document.getElementById("option8");
  var option_i = document.getElementById("option9");
  
  if (frm.order_ea.value==""  || frm.order_ea.value=="0" ) {
    alert("Please enter a number that you want to purchase.");
    frm.order_ea.focus();
    return false; 
  }
  
  if (option_a) {
    if (option_a.value=="") {
      alert("Please select Birth Stone that you want to purchase.");
      return false;
    }
  }
  
  if (option_b) {
    if (option_b.value=="") {
      alert("Please enter Initial Name that you want to purchase.");
      return false;
    }  
  }
  
  if (option_c) {
    if (option_c.value=="") {
      alert("Please select Metal Type/Color that you want to purchase.");
      return false;
    }    
  }
  
  if (option_d) {
    if (option_d.value=="") {
      alert("Please select Diamond/No Diamond that you want to purchase.");
      return false;
    }    
  }
  
  if (option_f) {
    if (option_f.value=="") {
      alert("Please select Length that you want to purchase.");
      return false;
    }    
  }
  
  if (option_g) {
    if (option_g.value=="") {
      alert("Please select Initial that you want to purchase.");
      return false;
    }    
  }
  
  if (option_h) {
    if (option_h.value=="") {
      alert("Please select Ring size that you want to purchase.");
      return false;
    }    
  }
  
  if (option_i) {
    if (option_i.value=="") {
      alert("Please select Metal Color that you want to purchase.");
      return false;
    }    
  }
  
	alert('You have been Log-Out. Please Log-In again.');
	frm.mode.value="order";
	window.open("pop_product_order.asp","pop","width=550,height=500,scrollbars=no");
	frm.target="pop";
	frm.action="pop_product_order.asp";
	frm.submit();

  //parent.act.location.href="/util/shoppingorder.asp?pro_code="+val+"&cart_ea="+frm.order_ea.value;
  
}

function cartcheck(){
//Compare List¿¡ ´ã±â    
   	alert('You have been Log-Out. Please Log-In again.');
	window.open("/login/pop_login.asp?mode=order","pop","width=550,height=500,scrollbars=no");

}


function shoppingCart() {
//¼îÇÎÄ«Æ®¿¡ ´ã±â 
  var frm = document.form1;
  
  var option_a = document.getElementById("option1");
  var option_b = document.getElementById("option2");
  var option_c = document.getElementById("option3");
  var option_d = document.getElementById("option4");
  var option_e = document.getElementById("option5");
  var option_f = document.getElementById("option6");
  var option_g = document.getElementById("option7");
  var option_h = document.getElementById("option8");
  var option_i = document.getElementById("option9");  
  
  if (frm.order_ea.value==""  || frm.order_ea.value=="0") {
    alert("Please enter a number that you want to purchase.");
    frm.order_ea.focus();
    return false; 
  }
  
  if (option_a) {
    if (option_a.value=="") {
      alert("Please select Birth Stone that you want to purchase.");
      return false;
    }
  }
  
  if (option_b) {
    if (option_b.value=="") {
      alert("Please enter Initial Name that you want to purchase.");
      return false;
    }  
  }
  
  if (option_c) {
    if (option_c.value=="") {
      alert("Please select Metal Type/Color that you want to purchase.");
      return false;
    }    
  }
  
  if (option_d) {
    if (option_d.value=="") {
      alert("Please select Diamond/No Diamond that you want to purchase.");
      return false;
    }    
  }
  
  if (option_f) {
    if (option_f.value=="") {
      alert("Please select Length that you want to purchase.");
      return false;
    }    
  }
  
  if (option_g) {
    if (option_g.value=="") {
      alert("Please select Initial that you want to purchase.");
      return false;
    }    
  }
  
  if (option_h) {
    if (option_h.value=="") {
      alert("Please select Ring size that you want to purchase.");
      return false;
    }    
  }
  
  if (option_i) {
    if (option_i.value=="") {
      alert("Please select Metal Color that you want to purchase.");
      return false;
    }    
  }
  
  frm.target="act";
  frm.action="/util/shoppingcart.asp";
  frm.submit();
  
}

function wishList(val) {
//À§½Ã ¸®½ºÆ®¿¡ ´ã±â    
    location.href="/util/wishlist.asp?pro_code="+val;
  
}

function compareList(val) {
//Compare List¿¡ ´ã±â    
    act.location.href="/util/comparelist.asp?pro_code="+val;
}




/*
±â´É : ¹®ÀÚÀÇ ¼ýÀÚ¿©ºÎ Check
»ç¿ë¹ý : isNumber(val)
*/
function isNumber(val)
{

	if(val.length == 0)
		return false;
	
	for(var i=0; i<val.length; i++){
		if(!('0' <= val.charAt(i) && val.charAt(i) <= '9')) 
			return false;
	}
	return true;

}


/*
±â´É : ¹®ÀÚÀÇ ¼ýÀÚ¿©ºÎ(¼Ò¼ýÁ¡Æ÷ÇÔ) Check
»ç¿ë¹ý : isDecimal(val)
*/
function isDecimal(val)
{

	if(val.length == 0)
		return false;
	//&& (parseInt(val.indexOf("."))<0 || (parseInt(val.length) - parseInt(val.indexOf(".")+1))<=2)
    if(isFinite(val)){ 
    	if(parseInt(val.indexOf("."))<0) return true;
    	else if ((parseInt(val.length) - parseInt(val.indexOf(".")+1))<=2) return true;
    	else return false;
    }else{
		return false;
	}
}


/**
 * ¼Ò¼öÁ¡ ¾Æ·¡ ¸îÀÚ¸® ÀÌÇÏ Àý»è.
 *
 * @param num ¼ýÀÚ
 * @param place ÀÚ¸®¼ö
 * @return Àý»èµÈ ¼ýÀÚ
 */
function getCutNumber(num, place) {
 return Math.floor( num * Math.pow(10,parseInt(place,10)) ) / Math.pow(10,parseInt(place,10)); 
}

/**
 * »óÇ° View ÆäÀÌÁö ÀÌ¹ÌÁö ·Îµå 
 *
 */
function clickshow(str)	{
	for (i=0;i<3;i++) {
	  imgch=eval("document.mainimg");	 				
		
	  imgch.src='/upload/product/'+str;
		
	}
}



function at(){
 alert("a")
}

