/***************************************************************************************
  ÇÁ·Î±×·¥ : View & Link JavaScript
  ÀÛ¾÷ÀÚ : 2005.06.21 bbanga ÃÖÃÊÀÛ¼º

  1. Display °ü·Ã ÇÔ¼ö
   - f_viewDiv(sub_nm)		: Div ºÎºÐÀ» View & HiddenÇÏ´Â ÇÔ¼ö
   - f_viewDiv(sub_nm,flag) : Div ºÎºÐÀ» View & HiddenÇÏ´Â ÇÔ¼ö, Flag µµ ¹ÞÀ½
   - f_checkAll(input)		: checkBox ¸¦ ¸ðµÎ Check/UncheckedÇÏ´Â ÇÔ¼ö
   - f_searchHostShop()		: È£½ºÆÃ¿¡ ¼ÓÇÑ »óÁ¡ID °Ë»ö

	--------------------------------------------
	¼öÁ¤»çÇ×
	- 2008.04.29 damong f_searchHostShop() Ãß°¡
	- 2009.08.20 jungah alert()À» f_alert()À¸·Î ¼öÁ¤

***************************************************************************************/  


// 1. Display °ü·Ã ÇÔ¼ö
// Div ºÎºÐÀ» View & HiddenÇÏ´Â ÇÔ¼ö [sub_nm -> Div id]
function f_viewDiv(div_nm) {
	sub_div = eval(div_nm);
	if ( sub_div[0] == undefined ) {
		if ( sub_div.style.display== "none" ) {
			sub_div.style.display = "";
		} else {
			sub_div.style.display = "none";
		}
	} else {
		if ( sub_div[0].style.display== "none") {
			for ( var i=0; i<sub_div.length; i++ )
				sub_div[i].style.display = "";
		} else {
			for ( var i=0; i<sub_div.length; i++ )
				sub_div[i].style.display = "none";
		}
	}
}

// Div ºÎºÐÀ» View & HiddenÇÏ´Â ÇÔ¼ö [sub_nm -> Div id]
function f_viewDivFlag(div_nm, flag) {
	sub_div = eval(div_nm);
	if ( sub_div[0]== undefined ) {
		if ( flag == 1 ) {
			sub_div.style.display = "";
		} else {
			sub_div.style.display = "none";
		}
	} else {
		if ( flag == 1 ) {
			for ( var i=0; i<sub_div.length; i++ )
				sub_div[i].style.display = "";
		} else {
			for ( var i=0; i<sub_div.length; i++ )
				sub_div[i].style.display = "none";
		}
	}
}

// checkBox ¸¦ ¸ðµÎ Check/UncheckedÇÏ´Â ÇÔ¼ö : input (Form name + Form Input Field)
function f_checkAll(input) {
	var field = eval(input);
	
	// ksh Ãß°¡. 
	if (field == undefined) {
		f_alert('Ã¼Å© ´ë»ó Ç×¸ñÀÌ ¾ø½À´Ï´Ù!',300,140);
		return;
	}

	var len = field.length;
	if ( field==undefined || len==0 ) {
		return;
	} if ( len==undefined || len==1 ) {
		if (field.checked == true ) field.checked = false;
		else field.checked = true;
	} if ( len==1 ) {
		if ( field.checked == true ) field.checked = false;
		else field.checked = true;
	} else {
		for ( i=0; i<len; i++) {
			if ( field[i].checked == true ) field[i].checked = false;
			else field[i].checked = true;
		}
	}
}

// checkBox Áß ÇÏ³ª¶óµµ ¼±ÅÃ µÇ¾ú´ÂÁö check ÇÔ¼ö
function f_checkedYn(input) {

	var field = eval(input);

	if( field == undefined ){
		return false;
	} else if( field[0] == undefined ){
		if( field.checked == true ){
			return true;;
		}
	} else {
		for(var i=0 ; i < field.length ; i++ ){
			if( field[i].checked == true ){
				return true;
			}
		}
	}

	return false;
}

// ¿ìÆí¹øÈ£ Ã£±â
function f_searchZip( zip_cd1, zip_cd2, addr1) {
	newWin = window.open("/servlet/AllatBizPop/common/pop_zipcode.jsp", "zip_cd", "width=365, height=400, scrollbars=1");
	window.obj1 = zip_cd1;
	window.obj2 = zip_cd2;
	window.obj3 = addr1;
}

