/***
1. checkbox ¸ðµÎ Ã¼Å©/Ãë¼Ò
2. checkbox Ã¼Å© °¹¼ö ±¸ÇÏ±â
3. ¿µ¹®°ú ¼ýÀÚ·Î¸¸ ±¸¼ºµÈ ¹®ÀÚ¿­ Ã¼Å©
4. ¼ýÀÚ·Î¸¸ ±¸¼ºµÈ ¹®ÀÚ¿­ Ã¼Å©
5. ÇÑ±Û·Î¸¸ ±¸¼ºµÈ ¹®ÀÚ¿­ Ã¼Å©
6. ÆäÀÌÁö ÀÌµ¿
7. ¹®ÀÚ¿­ÀÇ ¾çÂÊ(¿ÞÂÊ, ¿À¸¥ÂÊ) °ø¹é Á¦°Å > Return : °ø¹éÁ¦°ÅÈÄ ¹®ÀÚ
8. À¯´ÏÆû °ßÀû¼­ ÁÖ¹®»óÇ° ÀÌ¹ÌÁöÁ¤º¸ º¸±â
9. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® º¸±â
10. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® ·¹ÀÌ¾î °¡Á®¿À±â
11. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® ajaxÀ¸·Î ·¹ÀÌ¾î »ý¼ºÇÏ±â
12. 3Â÷ Ä«Å×°í¸® ·¹ÀÌ¾î Y À§Ä¡ ¹× ³ôÀÌ ¼³Á¤ÇÏ±â
13. °¡¿îµ¥ »ó´Ü Ä«Å×°í¸® ¸¶¿ì½º ¿À¹ö½Ã
14. °¡¿îµ¥ »ó´Ü Ä«Å×°í¸® ¸¶¿ì½º ¾Æ¿ô½Ã
15. ÇÑ°³ÀÇ ¹®ÀÚ Ã£¾Æ³»±â ¾øÀ¸¸é 0À» ¸®ÅÏ
16. »ó´Ü ÀüÃ¼Ä«Å×°í¸® ¹öÆ°¿¡ ¸¶¿ì½º ·Ñ¿À¹ö
17. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® Áß 2Â÷ Ä«Å×°í¸® ¸¶¿ì½º¿À¹ö½Ã 3,4Â÷ Ä«Å×°í¸® ajax ·Î »ý¼ºÇÏ±â
18. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® Áß 2Â÷ Ä«Å×°í¸® ¸¶¿ì½º¿À¹ö½Ã 3,4Â÷ Ä«Å×°í¸® ·¹ÀÌ¾î °¡Á®¿À±â
19. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® Áß 2Â÷ Ä«Å×°í¸® ¸¶¿ì½º ¿À¹ö½Ã 3,4 Ä«Å×°í¸® ·¹ÀÌ¾î º¸ÀÌ±â/¾Èº¸ÀÌ±â
20. ÀÚ¸®¼ö°¡ ¸ÂÀ¸¸é ´ÙÀ½°³Ã¼·Î ÀÌµ¿
21. ÇØ´ç ¸µÅ©·Î ÆäÀÌÁö ÀÌµ¿, Ã¢´Ý±â°¡ ÀÖÀ¸¸é ºÎ¸ðÆäÀÌÁö·Î ¸µÅ©ÆäÀÌÁö·Î ÀÌµ¿
22. ¼¼ÀÚ¸®¸¶´Ù ÄÞ¸¶Âï±â
***/

// 1. ÇØ´ç ÆäÀÌÁöÀÇ checkbox ¸ðµÎ Ã¼Å©/Ãë¼Ò(n_frm : form name / n_chk : checkbox name / v_val : checkbox.checked)
function allCheck(n_frm, n_chk, v_val){
	var frm=document.getElementById(n_frm);
	var chkBox=frm.getAttribute(n_chk);
	var chkLen=chkBox.length;
//	alert("chkLen : "+chkLen+" / v_val : "+v_val);
	if(chkBox){
		if(chkLen){	//--´Ù¼öÀÏ °æ¿ì
			for(i=0; i<chkLen; i++){
				chkBox[i].checked=v_val;
			}
		}
		else{	//--ÇÑ°³ÀÏ °æ¿ì
			chkBox.checked=v_val;
		}
	}
}

