// TOP FLASH MENU **************************************************************
function ClickMenu01()
{
	location.href ="/main.asp??=aboutus/aboutus01";
}
function ClickMenu02()
{
	location.href ="/main.asp??=service/quotation/write";
}
function ClickMenu03()
{
	location.href ="main.asp??=service/oem/write";
}
function ClickMenu04()
{
	location.href ="main.asp??=service/as/write";
}
function ClickMenu05()
{
	location.href ="/main.asp??=customCenter/main";
}

// THEME FLASH MENU ************************************************************
function ClickTheme_01()
{
	location.href ="main.asp??=item_etc/theme/theme01";
}
function ClickTheme_02()
{
	location.href ="main.asp??=item_etc/theme/theme02";
}
function ClickTheme_03()
{
	location.href ="main.asp??=item_etc/theme/theme03";
}
function ClickTheme_04()
{
	location.href ="main.asp??=item_etc/theme/theme04";
}
function ClickTheme_05()
{
	location.href ="main.asp??=item_etc/theme/theme05";
}
function ClickTheme_06()
{
	location.href ="main.asp??=item_etc/theme/theme06";
}



// ¼ýÀÚ¸¸ ÀÔ·Â (INPUT) *********************************************************
function num_only()
{
	if((event.keyCode < 48) || (event.keyCode > 57))
	{
		event.returnValue=false;
	}
}


// ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å© ***********************************************************
function numbercheck(theform)
{
	var chk	= 0;
	var yy	= theform.ssn1.value.substring(0,2);
	var mm	= theform.ssn1.value.substring(2,4);
	var dd	= theform.ssn1.value.substring(4,6);
	var sex	= theform.ssn2.value.substring(0,1);

	// ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å©
	for (var i = 0; i <= 5 ; i++)
	{
		chk = chk + ((i % 8 + 2) * parseInt(theform.ssn1.value.substring(i, i + 1)));
	}
	for (var i = 6; i <= 11 ; i++)
	{
		chk = chk + ((i % 8 + 2) * parseInt(theform.ssn2.value.substring(i - 6, i - 5)));
	}
	chk = 11 - (chk % 11);
	chk = chk % 10;

	if (chk != theform.ssn2.value.substring(6, 7))
	{
		alert ("À¯È¿ÇÏÁö ¾ÊÀº ÁÖ¹Îµî·Ï¹øÈ£ÀÔ´Ï´Ù.");
		theform.ssn1.value = "";
		theform.ssn1.focus();
		return false;
	}

	else if ((theform.ssn1.value.length != 6) || (yy < 25 || mm < 1 || mm >12 || dd < 1))
	{
		alert ("ÁÖ¹Îµî·Ï¹øÈ£°¡ Àß¸øµÇ¾ú½À´Ï´Ù.");
		theform.ssn1.value = "";
		theform.ssn1.focus();
		return false;
	}

	else if ((sex != 1 && sex !=2 )||(theform.ssn2.value.length != 7 ))
	{
		alert ("ÁÖ¹Îµî·Ï¹øÈ£°¡ Àß¸øµÇ¾ú½À´Ï´Ù.");
		theform.ssn2.value = "";
		theform.ssn2.focus();
		return false;
	}

	else
		return true;
}


// ¸ðµ¨ ¼ö·®º¯°æ ***************************************************************
function count_change(temp, no, cart_yn)
{
	// 2°³ ÀÌ»óÀÇ ¸ðµ¨À» °®°í ÀÖ´Ù¸é ¹è¿­·Î Ã³¸®
	if (document.frm.ea.length)
	{
		var ea = document.frm.ea[no].value;
		if(temp == 0){
			ea ++;
		}else if(temp == 1){
			if(ea > 1) ea --;
		}
		document.frm.ea[no].value = ea;
	}
	// ¸ðµ¨ÀÌ ÇÏ³ªÀÏ °æ¿ì
	else
	{
		var ea = document.frm.ea.value;
		if(temp == 0){
			ea ++;
		}else if(temp == 1){
			if(ea > 1) ea --;
		}
		document.frm.ea.value = ea;
	}

	// Àå¹Ù±¸´Ï¿¡¼­ »ç¿ëÇÒ °æ¿ì
	if (cart_yn == 1)
		price_change(ea, no);
}


