if (typeof(COMMON_JS) == 'undefined') { // 한번만 실행
    var COMMON_JS = true;

    // 전역 변수
    var errmsg = "";
    var errfld;

    // 필드 검사
    function check_field(fld, msg) 
    {
        if ((fld.value = trim(fld.value)) == "") 			   
            error_field(fld, msg);
        else
            clear_field(fld);
        return;
    }

    // 필드 오류 표시
    function error_field(fld, msg) 
    {
        if (msg != "")
            errmsg += msg + "\n";
        if (!errfld) errfld = fld;
        fld.style.background = "#BDDEF7";
    }

    // 필드를 깨끗하게
    function clear_field(fld) 
    {
        fld.style.background = "#FFFFFF";
    }

    function trim(s)
    {
        var t = "";
        var from_pos = to_pos = 0;

        for (i=0; i<s.length; i++)
        {
            if (s.charAt(i) == ' ')
                continue;
            else 
            {
                from_pos = i;
                break;
            }
        }

        for (i=s.length; i>=0; i--)
        {
            if (s.charAt(i-1) == ' ')
                continue;
            else 
            {
                to_pos = i;
                break;
            }
        }	

        t = s.substring(from_pos, to_pos);
        //				alert(from_pos + ',' + to_pos + ',' + t+'.');
        return t;
    }

    // 자바스크립트로 PHP의 number_format 흉내를 냄
    // 숫자에 , 를 출력
    function number_format(data) 
    {
        
        var tmp = '';
        var number = '';
        var cutlen = 3;
        var comma = ',';
        var i;
       
        len = data.length;
        mod = (len % cutlen);
        k = cutlen - mod;
        for (i=0; i<data.length; i++) 
        {
            number = number + data.charAt(i);
            
            if (i < data.length - 1) 
            {
                k++;
                if ((k % cutlen) == 0) 
                {
                    number = number + comma;
                    k = 0;
                }
            }
        }

        return number;
    }

    // 새 창
    function popup_window(url, winname, opt)
    {
        window.open(url, winname, opt);
    }


    // 폼메일 창
    function popup_formmail(url)
    {
        opt = 'scrollbars=yes,width=417,height=385,top=10,left=20';
        popup_window(url, "wformmail", opt);
    }

    // , 를 없앤다.
    function no_comma(data)
    {
        var tmp = '';
        var comma = ',';
        var i;

        for (i=0; i<data.length; i++)
        {
            if (data.charAt(i) != comma)
                tmp += data.charAt(i);
        }
        return tmp;
    }

    // 삭제 검사 확인
    function del(href) 
    {
        if(confirm("한번 삭제한 자료는 복구할 방법이 없습니다.\n\n정말 삭제하시겠습니까?")) {
            if (g4_charset.toUpperCase() == 'EUC-KR') 
                document.location.href = href;
            else
                document.location.href = encodeURI(href);
        }
    }

    // 쿠키 입력
    function set_cookie(name, value, expirehours, domain) 
    {
        var today = new Date();
        today.setTime(today.getTime() + (60*60*1000*expirehours));
        document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";";
        if (domain) {
            document.cookie += "domain=" + domain + ";";
        }
    }

    // 쿠키 얻음
    function get_cookie(name) 
    {
        var find_sw = false;
        var start, end;
        var i = 0;

        for (i=0; i<= document.cookie.length; i++)
        {
            start = i;
            end = start + name.length;

            if(document.cookie.substring(start, end) == name) 
            {
                find_sw = true
                break
            }
        }

        if (find_sw == true) 
        {
            start = end + 1;
            end = document.cookie.indexOf(";", start);

            if(end < start)
                end = document.cookie.length;

            return document.cookie.substring(start, end);
        }
        return "";
    }

    // 쿠키 지움
    function delete_cookie(name) 
    {
        var today = new Date();

        today.setTime(today.getTime() - 1);
        var value = get_cookie(name);
        if(value != "")
            document.cookie = name + "=" + value + "; path=/; expires=" + today.toGMTString();
    }

    // 이미지의 크기에 따라 새창의 크기가 변경됩니다.
    // zzzz님께서 알려주셨습니다. 2005/04/12
    function image_window(img)
    {
        var w = img.tmp_width; 
        var h = img.tmp_height; 
        var winl = (screen.width-w)/2; 
        var wint = (screen.height-h)/3; 

        if (w >= screen.width) { 
            winl = 0; 
            h = (parseInt)(w * (h / w)); 
        } 

        if (h >= screen.height) { 
            wint = 0; 
            w = (parseInt)(h * (w / h)); 
        } 

        var js_url = "<script language='JavaScript1.2'> \n"; 
            js_url += "<!-- \n"; 
            js_url += "var ie=document.all; \n"; 
            js_url += "var nn6=document.getElementById&&!document.all; \n"; 
            js_url += "var isdrag=false; \n"; 
            js_url += "var x,y; \n"; 
            js_url += "var dobj; \n"; 
            js_url += "function movemouse(e) \n"; 
            js_url += "{ \n"; 
            js_url += "  if (isdrag) \n"; 
            js_url += "  { \n"; 
            js_url += "    dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x; \n"; 
            js_url += "    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y; \n"; 
            js_url += "    return false; \n"; 
            js_url += "  } \n"; 
            js_url += "} \n"; 
            js_url += "function selectmouse(e) \n"; 
            js_url += "{ \n"; 
            js_url += "  var fobj      = nn6 ? e.target : event.srcElement; \n"; 
            js_url += "  var topelement = nn6 ? 'HTML' : 'BODY'; \n"; 
            js_url += "  while (fobj.tagName != topelement && fobj.className != 'dragme') \n"; 
            js_url += "  { \n"; 
            js_url += "    fobj = nn6 ? fobj.parentNode : fobj.parentElement; \n"; 
            js_url += "  } \n"; 
            js_url += "  if (fobj.className=='dragme') \n"; 
            js_url += "  { \n"; 
            js_url += "    isdrag = true; \n"; 
            js_url += "    dobj = fobj; \n"; 
            js_url += "    tx = parseInt(dobj.style.left+0); \n"; 
            js_url += "    ty = parseInt(dobj.style.top+0); \n"; 
            js_url += "    x = nn6 ? e.clientX : event.clientX; \n"; 
            js_url += "    y = nn6 ? e.clientY : event.clientY; \n"; 
            js_url += "    document.onmousemove=movemouse; \n"; 
            js_url += "    return false; \n"; 
            js_url += "  } \n"; 
            js_url += "} \n"; 
            js_url += "document.onmousedown=selectmouse; \n"; 
            js_url += "document.onmouseup=new Function('isdrag=false'); \n"; 
            js_url += "//--> \n"; 
            js_url += "</"+"script> \n"; 

        var settings;

        if (g4_is_gecko) {
            settings  ='width='+(w+10)+','; 
            settings +='height='+(h+10)+','; 
        } else {
            settings  ='width='+w+','; 
            settings +='height='+h+','; 
        }
        settings +='top='+wint+','; 
        settings +='left='+winl+','; 
        settings +='scrollbars=no,'; 
        settings +='resizable=yes,'; 
        settings +='status=no'; 


        win=window.open("","image_window",settings); 
        win.document.open(); 
        win.document.write ("<html><head> \n<meta http-equiv='imagetoolbar' CONTENT='no'> \n<meta http-equiv='content-type' content='text/html; charset="+g4_charset+"'>\n"); 
        var size = "이미지 사이즈 : "+w+" x "+h;
        win.document.write ("<title>"+size+"</title> \n"); 
        if(w >= screen.width || h >= screen.height) { 
            win.document.write (js_url); 
            var click = "ondblclick='window.close();' style='cursor:move' title=' "+size+" \n\n 이미지 사이즈가 화면보다 큽니다. \n 왼쪽 버튼을 클릭한 후 마우스를 움직여서 보세요. \n\n 더블 클릭하면 닫혀요. '"; 
        } 
        else 
            var click = "onclick='window.close();' style='cursor:pointer' title=' "+size+" \n\n 클릭하면 닫혀요. '"; 
        win.document.write ("<style>.dragme{position:relative;}</style> \n"); 
        win.document.write ("</head> \n\n"); 
        win.document.write ("<body leftmargin=0 topmargin=0 bgcolor=#dddddd style='cursor:arrow;'> \n"); 
        win.document.write ("<table width=100% height=100% cellpadding=0 cellspacing=0><tr><td align=center valign=middle><img src='"+img.src+"' width='"+w+"' height='"+h+"' border=0 class='dragme' "+click+"></td></tr></table>");
        win.document.write ("</body></html>"); 
        win.document.close(); 

        if(parseInt(navigator.appVersion) >= 4){win.window.focus();} 
    }

    // a 태그에서 onclick 이벤트를 사용하지 않기 위해
    function win_open(url, name, option)
    {
        var popup = window.open(url, name, option);
        popup.focus();
    }

    // 우편번호 창
    function win_zip(frm_name, frm_zip1, frm_zip2, frm_addr1, frm_addr2)
    {
        url = g4_path + "/" + g4_bbs + "/zip.php?frm_name="+frm_name+"&frm_zip1="+frm_zip1+"&frm_zip2="+frm_zip2+"&frm_addr1="+frm_addr1+"&frm_addr2="+frm_addr2;
        win_open(url, "winZip", "left=50,top=50,width=616,height=460,scrollbars=1");
    }

    // 쪽지 창
    function win_memo(url)
    {
        if (!url)
            url = g4_path + "/" + g4_bbs + "/memo.php";
        win_open(url, "winMemo", "left=50,top=50,width=620,height=460,scrollbars=1");
    }

    // 포인트 창
    function win_point(url)
    {
        win_open(g4_path + "/" + g4_bbs + "/point.php", "winPoint", "left=20, top=20, width=616, height=635, scrollbars=1");
    }

    // 스크랩 창
    function win_scrap(url)
    {
        if (!url)
            url = g4_path + "/" + g4_bbs + "/scrap.php";
        win_open(url, "scrap", "left=20, top=20, width=616, height=500, scrollbars=1");
    }

    // 패스워드 분실 창
    function win_password_forget()
    {
        win_open(g4_path + "/" + g4_bbs + "/password_forget.php", 'winPasswordForget', 'left=50, top=50, width=616, height=500, scrollbars=1');
    }

    // 코멘트 창
    function win_comment(url)
    {
        win_open(url, "winComment", "left=50, top=50, width=800, height=600, scrollbars=1");
    }

    // 폼메일 창
    function win_formmail(mb_id, name, email)
    {
		if (g4_charset.toLowerCase() == 'euc-kr')
	        win_open(g4_path+"/" + g4_bbs + "/formmail.php?mb_id="+mb_id+"&name="+name+"&email="+email, "winFormmail", "left=50, top=50, width=600, height=500, scrollbars=0");
		else
	        win_open(g4_path+"/" + g4_bbs + "/formmail.php?mb_id="+mb_id+"&name="+encodeURIComponent(name)+"&email="+email, "winFormmail", "left=50, top=50, width=600, height=480, scrollbars=0");
    }

    // 달력 창
    function win_calendar(fld, cur_date, delimiter, opt)
    {
        if (!opt)
            opt = "left=50, top=50, width=240, height=230, scrollbars=0,status=0,resizable=0";
        win_open(g4_path+"/" + g4_bbs + "/calendar.php?fld="+fld+"&cur_date="+cur_date+"&delimiter="+delimiter, "winCalendar", opt);
    }

    // 설문조사 창
    function win_poll(url)
    {
        if (!url)
            url = "";
        win_open(url, "winPoll", "left=50, top=50, width=616, height=500, scrollbars=1");
    }

    // 자기소개 창
    function win_profile(mb_id)
    {
        win_open(g4_path+"/" + g4_bbs + "/profile.php?mb_id="+mb_id, 'winProfile', 'left=50,top=50,width=620,height=510,scrollbars=1');
    }

    var last_id = null;
    function menu(id)
    {
        if (id != last_id)
        {
            if (last_id != null)
                document.getElementById(last_id).style.display = "none";
            document.getElementById(id).style.display = "block";
            last_id = id;
        }
        else
        {
            document.getElementById(id).style.display = "none";
            last_id = null;
        }
    }

    function textarea_decrease(id, row)
    {
        if (document.getElementById(id).rows - row > 0)
            document.getElementById(id).rows -= row;
    }

    function textarea_original(id, row)
    {
        document.getElementById(id).rows = row;
    }

    function textarea_increase(id, row)
    {
        document.getElementById(id).rows += row;
    }

    // 글숫자 검사
    function check_byte(content, target)
    {
        var i = 0;
        var cnt = 0;
        var ch = '';
        var cont = document.getElementById(content).value;

        for (i=0; i<cont.length; i++) {
            ch = cont.charAt(i);
            if (escape(ch).length > 4) {
                cnt += 2;
            } else {
                cnt += 1;
            }
        }
        // 숫자를 출력
        document.getElementById(target).innerHTML = cnt;

        return cnt;
    }

    // 브라우저에서 오브젝트의 왼쪽 좌표
    function get_left_pos(obj)
    {
        var parentObj = null;
        var clientObj = obj;
        //var left = obj.offsetLeft + document.body.clientLeft;
        var left = obj.offsetLeft;

        while((parentObj=clientObj.offsetParent) != null)
        {
            left = left + parentObj.offsetLeft;
            clientObj = parentObj;
        }

        return left;
    }

    // 브라우저에서 오브젝트의 상단 좌표
    function get_top_pos(obj)
    {
        var parentObj = null;
        var clientObj = obj;
        //var top = obj.offsetTop + document.body.clientTop;
        var top = obj.offsetTop;

        while((parentObj=clientObj.offsetParent) != null)
        {
            top = top + parentObj.offsetTop;
            clientObj = parentObj;
        }

        return top;
    }

    function flash_movie(src, ids, width, height, wmode)
    {
        var wh = "";
        if (parseInt(width) && parseInt(height)) 
            wh = " width='"+width+"' height='"+height+"' ";
        return "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' "+wh+" id="+ids+"><param name=wmode value="+wmode+"><param name=movie value="+src+"><param name=quality value=high><embed src="+src+" quality=high wmode="+wmode+" type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash' "+wh+"></embed></object>";
    }

    function obj_movie(src, ids, width, height, autostart)
    {
        var wh = "";
        if (parseInt(width) && parseInt(height)) 
            wh = " width='"+width+"' height='"+height+"' ";
        if (!autostart) autostart = false;
        return "<embed src='"+src+"' "+wh+" autostart='"+autostart+"'></embed>";
    }

    function doc_write(cont)
    {
        document.write(cont);
    }
}



