//join
function goJoin(){
	var referUrl = escape(document.location.href);
	document.location.href="/member/join/agreement.jsp?referUrl="+referUrl+"&referChanid=C04";
}

//my page
function goMyInfo(){
	var referUrl = escape(document.location.href);
	document.location.href="/member/mypage/modifyGate.jsp?referUrl="+referUrl+"&referChanid=C04";
}

//secede
function goSecede(){
	var referUrl = escape(document.location.href);
	document.location.href="/member/join/secedeForm.jsp?referUrl="+referUrl+"&referChanid=C04";
}

function goLogOut(){
	var referUrl = escape(document.location.href);
	document.location.href="/member/login/logOut.jsp?referUrl="+referUrl;
}

function login(){
	var referUrl = escape(document.location.href);
	document.location.href="/member/login/loginGate.jsp?referUrl="+referUrl+"&referChanid=C04";
}

function goRecommend() {
	var goURL = encodeURIComponent(document.location.href);
	if(parent) {
		goURL = encodeURIComponent(self.location.href);
		parent.location.href = "/brand/bamboosalt/common/recommend.jsp?recommendURL=" + goURL;
	} else {
		location.href = "/brand/bamboosalt/common/recommend.jsp?recommendURL=" + goURL;
	}
}

function isNull(name, txt){
	if(eval("document.getElementById('"+name+"').value;") == ""){
		alert(txt);
		eval("document.getElementById('"+name+"').focus();");
		return true;
	}
	return false;
}
function isEquals(name, txt){
	if(eval("document.getElementById('"+name+"').value;") == txt){
		return true;
	}
	return false;
}
function isRightLength(name, ln, txt){
	if(eval("document.getElementById('"+name+"').value.length;") != ln){
		alert(txt);
		eval("document.getElementById('"+name+"').focus();");
		return true;
	}
	return false;
}
function getLength(name){
	return eval("document.getElementById('"+name+"').value.length;");
}
function getValue(name){
	return eval("document.getElementById('"+name+"').value;");
}
function setValue(name, val){
	document.getElementById(name).value = val;
}
function setFocus(name){
	eval("document.getElementById('"+name+"').focus();");
}
function nextFocus(name1, ln, name2){
	if(eval("document.getElementById('"+name1+"').value.length") == ln)
		eval("document.getElementById('"+name2+"').focus();");
}
function onlyNumberInput(){
	var code = window.event.keyCode;
	if ((code > 34 && code < 41) || (code > 47 && code < 58) || (code > 95 && code < 106) || code == 8 || code == 9 || code == 13 || code == 46){
		window.event.returnValue = true;
		return;
	}
	window.event.returnValue = false;
}

// 사용예 : <textarea name="aField" onKeyUp="limitTextLength(this, 50)"></textarea>
function limitTextLength(obj, len) {
    if (obj.value.length > len) {
        alert(len + " 자 이상 입력하실 수 없습니다.");
        obj.value = obj.value.substr(0, len);
    }
}

function checkEmail(str) {
    var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
    return isValidFormat(str,format);
}
function isValidFormat(str,format) {
    if (str.search(format) != -1) {
        return true; //올바른 포맷 형식
    }
    return false;
}

function GetRadioValue(opt) {
	var leng = ((isNaN(opt.length*1))?1:opt.length*1);

	if (leng == 1)
	{
			if (opt.checked)
			{
				return opt.value;
			}
	}
	else {
		var n = opt.length;
		for (i=0; i<n; i++) {
			if (opt[i].checked) {
				return opt[i].value;
			}
		}
	}
	return "";
}

function goFullscreen(page) {
	var URLen=page;
	var windowNamen="mainflashwindow";
	var browserName=navigator.appName;
	var operatingSystem=navigator.platform;
	var version = parseFloat(navigator.appVersion);

	// Netscape check version 4.0+ on Win
	if (browserName.indexOf("Netscape")!=-1 && version>=4.0 && operatingSystem.indexOf("Mac")!=-1){
		window.open(URLen,windowNamen,'titlebar=no,top=0,left=0,width=' + window.screen.availWidth+',height='+window.screen.availWidth+',screenX=0,screenY=0,top=0,left=0')
	 }

	// MSIE Mac check
	else if (browserName.indexOf("Microsoft Internet Explorer")!=-1 && operatingSystem.indexOf("Mac")!=-1){
		window.open(URLen,windowNamen,'titlebar=no,top=0,left=0,width=' + window.screen.availWidth+',height='+window.screen.availWidth+',screenX=0,screenY=0,top=0,left=0')
	 }

	// Netscape Mac check
	else if (browserName.indexOf("Netscape")!=-1 && operatingSystem.indexOf("Mac")!=-1){
		window.open(URLen,windowNamen,'width='+screen.width+',height='+screen.height+',top=0,left=0');
	 }

	// MSIE Windows
	else if (browserName.indexOf("Microsoft Internet Explorer")!=-1 && operatingSystem.indexOf("Win")!=-1){
		var win = window.open(URLen,windowNamen,'titlebar=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,top=0,left=0,width=' + window.screen.availWidth+',height='+window.screen.availHeight+',screenX=0,screenY=0,top=0,left=0')
	 }

	// Netscape Windows
	else if (browserName.indexOf("Netscape")!=-1 && operatingSystem.indexOf("Win")!=-1){
		window.open(URLen,windowNamen,'width='+screen.width+',height='+screen.height+',top=0,left=0');
	 }

	else{
	 window.open(URLen,windowNamen);
	 }

}

function checkField(obj, message) {
    var tag = "";

    if (obj.tagName == null) {
        if (obj[0].type == "checkbox") tag = "CHECK";
        else if (obj[0].type == "radio") tag = "RADIO";
    }
    else {
        if (obj.tagName == "SELECT") tag = "SELECT";
        else if (obj.tagName == "INPUT") {
            if (obj.type == "text") tag = "TEXT";
            else if (obj.type == "hidden") tag = "HIDDEN";
            else if (obj.type == "file") tag = "FILE";
            else if (obj.type == "password") tag = "PASSWORD";
        }
        else if (obj.tagName == "TEXTAREA") tag = "TEXTAREA";
    }

    var valid = true;

    if (tag == "SELECT") {
        if (obj.options[obj.selectedIndex].value == '') valid = false;
    }
    else if (tag == "TEXT" || tag == "TEXTAREA" || tag == "FILE" || tag == "PASSWORD" || tag == "HIDDEN") {
        if (obj.value.trim() == "") valid = false;
    }
    else if (tag == "CHECK" || tag == "RADIO") {
        var isHit = false;
        for (var i=0; i<obj.length; i++) {
            if (obj[i].checked) {
                isHit = true;
                break;
            }
        }
        valid = isHit;
    }

	if (message != null){
		if (!valid) {
			alert(message);
			if (tag != "CHECK" && tag != "RADIO" && tag != "HIDDEN") obj.focus();
		}
	}

    return valid;
}

String.prototype.trim = function() {
    var format = /^\s*/g;
    var str = this;
    str = str.replace(format, "");
    format = /\s*$/g;
    str = str.replace(format, "");

    return str;
}