/**
@ program			: javascript ui framework;
@ auth				: thhh2¢â 
@ desc				: °øÅëÀÚ¹Ù½ºÅ©¸³Æ®
**/
//¸µÅ©Á¡¼¶¾ø¾Ö±â..
function jsBlur(){ 
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 
document.onfocusin=jsBlur; 

var th = { 

	actionfrm : "actionfrm",
	popupfrm : "popupfrm",
	checkfrm : 1, 

	// return object 
	$:function(id) { 
		if (typeof(id) !="object") return document.getElementById(id); 
		else return (id); 
	},
	$$:function(id) {
		if (typeof(id) !="object") return document.getElementsByName(id); 
		else return (id); 
	}, 
	Msg:function(types){
		switch(types){
			case "delete" : 
				return "»èÁ¦ÇÏ½Ã¸é º¹±¸ÇÒ ¼ö ¾ø½À´Ï´Ù.\n»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?";
				break; 
			case "leave" :
				return "Å»ÅðÇÏ½Ã¸é "; 
				break;
			case "error " :
				return "¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù."; 
				break; 
			case "form" :
				return "ÀÌ¹ÌÀü¼ÛÁßÀÔ´Ï´Ù. Àá½Ã¸¸ ±â´Ù·ÁÁÖ¼¼¿ä.";
				break; 
		}
	}, 


	//************************************************************************
	// Function : Onlynum
	// Description : °æ°í¸Þ½ÃÁö ¾øÀÌ ¹«Á¶°Ç ¼ýÀÚ¸¸
	// Argument : el - TextBox
	// Event : onKeyUp
	//************************************************************************
	Onlynum:function(){
		alert(event.keyCode);
		if((event.keyCode<48)||(event.keyCode>57))
		event.returnValue=false;
	},

	//************************************************************************
	// Function : onlyNumber
	// Description : °æ°í¸Þ½ÃÁö ¾øÀÌ ¹«Á¶°Ç ¼ýÀÚ¸¸
	// Argument : el - TextBox
	// Event : onKeyUp
	//************************************************************************
	onlyNumber:function ( el ) {
		if(event.keyCode != '37' && event.keyCode != '39') {
			el.value = el.value.replace( /\D/g, '' );
		}
	},

	//************************************************************************
	// Function : moveFocus
	// Description : ÀÚµ¿ ÀÚ¸® ÀÌµ¿ ÇÔ¼ö
	// Argument : num - Max Length(int), fromform - TextBox, toform - Next TextBox
	// Event : OnKeyUp
	//************************************************************************
	moveFocus:function (num,fromform,toform){
		var str = fromform.value.length;
		if(str == num)
			toform.focus();
	},





	
	English:function(){
	}, 

	Go : function(code, subp) {
		if (code!=null) {
			var url = "";
			if (arguments[2]) { url = arguments[2]; } 
			this.Url("/menucode.asp?code="+ code + "&subp="+subp + url, ""); 
//			window.location.href = "/menucode.asp?code="+ code + "&subp="+subp + url; 
		}
	},
	Back:function(){ window.history.go(-1);},
	Url : function(url, t){ 
		if (t=="blank") {
			window.open(url); 
		} else {
			window.location.href=url; 
		}
	},
	Reload : function() {
		window.location.reload();
	},
	Home : function() {
		this.Url("/menucode.asp?code=main&subp=00", ""); 
//		window.location.href="/menucode.asp?code=main&subp=00"; 
	},
	Open : function(url, name, features) {
		if (url) {
//			var contwin ="";
//			var contwin = name; 
//			if (contwin!=null && contwin.closed==false) { contwin.close(); }
			var contwin = window.open(url,name,features);
			if (contwin==null) {
				alert("Â÷´ÜµÈ ÆË¾÷Ã¢À» Çã¿ëÇØÁÖ¼¼¿ä.");
			} else {
				contwin.focus(); 
			}
			
		}
	},
	Close : function() { opener = self;  self.close(); },
	CloseToday : function(popid) { 
		var nowdate = new Date();
		// ¿À´ÃÀÚÁ¤±îÁö¸¸ ¶ç¿ò
		var time = 1440 - (nowdate.getHours()*60+nowdate.getMinutes());
		this.setCookie(popid, "none", time);
		this.Close();
	}, 
	Modal : function (url, name, features) { window.showModalDialog(url, window, features); },
	ModalResize : function() {
		var dw = window.dialogWidth;
		while (isNaN(dw))  {
		  dw = dw.substr(0,dw.length-1);
		}

		difw = dw - document.body.clientWidth;
		window.dialogWidth = document.body.scrollWidth+difw+'px';

		var dh = window.dialogHeight;
		while (isNaN(dh)) {
		  dh = dh.substr(0,dh.length-1);
		}
		difh = dh - document.body.clientHeight;
		window.dialogHeight = document.body.scrollHeight+difh+'px';
	},
	Error : function (e) {alert(e+"\n"+e.description); }, 
	Regular : function(chk, frm, msg) {
		var strValue = frm.value;
		var blnExp = false; 
		switch (chk) {
			case "id" : 
				if (frm.value.match(/[A-Za-z0-9]{4,15}\w*/g)!=strValue){break;}
				blnExp = true;
			case "email" :
				if (frm.value.match(/[\w\-]+\@[\w\-]+(\.[\w\-]+)+/g)!=strValue){break;}
				blnExp = true;
			case "number" :
				if (frm.value.match(/\d+/g)!=strValue){ break;}
				blnExp = true;
			case "phone" :
				if (frm.value.match(/[0-9]{2,3}\-[0-9]{3,4}\-[0-9]{4}/g)!=strValue){break;}
				blnExp = true;
			case "mphone" :		
				if (frm.value.match(/01[016789]\-[0-9]{3,4}\-[0-9]{4}/g)!=strValue){ break;}
				blnExp = true;
			case "date" :
				if (frm.value.match(/[0-9]{4}\-[0-9]{2}\-[0-9]{2}/g)!=strValue){break;}
				blnExp = true;
			case "homepage" :
				if (frm.value.match(/\w+:\/\/[^#]*/g)!=strValue){		break;}
				blnExp = true;
			case "checked" : 
				if (typeof(frm)=="object"){
					if (typeof(frm.length)=="undefined"){
						if (frm.checked) { blnExp = true; }
					}
					else{
						for (i = 0 ; i < frm.length; i++){
							if (frm[i].checked){	blnExp = true;		}
						}
					}
				}
				
				break;
			case "selected" :
				if (frm.value==""){ break ;}
				blnExp = true;
				
			case "idn1" :
				if (frm.value.match(/[0-9]{6}/g)!=strValue){ break; }
				blnExp = true;
			case "idn2" :
				if (frm.value.match(/[0-9]{7}/g)!=strValue){break; }
				blnExp = true;
			case "company" :
				if (frm.value.match(/[0-9]{3}\-[0-9]{2}\-[0-9]{5}/g)!=strValue){break;}
				blnExp = true;	
			
			default : //°ø¹éÃ¼Å©;
				if (frm.value.match(/\S/)==null){break;}
				blnExp = true;
		}
		
		if (!blnExp){ if (msg) alert(msg);if ((chk!="checked")&&(chk!="selected")){frm.focus();};	return false;	}
		else{return true;}
	},

	// get operating system;
	getOs : function() { return window.navigator.appVersion.split(";")[2]; 	}, 
	// get brower version; 
	getBrower : function(){ return navigator.userAgent.toUpperCase();}, 
	ShowHide : function(o, action) { o.style.display=action; }, 
	ShowHideyn : function(o) { return (o.style.display=="none") ? false : true; }, 
	ShowHideArray : function(o, num) {
		var obj = th.$$(o); 
//		var obj = document.all[o]; 

		if (obj.length==null) {
			(this.ShowHideyn(obj)) ? this.ShowHide(obj, "none") : this.ShowHide(obj,"block"); 
		} else {
			for (i=0; i<obj.length; i++) {
				if (i==num) {
					(this.ShowHideyn(obj[num])) ? this.ShowHide(obj[num], "none") : this.ShowHide(obj[num],"block"); 
				} else {
					this.ShowHide(obj[i], "none"); 
				}
			}
		}
	},

	Toggle : function(id) { 
		this.$(id).style.display=(this.getStyle(this.$(id), "display")=="none") ? "block":"none"; 
	},
	
	getStyle : function(obj, att) {
		return obj.style[att]; 
	},

	Trim : function(str){
		return str.replace(/S/g, ""); 
	}, 


	Flash : function(url, width, height, strparam) {
		var wmode = "transparent";
		var id = "";
		var quality = "high";
		var menu = "false";
		var allowScriptAccess = "sameDomain";

		var flash='';
		flash += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ width +'" height="'+ height +'"> ';
		flash += '<param name="movie" value="'+ url +'">';
		flash += '<param name="quality" value="'+ quality +'">';
		flash += '<param name="menu" value="'+ menu +'">';
		flash += '<param name="wmode" value="'+ wmode +'">';
		flash += '<param name="FlashVars" value="'+ strparam +'">';
		flash += '<embed src="'+ url +'" quality="'+ quality +'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'" wmode="transparent"></embed> ';
		flash += '</object>';

		document.write(flash);
	}, 
	
	Embed : function(url, width, height) {
		var object='';
		object='<embed src="'+url+'" width="'+width+'" height="'+height+'" align="baseline" border="0" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=media&sba=plugin&" name="MediaPlayer" showcontrols="1" showpositioncontrols="0" showaudiocontrols="1" showtracker="1" showdisplay="0" showstatusbar="1" autosize="0" showgotobar="0" showcaptioning="0" autostart="1" autorewind="0" animationatstart="0" transparentatstart="0" allowscan="1" enablecontextmenu="1" clicktoplay="0" invokeurls="1" defaultframe="datawindow"></embed>';
		document.write(object); 
	}, 


	ImageResize:function(imgid, sizew) {
		var img = document.images(imgid); 
		if (img) {
			if (img.length==null){
				imgwidth = img.width ; imgheight = img.height;
				if (sizew < imgwidth){
					imgW = sizew; 
					imgH = parseInt((sizew/imgwidth) * imgheight);
				}
				else{
					imgW = imgwidth ;
					imgH = imgheight;
				}
				img.width = imgW;
				img.height = imgH;		
			}
			else{
				for (i = 0 ; i < img.length; i++) {
					imgwidth = img[i].width ; imgheight = img[i].height;
					if (sizew < imgwidth){
						imgW = sizew; 
						imgH = parseInt((sizew/imgwidth) * imgheight);
					}
					else{
						imgW = imgwidth ;
						imgH = imgheight;
					}
					img[i].width = imgW;
					img[i].height = imgH;
				}
			}
		}
	},

	
	setCookie : function(name, value, expiredays) {
		var todayDate = new Date();
		todayDate.setTime(todayDate.getTime() + (1000*60*parseInt(expiredays)) );
		document.cookie = name +"="+escape(value)+";path=/; expires=" + todayDate.toGMTString() + ";" ;			
	},

	getCookie : function(name) {
		var nameOfCookie = name + "="; 
		var x = 0; 
		while ( x <= document.cookie.length ) { 
				 var y = (x+nameOfCookie.length); 
				 if ( document.cookie.substring( x, y ) == nameOfCookie ) { 
					   if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) 
								endOfCookie = document.cookie.length; 
					   return unescape( document.cookie.substring( y, endOfCookie ) ); 
				 } 
				 x = document.cookie.indexOf( " ", x ) + 1; 
				 if ( x == 0 ) 
					   break; 
		} 
		return ""; 
	},
	

	// check
	CheckAll : function(f) {

		var chkvalue = document.all.item(f);

		if (chkvalue) {
			var chklen = chkvalue.length;
		
			if (chklen==null || chklen==""){
				if(chkvalue.checked) { chkvalue.checked=false; }
				else { 
					if (chkvalue.disabled==false) { chkvalue.checked=true; } 
				}
			}
			else{
				for(i=0;i<chklen;i++){
					if(chkvalue[i].type=='checkbox'){
						if(chkvalue[i].checked) { chkvalue[i].checked=false; }
						else {
							if (chkvalue[i].disabled==false) { chkvalue[i].checked=true; } 
							// chkvalue[i].checked=true; 
						}
					}
				}
			}
		}
	},

	// checkbox value; 
	CheckValue : function(f, msg) {
		var v="" , msg ;
		var chkvalue = document.all.item(f);
		var chklen = chkvalue.length;
		
		if (chklen==null || chklen==""){
			if (chkvalue.checked){
				v=chkvalue.value+",";
			}
		}
		else{
			for(i=0;i<chklen;i++){
				if(chkvalue[i].type=='checkbox'){
					if(chkvalue[i].checked) { 
						v=chkvalue[i].value+","+v
					}
				} else {
					v = chkvalue[i].value +  "," + v
				}
			}
		}
		
		if (v==""){	alert(msg); return false;}
		else{return v;}
	}, 

	// checked value; 
	CheckedValue:function(frm) {
		try { 
			var returnvalue;

			if (typeof(frm)=="object"){
				if (typeof(frm.length)=="undefined"){
					if (frm.checked) { returnvalue = frm.value; }

				}
				else{
					for (i = 0 ; i < frm.length; i++){
						if (frm[i].checked){ returnvalue = frm[i].value; }
					}
				}
			}

			return returnvalue;

		}
		catch (e) {
			this.Error(e);
		}
	}, 

	Lower:function(s) { return s.toLowerCase(); }, 
	Upper:function(s) { return s.toUpperCase(); },

	ResizeFrame:function(name){
		var frame = parent.th.$(name); 
		if (frame) {
			frame.style.height=document.body.scrollHeight;
		}
	},
	ByteCheck:function(input,id,length){
		var obj = this.$(id); 
		var j=0;
		for(var i=0;i<input.value.length;i++) {
			val=escape(input.value.charAt(i)).length;
			if(val== 6) { j++; }
			else{ j++; }
		}
		
		obj.innerHTML = j;
		if(j > length) {
			alert(length+'ÀÚ ÀÌÇÏ·Î ÇØÁÖ¼¼¿ä!   '); return false;
		} 
		else {  return true;  }
	}, 
	
	Zoom:function(url) {
		this.Open('/common/zoom.asp?name='+url,'','directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=400,height=400');
	}, 
	ContentsDivide:function(f, strValue) {
		var limit = 102399; 
		var temp = ""; 
		while (strValue.length > 0 ) {
			temp = document.createElement("TEXTAREA"); 
			temp.name = "contents1";
			temp.value = strValue.substr(0, limit); 
			f.appendChild(temp); 
			strValue = strValue.substr(limit); 
		}

		temp = document.createElement("TEXTAREA");
		temp.name = "contents1"; 
		temp.value = strValue; 
		f.appendChild(temp); 
	},
	
	Leftmenu:function(code){
		if (code > 0){
			var obj_img = document.all["leftnavi"+code] ;
			var img_name = obj_img.name;
			obj_img.src = "/images/"+imgfolder+"/"+img_name+"_over_"+ code +".gif";
			this.LeftmenuTr(code);
		}
	},
	
	LeftmenuTr:function(code){
		if (code > 0){
			var obj_tr = document.all["leftnavi"+ code +"_tr"]; 
			if (typeof(obj_tr)=="object") {
				if (obj_tr.style.display=="none") {
					obj_tr.style.display = "block";
				}
			}
		}
	},
	
	LeftmenuSub:function(code,subp){
		try {
			if (code > 0){
				var obj_img = document.all["leftnavi"+code+subp] ;
				var img_name = obj_img.name;
				obj_img.src = "/images/"+imgfolder+"/"+img_name+"_over_"+ subp +".gif";
			}			
		}
		catch (e) {
		}
	},




	ChangeFocus:function(val,len,nextfrm){
		if( val.length == len) nextfrm.focus();
	},


	

	Nokey:function(){
		event.returnValue=false;
	},
	

	GoLogin:function(){
		var strparameter = window.location.search; 
		if (strparameter.length>0) {
			if (strparameter.indexOf("returl" , 0) > 0){
				window.location.reload();
			}
			else {
				window.location.href="/?code=login&subp=0101&returl="+escape(window.location.pathname+window.location.search);
			}
		}
		else {
			window.location.href="/?code=login&subp=0101&returl="+escape(window.location.pathname+window.location.search);
		}

		return;
	},
	GoLogout:function(){
		var strparameter = window.location.search; 
		var tmp = ""; 
		if (strparameter.length>0) {
			tmp = escape(window.location.pathname+window.location.search);
		} 
		window.location.href="/common/logout.asp?returl="+tmp;
	},
	NeedLogin:function(){
		alert("·Î±×ÀÎÀÌ ÇÊ¿äÇÑ ¼­ºñ½º ÀÔ´Ï´Ù.\n·Î±×ÀÎ ÈÄ ÀÌ¿ëÇÏ½Ã±â ¹Ù¶ø´Ï´Ù.");
		window.location.href="/?code=login&subp=0101&returl="+escape(window.location.pathname+window.location.search);
		return;
	}, 
	
	// ³¯Â¥ºñ±³, ¾ÕµÚ
	IsDate:function(sdate,edate){
		if (sdate.indexOf("-")>0) {
			split_sdate = sdate.split("-"); 
			syear = split_sdate[0]; 
			smonth = Number(split_sdate[1]); 
			sday = Number(split_sdate[2]); 
		} 
		if (edate.indexOf("-")>0) {
			split_edate = edate.split("-"); 
			eyear = split_edate[0]; 
			emonth = Number(split_edate[1]); 
			eday = Number(split_edate[2]); 
		} 

		var start_date = new Date(syear,smonth-1,sday);
		var end_date = new Date(eyear,emonth-1,eday);

		var start_date = new Date(Date.parse(start_date));
		var end_date = new Date(Date.parse(end_date));
		
		if (start_date > end_date){
			return false;
		}
		else {
			return true;
		}
	},

	
	GoPrint:function(){
		var obj = th.$("printHTML");
		if (obj!=null){
			this.Open('/popup/popup_print.asp','printpopup','width=743, height=550,scrollbars=yes');
		}
		else{ alert("ÀÎ¼âÇÒ ³»¿ëÀÌ ¾ø½À´Ï´Ù."); }
	},
	StatusBar:function(){
		window.status = "¿Ï·á";
		return true;
	},
	Price:function(v){
		this.Open('/facil/popup/price.html', 'price', 'width=693, height=550, scrollbars=yes'); 
	}
};




if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT | Event.MOUSEDOWN); 
document.onmouseover = th.StatusBar;
document.onmouseout = th.StatusBar;
document.onclick = th.StatusBar;

//DESIGN¿¡ ÇÊ¿äÇÑ ½ºÅ©¸³Æ®
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//************************************************************************
// Function : id2Test
// Description : ID ¹× ´Ð³×ÀÓ Áßº¹Ã¼Å©
// Argument : mode - string
//************************************************************************
function id2Test(mode)
{
	if(mode == 'ID') {
		if(!frm.ID.value){
			alert("Èñ¸Á ID¸¦ ÀÔ·ÂÇÏ¼¼¿ä")
			frm.ID.focus();
			return;
		}


		if (!checkID(frm.ID)) return false;	

		/*
		var url = "id_check.html", arg = "" , ID = "";
		if ( document.frm.id.value != "" )
			arg = "?str=" + document.frm.id.value + "&mode=" + mode;
			
		*/
		var url = JS_HOME_URL + "member/member_check.asp";
		//var arg = "?MEM_ID=" + escape(document.frm.ID.value);
		//var arg = "MEM_ID=" + document.frm.ID.value;
		var responseText = "";
		
		if(window.XMLHttpRequest) {
			xmlhttp = new XMLHttpRequest();
		} else if(window.ActiveXObject) {
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e1) {
				try {
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e2) {
				}
			}
		}



		xmlhttp.open("POST", url, true);
		//xmlhttp.open("POST", url + arg, true);
		//xmlhttp.open("GET", url + arg, true);
		//alert(url + arg);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		//xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');

	
	  	xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4)
			{
				switch (xmlhttp.status) 
				{
					case 404:
				   		alert("¿À·ù404");
						break;
				   case 500:
				   		alert("¿À·ù500");
					   break;
				}            
			}
				   		//alert(xmlhttp.readyState);
				   		//alert(xmlhttp.status);
				   		//alert(xmlhttp.statusText);

		   	if(xmlhttp.readyState==4 && xmlhttp.status == 200 && xmlhttp.statusText=='OK') {
			    responseText = xmlhttp.responseText;
		   	}
		}
		
		var pramMEM_ID = document.frm.ID.value;

		xmlhttp.send("MEM_ID=" + pramMEM_ID);
		//xmlhttp.send();

		if (responseText=="YES") {
	   		alert("ÀÌ¹Ì µî·ÏµÈ IDÀÔ´Ï´Ù.\n\n´Ù½Ã ÀÔ·ÂÇÏ½Ã±â ¹Ù¶ø´Ï´Ù.");
	   		return;
	   	} else {
	   		//url = "http://210.204.162.1/check_web/member_check.asp";
			//arg = "?str=" + document.frm.id.value + "&mode=" + mode;
	   		alert("µî·ÏµÇÁö ¾ÊÀº IDÀÔ´Ï´Ù.\n\nÀÌ¿ë°¡´ÉÇÕ´Ï´Ù.");
	   		frm.iddup.value = "true";
	   		return;
	   	}
	} else if(mode == 'nick') {
		if(!frm.nickname.value){
			alert("´Ð³×ÀÓÀ» ÀÔ·ÂÇÏ¼¼¿ä")
			frm.nickname.focus();
			return;
		}
		var url = "id_check.html", arg = "" , ID = "";
		if ( document.frm.nickname.value != "" )
			arg = "?str=" + document.frm.nickname.value + "&mode=" + mode;
	}
	
	var win = window.open( url + arg, "check", "width=250,height=170,resizable= no" );
	if ( win.focus )
		win.focus();
}



