	/**
		1. flag 는 모든 form 안에 hidden 값으로 넣어 놔야 된다.
			( <s:hidden name="flag"> )
		2. submit 이미지나 버튼은  id 의 value 를 btn_submit 라고 해야 한다.
			( <s:submit type="button" id="btn_submit" align="center" value="로그인"/> )
		3. function 안은 input type 을 체크하고 난 뒤에 checkFlag() 를 실행해야 한다. 
	*/
	function checkFlag(){
		if(document.getElementById("flag").value==1){	  		
	  		return false;
		}
		document.getElementById("flag").value=1;
		document.getElementById("btn_submit").style.display = 'none';
		document.getElementById("BoxCenter").style.display ='';
	}
	
	/**********************************************************
	* 숫자만 입력
	**********************************************************/
	function onlyNumber() {
		//cssStyle="ime-mode:disabled" 을 text 필드에 꼭 넣어주고
		// text 필드의 이벤트는 onkeypress 이다.
		if((event.keyCode<48)||(event.keyCode>57)) {
			event.returnValue=false;
	    }
	}
	
	/**********************************************************
	* 새창 가운데로 열기
	**********************************************************/
	function openWin(url,w,h,yn) {
		
		l = (screen.width) ? (screen.width-w)/2 : 0; 
	    t  = (screen.height) ? (screen.height-h)/2 : 0;
	    title = Math.round(Math.random()*10000);
		window.open(url,title,'width='+w+',height='+h+',left='+l+',top='+t+',scrollbars='+yn);
	}
	
	function openWin1(sURL, sWindowName, w, h, sScroll) {
 	  var x = (screen.width - w) / 2;
	  var y = (screen.height - h) / 2;
	
	  if (sScroll==null) sScroll = "no";
	
	  var sOption = "";
	  sOption = sOption + "toolbar=no, channelmode=no, location=no, directories=no, resizable=no, menubar=no";
	  sOption = sOption + ", scrollbars=" + sScroll + ", left=" + x + ", top=" + y + ", width=" + w + ", height=" + h;
	
	  var win = window.open(sURL, sWindowName, sOption);
	  return win;
	}
	
	function isInnerLen(input,start,end) {
	 	var len = input.value.length;
	 	if (len >= start && len <= end)
	 		return true;
	 	else
	 		return false; 
	 }
	function containsCharsOnly(input,chars) {
		for (var inx = 0; inx < input.value.length; inx++) {
	       if (chars.indexOf(input.value.charAt(inx)) == -1)
	           return false;
	    }
	    return true;
	}
	function isAlphaNum(input) {
	   	var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
	   	return containsCharsOnly(input,chars);
	}
	function isEmpty(input) {
	    if (input.value == null || input.value.replace(/ /gi,"") == "") {
	        return true;
	    }
	   	return false;
	}
	
	/**********************************************************
	* 숫자영역 원화표시/환원 하기
	**********************************************************/
	function commaIn(input) {
		var coreVal = eval(input).value.replace(/,/gi,"");	// 먼저 comma 를 제거
		eval(input).value = putComma(coreVal);
	}
	
	function commaOut(input) {
		eval(input).value = eval(input).value.replace(/,/gi,"");
	}
	
	function putComma(input) {
		var num = input;
	
		if (num < 0) {
			num *= -1;
			var minus = true;
		}else{
			var minus = false;
		}
	
		var dotPos = (num+"").split(".")
		var dotU = dotPos[0];
		var dotD = dotPos[1];
		var commaFlag = dotU.length%3;
	
		if(commaFlag) {
			var out = dotU.substring(0, commaFlag);
			if (dotU.length > 3) out += ",";
		}
		else var out = ""
	
		for (var i=commaFlag; i < dotU.length; i+=3) {
			out += dotU.substring(i, i+3);
			if( i < dotU.length-3) out += ","
		}
	
		if(minus) out = "-" + out;
		if(dotD) return out + "." + dotD;
		else return out
	}
	
	/**********************************************************
	* 숫자만 입력되었는지 체크
	**********************************************************/
	function checkNumber(obj){
		//입력시 체크		 
		var text =/[^0-9]/; 
		var check = obj.value.match(text); 
		if(check){ 
			alert("주문수량은 숫자만 가능합니다."); 
			obj.value = "1";
			return false;
		}
	}
	/**********************************************************
	* 로그인시 특수문자 제어(SQL Injection 처리)
	**********************************************************/
	function checkLogin(){
		//입력시 체크		 
		var text =/[^a-zA-Z0-9_]/; 
		var check = document.getElementById("user_id").value.match(text); 
		if(check){ 
			alert("아이디는 영어/숫자/_(언더바)만 가능합니다.."); 
			document.getElementById("user_id").value = "";
			return false;
		}	
		if(document.getElementById("user_id").value == ''){
			alert('아이디를 입력하십시요.');
			document.getElementById("user_id").focus();
			return false;
		}
		if(document.getElementById("user_pass").value == ''){
			alert('비밀번호를 입력하십시요.');
			document.getElementById("user_pass").focus();
			return false;
		}
		// 플래그 세팅
		checkFlag();
	}
	
	/**********************************************************
	* XSS 취약점 해결
	**********************************************************/
	function chkJavascript(oField) {
		
		pattern = /<\s*script.+?<\/\s*script\s*>/gi	
		result = pattern.test(oField);
		
		if(result) {
			alert("입력하신 내용 중에 클라이언트 스크립트가 포함되어 있습니다.\n\n자바스크립트 소스가 포함되면 입력되지 않습니다.");
			return false;
		}
		return true;		
	} 
	
	
	function getPrevDate(val, flag) {
		var n_day = new Date();
		var y,m,d;
    	y = n_day.getYear();
    	if(flag == "M") {
			m = (n_day.getMonth()-val) + 1; // getMonth()는 0~11의 값을 가져오므로 +1을 한다
			d = n_day.getDate();
    	} else if (flag == "D") {
    		if(val == 15) n_day.setTime((n_day.getTime()-(15*24*60*60*1000)));
			y = n_day.getYear();
			m = (n_day.getMonth()+1);
			d = n_day.getDate();
    	}
		if(m<10) m="0"+m;  // 월이 10보다 작을때 앞에 0을 붙힌다
		if(d<10) d="0"+d;   // 일이 10보다 작을때 앞에 0을 붙힌다
   		return (y+'-'+m+'-'+d)
  	}