// Àå¹Ù±¸´Ï °¡°Ýº¯°æ ***********************************************************
function price_change(ea, no)
{
	// 2°³ ÀÌ»óÀÇ ¸ðµ¨À» °®°í ÀÖ´Ù¸é ¹è¿­·Î Ã³¸®
	if (document.frm.ea.length)
	{
		var package_quantity		= document.frm.package_quantity[no].value;
		var package_price			= document.frm.package_price[no].value;
		var array_package_quantity	= package_quantity.split(",");
		var array_package_price		= package_price.split(",");

		if (array_package_quantity.length > 1)
		{
			for (i = array_package_quantity.length - 1; i >= 0; i--)
			{
				if (array_package_quantity[i] <= ea)
				{
					price			= array_package_price[i];
					price_times_ea	= price * ea;
					document.frm.price[no].value = number_format(price) + "¿ø";
					document.frm.price_times_ea[no].value = number_format(price_times_ea) + "¿ø";
					break;
				}
			}
		}
		else if (package_price != 0)
		{
			price_times_ea			= package_price * ea;
			document.frm.price_times_ea[no].value = number_format(price_times_ea) + "¿ø";
		}
	}
	// ¸ðµ¨ÀÌ ÇÏ³ªÀÏ °æ¿ì
	else
	{
		var package_quantity		= document.frm.package_quantity.value;
		var package_price			= document.frm.package_price.value;
		var array_package_quantity	= package_quantity.split(",");
		var array_package_price		= package_price.split(",");

		if (array_package_quantity.length > 1)
		{
			for (i = array_package_quantity.length - 1; i >= 0; i--)
			{
				if (array_package_quantity[i] <= ea)
				{
					price			= array_package_price[i];
					price_times_ea	= price * ea;
					document.frm.price.value = number_format(price) + "¿ø";
					document.frm.price_times_ea.value = number_format(price_times_ea) + "¿ø";
					break;
				}
			}
		}
		else if (package_price != 0)
		{
			price_times_ea			= package_price * ea;
			document.frm.price_times_ea.value = number_format(price_times_ea) + "¿ø";
		}
	}

	price_check();
}


// ÃÑÇÕ ±Ý¾× º¯°æ **************************************************************
function price_check()
{
	var frm = document.frm;
	var sum_price_times_ea = 0;

	// 2°³ ÀÌ»óÀÇ ¸ðµ¨À» °®°í ÀÖ´Ù¸é ¹è¿­·Î Ã³¸®
	if (frm.ea.length)
	{
		for (i = 0; i < frm.ea.length; i++)
		{
			sum_price_times_ea		= sum_price_times_ea + parseInt(frm.price_times_ea[i].value.replace(/,/g, ""));
		}

		if (sum_price_times_ea * 1.1 < 100000)
		{
			shipping_fees			= 3500
			document.all.table_VAT.style.display = "block";
		}
		else
		{
			shipping_fees			= 0
			document.all.table_VAT.style.display = "none";
		}

		frm.sum_price_times_ea.value= number_format(sum_price_times_ea) + "¿ø";
		frm.VAT.value				= number_format(sum_price_times_ea * 0.1) + "¿ø";
		frm.total_order_price.value	= number_format(parseInt(sum_price_times_ea * 1.1 + shipping_fees)) + "¿ø";
	}
	// ¸ðµ¨ÀÌ ÇÏ³ªÀÏ °æ¿ì
	else
	{
		sum_price_times_ea			= parseInt(frm.price_times_ea.value.replace(/,/g, ""));

		if (sum_price_times_ea * 1.1 < 100000)
		{
			shipping_fees			= 3500
			document.all.table_VAT.style.display = "block";
		}
		else
		{
			shipping_fees			= 0
			document.all.table_VAT.style.display = "none";
		}

		frm.sum_price_times_ea.value= number_format(sum_price_times_ea) + "¿ø";
		frm.VAT.value				= number_format(sum_price_times_ea * 0.1) + "¿ø";
		frm.total_order_price.value	= number_format(parseInt(sum_price_times_ea * 1.1 + shipping_fees)) + "¿ø";
	}
}