function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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];}
}

if(window.location.href.replace(g4_url,'').indexOf('/bbs/') < 0 && g4_url.indexOf('staff') < 0)
{
	$(document).ready(function (){
	
		new GenerationHTML4XHTML();
		if(window.location.href.replace(g4_url,'') != '/') 	new InitLeftMenu();
		else 												new initVod();
		if(window.location.href.replace(g4_url,'') == '/aboutus/map') new MapToggle();
		if(window.location.href.replace(g4_url,'') == '/participation/application') new ApplicationToggle();
		if(window.location.href.replace(g4_url,'') == '/aboutus/vision') new VisionToggle();
		new InitFooter();
		new onFocusBlurInit();
	});
}

function onFocusBlurInit()
{
	$('a').each(function(){
		if($(this).attr('onfocus') == null){
			$(this).focus(function (){
				$(this).blur();
			});
		}
	})
}

function getSchedule(uq,year,month,day,ingType)
{
	$.post('/common/schedule/getSchedulePerDay.grace', {
		sidx : uq,
	    yyyy : year,
	    mm : month,
	    dd : day,
	    type : ingType
	}, function(data) {
		//alert(data);
	    $('#detail_information_about_schedule',window.parent.document).html(data);
	});
}

function GenerationHTML4XHTML()
{
	$('img[align=absmiddle]').each(function(i){
		$(this).attr('align','center');
		$(this).attr('style','margin-top:-2px');
	});
}

