
var NSComment=new Object;NSComment.loadingHTML='<img src="http://images2.ensight.co.kr/helizet/profile/ajax-loader.gif" />';NSComment.ckVal={};NSComment.getCookie=function(key){if(NSComment.ckVal[key]!==null&&typeof NSComment.ckVal[key]!==undefined)return NSComment.ckVal[key];NSComment.ckVal[key]=decodeURIComponent(Cookie.get(key));return NSComment.ckVal[key];};NSComment.fillInputBox=function(container){var oFrm=j$(container).find('form');oFrm.find('[name=Name]').val(this.getCookie('_PROFILE_NICKNAME'));oFrm.find('[name=Email]').val(this.getCookie('_PROFILE_EMAIL'));oFrm.find('[name=URL]').val(this.getCookie('_PROFILE_URL'));};NSComment.highlight=function(highlightCallback){var uri=window.location.href;var uris=uri.split('#');if(!uris[1]||uris[1]===undefined)return false;if(typeof highlightCallback=='function')highlightCallback('#'+uris[1]);else j$('#'+uris[1]).show('highlight',{},3000);return true;};NSComment.add=function(frm,el,cb){return false;};NSComment.remove=function(el,url,param,callback,uid){var crt_btn=j$(el);var crt_btn_click=crt_btn.click;var crt_btn_html=crt_btn.html();crt_btn.unbind('click',crt_btn.attr('onclick'));crt_btn.html(NSComment.loadingHTML);if(!confirm('해당 댓글을 삭제 하시겠어요?')){crt_btn.click=crt_btn_click;crt_btn.html(crt_btn_html);return false;}
j$.post(url,param,function(data){if(data.error=='0'){if(typeof callback=='function')callback(data,uid);else alert('삭제 되었습니다.');}else{alert(data.message);}
crt_btn.click=crt_btn_click;crt_btn.html(crt_btn_html);},'json');return false;};NSComment.loadList=function(el,url,param,callback){try{SWFU.destroy();}catch(e){};j$(el).load(url,param,callback);};NSComment.makeDatePaging=function(el,prevDate,nextDate,sUrl){var html=[];if(prevDate&&prevDate!='undefined'){var sb=[];var aPrevDate=prevDate.split('/');var fUrl=[sUrl,prevDate].join('/');if(aPrevDate[0])sb.push(aPrevDate[0]+'년');if(aPrevDate[1])sb.push(aPrevDate[1]+'월');if(aPrevDate[2])sb.push(aPrevDate[2]+'일');html.push(['<a href="'+fUrl+'" style="float:left;border:none">',sb.join(' '),'</a>'].join(''));}
if(nextDate&&nextDate!='undefined'){var sb=[];var aNextDate=nextDate.split('/');var fUrl=[sUrl,nextDate].join('/');if(aNextDate[0])sb.push(aNextDate[0]+'년');if(aNextDate[1])sb.push(aNextDate[1]+'월');if(aNextDate[2])sb.push(aNextDate[2]+'일');html.push(['<a href="'+fUrl+'" style="float:right;border:none">',sb.join(' '),'</a>'].join(''));}
j$(el).html(html.join(''));};NSComment.makePaging=function(el,nTotalPage,nPageSize,nCurPage,sParam,sUrl){sParam=sParam||'';var nPgTerm=parseInt(nPageSize/2);var nStartPg=nTotalPage<=nPageSize||nCurPage-nPgTerm<1?1:nCurPage-nPgTerm;var nEndPg=nCurPage+nPgTerm>=nTotalPage?nTotalPage:(nCurPage+nPgTerm<nPageSize?(nPageSize>nTotalPage?nTotalPage:nPageSize):nCurPage+nPgTerm);nStartPg=nEndPg-nStartPg<nPageSize&&nStartPg>1?nStartPg-((nPageSize-1)-(nEndPg-nStartPg)):nStartPg;var sPaging='';for(i=nStartPg;i<=nEndPg;i++){var sFurl=sUrl+sParam+'&PageNo='+i;var jsonParam='{}';var func='function(){NSComment.makePaging(\''+el+'\','+nTotalPage+','+nPageSize+','+i+',\''+sParam+'\',\''+sUrl+'\');}';if(nCurPage==i)sPaging+=' <strong>'+i+'</strong>';else sPaging+=' <a href="#" onclick="NSComment.loadList(\'.comment_list\',\''+sFurl+'\','+jsonParam+','+func+');return true;">'+i+'</a>';}
if(nCurPage>1){var i=(nCurPage-1>0?nCurPage-1:1);var sFurl=sUrl+sParam+'&PageNo='+i;var jsonParam='{}';var func='function(){NSComment.makePaging(\''+el+'\','+nTotalPage+','+nPageSize+','+i+',\''+sParam+'\',\''+sUrl+'\');}';sPaging='<a href="#" onclick="NSComment.loadList(\'.comment_list\',\''+sFurl+'\','+jsonParam+','+func+');return true;" class="pre">이전</a> '+sPaging;}
if(nCurPage<nTotalPage){var i=(nCurPage+1>nTotalPage?nTotalPage:nCurPage+1);var sFurl=sUrl+sParam+'&PageNo='+i;var jsonParam='{}';var func='function(){NSComment.makePaging(\''+el+'\','+nTotalPage+','+nPageSize+','+i+',\''+sParam+'\',\''+sUrl+'\');}';sPaging=sPaging+' <a href="#" onclick="NSComment.loadList(\'.comment_list\',\''+sFurl+'\','+jsonParam+','+func+');return true;" class="next">다음</a>';}
j$(el).html(sPaging);if(nCurPage>1)
NSComment.init(container);return false;};NSComment.init=function(container,highlightCallback){NSComment.initOnce(container,highlightCallback);try{NSComment.initForm(container);}catch(e){}
jQuery.each(j$(container).find('textarea'),function(){j$(this).autogrow({maxHeight:240,minHeight:32,lineHeight:16});j$(this).keydown(function(e){if(e.keyCode==9){j$(this).parent().parent().find("input[type='image']").focus();return false;};return limitCharacters(this,450,j$(this).parent().next().find('.text-len'));});var oSubmit=j$(this).parent().parent().find("input[type='image']");oSubmit.bind('click.addCmmt',function(){var
oFrm=jQuery(this).parents('form'),crt_btn=oFrm.find('.button_write').html(),oAttachStat=oFrm.find('#box-message > span').html(),oPreviewStat=oFrm.find('img[class="img_thum"]').attr('src'),oTextArea=oFrm.find('textarea'),sTargetUrl=oFrm.find('input[name="TargetURL"]').val(),sTargetEl=oFrm.find('input[name="TargetEL"]').val(),sCallBack=oFrm.find('input[name="CallBack"]').val(),sFormType=oFrm.attr('name');if((!oAttachStat&&!oPreviewStat)||((oAttachStat=='0%'||oAttachStat=='100%'))){var oWriteBtn=oFrm.find('.button_write');oWriteBtn.html(NSComment.loadingHTML);jQuery.post(sTargetUrl,oFrm.serializeArray(),function(data){if(data.error=='0'){jQuery(sTargetEl).html(data.comment_list);jQuery('#'+data.inserted.uid).show('highlight',null,1500);NSComment.init(sTargetEl);oTextArea.val('').find('.text-len').text('0');try{if(sCallBack!='')
{}}catch(e){alert(e);};}else{alert(data.message);}
oWriteBtn.html(crt_btn);},'json');}else
{alert('첨부파일 업로드가 '+oAttachStat+' 진행중입니다. 업로드 완료 후 시도해 주세요.');}
return false;});});NSComment.fillInputBox(container);};NSComment.inited=false;NSComment.initOnce=function(container,highlightCallback){if(NSComment.inited)return false;NSComment.highlight(highlightCallback);NSComment.inited=true;return true;};NSComment.getPageScroll=function(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
return new Array(xScroll,yScroll)}
NSComment.getPageHeight=function(){var windowHeight
if(self.innerHeight){windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowHeight=document.documentElement.clientHeight;}else if(document.body){windowHeight=document.body.clientHeight;}
return windowHeight}
NSComment.getPageWidth=function(){var windowWidth;if(typeof(window.innerWidth)=='number'){windowWidth=window.innerWidth;}else if(document.documentElement&&(document.documentElement.clientWidth)){windowWidth=document.documentElement.clientWidth;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){windowWidth=document.body.clientWidth;}
return windowWidth}
NSComment.makeupProfileImg=function(n,sImgUrl)
{var oUploadPlace=j$('.find').eq(n),oUploadGuide=oUploadPlace.find('.text_left'),output='';output=output+(sImgUrl?'<img src="'+sImgUrl+'" class="img_thum" alt="" onClick="NSComment.changeImage(j$(j$(this)).attr(\'src\'));" />':'');output=output+(sImgUrl?'<a onclick="NSComment.makeupProfileImg('+n+',\'\');" class="delete-x">사진삭제</a>':'');SWFU._aHolder[n].setButtonImageURL(sImgUrl?SWFU.BTN_CHANGE:SWFU.BTN_DEF);if(sImgUrl){oUploadGuide.hide();}else{oUploadGuide.show();}
j$('.frmComment input:[name=ImgURL]').eq(n).val(sImgUrl);oUploadPlace.find('div:[id=save'+n+']').html(output);}
NSComment.initSWFUButton=function(n,sImgUrl)
{var oUploadPlace=j$('.find').eq(n);if(oUploadPlace.find('object').length<=0){oUploadPlace.html('<div class="btn-img"><span id="btnUp'+n+'"></span></div><div id="save'+n+'"></div>');SWFU.load({holder:'btnUp'+n,inst:'pkwd',rt:n,button:''});}}
NSComment.initForm=function(container)
{try{if(container.substring(0,1)==".")
{NSComment.makeupProfileImg(0,'');}else
{var sIdx=j$(document).find("div[id*='div_child'] ul").index(j$(container));var oDiVChild=j$(document).find("div[id*='div_child']");NSComment.makeupProfileImg((sIdx+1),'');}}catch(e){}}
NSComment.clearSWFUButton=function(nIdx)
{j$('.find').eq(nIdx).hide();}
NSComment.makeAndShowSelection=function(sBox,sInput,opt)
{var cont=sBox;var listCont=cont.find('ul');var inputBox=sInput;cont.css('z-index',100);if(cont.is(':visible')){cont.hide();return;}
cont.mouseover(function(event){inputBox.hasfocus=1;}).mouseout(function(event){inputBox.hasfocus=0;inputBox.focus();})
inputBox.blur(function(event){if(cont.is(':visible')&&!inputBox.hasfocus){cont.hide();}});jQuery.each(listCont.find('li'),function(){j$(this).mouseover(function(event){inputBox.hasfocus=1;}).mouseout(function(event){inputBox.hasfocus=0;}).mousedown(function(event){inputBox.val(j$(this).text());NSComment.clickSelect(j$(".frmComment li[id="+j$(this).attr('id')+"]").index(this),j$(this).attr('id'));cont.hide();})})
cont.show('blind');}
NSComment.clickComm=function(nIdx,oThis,sInst){var cont=j$(oThis);var listCont=cont.find('ul');var inputBox=cont.find('a[id=select]');var inst=(sInst==null?'pkwd':sInst);j$('.frmComment div[class=select_a]').eq(nIdx).find('ul').toggle();j$('.frmComment div[class=select_a]').eq(nIdx).blur(function(){j$(this).find('ul').hide();});if(j$('.find').eq(nIdx).find('object').length<=0){j$('.find').eq(nIdx).html('<div id="box-message"></div> <div id="box" style="display:;"><div class="btn-img"><span id="btnUp'+nIdx+'"></span></div><div id="save'+nIdx+'"></div></div>').hide();var progress_Cont=j$('.find').eq(nIdx).find('div[id=box-message]');SWFU.load({holder:'btnUp'+nIdx,inst:inst,rt:nIdx,button:'',progressCont:progress_Cont});}
jQuery.each(j$('.frmComment div[class=select_a] ul').eq(nIdx).find('li'),function(){j$(this).mousedown(function(event){inputBox.text(j$(this).text());NSComment.clickSelect(j$(".frmComment li[id="+j$(this).attr('id')+"]").index(this),j$(this).attr('id'));listCont.hide();})})}
NSComment.clickSelect=function(nIdx,sID){if(sID=="Text"){NSComment.clearSWFUButton(nIdx);}else{j$('.find').eq(nIdx).show();try{_NS_F.resize();}catch(e){}}}
NSComment.changeImage=function(src){if(src.match(/\.(jpg|jpeg|gif|png)/i)){var ext='';var size='';var filename=src.substring(src.lastIndexOf('/')+1);if(filename.indexOf('&')>-1){size=filename.substring(filename.indexOf('&')+1);filename=filename.substring(0,filename.indexOf('&'));}
ext=filename.substring(filename.lastIndexOf('.')+1,filename.length);filename=filename.substring(0,filename.indexOf('.'));imgPath=src.substring(0,src.lastIndexOf('/')+1)+filename+"."+ext;NSComment.showOverlay();var oLoader=j$('#loader');oLoader.empty().addClass('loading').css({top:NSComment.getPageScroll()[1]+(NSComment.getPageHeight()/2)-(50/2),left:j$(window).width()/2-(50/2),width:50,height:50}).show();NSComment.preloadImage(imgPath);}}
NSComment.showOverlay=function(){var
oOverlay=j$('#overlay'),oLoader=j$('#loader'),oBody=j$('body');if(oOverlay.length==0)oBody.append('<div id="overlay" class="overlayBG"></div>');if(oLoader.length==0)oBody.append('<div id="loader"></div>');j$('#overlay').css('opacity','0.3').click(function(){j$(document).trigger('close.box');});return false;}
NSComment.hideOverlay=function(){j$('#overlay').css('opacity','0.3').fadeOut(200,function(){j$(this).removeClass("overlayBG").addClass("facebox_hide").remove();});return false;}
NSComment.preloadImage=function(imgPath){if(j$('#loader:animated').length!=0){return false;}else{var maxwidth=NSComment.getPageWidth();var maxheight=NSComment.getPageHeight();var img=new Image();j$(img).load(function(){j$(this).hide();j$('#loader').removeClass('loading').html(this);j$(this).css({"height":'auto',"width":'auto'});iHeight=j$(this).height();iWidth=j$(this).width();var ratio=1.0;if(iWidth>maxwidth){ratio=iWidth/iHeight;iWidth=maxwidth;iHeight=Math.round(maxwidth/ratio);}
j$(this).width(iWidth);j$(this).height(iHeight);var loaderTop=NSComment.getPageScroll()[1]+(NSComment.getPageHeight()/2)-(iHeight/2)<0?10:NSComment.getPageScroll()[1]+(NSComment.getPageHeight()/2)-(iHeight/2);j$('#loader').css({top:loaderTop,left:385.5}).show();j$('#loader').css('left',j$(window).width()/2-(iWidth/2));lHeight=j$('#loader').height();if(lHeight==iHeight){j$(this).fadeIn();}else{j$(this).animate({opacity:'toggle',height:'toggle',width:'toggle'},200,function(){j$('#overlay').css({'opacity':'0.3','height':j$(document).height()})});}}).error(function(){}).attr('src',imgPath).addClass('fullSizeImage').click(function(){j$(document).trigger('close.box');});}}
NSComment.firstCmmtFrmInit=function(){if(j$('dl .nick').length<=0)
{var sMsgBgColor=typeof arguments[0]!='undefined'?arguments[0]:'';j$(document).ready(function(){var oBtnHolder=j$('form .find').eq(0);oBtnHolder.prepend('<div id="box-message" style="background-color:'+sMsgBgColor+';"></div><div id="box" style="display:block;"><div class="btn-img"><span id="btnUp0"></span></div><div id="save0"></div></div>');SWFU.load({'holder':'btnUp0','inst':'pprf','rt':'0','button':'','progressCont':oBtnHolder.find('div[id=box-message]')});});}
return true;}
j$(document).bind('close.box',function(){j$('#loader').empty().css({width:50,height:50}).hide();NSComment.hideOverlay();});j$(document).bind('resize.box',function(){var
oLoader=j$('#loader'),oLoaderImg=oLoader.find('img');if(oLoaderImg.length<=0)return;iWidth=oLoaderImg.width();iHeight=oLoaderImg.height();var loaderTop=NSComment.getPageScroll()[1]+(NSComment.getPageHeight()/2)-(iHeight/2)<0?10:NSComment.getPageScroll()[1]+(NSComment.getPageHeight()/2)-(iHeight/2);oLoader.css({top:loaderTop,left:385.5}).show();j$('#overlay').css('height',j$(document).height());oLoader.css('left',j$(window).width()/2-(iWidth/2));});