// 2. ÇØ´ç ÆäÀÌÁöÀÇ checkbox Ã¼Å© °¹¼ö ±¸ÇÏ±â/Ãë¼Ò(n_frm : form name / n_chk : checkbox name)
function allCheckCnt(n_frm, n_chk){
	var frm=document.getElementById(n_frm);
	var chkBox=frm.getAttribute(n_chk);
	var chkLen=chkBox.length;
	var chkCnt=0
//	alert("chkLen : "+chkLen+");
	if(chkBox){
		if(chkLen){	//--´Ù¼öÀÏ °æ¿ì
			for(i=0; i<chkLen; i++){
				if(chkBox[i].checked){
					chkCnt++;
				}
			}
		}
		else{	//--ÇÑ°³ÀÏ °æ¿ì
			if(chkBox.checked){
				chkCnt++;
			}
		}
	}
	return chkCnt;
}

// 3. ¿µ¹®°ú ¼ýÀÚ·Î¸¸ ±¸¼ºµÈ ¹®ÀÚ¿­ Ã¼Å©
function abc_num_charCheck(v_string){
	if (v_string.length <= 3 || v_string.length >= 20){
		return true;
	}
	Counter = 0;
	for (i = 0; i < v_string.length; i++){
		if ((v_string.charAt(i) < '0' || v_string.charAt(i) > '9') && (v_string.charAt(i) < 'a' || v_string.charAt(i) > 'z')
			&& (v_string.charAt(i) < 'A' || v_string.charAt(i) > 'Z')	&& v_string.charAt(i) != '-' && v_string.charAt(i) != '_'){
			Counter++;
		}
	}
		
	if (Counter > 0){
		return true;
	}
}

// 4. ¼ýÀÚ·Î¸¸ ±¸¼ºµÈ ¹®ÀÚ¿­ Ã¼Å©
function numeric_charCheck(v_num){
    cnt = 0;
	v_num = v_num.replace("+", "");
	v_num = v_num.replace("-", "");
	for (i = 0; i < v_num.length; i++){
		if (v_num.charAt(i) < '0' || v_num.charAt(i) > '9'){
			return true;
		}
		cnt++;
	}
}

// 5. ÇÑ±Û·Î¸¸ ±¸¼ºµÈ ¹®ÀÚ¿­ Ã¼Å©
function kor_charCheck(v_string){
	for (i = 0; i < v_string.length; i++)
		if (v_string.charAt(i) < '°¡' || v_string.charAt(i) > 'Èþ'){
			return true;
		}     
}

// 6. ÆäÀÌÁö ÀÌµ¿
function goto_page(v_page){
	var frm = document.pageFrm;

	if(frm.act_url) frm.action=frm.act_url.value;
	if(frm.act_target) frm.target=frm.act_target.value;
	if(frm.act_method) frm.method=frm.act_method.value;

	frm.page.value = v_page;
	frm.submit();
}

// 7. ¹®ÀÚ¿­ÀÇ ¾çÂÊ(¿ÞÂÊ, ¿À¸¥ÂÊ) °ø¹é Á¦°Å > Return : °ø¹éÁ¦°ÅÈÄ ¹®ÀÚ
function trim_side(pstr){
	var search = 0
	while (pstr.charAt(search) == " "){
		search = search + 1
	}
	pstr = pstr.substring(search, (pstr.length))
	search = pstr.length - 1
	while (pstr.charAt(search) ==" "){
		search = search - 1
	}
	return pstr.substring(0, search + 1)         
}

// 8. À¯´ÏÆû °ßÀû¼­ ÁÖ¹®»óÇ° ÀÌ¹ÌÁöÁ¤º¸ º¸±â
function get_goods_view(v_g_idx, v_oes_idx){
	var oes_idx_chk = 0;
	var strScript;
	
	if(v_oes_idx != 0){
		oes_idx_chk = 1;
	}
	strScript = "/goods/zoom.asp?num="+v_g_idx+"&oes_idx_chk="+oes_idx_chk;
	window.open(strScript, "zoom", "height=546,width=700,left=0,top=0,scrollbars=no,toolbar=0,location=0,directories=0,status=0,menubar=0,copyhistory=0");
}