// 좌측메뉴 초기화
function InitLeftMenu()
{
	var params = $('a[href='+window.location.href.replace(g4_url,'')+']>img').attr('src').split('_');
		
	if($('a[href='+window.location.href.replace(g4_url,'')+']>img').attr('src').indexOf('o.gif') < 0)
		$('a[href='+window.location.href.replace(g4_url,'')+']').parent().html($('a[href='+window.location.href.replace(g4_url,'')+']').html().replace('.gif','o.gif'));
	else
		$('a[href='+window.location.href.replace(g4_url,'')+']').parent().html($('a[href='+window.location.href.replace(g4_url,'')+']').html());

	var cat_main = parseInt(params[1].substring(1,3).replace('0',''));
	if(cat_main == 5)	cat_main = 1;
	else				cat_main++;
	
	$('#subVisualFlash').html(flash_movie('/images/swf/sub_visual0'+cat_main+'.swf?main='+cat_main+'&sub='+params[2].substring(0,2).replace('0',''), 'subvisual', 668, 277, 'transparent'));
	/* jquery flash plugin is not support for allowscriptaccess param option
	$('#subVisualFlash').flash(
		{ 
		  src: '/images/swf/sub_visual0'+cat_main+'.swf',
		  width: 668,
		  height: 277,
		  wmode: 'transparent',
		  AllowScriptAccess: 'sameDomain',
		  flashvars: { main: cat_main, sub: params[2].substring(0,2).replace('0','') }
		},
		{ version: 8 }
	 );
	*/
	$("img#print_button").click(function(){
		if($('#main').attr('tagName') == 'IFRAME')
		{
			$("#main").contents().find('html').printArea(
					{
						popTitle 	: '',
						popClose 	: true,
						strict 		: false,
						mode		: 'popup',
						popWd		: '660px',
						popScrol	: 'yes'
					}
			);
		}
		else
		{
			$("#myPrintArea").printArea(
					{
						popTitle 	: '',
						popClose 	: true,
						strict 		: true,
						mode		: 'popup',
						popWd		: '700px',
						popScrol	: 'yes'
					}
			);
		}
	});
}