//************************************************************************
// Function : checkSpace
// Description : ¹®ÀÚ¿­ Áß°£¿¡ °ø¹éÀÌ ÀÖ´ÂÁö ¿©ºÎ È®ÀÎ
// Argument : str - string
// Return : true/false(1/0)
//************************************************************************
function checkSpace( str )
{
     if(str.search(/\s/) != -1){
     	return 1;
     }
     else {
        return 0;
     }
}


//************************************************************************
// Function : checkID
// Description : ¾ÆÀÌµð Ã¼Å© ( Ã¹ÀÚ ¿µ¹®ÀÚ, 4~12ÀÚ )
// Argument : IDS - TextBox
// Return : true/false(1/0)
//************************************************************************
function checkID( IDS )
{
 	 str = IDS.value;
	 /* check whether input value is included space or not  */
     if( checkSpace(str) ) {
        alert("¾ÆÀÌµð´Â ºó °ø°£ ¾øÀÌ ÀÔ·ÂÇÏ½Ã±â ¹Ù¶ø´Ï´Ù.");
		IDS.focus(); 
		return 0; 
     } 

	 var ch = str.charAt(0);
	 var isCH = /^[a-z]$/;
	 if ( !isCH.test(ch) ) {
		alert("¾ÆÀÌµð Ã¹ ¹®ÀÚ´Â ¹Ýµå½Ã ¿µ¹® ¼Ò¹®ÀÚ¸¦ »ç¿ëÇØ ÁÖ¼¼¿ä.");
		IDS.focus(); 
		return 0;
     }

     /* checkFormat  */
     var isID = /^[a-z0-9]{4,12}$/;
     if( !isID.test(str) ) {
        alert("¾ÆÀÌµð´Â 4~12ÀÚÀÇ ¿µ¹® ¼Ò¹®ÀÚ¿Í ¼ýÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù."); 
		IDS.focus(); 
		return 0; 
     }

     return 1;
}