// 9. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® º¸±â
var v_pageCode = ""
function get_all_cate_out(v_id){
	var cate_obj = document.getElementById(v_id).style

	if(document.getElementById("divMainMenuLayer")){
		document.getElementById("divMainMenuLayer").style.display = "none";
	}
	if(document.getElementById("div_cate2")){
		document.getElementById("div_cate2").style.display = "none";
	}
	if(document.getElementById("div_cate3")){
		document.getElementById("div_cate3").style.display = "none";
	}
	if(document.getElementById("div_cate4")){
		document.getElementById("div_cate4").style.display = "none";	//-- 4Â÷ Ä«Å×°í¸® ·¹ÀÌ¾î ´Ý±â
	}
	if(document.getElementById("div_cate3_main")){
		document.getElementById("div_cate3_main").style.display = "none";	//-- main.aspÀÇ 3Â÷ Ä«Å×°í¸® ·¹ÀÌ¾î ´Ý±â
	}
	if(document.getElementById("div_cate4_main")){
		document.getElementById("div_cate4_main").style.display = "none";	//-- main.aspÀÇ 4Â÷ Ä«Å×°í¸® ·¹ÀÌ¾î ´Ý±â
	}

	if(cate_obj.display == "none"){
		cate_obj.display = "block";
		if(v_pageCode == "main"){
			document.getElementById("btn_all_cate_img").src = "/images/common/btn_all_cate_close.gif"
		}
		else{
			document.getElementById("btn_all_cate_img").src = "/images/common/btn_all_cate_close_1.gif"
		}
	}
	else{
		cate_obj.display = "none";
		if(v_pageCode == "main"){
			document.getElementById("btn_all_cate_img").src = "/images/common/btn_all_cate_view.gif"
		}
		else{
			document.getElementById("btn_all_cate_img").src = "/images/common/btn_all_cate_open_1.gif"
		}
	}
}

// 10. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® ·¹ÀÌ¾î °¡Á®¿À±â
function get_all_cate_info(v_id){
	var cate_obj;
	
	cate_obj = document.getElementById(v_id);
	cate_obj.innerHTML = XMLStr;
}

// 11. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® ajaxÀ¸·Î ·¹ÀÌ¾î »ý¼ºÇÏ±â
function set_all_cate_ajax(v_id){
	var str_fnc;
	str_fnc = "get_all_cate_info('"+ v_id +"')";
	if(document.getElementById(v_id).style.display == "none"){
		setXML_load_post("/lib/class/cate_all_ajax.asp", str_fnc);
	}
}

// 12. 3Â÷ Ä«Å×°í¸® ·¹ÀÌ¾î Y À§Ä¡ ¹× ³ôÀÌ ¼³Á¤ÇÏ±â
function set_cate3_obj_top_height(v_obj, v_top, v_height){
	if(parseInt(v_top, 10) != 0){
		v_obj.style.top = v_top;
	}
	else{
		v_obj.style.top = 0;
	}
	
	if(parseInt(v_height, 10) != 0){
		v_obj.style.height = v_height;
	}
	else{
		v_obj.style.height = 660;
	}

	return;
}

// 13. °¡¿îµ¥ »ó´Ü Ä«Å×°í¸® ¸¶¿ì½º ¿À¹ö½Ã
function a_gray_color_over(v_obj, v_color){
	v_obj.style.backgroundColor = v_color;
	v_obj.style.color = "#ffffff";
	v_obj.style.textDecoration = "none";
}

// 14. °¡¿îµ¥ »ó´Ü Ä«Å×°í¸® ¸¶¿ì½º ¾Æ¿ô½Ã
function a_gray_color_out(v_obj, v_color){
	v_obj.style.backgroundColor = v_color;
	v_obj.style.color = "";
	v_obj.style.textDecoration = "none";
}

// 15. ÇÑ°³ÀÇ ¹®ÀÚ Ã£¾Æ³»±â ¾øÀ¸¸é 0À» ¸®ÅÏ
function inStr(v_str, search_str){
	for(i==0; i < v_str.length; i++){
		if(v_str.charAt(i) == search_str){
			return 1;
		}
	}
	return 0;
}

