//±âÅ¸ °øÅë ######
	
	//¹®ÀÚ¿­ Trim
	String.prototype.Trim = function() {
	    return this.replace(/(^ *)|( *$)/g, "");
	}

	//id,ºñ¹øÀÇ À¯È¿¼º Ã¼Å©
	function isValidAlphaNum(idPassStr)
	{	
		var AlphaNumCheck = /[^_a-zA-Z0-9-]/ ;
		try{
			idPassStr = idPassStr.Trim();
			if( idPassStr.length >= 4 &&  idPassStr.length <=16 && AlphaNumCheck.test(idPassStr) == false ){
				return true;
			}else{
				return false;
			}
		}catch(ex){alert(ex.message); return false; }
	}
	//ÀÌ¸ÞÀÏ À¯È¿¼º Ã¼Å©
	function isValuidEmail(emailStr)
	{
		try{
			emailStr = emailStr.Trim();
			if (emailStr.search(/(\S+)@(\S+)\.(\S+)/) == -1 ) {
				return false;
			}
			return true;
		}catch(e){return false; }
	}
	//¿£ÅÍ½Ã Æ÷Ä¿½º ÀÌµ¿
	function next_focus(nextObj) 
	{
		var type_name = typeof(nextObj) ;
		try{
			if( type_name == "object"  && event.keyCode == 13){
				nextObj.focus();
			}else if ( type_name == "function"  && event.keyCode == 13 ){
				nextObj();
			}
		}catch(ex) {;}
	}

	//¶óµð¿À ¹öÆ° ¶óº§ ±â´É
	function ch_radio(id_str)
	{
		try{
			document.getElementById(id_str).checked = true;
		}catch(ex){alert(ex.message);}
	}


	//TR ÅÂ±×¿¡ ¸¶¿ì½º ¿À¹ö, ¾Æ¿ô½Ã »ö»ó º¯°æ
	function over_tr(objTR, color)
	{
		objTR.style.backgroundColor = color ;
	}

	//ÇØ´ç °ªÀÌ ¼ýÀÚÀÎÁö È®ÀÎ
	function is_number(num)
	{
		var regNum = /[^0-9]/ ;
		if(num == "" || regNum.test(num)){
			return false;
		}else{
			return true;
		}
	}
	function num_ch(thisObj)
	{
		var regNum = /[^0-9]/ ;
		if (regNum.test(thisObj.value) ){
			thisObj.value = "";
			thisObj.focus();
		}
	}

	//select ¹Ú½º¿¡¼­ ÇöÀç ¼±ÅÃÇÑ option Ç¥½ÃÇÏ±â - ÁÖ·Î °Ë»ö¿¡¼­ »ç¿ëÇÔ.
	function set_combo_selected(selectObj, reqValue ){
		try{
			for(i=0; i< selectObj.options.length; i++){
				if( selectObj.options[i].value == reqValue ){
					selectObj.options[i].selected = true;
				}
			}
		}catch(ex) {; }
	}
	
	//1000 ´ÜÀ§·Î ÄÞ¸¶ ºÙÀÌ±â
	function comma(x) 
	{
		var txtNumber = '' + x;
		var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
		var arrNumber = txtNumber.split('.');
		arrNumber[0] += '.';
		do {
			arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');
		} 
		while (rxSplit.test(arrNumber[0]));
		if (arrNumber.length > 1) 
		{
			return arrNumber.join('');
		}else {
			return arrNumber[0].split('.')[0];
		 }
	}
	
	//³»¿ëº¸±â ZOOM - °øÅë
	function zoom_detail(flag){
		try{
			var elem = document.getElementById("content_box");
			if( elem.style.zoom == ""){
				 elem.style.zoom = "100%"
			}
			elem.style.zoom = parseInt( elem.style.zoom) + 10 * flag + "%";
		}catch(ex){alert(ex.message);}
	}
	//ÆäÀÌÁö ÇÁ¸°Æ®
	function page_print(idx, cid){
		window.open("./print_page.asp?cid=" + cid +"&idx=" + idx, "print","width=700, height=600 , top=0, left=100, scrollbars=yes, resizable=yes");
	}
	//ÆäÀÌÁö ÀÌ¸ÞÀÏ ¹ß¼Û
	function page_email(idx, cid){
		//alert("ÁØºñÁßÀÎ ±â´ÉÀÔ´Ï´Ù.")
		var ww = screen.width/2 - 240;
		var hh = screen.height/2 - 120;
		
		window.open("../mboard/print_email.asp?cid=" + cid +"&idx=" + idx, "email","width=480, height=240, scrollbars=no, resizable=no , top=" + hh + ", left=" + ww);
	}
	//ÆäÀÌÁö ½ºÅ©·¦ : AJAX ÀÌ¿ë
	function page_scrap(idx, cid){
		
		var remote_url = "../mboard/scrap_do.asp";
		var query_string = "idx=" + idx + "&cid=" + cid;
		
		var user_callback_func = scrap_result;	//°á°ú¸¦ ¹ÞÀ» ÇÔ¼ö
		ajax_http_init(remote_url, "post", query_string, user_callback_func);		
	}
	//ÆäÀÌÁö ½ºÅ©·¦ ¼º°ø Ã³¸®
	function scrap_result(req) 
	{
		try{
			returnStr = req.responseText;
			if(returnStr == "ok"){
				alert("OK");
			}else{
				if( confirm("You have to log in.\n\nDo you move LogIn page?") ){
					
					document.location.href = "../join/login.asp?go_url=" + escape(document.location.href);
				}
			}
		}catch(ex){alert(ex.message)}
	}