// ¼ýÀÚÆ÷¸Ë (,) ³Ö±â ***********************************************************
function number_format(number)
{
	unit		= 3;
	i			= 0;
	rst			= '';
	number		= number + '';
	len			= number.length;
	arr			= new Array(len);

	while(i <len){
		arr[i]	= number.charAt(len-i-1);
		rst		= arr[i] + rst;
		i++;
		if(i % unit == 0 && i != len)
			rst	= ',' + rst;
	}
	return rst;
}


// Àå¹Ù±¸´Ï ¼±ÅÃÁÖ¹®/°ßÀû ******************************************************
function get_cartParam(mode, cart_model_idx, no)
{
	var frm = document.frm;

	// 2°³ ÀÌ»óÀÇ ¸ðµ¨À» °®°í ÀÖ´Ù¸é ¹è¿­·Î Ã³¸®
	if (frm.ea.length)
		cart_ea = frm.ea[no].value;
	// ¸ðµ¨ÀÌ ÇÏ³ªÀÏ °æ¿ì
	else
		cart_ea = frm.ea.value;

	location.href = "main.asp??=cart/main&mode=" + mode + "&cart_model_idx=" + cart_model_idx + "&cart_ea=" + cart_ea;
}


// ÁÖ¹®ÇÏ±â (¹Ù·ÎÁÖ¹®/ÀüÃ¼ÁÖ¹®) ************************************************
function cart_buy(cookie_type)
{
	document.frm.action = "main.asp??=cart/buy/buy_step01&cookie_type="+ cookie_type;
	document.frm.submit();
}


// °ßÀû¿äÃ» (¹Ù·Î°ßÀû/ÀüÃ¼°ßÀû) ************************************************
function quotation_request(cookie_type)
{
	document.frm.action = "main.asp??=cart/quotation/quotation_step01&cookie_type="+ cookie_type;
	document.frm.submit();
}


// À§½Ã¸®½ºÆ® ´ã±â *************************************************************
function wishlist()
{
	document.frm.action_mode.value = "wishlist";
	document.frm.submit();
}


// °ßÀû¼­ ÀÎ¼âÇÏ±â *************************************************************
function print_quotation(cookie_type, buy_idx)
{
	win = "frameset.asp??=cart/quotation/quotation_print&cookie_type=" + cookie_type + "&buy_idx=" + buy_idx;
	window.open(win, "print", "left=20, top=25, width=667, height=800, scrollbars=yes");
}


// ¸¶ÀÌÆäÀÌÁö ÀÎ¼âÇÏ±â *********************************************************
function print_mypage_quotation(buy_idx, quotation_admin_idx)
{
	win = "frameset.asp??=mypage/shopping/print/print&buy_idx=" + buy_idx + "&quotation_admin_idx=" + quotation_admin_idx;
	window.open(win, "print", "left=20, top=25, width=667, height=800, scrollbars=yes");
}


// ÁÖ¼ÒÃ£±â ********************************************************************
function popup_addressCheck(formName, siName, dongName,moreName, zipCodeName)
{
	var win = "/Common/toolkit/NWS_address/address.asp?formName="+ formName +"&siName="+ siName +"&dongName="+ dongName +"&moreName="+ moreName +"&zipCodeName="+ zipCodeName;
	window.open(win, "address", "width=457, height=568, left=200, top=200, scrollbars=yes");
}


// ¾ÆÀÌµð Ã¼Å© *****************************************************************
function checkid(formName, member_id)
{
	if(document.frm.member_id.value==0)
		alert("ID¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä");
	else
	{
		var id = eval(formName +"."+ member_id +".value");
		var win ="none.asp??=join/popup/id_check&formName="+ formName +"&member_id="+ id;
		window.open(win, "id_check", "width=440, height=330, left=200, top=200");
	}
}