// 하단 공통영역 초기화
function InitFooter()
{
	$('#full_view_sponsor').click(function(){
		window.location.href = '/participation/sponsor';
	})
}

function VisionToggle()
{
	var tmp_vbox = 0;
	
	$('img','#vision_title_box').each(function(i){
		$(this).click(function(){
			
			if(i != tmp_vbox)
			{
				$('table[vbox='+i+']','#vision_detail').slideDown('fast');
				$('table[vbox='+tmp_vbox+']','#vision_detail').toggle();
							
				tmp_vbox = i;
			}
		})
		
		$(this).css('cursor','hand');
	})
}

// 오시는길 정보 관리
function MapToggle()
{
	var tmp = "";
	
	$('img','table#map_cat_table').each(function(i){
		
		$(this).click(function(){

			for(j=1;j<5;j++)
			{
				if(j == $(this).attr('cat'))
				{
					$('img[cat="'+j+'"]','table#map_cat_table').attr('src','/images/raphael/map_tap0'+j+'o.gif');
					$('#map_info_0'+j).css('display','block');
				}
				else
				{
					$('img[cat="'+j+'"]','table#map_cat_table').attr('src','/images/raphael/map_tap0'+j+'.gif');
					$('#map_info_0'+j).css('display','none');
				}
			}
			
			$('img#map_img').attr('src','/images/raphael/map_img0'+$(this).attr('cat')+'.gif');

			return false;
		});
		
		$(this).css('cursor','hand');
		
		/*
		$(this).hover(function (){
			tmp = $(this).attr('src');
			$(this).attr('src','/images/raphael/map_tap0'+$(this).attr('cat')+'o.gif');
			return false;
		},function (){
			$(this).attr('src',tmp);
			return false;
		});
		$(this).focus(function (){
			$(this).attr('src','/images/raphael/map_tap0'+$(this).attr('cat')+'o.gif');
			return false;
		});
		$(this).blur(function (){
			$(this).attr('src',tmp);
			return false;
		});
		*/
	});
}