// 16. »ó´Ü ÀüÃ¼Ä«Å×°í¸® ¹öÆ°¿¡ ¸¶¿ì½º ·Ñ¿À¹ö
function chg_all_cate_view_img(){	
	if(v_chk == 1){
		document.getElementById("categorylayermenu").src = "/images/common/btn_all_cate_view_over.gif"
	}
	else{
		if(divMainMenuLayer){
			document.getElementById("categorylayermenu").src = "/images/common/btn_all_cate_view_over.gif"
		}
		else{
			document.getElementById("categorylayermenu").src = "/images/common/btn_all_cate_view_1.gif"
		}
	}
}

// 17. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® Áß 2Â÷ Ä«Å×°í¸® ¸¶¿ì½º¿À¹ö½Ã 3,4Â÷ Ä«Å×°í¸® ajax ·Î »ý¼ºÇÏ±â
function set_all_cate_sub_ajax(rq_one, rq_two){
	var str_fnc;
	str_fnc = "get_all_cate_sub_info("+ rq_one +","+ rq_two +")";
	setXML_load_post("/lib/class/cate_all_sub_ajax.asp?one="+ rq_one +"&two="+ rq_two, str_fnc);
}

// 18. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® Áß 2Â÷ Ä«Å×°í¸® ¸¶¿ì½º¿À¹ö½Ã 3,4Â÷ Ä«Å×°í¸® ·¹ÀÌ¾î °¡Á®¿À±â
function get_all_cate_sub_info(rq_one, rq_two){
	var cate_obj;
	cate_obj = document.getElementById("div_all_cate_sub");
	cate_obj.innerHTML = XMLStr;
	get_all_cate_sub_out(1);
	cate_obj.style.left = 20;
	cate_obj.style.width = 745;

	if(rq_one == 1){	//-- ±¸±âÁ¾¸ñ¤ýÀ°»ó
		cate_obj.style.top = 88;
		if(rq_two == 9 || rq_two == 10 || rq_two == 11) cate_obj.style.left = 150;	//-- ·°ºñ¡¤¹Ì½ÄÃà±¸¡¤ÇÏÅ°¡¤ÇÃ·Î¾îº¼, °ÔÀÌÆ®º¼, À°»ó
		if(rq_two == 2){	//-- Á·±¸
			cate_obj.style.height = 370;
		}
		else if(rq_two == 5){	//-- ¹è±¸
			cate_obj.style.height = 320;
		}
		else if(rq_two == 6){	//-- ÇÚµåº¼
			cate_obj.style.height = 310;
		}
		else if(rq_two == 8){	//-- º¼¸µ
			cate_obj.style.height = 200;
		}
		else if(rq_two == 9){	//-- ·°ºñ
			cate_obj.style.height = 500;
		}
		else if(rq_two == 10){	//-- °ÔÀÌÆ®º¼
			cate_obj.style.height = 460;
		}
		else{
			cate_obj.style.height = 600;
		}
	}
	else if(rq_one == 2){ //-- ¶óÄÏ½ºÆ÷Ã÷
		cate_obj.style.top = 128;
		if(rq_two == 2){	//-- º£µå¹ÎÅÏ
			cate_obj.style.height = 530;
		}
		else if(rq_two == 4){	//-- ½ºÄõ½Ã
			cate_obj.style.height = 290;
		}
		else{
			cate_obj.style.height = 600;
		}
	}
	else if(rq_one == 3){	//-- ¹«¼ú¤ý°ÝÅõ±â
		cate_obj.style.top = 169;
		if(rq_two == 2){	//-- ÅÂ±Çµµ
			cate_obj.style.height = 310;
		}
		else{
			cate_obj.style.height = 600;
		}
	}
	else if(rq_one == 4){	//-- Çï½º¤ý·¹Á®¤ýÀÍ½ºÆ®¸²
		cate_obj.style.top = 211;
		if(rq_two == 1){	//-- Çï½º±â±¸
			cate_obj.style.height = 390;
		}
		else if(rq_two == 2){	//-- Çï½ºº¸ÃæÁ¦
			cate_obj.style.height = 170;
		}
		else if(rq_two == 3){	//-- ¿ä°¡
			cate_obj.style.height = 460;
		}
		else if(rq_two == 4){	//-- µî»ê
			cate_obj.style.height = 360;
		}
		else if(rq_two == 7){	//-- ³¬½Ã
			cate_obj.style.height = 290;
		}
		else if(rq_two == 5){	//-- ÀÚÀü°Å
			cate_obj.style.height = 430;
		}
		else if(rq_two == 6){	//-- ÀÎ¶óÀÎ½ºÄÉÀÌÆ®
			cate_obj.style.height = 480;
		}
		else{
			cate_obj.style.height = 600;
		}
	}
	else if(rq_one == 5){	//-- °Ç°­¤ýÀÇ·á¤ý½ÅÃ¼ÃøÁ¤
		cate_obj.style.top = 252;
		if(rq_two == 2){	//-- ÀÇ·á¿ëÇ°
			cate_obj.style.height = 350;
		}
		else{
			cate_obj.style.height = 600;
		}
	}
	else if(rq_one == 6){	//-- °èÀý½ºÆ÷Ã÷
		cate_obj.style.top = 293;
		if(rq_two == 4){	//-- ¼ö»ó½ºÆ÷Ã÷
			cate_obj.style.height = 420;
		}
		else{
			cate_obj.style.height = 600;
		}
	}
	else if(rq_one == 7){	//-- ±âÅ¸½ºÆ÷Ã÷
		cate_obj.style.top = 334;
		if(rq_two == 4 || rq_two == 5 || rq_two == 6) cate_obj.style.left = 150;	//-- ÇÃ¶óÀ×µð½ºÅ©, ÆÐ·¯±Û¶óÀÌµù, ½Â¸¶
		if(rq_two == 1){	//-- ¾ç±Ã
			cate_obj.style.height = 460;
		}
		else if(rq_two == 3){	//-- ¾¾¸§
			cate_obj.style.height = 510;
		}
		else if(rq_two == 4){	//-- ÇÃ¶óÀ×µð½ºÅ©
			cate_obj.style.height = 250;
		}
		else if(rq_two == 5){	//-- Æä·¯±Û¶óÀÌµù
			cate_obj.style.height = 70;
		}
		else if(rq_two == 6){	//-- ½Â¸¶
			cate_obj.style.height = 300;
		}
		else{
			cate_obj.style.height = 600;
		}
	}
	else if(rq_one == 8){	//-- ÇÐ±³¿ëÇ°¤ýÃ¼À°½Ã¼³
		cate_obj.style.top = 374;
		if(rq_two == 5 || rq_two == 4 || rq_two == 6) cate_obj.style.left = 150;	//-- ±³±¸¤ý°¡±¸, ¿î¹ÝÂ÷¤ýÁ¤¸®´ë, Á¤¿ø¿ëÇ°¤ýÆæ¼Ç¿ëÇ°
		if(rq_two == 7){	//-- ±³À°¿ë¾Ç±â¡¤ÀüÅë¾Ç±â¡¤¼ÒÇ°
			cate_obj.style.width = 770;
			cate_obj.style.left = 114;
		}
		
		if(rq_two == 8){	//-- ´º½ºÆ÷Ã÷
			cate_obj.style.height = 600;
		}
		else if(rq_two == 3){	//-- ½ºÆ÷Ã÷¸ÅÆ®
			cate_obj.style.height = 460;
		}
		else if(rq_two == 5){	//-- ±³±¸
			cate_obj.style.height = 420;
		}
		else if(rq_two == 4){	//-- ¿î¹ÝÂ÷
			cate_obj.style.height = 400;
		}
		else if(rq_two == 6){	//-- Á¤¿ø¿ëÇ°
			cate_obj.style.top = 393;
			cate_obj.style.height = 250;
		}
		else{
			cate_obj.style.height = 600;
		}
	}
	else if(rq_one == 9){	//-- Æ®·¹ÀÌ´×º¹¤ýÀÇ·ù
		cate_obj.style.top = 432;
		cate_obj.style.height = 600;
	}
	else if(rq_one == 10){	//-- ±âÅ¸¿ëÇ°
		cate_obj.style.top = 473;
		if(rq_two == 1){	//-- ÃÊ½Ã°è
			cate_obj.style.height = 100;
		}
		else if(rq_two == 4){	//-- ±âÅ¸
			cate_obj.style.height = 530;
		}
		else{
			cate_obj.style.height = 600;
		}
	}
	else if(rq_one == 11){	//-- ½ºÆ÷Å¾Á¸
		cate_obj.style.top = 514;
		if(rq_two == 1){	//-- º¹½Ì
			cate_obj.style.height = 530;
		}
		else if(rq_two == 2){	//-- ÅÂ±Çµµ
			cate_obj.style.height = 250;
		}
		else if(rq_two == 3){	//-- °Ëµµ
			cate_obj.style.height = 50;
		}
		else if(rq_two == 4){	//-- ±âÅ¸ÀÇ·ù
			cate_obj.style.height = 180;
		}
		else if(rq_two == 5){	//-- ´Ü·Ã¿ëÇ°
			cate_obj.style.height = 130;
		}
		else if(rq_two == 6){	//-- ±âÅ¸
			cate_obj.style.height = 280;
		}
		else{
			cate_obj.style.height = 600;
		}
	}
	else{
		cate_obj.style.width = 745;
		cate_obj.style.left = 20;
	}
}

