	var FONT_LARGE_SIZE= 28;
	var FONT_SMALL_LSIZE= 10;
	fontResize = function(obj, option){

		$mainText = $('.' + obj)
		var currentSize = $mainText.css('font-size')
		var num = parseFloat(currentSize, 10);
		var unit = currentSize.slice(-2);
		if (option == 'large'){
			num = num * 1.1;
		} else if (option == 'small'){
			num = num / 1.1;
		}
		if (num > FONT_LARGE_SIZE)
			return;
		if (num < FONT_SMALL_LSIZE)
			return;
		$mainText.css('font-size', num + unit);
	}
	
	byteLength = function(text) {
		 var byteSize = 0;
		 for (var i = 0; i < text.length; i++) {
		     val = escape(text.charAt(i)).length;
		     if (val == 6) byteSize++;
		     byteSize++;
		 }
		 return byteSize;
	}	
	//글자수 제한
	function updateChar(textobject, spanname, length_limit)
	{
	    var msg = textobject.value;
	    var length = byteLength(msg);
	    if (spanname != '') {
	        document.getElementById(spanname).innerHTML = toMoneyExp(length);
	    }
	    if (length > length_limit) {
	        alert("최대 " + length_limit + "byte이므로 초과된 글자수는 자동으로 삭제됩니다.");
	        textobject.value = textobject.value.replace(/\r\n$/, "");
	        textobject.value = assert_msglen(textobject.value, length_limit, spanname);
	    }
	    
	}
	//세자리마다 ',' 기호를 넣는다.
	function toMoneyExp(digit) {
	 var digitstr = digit + "";
	 var retstr = "";
	 for (var i = digitstr.length - 1, j = 0; i >= 0; i--, j++) {
	     if (j != 0 && j %3 == 0) retstr = "," + retstr;
	     retstr = digitstr.charAt(i) + retstr;
	 }
	 return retstr;
	}
	
	function assert_msglen(message, maximum, spanname)
	{
	    var inc = 0;
	    var nbytes = 0;
	    var msg = "";
	    var msglen = message.length;

	    for (i=0; i<msglen; i++) {
	        var ch = message.charAt(i);
	        if (escape(ch).length > 4) {
	            inc = 2;
	        } else if (ch == '\n') {
	            if (message.charAt(i-1) != '\r') {
	                inc = 1;
	            }
	        } else if (ch == '<' || ch == '>') {
	            inc = 4;
	        } else {
	            inc = 1;
	        }
	        if ((nbytes + inc) > maximum) {
	            break;
	        }
	        nbytes += inc;
	        msg += ch;
	    }
	    if (spanname != '') {
	        document.getElementById(spanname).innerHTML = toMoneyExp(nbytes);
	    }
	    return msg;
	}

	function openUploadImageWindow(callbackFunctionName, location, xss, use) {
	    var url = '/popup/image.md?callback_function=' + callbackFunctionName + '&location=' + location + '&xss=' + xss;
	    if (use != null) { url = url + '&use=' + use; }
	    popup(url, 'upload_image', 490, 481, 'no');
	}

	function ShowFlash(url, width, height, varname){
		document.write('<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" WIDTH="' + width + '" HEIGHT="' + height + '" id="index_navi_01" ALIGN="">');
		document.write('<PARAM NAME=movie VALUE="' + url + '">');
		document.write('<PARAM NAME=loop VALUE=true>');
		document.write('<PARAM NAME=menu VALUE=false>');
		document.write('<PARAM NAME=quality VALUE=high>');
		document.write('<PARAM NAME=scale VALUE=noscale>');
		document.write('<PARAM NAME=wmode VALUE=transparent>');
		document.write('<PARAM NAME=bgcolor VALUE=#437493>');
		document.write('<PARAM NAME=allowScriptAccess VALUE=always>');
		document.write('<PARAM NAME=flashVars VALUE="' + varname + '">');
		document.write('<EMBED src="' + url + '" menu=false quality=high scale=noscale wmode=transparent allowScriptAccess="always" loop="true" bgcolor=#437493  WIDTH="' + width + '" HEIGHT="' + height + '" NAME="index_navi_01" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
		document.write('</OBJECT>');
	}
	
	//공통팝업 
	function openPopWindow(szURL, szTarget, iWidth, iHeight, scrollable, resizable, returnwin) {
	    var argv = openPopWindow.arguments;
	    if (scrollable == undefined) scrollable = "no";
	    if (resizable == undefined) resizable = "no";
	    var option = 'width=' + iWidth + ',height=' + iHeight + ',resizable=' + resizable + ',scrollbars=' + scrollable;

	    var openWindow = window.open(szURL, szTarget, option);
	    openWindow.focus();

	    if (returnwin != undefined && returnwin == true) {
	        return openWindow;
	    }
	}
	
	//브라우져 종류에 따른 popup 높이 조정
	function popup(url, wndName, width, height, scrollable, resizable) {
	    if (typeof scrollable == 'undefined') scrollable = "no";
	    if (typeof resizable == 'undefined') resizable = "no";

	    return openPopWindow(url, wndName, parseInt(width), parseInt(height) + getAdditionalWindowBorderHeight(), scrollable, resizable);
	}

	function getAdditionalWindowBorderHeight() {
	    var h = 0;
	    if (navigator.userAgent.indexOf("SV1") > 0) {
	        h = 14;
	    } else if(navigator.userAgent.indexOf("MSIE 7") > 0) {
	        h = 45;
	    } else if(navigator.userAgent.indexOf("Gecko") > 0
	            && navigator.userAgent.indexOf("Firefox") <= 0
	            && navigator.userAgent.indexOf("Netscape") <= 0 ) {
	        h = 22;
	    } else if(navigator.userAgent.indexOf("Firefox") > 0 ) {
	        h = 18;
	    } else if(navigator.userAgent.indexOf("Netscape") > 0 ) {
	        h = -2;
	    } else {
	        h = 0;
	    }
	    return h;
	}
	
	
	noThumbNail=function(img, changeimage) {
		img.src = changeimage;
	}
	checkInput=function(id, color){
		if($("#" + id).val().length > 0 )
			$("#" + id).css("background",color);
	}	
	
	var HashMap = function()
	{
	    var mapVal  = {};    // private
	    var pos     = new Array();

	    this.get = function( key )
	    {
	        return mapVal[ key ];
	    }

	    this.getPos = function( n )
	    {
	        return mapVal[ pos[n] ];
	    }

	    this.remove = function( n )
	    {
	        var ary = new Array();
	        for( var i=0; i<map.size(); i++ )
	        {
	            if( i != n )
	            {
	                ary.push( pos[i] );
	            }
	        }
	        pos = ary;
	    }

	    this.put = function( key, val )
	    {
	        mapVal[key] = val;

	        var flg = true;
	        for( var i=0; i<pos.length; i++ )
	        {
	            if( key == pos[i] )
	                flg = false;
	        }

	        if( flg )
	            pos.push( key );
	    }

	    this.size = function()
	    {
	        return pos.length;
	    }
	}

	wait=function(msecs){
		var start = new Date().getTime();
		var cur = start;
		while(cur - start < msecs)
		{
			cur = new Date().getTime();
		}
	}
	
	frnRecommend=function(_id, _type){
		$.ajax({
			type: "POST",
			url: "/process/recommend.md",
			data: "id=" + _id + "&type=" + _type,
			success: function(data){
				if (data == "추천 되었습니다."){
					alert(data+'\n오늘도 건강한 하루 되세요.');
					$container = $('#cnt_' + _id);
					var cnt = parseInt($container.text().replace('(','').replace(')',''))+1;
					/*if (_type =='ST')
						$container.text('('+ cnt + ')');
					else*/
						$container.text(cnt);
						
				} else {
					alert(data);
				}
			},
			error:function(){alert('추천 하는 도중 문제가 발생 하여\n추천 되지 않았습니다.')}
		});     	
	}

	frnScrap=function(_id, _type, _url, _subject){
		$.ajax({
			type: "POST",
			url: "/process/scrap.md",
			data: {id:_id,
				type:_type,
				url:_url,
				subject:_subject},
			success: function(data){
				alert(data+'\n오늘도 건강한 하루 되세요.');
			},
			error:function(){alert('스크랩 하는 도중 문제가 발생 하여\n스크랩 되지 않았습니다.')}
		});     	
	}
    
	lpad = function(i,l,s) {
		var o = i.toString();
		if (!s) { s = '0'; }
		while (o.length < l) {
			o = s + o;
		}
		return o;
	}

	loginIframeAction = function(element) {
		var href = '/register/login.md?url=' +
			encodeURIComponent(
					document.location.href +
					((document.location.href.indexOf('?') < 0) ? '?' : '&') +
					'_action=' + encodeURIComponent(element.href)
			);
		document.location.href = href;
		return false;  
	}

	getTreatment=function(_type, _catetype, _catecode, _display){
		$.ajax({
			type: "POST",
			url: "/data/treatment.md",
			data: "type=" + _type + "&catecode=" + _catecode + "&catetype=" + _catetype,
			success: function(data){
				$('.'+_display).html('').append(data);
			},
			error:function(){
				alert('Data 통신이  실패 하였습니다.');
			}
		});
	}
	
	function open_pop(url, name, wid, hei, top, left){
   		window.open(url, name, 'toolbar=0,location=0,directories=0, status=no,menubar=0,scrollbars=YES,resizable=yes,width='+wid+',height='+hei+',top='+top+',left='+left);
	}
	
	function chat_string_create_urls(input)
	{
	    return input
	    	.replace(/<br>/gim, '\n')
	    	.replace(/(ftp|http|https|file):\/\/[\S]+(\b|$)/gim,
				'<a href="$&" class="my_link" target="_blank">$&</a>')
	    	.replace(/([^\/])(www[\S]+(\b|$))/gim,
				'$1<a href="http://$2" class="my_link" target="_blank">$2</a>')
			.replace(/\n/gim, '<br>');
	} 

	function createLinks(ele) {
		$(ele).each(function() {
			var text = chat_string_create_urls($.trim($(this).html()));
			//alert($(this).html()+'\n----\n'+text);
			$(this).html(text);
		});
	}
	
	function input(name, value) {
		if (typeof value == 'undefined') {
			return $.trim($('input[name="'+name+'"]').val());
		} else {
			$('input[name="'+name+'"]').val(value);
		}
	}
