function PreviewImage(no) 
{

	var oInput = event.srcElement;
	var fname = oInput.value;
	var tImg = eval("document."+oInput.name+"_pre");
	if(!(/(.jpg|.jpeg)$/i).test(fname))
	{
	  alert('ÀÌ¹ÌÁö´Â jpg ÆÄÀÏ¸¸ °¡´ÉÇÕ´Ï´Ù.');
	  return false;
	}
	
	tImg.src = fname;
	
	var blankImgUrl = "./img/blank"+no+"_80.gif";	
	return true;
}

//Á¦Ç°µî·Ï½Ã 

function chk(){
theform=document.form;
if(theform.prd_name.value==false){
alert("Á¦Ç°¸íÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
theform.prd_name.focus();
return false;
}
if(theform.cate_name.value==false){
alert("ºÐ·ù¸¦ ¼±ÅÃÇÏ¼¼¿ä.");
theform.cate_name.focus();
return false;
}
if(theform.ufile_1.value==false){
alert("´ëÇ¥ÀÌ¹ÌÁö¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
theform.ufile_1.focus();
return false;
}
s_count=form.color.options.length;
c_val='';
for(k=1;k<s_count;k++){ 
c_val=c_val+form.color.options[k].text+'|';
}
theform.color_val.value=c_val;
theform.submit();
}

function e_chk(){//¼öÁ¤
theform=document.form;
if(theform.prd_name.value==false){
alert("Á¦Ç°¸íÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
theform.prd_name.focus();
return false;
}
if(theform.cate_name.value==false){
alert("ºÐ·ù¸¦ ¼±ÅÃÇÏ¼¼¿ä.");
theform.cate_name.focus();
return false;
}
if(theform.oufile_1.value==false){
	if(theform.ufile_1.value==false){
alert("´ëÇ¥ÀÌ¹ÌÁö¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
theform.ufile_1.focus();
return false;
}
}
s_count=form.color.options.length;
c_val='';
for(k=1;k<s_count;k++){ 
c_val=c_val+form.color.options[k].text+'|';
}
theform.color_val.value=c_val;
theform.submit();
}


//»ö»ó ¼¿·ºÆ® ¹Ú½º Ãß°¡ »èÁ¦ ½ºÅ©¸³Æ®
function sel_plus() 
{ 
co=form.color.options.length;
p_cl=form.sel01.selectedIndex; 
cl=form.sel01.options[p_cl].text; 

p_cv=cl+'-'+form.text01.value;
cv=new Option(p_cv);
form.color.options[co]=cv;

} 

function sel_del() 
{ 
co=form.color.selectedIndex+1;

for(i=0;i<co;i++){ 
if(form.color.options[i].selected);
form.color.options[i]=null;
} 
} 
//µî·Ï Ã¼Å©


//ÇÊµå Ãß°¡ ÆäÀÌÁö¿¡ ¾²ÀÌ´Â ½ºÅ©¸³Æ®
function plus_field(){
location.href="field_write.php";
}

function field_wgo(){
theform=document.form;
if(theform.field_name.value==false){
alert("Ç×¸ñÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä.");
theform.field_name.focus();
return false;
}
if(theform.ofield.value==false){
alert("Ä®·³¸íÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
theform.ofield.focus();
return false;
}
if(theform.field_type.value==false){
alert("µ¥ÀÌÅ¸ÇüÀ» ¼±ÅÃÇÏ¼¼¿ä.");
theform.field_type.focus();
return false;
}
if(theform.field_type.value!="text"){
	if(theform.field_len.value==false){
	alert("µ¥ÀÌÅ¸ ±æÀÌ¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
	theform.field_len.focus();
	return false;
	}
}
theform.submit();
}

function field_lgo(){
location.href="field_list.php";
}

function edit_field(fname,ftype,flen){
location.href="field_write.php?mode=edit&old_ofield="+fname+"&old_ftype="+ftype+"&old_flen="+flen;
}

function del_field(fname){
	vn_con = confirm('Ä®·³À» »èÁ¦ÇÏ½Ã¸é ÇØ´ç µ¥ÀÌÅ¸µµ ÇÔ²² »èÁ¦ µË´Ï´Ù.\nÁ¤¸» »èÁ¦ ÇÏ½Ã°Ú½À´Ï±î?');
	 if ( vn_con == true  )
	 {
	location.href="field_write_act.php?mode=del&ofield="+fname;
	}

}

//ÀÌµ¿,»èÁ¦,¼öÁ¤ µî ÇÔ¼ö
function write_go(){
document.form.action="product_write.php";
document.form.submit();
}
function view_go(idx){
document.form.action="product_view.php?idx="+idx;
document.form.submit();
}
function edit_go(idx){
document.form.action="product_edit.php?idx="+idx;
document.form.submit();
}
function del_go(idx){
	vn_con = confirm('ÀÌ Á¦Ç°À» »èÁ¦ ÇÏ½Ã°Ú½À´Ï±î?');
	 if ( vn_con == true  )
	 {
	document.form.action="product_del.php?idx="+idx;
	document.form.submit();
	}

}
function list_go(){
document.form.action="product_list.php";
document.form.submit();
}

///////////////////////////
	//Ã¼Å©¹Ú½º ¼±ÅÃ ÇÏ±â
//////////////////////////
function allcheck(theform)
{
	var check_box=theform["check[]"]; 
	if(!check_box)
	{
	alert('°ªÀÌ ¾ø½À´Ï´Ù.');
	    return false;
	}
	for(var i=0; i<check_box.length;i++)
	{
		var ele = check_box[i];
		if(ele.checked == false)
		{
			ele.checked = true;
		}	
	}
	return;
}

//¼±ÅÃÃë¼Ò
function discheck(theform)
{
	for( var i=0; i<theform.elements.length; i++) 
	{
		var ele = theform.elements[i];
		if(ele.name == 'check[]')
			ele.checked = false;
	}
	return;
}


//¼±ÅÃºÎºÐ ¹ÝÀü
function invert_check(theform)
{
	for( var i=0; i<theform.elements.length; i++) 
	{
		var ele1 = theform.elements[i];
		if(ele1.name == 'check[]')
		{
			if(ele1.checked == true)
			{
				ele1.checked = false;
			} 
			else 
			{
				ele1.checked = true;
			}
		}
		
	}
	return;
}


/////////////¼±ÅÃ±Û »èÁ¦

function delall(theform)
 { 
var check_box=theform["check[]"]; 
	
		for(var i=0; i<check_box.length;i++)
		{
			var ele = check_box[i];
			if(ele.checked == true)	break;		
		}
	if(i==check_box.length)
		{
			alert('¼±ÅÃÀ» ÇÏÁö ¾ÊÀ¸¼Ì½À´Ï´Ù.');
			return;
		}
 else 
   {
     if(confirm("¼±ÅÃµÈ Á¦Ç°ÀÌ Áö¿öÁý´Ï´Ù."))
	  {
	  theform.action="select_all_del_ok.php";
      theform.submit();
	  }
	 else
	  {
		
     location.href="#";  
	  }
   }
 } 

 //À¯Àú¸ðµå ÀÌ¹ÌÁö º¯°æÁ¦¾î

function img_chg(fname,i){//ÅÇ¹× ÀÌ¹ÌÁöÁ¦¾î
document.getElementById("vimg1").src="../data/product/"+fname+"_"+i+"_L.jpg";
}

//ÁÖ¹®°ü·Ã ½ºÅ©¸³Æ®
function order_go(o_idx){
document.form.o_idx.value=o_idx;
document.form.v_idx.value=o_idx;
document.form.action="products.php?#order";
document.form.submit();
}

function forder_go(color_yn){
if(confirm("Please re-check the MOQ.\nOtherwise it doesn¡¯t proceed properly.")){
	theform=document.form;
	if(color_yn=="YES"){
		if(theform.color.value==false){
			alert('Select color!');
			theform.color.focus();
			return false;
		}
	}
	if(theform.quantity.value==false){
			alert('Input the quantity!');
			theform.quantity.focus();
			return false;
	}
		if (isNaN(theform.quantity.value)) {//¼ýÀÚÀÎ°¡ ºñ±³
			alert("Please fill in numbers only");        
			theform.quantity.focus();
			return false;
      
	}

theform.action="../product/forder_act.php";
theform.submit();
}
}

function order_edit(o_idx,num,color_yn){
	theform=document.form;

	if(confirm("Do you want to modify?")){
	theform.action="products.php?ed_idx="+o_idx+"#order";
	inq=document.getElementById("quantity_"+num).value;
	theform.ed_q.value=inq;

	if(theform.ed_q.value==false){
			alert('Input the quantity!');
			return false;
	}
	
		if (isNaN(theform.ed_q.value)) {//¼ýÀÚÀÎ°¡ ºñ±³
			alert("Please fill in numbers only");
			return false;
        }

	
	if(color_yn=="YES"){
	inc=document.getElementById("color_"+num).value;
	theform.ed_c.value=inc;

		if(theform.ed_c.value==false){
			alert('Select color!');
			return false;
		}
	}

	theform.submit();
	}

	
}

function order_del(idx){
	theform=document.form;

	if(confirm("Do you want to delete?")){
	theform.action="products.php?del_idx="+idx+"#order";
	theform.submit();
	}

	
}

function allorder_go(){
	theform=document.form;

	if(confirm("Will you place an order for the confirmed items?\nAfter placing an order, it is unable to delete or modify.")){
	theform.action="../product/order_act.php";
	theform.submit();
	}

	
}

function order_alert(){
alert('Your order will be completed after pressing \"confirmed\" button per each item.\nPlease press \"confirmed\" button when you are ready to place an order.');
}



//Ãß°¡ JuNee


//»ó¼¼ÀÌ¹ÌÁö º¸±â
function showBigImg(){
	var url=document.form.Hid_Img.value;
	var w=document.form.Hid_Imgw.value;
	var h=document.form.Hid_Imgh.value;
		if(url==""){
			alert("\n\nNo image\n\n");
		}else{
		var sw=screen.width;
		var sh=screen.height;
		var sc="";
		if(w>sw){
			winw=sw;
			sc="yes";
		}else{
			winw=w;
		}
		if(h>sh){
			winh=sh;
			sc="yes";
		}else{
			winh=h;
		}
		if(sc!="yes"){
			sc="no";
		}

			window.open("./showdata.php?url="+url,"bigImg","width="+winw+",height="+winh+", scrollbars="+sc);
		}
}

//»ó¼¼º¸±â ÀÌ¹ÌÁö ±³Ã¼
function chg_BIG_img(Burl,Lurl,w,h){
	document.form.Hid_Img.value=Burl;
	document.form.Hid_Imgw.value=w;
	document.form.Hid_Imgh.value=h;
	document.all.bigImg.src=Lurl;
}

//Ä®¶óÆÇ º¸±â
function showcolor(){
window.open("./open/color_cart.php","c_view","width=817,height=500,scrollbars=yes");
}

//Ç°ÀýÀÏ¶§
function stock_go(){
alert('This item is out of stock now.');
}

//»ó¼¼ÀÌ¹ÌÁö º¸±â(°ü¸®ÀÚ)
function showBigImg_a(){
	var url=document.form.Hid_Img.value;
		if(url=="") alert("\n\nNo image\n\n");
		else window.open("../../html/showdata.php?url="+url,"bigImg","width="+screen.width+",height="+screen.height+", scrollbars=yes");
}