//goodsView bbs
function flashWrite( id, flashUri, vWidth, vHeight ) {
   var _obj_ = "";

   _obj_ = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" align="middle">';
	_obj_ += '<param name="movie" value="' + flashUri + '" />';
   _obj_ += '<param name="quality" value="high" />';
   _obj_ += '<param name="wmode" value="transparent" />    ';
	_obj_ += '<param name="menu" value="false" />    ';
   _obj_ += '<param name="bgcolor" value="#ffffff" />        ';
   _obj_ += '<embed src="' + flashUri + '" quality="high" wmode="transparent" bgcolor="#ffffff" width="' + vWidth +'" height="' + vHeight + '" id="' + id + '" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>    ';
   _obj_ += '</object>';
   document.writeln( _obj_ );
}


//category menu
function startCateScrollScroll() {
    setTimeout("slideCateScroll()",10);
}
function slideCateScroll() {
    var Sel_Height=210; 
        el = document.getElementById("scroll-list");
    if (el.heightPos == null || (el.isDone && el.isOn == false)) {
        el.isDone = false;
        el.heightPos = 1;
        el.heightTo = Sel_Height;
    } else if (el.isDone && el.isOn){
        el.isDone = false;
        el.heightTo = 1; 
    }
    if (Math.abs(el.heightTo - el.heightPos) > 1) {
        el.heightPos += (el.heightTo - el.heightPos) / 10;
        el.style.height = el.heightPos + "px";
        startCateScrollScroll();
    } else {
    if (el.heightTo == Sel_Height) {
        el.isOn = true;
    } else {
        el.isOn = false;
    }
        el.heightPos = el.heightTo;
        el.style.height = el.heightPos + "px";
        el.isDone = true;
    }
}




//eight tap menu
function eightMenu(index) {
	for (i=1; i<=8; i++)	
	if (index == i) {
		thisMenu = eval("menu" + index + ".style");
		thisMenu.display = "";
	} 
	else {
		otherMenu = eval("menu" + i + ".style"); 
		otherMenu.display = "none"; 
	}
}

//product tap menu
function productMenu(index) {
	for (i=1; i<=5; i++)	
	if (index == i) {
		thisMenu = eval("menu" + index + ".style");
		thisMenu.display = "";
	} 
	else {
		otherMenu = eval("menu" + i + ".style"); 
		otherMenu.display = "none"; 
	}
}

//process tap menu
function processMenu(index) {
	for (i=1; i<=3; i++)	
	if (index == i) {
		thisMenu = eval("menu" + index + ".style");
		thisMenu.display = "";
	} 
	else {
		otherMenu = eval("menu" + i + ".style"); 
		otherMenu.display = "none"; 
	}
}

	function stringLength(str) {
		var cnt = 0;
         for (var i = 0; i < str.length; i++) {
        	 if (str.charCodeAt(i) > 127)
            	 cnt += 2;
             else
                 cnt++;
         }
         return cnt;
	}



//special tap menu
function specialMenu(index) {
	for (i=1; i<=5; i++)	
	if (index == i) {
		thisMenu = eval("menu" + index + ".style");
		thisMenu.display = "";
	} 
	else {
		otherMenu = eval("menu" + i + ".style"); 
		otherMenu.display = "none"; 
	}
}