//오시는길 정보 관리
function ApplicationToggle()
{
	$('img','table#app_cat_table').each(function(i){
		
		$(this).click(function(){

			for(j=1;j<5;j++)
			{
				if(j == $(this).attr('cat'))
				{
					$('img[cat="'+j+'"]','table#app_cat_table').attr('src','/images/support/app_tap0'+j+'o.gif');
				}
				else
				{
					$('img[cat="'+j+'"]','table#app_cat_table').attr('src','/images/support/app_tap0'+j+'.gif');
				}
			}
			
			
			$.post('/common/application/application_form_'+$(this).attr('cat')+'.grace', function(data) {
				$('div#application_form').html(data);
			});

			return false;
		});
		
		$(this).css('cursor','hand');
		
		$.post('/common/application/application_form_'+appType+'.grace', function(data) {
			$('div#application_form').html(data);
		});
	});
}

// 미디어 플레이어 제어
function initVod()
{
	if($.cookie('HOME_VOD_START') == 'false')
	{
		document.vodPlayer.stop();
		$('img#playBtnImg').attr('src','/images/movie_play.gif');
	}
	
	if($.cookie('HOME_SOUND_MUTE') != null) document.vodPlayer.Mute = $.cookie('HOME_SOUND_MUTE');
	
	if(document.vodPlayer.Mute) $('img#soundBtnImg').attr('src','/images/movie_soundoff.gif');
	
	$('div#vodFaceCtl').css('cursor','hand');
	$('div#vodFaceCtl').click(function(){
		window.location.href='/aboutus/pr';
	});
}