// »óÇ°ÀÌ¹ÌÁö Å©°Ôº¸±â *********************************************************
function popup_enlarge(item_idx)
{
	var url = 'none.asp??=item/popup_enlarge&item_idx=' + item_idx;
	window.open(url, "enlarge", "width=683, height=545");
}

// ·Î±×ÀÎ **********************************************************************
function login(quotation_admin_idx)
{
	if (quotation_admin_idx != "")
		var win = "none.asp??=passport/member_login&mode=login&quotation_admin_idx=" + quotation_admin_idx;
	else
		var win = "none.asp??=passport/member_login&mode=login";

	window.open(win, "login", "left=20, top=25, width=440, height=320");
}

// ºñÈ¸¿ø·Î±×ÀÎ ****************************************************************
function nonmember_login(no)
{
	var win;
	if (no == 1)
		win = "none.asp??=passport/nonmember_login&mode=buy";					// ÁÖ¹®/¹è¼ÛÁ¶È¸
	else if (no == 2)
		win = "none.asp??=passport/nonmember_login&mode=quotation";				// ºñÈ¸¿ø°ßÀû¼­Á¶È¸

	window.open(win, "login", "left=20, top=25, width=440, height=372");
}

// ÀÌ¸ÞÀÏ·Î±×ÀÎ ****************************************************************
function email_quotation_login(quotation_admin_idx)
{
	win = "none.asp??=passport/nonmember_login&mode=quotation&quotation_admin_idx=" + quotation_admin_idx;
	window.open(win, "login", "left=20, top=25, width=440, height=372");
}

// ¸¶ÀÌÆäÀÌÁö Á¶È¸³¯Â¥ º¯°æ ****************************************************
function change_date(str_date)
{
	var date	= new Date();

	var today_year		= date.getFullYear();
	var today_month		= date.getMonth() + 1;
	var today_day		= date.getDate();

	if (("" + today_month).length == 1)
		today_month		= "0" + today_month;
	if (("" + today_day).length == 1)
		today_day		= "0" + today_day;

	document.frm.from_year.value	= str_date.substring(0, 4);
	document.frm.from_month.value	= str_date.substring(5, 7);
	document.frm.from_day.value		= str_date.substring(8, 10);
	document.frm.to_year.value		= today_year;
	document.frm.to_month.value		= today_month;
	document.frm.to_day.value		= today_day;
}


// ·¹ÀÌ¾î View or Hidden *******************************************************
function show_layer(lname)
{
//	var layer = (navigator.appName == 'Netscape') ? document.layers[lname] : document.all[lname];
	var layer = document.getElementById(lname);
	if (lname == '') return;
//	if (navigator.appName == 'Netscape') layer.visibility = 'show';
//	else
		layer.style.visibility = 'visible';
}

function hide_layer(lname)
{
	if (lname)
	{
//		var layer = (navigator.appName == 'Netscape') ? document.layers[lname] : document.all[lname];
		var layer = document.getElementById(lname);
//		if (navigator.appName == 'Netscape') layer.visibility = 'hide';
//		else
			layer.style.visibility = 'hidden';
	}
	else
	{
		for (i = 1 ; i <= 10 ; i ++)
		{
			var lname = 'layer'+i;
//			var layer = (navigator.appName == 'Netscape') ? document.layers[lname] : document.all[lname];
			var layer = document.getElementById(lname);
//			if (navigator.appName == 'Netscape') layer.visibility = 'hide';
//			else
				layer.style.visibility = 'hidden';
		}
	}
}


// TOPMENU »óÇ° °Ë»ö ***********************************************************
function checkform_top_search(theform)
{
	if (theform.search_value1.value == "")
	{
		alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À.");
		theform.search_value1.focus();
		return false;
	}
//	else if (theform.search_value1.value.length < 3)
//	{
//		alert("°Ë»ö¾î´Â 3ÀÚ ÀÌ»óÀÌ¾î¾ß ÇÕ´Ï´Ù.");
//		theform.search_value1.focus();
//		return false;
//	}
}