//ÇÃ·¡½¬ °ü·Ã ####
	//¸ÞÀÎºñÁÖ¾ó°ú ¸Þ´º Ãâ·Â (ÆÄÀÏ¸í, ³Êºñ, ³ôÀÌ)
	function printFlash (swfName, ww, hh )
	{
		try{
			var path_info = location.href;
			swfName = swfName + "?path_info=" + path_info.substr(0, path_info.indexOf(".asp") );
			tagString = ""
				+ "<object width=" + ww +" height=" + hh +" id='menu_main' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' align='middle'>"
				+ "<param name='allowScriptAccess' value='sameDomain' />"
				+ "<param name='movie' value='" + swfName + "' />"
				+ "<param name='quality' value='high' />"
				+ "<param name='wmode' value='transparent' />"
				+ "<param name='bgcolor' value='#ffffff' />"
				+ "<embed src='" + swfName + "' bgcolor='#ffffff' width=" + ww +" height="+ hh + " name='menu_main' quality='high' wmode='transparent'  align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
				+ "</object>";
			//Ãâ·Â
			document.write(tagString);
		}catch(ex) { ; }
	}

//ÆË¾÷ °øÁö °ü·Ã ####
	function getCookie( 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 "";
	}

//°Ë»ö °ü·Ã ####
	//¸ÞÀÎ °Ë»ö
	function search_main(objForm)
	{
		try{
			var sword = objForm.sword.value.Trim() ;
			if( sword == "" || sword.length < 2 ){
				alert("Please enter a keyword")
				objForm.sword.focus();
				return;
			}
			objForm.submit();
			
		}catch(ex) {;}
	}


//·Î±×ÀÎ °ü·Ã ####
	var form_idArr = new Array();
	form_idArr[0] = "loginForm";
	form_idArr[1] = "loginBodyForm";

	//ÅØ½ºÆ® ¹Ú½º¿¡ Æ÷Ä¿½º ÇÏ¸é ¹è°æ ÀÌ¹ÌÁö ¾ø¾Ö±â
	function elem_text_focus(objElem)
	{
		try{
			objElem.style.backgroundImage = "";
			objElem.select();
		}catch(ex) {;}
	}

	//ÁÂÃø ·Î±×ÀÎ Ã¢¿¡¼­ Àü¼Û
	function send_login(){
		try{
			send_login_do(document.loginForm);
		}catch(ex){ ; }
	}
	
	//º»¹® ·Î±×ÀÎ Ã¢¿¡¼­ Àü¼Û
	function send_login_body(){
		try{
			send_login_do(document.loginBodyForm);
		}catch(ex){ ; }
	}
	
	//·Î±×ÀÎ Àü¼Û
	var go_url; 	//·Î±×ÀÎ ¿Ï·áÈÄ ÀÌµ¿ÇÒ ÆäÀÌÁö
	function send_login_do(objForm)
	{
		try{
			var email = objForm.email.value;
			var u_pw = objForm.u_pw.value;
			go_url = objForm.go_url.value;
			if( ! isValuidEmail(email) ){
				alert("Please your email address correctly");
				objForm.email.focus();
				return; 
			}
			if( u_pw.length < 4 || u_pw.length > 12 ){
				alert("Please enter correct password : 4~12 characters");
				objForm.u_pw.focus();
				return; 
			}
			
			var remote_url = "../join/login_do.asp";
			var query_string = "email=" + email + "&u_pw=" + u_pw ;
			var user_callback_func = login_result;	//°á°ú¸¦ ¹ÞÀ» ÇÔ¼ö
			ajax_http_init(remote_url, "post", query_string, user_callback_func);

		}catch(ex){alert(ex.message); }
	}
	//·Î±×ÀÎ ¼º°ø Ã³¸®
	function login_result(req) 
	{
		try{
			returnStr = req.responseText;
			if(returnStr=="ok"){	//·Î±×ÀÎ ¼º°ø½Ã
				document.location.href = go_url ;
				//document.referrer
			}else{
				alert(returnStr)
			}
			
		}catch(ex){alert(ex.message)}
	}

//AJAX °ü·Ã #####

	//ºó ÇÔ¼ö
	function void_function(){;}
	
	//AJAX ¿¬°á
	function ajax_http_request()
	{
		req = null;
		try{
			request = new XMLHttpRequest();
		} catch(trymicrosoft){
			try{
				request = new ActiveXObject("Mszm12.XMLHTTP");
			}catch(failed){
				try{
					request = new ActiveXObject("Microsoft.XMLHTTP");
				}catch(failed){
					request = null;
				}
			}
		}
		return request;
	}
	//AJAX ÃÊ±âÈ­
	function ajax_http_init(remote_url, query_method, query_string, user_callback_func)
	{
		try{
			var req = ajax_http_request();
			if(!req){
				alert("browser");	
			}else{
				req.onreadystatechange = function(){
					
					//alert(req.status)
					if (req.readyState == 4) {
						if (req.status == 200) {
							user_callback_func(req);
						}else if (req.status == 500) {
							alert(req.responseText);
						}
					}
				}
				req.open(query_method, remote_url, true);
				if(query_method.toLowerCase() == "post"){
					req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				}
				
				
				req.send(query_string);
			}
		} catch(ex){alert(ex.message); }
	}