function vod_toggle(o){
	var _cookie_name = 'HOME_VOD_START';
    var _cookie_options = { path: '/', expires: 7 };

	if(o.src.replace(g4_url,'') == '/images/movie_stop.gif')
	{
		document.vodPlayer.stop();
		o.src = "/images/movie_play.gif";
		$.cookie(_cookie_name, false, _cookie_options);
	}
	else
	{
		document.vodPlayer.play();
		o.src = "/images/movie_stop.gif";
		$.cookie(_cookie_name, true, _cookie_options);
	}
 }

function sound_toggle(o){
	var _cookie_name = 'HOME_SOUND_MUTE';
    var _cookie_options = { path: '/', expires: 7 };
    
	if(!document.vodPlayer.Mute)
	{
		document.vodPlayer.Mute = true;
		o.src = "/images/movie_soundoff.gif";
		$.cookie(_cookie_name, true, _cookie_options);
	}
	else
	{
		document.vodPlayer.Mute = false;
		o.src = "/images/movie_soundon.gif";
		$.cookie(_cookie_name, false, _cookie_options);
	}
}


// layer 콘텐츠 가져오기
function getLayerCNT(tpl){
	$.post('/common/layer.grace', {
		layerCTN : tpl
	}, function(data) {
		$('div#popUpLayer').html(data);
	});
}
function getLayerCNTParam(params){
	$.post('/common/layer.grace', params, function(data) {
		$('div#popUpLayer').html(data);
	});
}
function delLayerCNT(){
	$('div#popUpLayer').html('');
}


// 로그아웃 처리
function logout(){
	$.post('/bbs/logout.php', function(data) {
		$('div#popUpLayer').html(data);
	});
}


// 쿠키
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