//-- 19. »ó´ÜÀÇ ÀüÃ¼ Ä«Å×°í¸® Áß 2Â÷ Ä«Å×°í¸® ¸¶¿ì½º ¿À¹ö½Ã 3,4 Ä«Å×°í¸® ·¹ÀÌ¾î º¸ÀÌ±â/¾Èº¸ÀÌ±â
var a_id_cate2 = "";	//-- »ó´Ü ÀüÃ¼ Ä«Å×°í¸®ÀÇ 2Â÷ Ä«Å×°í¸® a ÅÂ±×ÀÇ id
function get_all_cate_sub_out(v_chk){
	var cate_obj = document.getElementById("div_all_cate_sub");
	if(v_chk == 1){
		if(cate_obj.style.display == "none"){
			a_gray_color_over(document.getElementById(a_id_cate2), '#FC6D18');
			cate_obj.style.display = "block";
		}
		else{
			a_gray_color_out(document.getElementById(a_id_cate2), '');
			cate_obj.style.display = "none";
		}
	}
	else{
		if(cate_obj.style.display == "block"){
			cate_obj.style.display = "none";
		}
		a_gray_color_out(document.getElementById(a_id_cate2), '');
		cate_obj.style.display = "none";
	}
}

// 20. ÀÚ¸®¼ö°¡ ¸ÂÀ¸¸é ´ÙÀ½°³Ã¼·Î ÀÌµ¿
function moveFocus(v_obj1, v_cnt, v_obj2){
	if(v_obj1.value.length == v_cnt){
		v_obj2.focus();
	}
}

// 21. ÇØ´ç ¸µÅ©·Î ÆäÀÌÁö ÀÌµ¿, Ã¢´Ý±â°¡ ÀÖÀ¸¸é ºÎ¸ðÆäÀÌÁö·Î ¸µÅ©ÆäÀÌÁö·Î ÀÌµ¿
function goPage(rq_url, rq_win_colse){	
	if(rq_win_colse == 1){
		opener.location.href = rq_url;
		self.close();
	}
	else{
		location.href = rq_url;
	}
}

// 22. ¼¼ÀÚ¸®¸¶´Ù ÄÞ¸¶Âï±â
function get_comma_price(v_price){
	var comma_cnt = 3;	//--ÀÚ¸®¼ö
	
    var str = new Array(); 
    v_price = String(v_price); 
	for(var i=1; i<=v_price.length; i++){ 
		if(i%comma_cnt){
			str[v_price.length-i] = v_price.charAt(v_price.length-i); 
		}
		else{
			str[v_price.length-i] = "," + v_price.charAt(v_price.length-i);
		}
	}
	
	return str.join("").replace(/^,/,""); 
}