// »ç¾÷ÀÚ¹øÈ£ Áßº¹È®ÀÎ
function f_dupBizNo( obj1, obj2, obj3 ) {
	var business_no = f_trim(obj1.value) + f_trim(obj2.value) + f_trim(obj3.value);
	if( business_no.length != 10 ) {
		f_alert("»ç¾÷ÀÚ¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.", 300, 140, "obj1.focus();");
		return;
	} else {
		if( !f_checkBizNo(business_no) ) {
			f_alert("»ç¾÷ÀÚ¹øÈ£¸¦ Çü½Ä¿¡ ¸Â°Ô ÀÔ·ÂÇÏ¼¼¿ä.", 300, 140, "obj1.focus();");
			return;
		}
	}
	newWin = window.open("/servlet/AllatBizPop/common/pop_bizno.jsp?biz_no1=" + obj1.value + 
			"&biz_no2=" + obj2.value + "&biz_no3=" + obj3.value, "biz_no", "width=350, height=250, scrollbars=0");
	window.obj1 = obj1;
	window.obj2 = obj2;
	window.obj3 = obj3;
}

// ´ëÇ¥»óÁ¡ID Áßº¹È®ÀÎ
function f_dupMainShopId( obj ) {
	if( f_trim(obj.value) == "" ) {
		f_alert("»óÁ¡ID¸¦ ÀÔ·ÂÇÏ¼¼¿ä. ", 300, 140, "obj.focus();");
		return;
	}
	newWin = window.open("/servlet/AllatBizPop/common/pop_main_shopid.jsp?shop_id=" + obj.value,
			 "main_shop_id", "width=350, height=250, scrollbars=0");
	window.obj = obj;
}

// ´ëÇ¥»óÁ¡ID Áßº¹È®ÀÎ È£½ºÆÃ»ç Prefix ÀÌ¿ë
function f_dupMainShopIdPrefix( shopId, hostId ){

    if( shopId.value == ''){
        f_alert("»óÁ¡ID¸¦ ÀÔ·ÂÇÏ¼¼¿ä", 300,140, "shopId.focus();");
        return;
    }

	   newWin = window.open("/servlet/AllatBizPop/common/pop_main_shopid_prefix.jsp?shop_id="+shopId.value+"&host_id="+hostId.value, "main_shop_id_prefix", "width=350, height=250, scrollbars=0");
}

// »óÁ¡ID Áßº¹È®ÀÎ
function f_dupShopId( obj ) {
	if( f_trim(obj.value) == "" ) {
		f_alert("»óÁ¡ID¸¦ ÀÔ·ÂÇÏ¼¼¿ä. ", 300, 140, "obj.focus();");
		return;
	}
	newWin = window.open("/servlet/AllatBizPop/common/pop_shopid.jsp?shop_id=" + obj.value,
			 "shop_id", "width=350, height=250, scrollbars=0");
	window.obj = obj;
}

// ¿î¿µÀÚID Áßº¹È®ÀÎ
function f_dupManagerId( obj ) {
	if( f_trim(obj.value) == "" ) {
		f_alert("¿î¿µÀÚID¸¦ ÀÔ·ÂÇÏ¼¼¿ä. ", 300, 140, "obj.focus();");
		return;
	}
	newWin = window.open("/servlet/AllatBizPop/common/pop_managerid.jsp?manager_id=" + obj.value,
			 "manager_id", "width=350, height=250, scrollbars=0");
	window.obj = obj;
}

// ¼ö¼ö·á Popup
function f_feeAmtView(){
	var url ="/servlet/AllatBizPop/member/shop_pgfee_list.jsp";
	NewWin = open(url,'feeAmtView', 'scrollbars=1, width=758, height=350');
}

// ¼ö¼ö·á Popup(getManagerTypeÀÌ A1ÀÏ ¶§)
function f_feeAmtView_A(){
	var url ="/servlet/AllatBizPop/member/pop_pgfee_list_A.jsp";
	NewWin = open(url,'feeAmtView_A', 'scrollbars=1, width=678, height=350');
}

// ¿µ¼öÁõ Ãâ·Â
function f_printBill( obj ) {
	window.open("","app","width=410,height=650,scrollbars=0");
	obj.action="/servlet/AllatBizPop/member/pop_card_receipt.jsp";
	obj.target="app";
	obj.submit();
}

// È£½ºÆÃ¿¡ ¼ÓÇÑ »óÁ¡ID °Ë»ö
function f_searchHostShop() {
    window.open("/servlet/AllatBizPop/common/pop_host_shop_search.jsp", "host_shop_search",
    "top=10,left=10,width=400,height=420,scrollbars=0");
}

// °í°´¿ë Alert
function f_alert(msg, width, height){
	var w = eval(width);
	var h = eval(height);
	var top = (screen.height/2) - h/2-50;
	var left = (screen.width/2) - w/2;
	var ops = 'width='+w+',height='+h+',top='+top+',left='+left+',scrollbars=0,resizable=0,status=0';
	var url = '/common/alert.jsp?alert_msg='+msg;
	//var obj = window.open(url,'',ops);
	alertWin(url, width,height,top,left,1);
}

