﻿function vs_back() {
	history.back();
}
function vs_error(msg) {
	alert(msg);
	if (history.length > 0)
		history.back();
	else
		location.href = "/vs/";
}
function vs_go(url, index) {
	if (index == null || document.all.tags("base")[index] == null)
		location.href = url;
	else
		window.open(url, document.all.tags("base")[index].target);
}
function vs_load(obj) {
	for (var i = 0; i < obj.all.length; i++)
		with (obj.all[i]) {
			switch (tagName) {
				case "TBODY":
					if (parentElement.className.toLowerCase() == "list")
						for (var j = 0; j < rows.length; j++)
							with (rows[j]) {
								onmouseout = vs_onmouseout4highlight;
								onmouseover = vs_onmouseover4highlight;
							}
					break;
			}
			if (onclick != null)
				style.cursor = "hand";
		}
	if (exceptionmessage != "") {
		alert(exceptionmessage);
		vs_back();
	}
}
function vs_onmouseout4highlight() {
	this.className = "";
}
function vs_onmouseover4highlight() {
	this.className = "highlight";
}
function selectBox(obj, value) {
	for (i = 0; i < obj.all.length; i++)
		if (obj[i].value == value)
			obj.selectedIndex = i;
}
function showReceipt(tid) {
	var receiptUrl = "https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid=" + tid + "&noMethod=1";
	window.open(receiptUrl, "receipt", "menubar=1,width=430,height=700, scrollbars=yes,resizable=yes,left=252,top=116");
}
function UseCoupon(obj, surtax) {
	location.href = "?discount_no=" + obj.value + "&surtax=" + surtax;
}
////////////////////////////////////////////////////////////////////////////////
function check_reg(n) {
	sum = parseInt(n.charAt(0)) * 2 + parseInt(n.charAt(1)) * 3 + parseInt(n.charAt(2)) * 4 + parseInt(n.charAt(3)) * 5 + parseInt(n.charAt(4)) * 6 + parseInt(n.charAt(5)) * 7 + parseInt(n.charAt(7)) * 8 + parseInt(n.charAt(8)) * 9 + parseInt(n.charAt(9)) * 2 + parseInt(n.charAt(10)) * 3 + parseInt(n.charAt(11)) * 4 + parseInt(n.charAt(12)) * 5;
	return n.charAt(13) == (11 - (sum % 11)) % 10;
}
function regexp(s, exp) {
	m = s.match(exp);
	return (m != null) && (s == m[0]);
}
function trim(s) {
	s = s.replace(/^\s*/, '').replace(/\s*$/, '');
	return s;
}
function submit_userdata(obj) {
	with (obj) {
		//address2.value = trim(address2.value);
		if (document.all.account == null || regexp(account.value, /[a-z0-9]{4,16}/))
			if (regexp(password.value, /[\u0000-\u00FF]{4,16}/))
				if (password.value == password2.value)
					if (document.all.fullname == null || regexp(fullname.value, /[^\u0000-\u00FF]{2,4}/))
						if (document.all.residence == null || regexp(residence.value, /\d{6}-\d{7}/))
							if (document.all.residence == null || check_reg(residence.value))
								if (document.all.birth == null || regexp(birth.value, /\d{2,4}-\d{1,2}-\d{1,2}/))
									if (document.all.calendar == null || calendar[0].checked || calendar[1].checked)
										if (regexp(email.value, /.+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+/))
											if (!(regexp(email.value, /.+(sayclub.com|orgio.net|funshop.co.kr|artworks.co.kr|simmani.com|cj.net|funshop.com|netian.com)/)))
												if (email.value == email2.value)
													if (document.all.phone == null || regexp(phone.value, /(02|031|032|033|041|042|043|051|052|053|054|055|061|062|063|064|0502|0504|0505|0506|070)-\d{3,4}-\d{4}/))
														if (document.all.mobile == null || regexp(mobile.value, /(010|011|016|017|018|019|0502|0504|0505|0506)-\d{3,4}-\d{4}/))
															if (document.all.zipcode_no == null || zipcode_no.value != "" && zipcode_no.value != "0")
																if (document.all.address2 == null || address2.value != "")
																	if (mailing[0].checked || mailing[1].checked)
																		obj.submit();
																	else
																		alert("메일수신여부를 선택해 주세요");
																else {
																	alert("주소#2를 입력해 주세요");
																	address2.focus();
																}
															else {
																alert("우편번호를 입력해 주세요");
																search.focus();
															}
														else {
															alert("잘못된 휴대폰번호입니다");
															mobile.focus();
														}
													else {
														alert("잘못된 전화번호입니다");
														phone.focus();
													}
												else {
													alert("입력된 두개의 이메일 주소가 일치하지 않습니다");
													email.focus();
												}
											else {
												alert("사용 금지 메일 계정\n\nartworks.co.kr\ncj.net\nnetian.com\nfunshop.co.kr\nfunshop.com\norgio.net\nsayclub.com\nsimmani.com\n");
												email.focus();
											}
										else {
											alert("전자우편주소는 32자 이하의 소문자만 입력해 주세요\n예) webmaster@funshop.co.kr ");
											email.focus();
										}
									else
										alert("양력/음력을 선택해 주세요");
								else {
									alert("잘못된 생년월일입니다");
									birth.focus();
								}
							else {
								alert("잘못된 주민등록번호입니다");
								residence.focus();
							}
						else {
							alert("주민등록번호는 구분기호(-)를 포함한 14자리 숫자만 가능합니다");
							residence.focus();
						}
					else {
						alert("성명은 공백 없이 2자 이상 4자 이하의 한글만 가능합니다");
						fullname.focus();
					}
				else {
					alert("입력된 두개의 비밀번호가 일치하지 않습니다");
					password.focus();
				}
			else {
				alert("비밀번호는 4자 이상 16자 이하만 가능합니다");
				password.focus();
			}
		else {
			alert("아이디는 공백 없이 4자 이상 16자 이하의 소문자, 숫자만 가능합니다");
			account.focus();
		}
	}
}
function flash_home() {
	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' height='364' width='416'><param name='movie' value='/vs/images/home.swf'></object>");
}


function searchFieldCheck(objField)
{
	var searchValue = objField.value.split(" ").join("");
	
	if (searchValue == "")
	{
		objField.value = "";
		return true;
	}
/*	else if (searchValue.length > 0 && searchValue.length < 1)
	{
		alert("검색어는 2글자 이상만 가능합니다.");
		objField.focus();
		return false;
	}
*/
	else if (excludeChars(objField,"\"('”/\;:+)_<>*&^%$@#"))
//	else if (excludeChars(objField,"\"('”/\;:-+)_<>*&^%$@"))
	{
		alert("특수문자는 검색어로 입력할 수 없습니다.");
		objField.focus();
		return false;
	}
	else
		return true;
}

function excludeChars(input,chars) {
    for (var inx = 0; inx < input.value.length; inx++) {
       if (chars.indexOf(input.value.charAt(inx)) != -1)
           return true;
    }
    return false;
}