// ÀÌ¹ÌÁö Å©±â Á¶ÀýÇÏ¿© img ÅÂ±× Ãâ·Â ******************************************
function change_image_size(image_url, limit_width, limit_height)
{
	imgFile					= new Image();
	imgFile.src				= image_url;

	var real_width			= imgFile.width;
	var real_height			= imgFile.height;

	if (real_width >= real_height)
	{
		if (real_width <= limit_width)
		{
			result_width	= real_width;
			result_height	= real_height;
		}
		else
		{
			result_width	= limit_width;
			result_height	= parseInt((real_height * limit_width) / real_width);
		}
	}
	else
	{
		if (real_height <= limit_height)
		{
			result_width	= real_width;
			result_height	= real_height;
		}
		else
		{
			result_width	= parseInt((real_width * limit_height) / real_height);
			result_height	= limit_height;
		}
	}

	document.write ("<img src='"+ image_url +"' width='"+ result_width +"' height='"+ result_height +"' border='0' style='cursor:hand' onclick='popup_realsize(\""+ image_url +"\")'>");
}


// ÀÌ¹ÌÁö Á¦Å©±â·Î ÆË¾÷Ã¢ ¶ç¿ì±â ***********************************************
function popup_realsize(image_url)
{
	imgFile					= new Image();
	imgFile.src				= image_url;

	var real_width			= imgFile.width + 17;
	var real_height			= imgFile.height;

	var O					= "width="+ real_width +", height="+ real_height +", scrollbars=1, resizable=1";
	imgWin					= window.open("", "", O);
	imgWin.document.write("<html><head></head>");
	imgWin.document.write("<body topmargin=0 leftmargin=0 onload='resizeTo("+ real_width +", "+ real_height +")'>");
	imgWin.document.write("<img src='"+ image_url +"' style='cursor:hand' onclick='self.close()'>");
}


// input or textarea OnFocus ³»¿ëÁö¿ì±â ****************************************
function delete_contents(input)
{
	if (input.value == input.defaultValue)
	{
		input.value = "";
	}
}

// ÀÔ·Â¾øÀ½ Ã¼Å© & ¾È³» ********************************************************
function emptyInputYN(input_obj, lable)
{
	var input = input_obj;
	var type = "";
	var type_no = 0;

	type = input_obj.type;

	if (type == undefined && input_obj.length != undefined)
		type = input_obj[0].type;
	else if (type == undefined)
		type_no = 1;

	if (type == undefined)
		type = "";
	else
		type = type.toUpperCase();

	if (type == "TEXT" || type == "HIDDEN" || type == "TEXTAREA" || type == "PASSWORD")
		type_no = 1;
	else if (type == "SELECT-ONE" || type == "SELECT-MULTIPLE")
		type_no = 2;
	else if (type == "RADIO" || type == "CHECKBOX")
		type_no = 3;

	if(type_no == 1 && input_obj.value == '')
	{
		alert(lable + ' ÀÔ·ÂÇØ ÁÖ¼¼¿ä.');
		if (!input_obj.readOnly && !input_obj.disabled)
			input_obj.focus();
		return true;
	}
	else if (type_no == 2 && input_obj.value == '')
	{
		alert(lable + ' ¼±ÅÃÇØ ÁÖ¼¼¿ä.');
		input_obj.focus();
		return true;
	}
	else if (type_no == 3)
	{
		if (input_obj.length > 1)
		{
			if (!radioCheckedYN(input_obj))
			{
				alert(lable + ' ¼±ÅÃÇØ ÁÖ¼¼¿ä.');
				input_obj[0].focus();
				return true;
			}
		}
	}
	else
		return false;
}


// ¹è¿­ Áß °°Àº °ªÀÌ Á¸ÀçÇÏ´ÂÁö È®ÀÎ (Àç±ÍÇÔ¼ö)
function IsSameValue(arr_obj)
{
	if (arr_obj.length >= 2)
	{
		arr_sub = new Array(arr_obj.length - 1);

		for (i = 1; i < arr_obj.length ; i++)
		{
			arr_sub[i - 1] = arr_obj[i];
			if (arr_obj[0] == arr_obj[i])
			{
				return true;
				break;
			}
		}

		return IsSameValue(arr_sub);
	}

	return false;
}