// =============================================
// 링크 테두리시 점선 안보이기
// =============================================
function bluring() 
{
        if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}

document.onfocusin=bluring;
//-->

// ----------------------------------------------------------------------------------

// makes a Element Body
var ElementUtil = new Object() ;

// gets an Element Body
ElementUtil.getRealBody = function()
{
   return ( document.compatMode && document.compatMode!="BackCompat" ) ? document.documentElement : document.body ; 
   //return ( document.documentElement ) ? document.documentElement : document.body ; 
}

// makes a StringUtil Object
var StringUtil = new Object() ;

// Number format
StringUtil.toNumber = function( str )
{
   str += '' ;
   x = str.split( '.' ) ;
   x1 = x[0] ;
   x2 = x.length > 1 ? '.' + x[1] : '' ;
   
   var rgx = /(\d+)(\d{3})/ ;
   
   while (rgx.test(x1))
      x1 = x1.replace(rgx, '$1' + ',' + '$2') ;
   
   return x1 + x2 ;
}

// Check null
StringUtil.isNull = function(value) 
{
   var num = 0 ;
   
   try { num = value.length ; } catch(e) { return true; }
   
   if ( num == 0 ) return true ;
   
   for(var i = 0; i != num; i++)
   {
      aChar = value.substring(i, i+1) ;
      if ( aChar !=" " && aChar != null )			
         return false;
   }
   return true ;
}

// Removes leading whitespaces
StringUtil.ltrim = function( value ) 
{	
   var re = /\s*((\S+\s*)*)/ ;
   return value.replace(re, "$1") ;
}

// Removes ending whitespaces
StringUtil.rtrim = function( value ) 
{
   var re = /((\s*\S+)*)\s*/ ;
   return value.replace(re, "$1") ;	
}

// Removes leading and ending whitespaces
StringUtil.trim = function( value ) 
{	
   return StringUtil.ltrim(StringUtil.rtrim(value)) ;
}

// Replaces all characters
StringUtil.replaceAll = function(sSrc, sTarget) 
{
   sSrc = sSrc.replace(new RegExp("(\\W)", "g"), "\\$1") ;
   sTarget = sTarget.replace(new RegExp("\\$", "g"), "$$$$") ;
   
   return this.replace(new RegExp(sSrc, "gm"), sTarget) ;
}

// Validates url
StringUtil.isValidURL = function( sUrl )
{
   var reg = new RegExp() ;
   reg.compile( "^[A-Za-z]+://[A-Za-z0-9-]+\.[A-Za-z0-9]+" ) ; 
   return reg.test(sUrl) ;
}

// Validates email
StringUtil.isValidEMail = function( sMail )
{
   var reg = new RegExp(/[a-z0-9]{2,}@[a-z0-9-]{2,}\.[a-z0-9]{2,}/i) ;
   return reg.test(sMail) ;

}

// cut string
StringUtil.cutString = function( str, iLength )
{
   var il = 0 ;

   for (var i = 0 ; i < str.length ; i++ )
   {
      il += (str.charCodeAt(i) > 128) ? 2 : 1;
      if ( il > iLength ) return str.substring(0, i) + '..' ;
   }

   return str ;
}

// copies a string to the clipboard
StringUtil.copyToClipboard = function ( str ) 
{
   if (window.clipboardData) {
      window.clipboardData.setData( "Text", str ) ;
   } 
   else 
   {
      var sFlashCopier = 'flashcopier' ;
      if ( !document.getElementById(sFlashCopier) ) 
      {
         var oDivHolder = document.createElement('div') ;
         oDivHolder.id = sFlashCopier ;
         document.body.appendChild(oDivHolder) ;
      }
      document.getElementById(sFlashCopier).innerHTML = '' ;
      
      var sDIVinfo = '<embed src="http://images.ensight.co.kr/swf/clipboard.swf" FlashVars="clipboard='+escape(str)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>' ;
      document.getElementById(sFlashCopier).innerHTML = sDIVinfo ;
   }
}

function popupWindow(url,width,height,windowname,scrollbar)
{ // open widdow
	if(scrollbar == ''){ scrollbar = 'yes'; }
	wleft = (screen.width-width)/2;
	wtop = (screen.height-height)/2;
	opt = 'width='+width+',height='+height+',left='+wleft+',top='+wtop+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbar + ',resizable=yes'
	win = window.open(url,windowname,opt);
	//window.focus = win;
	win.focus();
}

function popupWindow2(url, windowname, width, height,  wleft, wtop, scrollbar, resizable, status)
{ // open widdow2
	if(scrollbar == ''){ scrollbar = 'no'; }
	if(resizable == ''){ resizable = 'no'; }
	if(status == ''){ status = 'no'; }
	if(wleft == '') { wleft = (screen.width-width)/2; }
	if(wtop == '') { wtop = (screen.height-height)/2; }
	opt = 'width='+width+',height='+height+',left='+wleft+',top='+wtop+',scrollbars=' + scrollbar + ',resizable='+ resizable +', status='+ status +'toolbar=no,location=no,directories=no,menubar=no,'
	win = window.open(url,windowname,opt);
	window.focus = win;
}

// 오프너 페이지 이동
function opener_page_open(url) {
	if(parent.opener.closed) {
		window.open(url).focus();
	}else {
		//alert(opener.location);
		parent.opener.location = url;
		parent.opener.focus();
	}
}


// checkbox 전체선택 , 선택해제
function actCheckBox(form, option, target)
{	// checkBox on/off
	var ele_length = form.elements.length ;
	for(i=0;i < ele_length;i++){
		var ele_name = form.elements[i].name ;
		var ele_type = form.elements[i].type ;
		var ele_disabled = form.elements[i].disabled ;
		//alert(ele_disabled);return false;
		if(ele_name.search(/target/i) == -1 && ele_type == "checkbox"){
			//alert(target + ' ' + ele_name + ' ' + ele_name.search(/target/i));
			if(ele_disabled == false) { // disabled 처리된 것은 동작하지 않는다.
				if(option  == "on"){
					form.elements[i].checked = true;
				}else{
					form.elements[i].checked = false;
				}
			}
		}
	}
	return false;
}


function checkLength(obj , len){
	if(obj.value != "" && obj.value.length != len){
		alert('입력개수가 올바르지 못합니다.');
		obj.focus();
		obj.select();
	}
}


function getRadioValue(form , obj_name){
	obj = eval('form.' + obj_name);
	str = '';
	if(!obj.length){	 // redio 버튼이 1개인 경우
		if(obj.checked == true){
			str = obj.value;
		}
	}
	else{				// radio 버튼이 2개 이상인 경우
		for(i=0 ; i<obj.length ; i++){ 
			if(eval('obj[' + i + '].checked') == true){
				str = eval('obj[' + i + '].value');
				break;
			}
		}
	}
	return str;
} 


function resizeWin(width , height)
{
	//alert('test');
	self.resizeTo(width , height);
}


function resizeImage(name, user_width, user_height)
{	// image resize
	var width = eval('document.all.'+name+'.width');
	var height = eval('document.all.'+name+'.height');
	var diff_width = width - user_width;
	var diff_height = height - user_height;
	if(width < user_width && height < user_height){
		//eval('document.all.'+name+'.width = ' + width);
		//eval('document.all.'+name+'.height = ' + height);
	}
	else if(diff_width > diff_height){
		user_size = height * (user_width / width);
		eval('document.all.'+name+'.width = ' + user_width);
		eval('document.all.'+name+'.height = ' + user_size);
	}
	else if(diff_width < diff_height){
		user_size = width * (user_height / height);
		eval('document.all.'+name+'.width = ' + user_size);
		eval('document.all.'+name+'.height = ' + user_height);
	}
}


function resizeImage2(id, user_width)
{	// image resize
	var obj = document.getElementById(id);
	var width = eval(obj.width);
	if(width > user_width) {
		obj.width = user_width;
	}
}


function is_selected(form , total_cnt , obj){
	if (eval('form.' + total_cnt) == ""){
		alert("선택하실 항목이  없습니다.");
		return false;
	}
    var j = 0;
    for (var i = 0; i <eval('form.' + total_cnt + '.value') ; i++){
        if (eval('form.' + obj + i + '.checked') == true){
            j++;
        }
    }
    if (j == 0){
        alert("항목을 선택 하십시요.");
        return false;
    }
	return true;
}



// 선택된 개수를 return 한다.
function is_selected2(form , total_cnt , obj){
	if (eval('form.' + total_cnt) == ""){
		return 0;
	}
    var j = 0;
    for (var i = 0; i <eval('form.' + total_cnt + '.value') ; i++){
        if (eval('form.' + obj + i + '.checked') == true){
            j++;
        }
    }
	return j;
}



// 반각 체크 
// if ( !checkisHankaku(......)) { alert('전각이 포함되어 있습니다.'); return; }
function checkIsHankaku(str)
{
	var iCount;
	var sTemp;
	for (iCount=0;iCount<str.length;iCount++) {
		sTemp = escape(str.charAt(iCount));
		if (sTemp.length >= 4) return false;
	}
	return true;
}


function doResize()  
{  
	h = document.body.scrollHeight;  
	w = document.body.scrollWidth;
	window.resizeTo(w,h);
}



//TEXTAREA - 실제 문자가 입려된 열수
// 출처 : phpschool.com [미바니]님의 글
function GetTextareaRowCount(otextarea) { 
	var count = 0; 
	var rowsplit = new Array(); 
	rowsplit = otextarea.value.replaceAll("\r\n\r\n","\r\n").split("\r\n"); 
	rowlen = (otextarea.value)?rowsplit.length:0; 
	count = rowlen; 
	if(rowsplit[0]=="") count--; 
	if(rowsplit[rowlen-1]=="") count--; 
	return count; 
} 

String.prototype.replaceAll = function( searchStr, replaceStr ) 
{ 
	var temp = this; 
	while( temp.indexOf( searchStr ) != -1 ) temp = temp.replace( searchStr, replaceStr ); 
	return temp; 
} 


// 회원 여부
function is_member()
{
	if(__UserID == '') 
	{
		alert("회원만 이용가능합니다.");
		return false;
	}
	//alert(UserID);
	return true;
}

// 플래시 파일을 테두리 없이 로딩
//	사용법 : <script language="javascript">flash('537','88','../flash/top.swf');</script>
// 가로사이즈, 세로사이즈, 파일명
//

function flash(width, height, src) 
{
	 var flash_tag = "";
	 flash_tag = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	 flash_tag +='codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ';
	 flash_tag +='WIDTH="'+width+'" HEIGHT="'+height+'" >';
	 flash_tag +='<param name="wmode" value="transparent">'; 
	 //이부분은 플래쉬 배경을 투명으로 설정하는 부분으로 필요없다면 삭제해도 무방함
	 flash_tag +='<param name="movie" value="'+src+'">';
	 flash_tag +='<param name="quality" value="high">';
	 flash_tag +='<embed src="'+src+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	 flash_tag +='type="application/x-shockwave-flash"  WIDTH="'+width+'" HEIGHT="'+height+'"></embed></object>'
	 document.write(flash_tag);
}


function music(a,b,c) 
{
	 var music_play = "";
	 music_play = '<EMBED style="filter:alpha(opacity=100, style=2, finishopacity=0)gray()" ';
	 music_play +='src="'+c+'" ';
	 music_play +='width="'+a+'" height="'+b+'" '
	 music_play +='type=audio/mpeg invokeURLS="0" AllowScriptAccess="never" '
	 music_play +='enablecontextmenu="0" showaudiocontrols="1" showpositioncontrols="0" autostart="true"></EMBED>'
	 document.write(music_play);
}


function movie(url) 
{
	 var movie_play = "";
	 movie_play = '<EMBED style="filter: alpha(opacity=100, style=0, finishopacity=0)gray()" ';
	 movie_play +='src="'+url+'" ';
	 movie_play +='width=638 height=475 '
	 movie_play +='type=audio/mpeg invokeURLS="0" AllowScriptAccess="never" '
	 movie_play +='enablecontextmenu="1" showaudiocontrols="1" showpositioncontrols="1" autostart="true"></EMBED>'
	 document.write(movie_play);
}



//20050811  add by shj // 디자인위치에서 발췌
function view(bid,no,listkey)
{
   var isAdmin  =  ""
   
   if (isAdmin == "admin") 
   {
      document.location.href = "sub/sub05_02_read.asp?seqno="+arg1 ;
   }
   else
	{
      document.location.href = "sub/sub05_inputpass.asp?bid="+bid+"&no="+no ;
	}
}

//20080211  add by mirang
function list()
{
	document.location.href = "/board/list.php";
}

// 20080213 add by mirang
function download(bid,no,fileno)
{
	if(!bid || !no || !fileno) 
	{
		alert("정보가 올바르지 않습니다.");
		location.reload();
		return false;
	}
	document.location.href = "/board/dn.php?bid="+bid+"&no="+no+"&fileno="+fileno ;
	return true;
}

// 20080214 add by mirang
function cinelist()
{
	document.location.href = "/cinema/list.php";
	return true;
}

function cineview(no)
{
	document.location.href = "/cinema/list.php?&no="+no;
	return true;
}

// 네이버 영화 링크
function naver_url(no)
{
	window.open("http://movie.naver.com/movie/bi/mi/basic.nhn?code="+no , '_blank');
	return true;
}

// 덧글 삭제
function del_cmt(bid,page,no,cmt_no,cno)
{
	document.location.href = "/board/delete_cmt_ok.php?bid="+bid+"&no="+no+"&page="+page+"&cmt_no="+cmt_no+"&cno="+cno; 
}

// 영화 덧글 삭제
function cine_del_cmt(page,no,cmt_no,cno)
{
	document.location.href = "/cinema/delete_cmt_ok.php?no="+no+"&page="+page+"&cmt_no="+cmt_no+"&cno="+cno; 
}

// 배경음악 검색창
function bgm_search(bid) 
{
  sList = window.open("bgm_search.php?bid="+bid, "BGM_Search", "width=450,height=500,scrollbars=yes,resizable=yes,location=no");
}


// 문서를 닫을때 팝업창의 opener 속성을 null 로 만들어 줍니다
function remLink() 
{
  if (window.sList && window.sList.open && !window.sList.closed)
    window.sList.opener = null;
}

// 주크박스 자동 등록 창
function autoup(bid) 
{
  sList = window.open("auto_upload.php?bid="+bid, "Jukebox_Autoup", "width=600,height=300,scrollbars=auto,resizable=yes,location=no");
}

// =============================================
// 마우스 오버시 예쁜 창 뜨는 소스
// 2008.02.15 추가
// =============================================
<!--
function wgposit_list(no,evt)
{
	var div = document.getElementById("wg_info_" + no);
	if(navigator.appName == "Netscape")
	{
		/*========================*/
		// 마우스 위치값에 따른 정의
		/* ========================*/
		//		div.style.posLeft = event.x - 130;
		//		div.style.posTop = event.y - 40;

		div.style.posLeft = 2;
		div.style.posTop = 107;
	} 
	else 
	{
		/*========================*/
		// 마우스 위치값에 따른 정의
		/* ========================*/
		//		div.style.posLeft = event.x - 130;
		//		div.style.posTop = event.y - 40;
		
		div.style.posLeft = 2;
		div.style.posTop = 107;
	}
}

function wgset_list(no)
{
	var div = document.getElementById("wg_info_" + no);
	div.style.display = "inline";
}

function wghide_list(no)
{
	var div = document.getElementById("wg_info_" + no);
	div.style.display = "none";
}

if(navigator.appName == "Netscape")
{
	document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
	document.onmousemove = wgposit_list;
}




// =============================================
// 마우스 오버시 예쁜 창 뜨는 소스
// 2008.02.15 추가
// =============================================
<!--
function msgposit_list(no,evt)
{
	var div = document.getElementById("data_info_" + no);
	if(navigator.appName == "Netscape")
	{
		/*========================*/
		// 마우스 위치값에 따른 정의
		/* ========================*/
		//		div.style.posLeft = event.x - 130;
		//		div.style.posTop = event.y - 40;

		div.style.posLeft = 0;
		div.style.posTop = 116;
	} 
	else 
	{
		/*========================*/
		// 마우스 위치값에 따른 정의
		/* ========================*/
		//		div.style.posLeft = event.x - 130;
		//		div.style.posTop = event.y - 40;
		
		div.style.posLeft = 0;
		div.style.posTop = 116;
	}
}

function msgset_list(no)
{
	var div = document.getElementById("data_info_" + no);
	div.style.display = "inline";
}

function msghide_list(no)
{
	var div = document.getElementById("data_info_" + no);
	div.style.display = "none";
}

if(navigator.appName == "Netscape")
{
	document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
	document.onmousemove = msgposit_list;
}

// =============================================
// FOTO Player - 풀화면 창 띄우기
// 2008.02.22 추가
// =============================================
function fullscreen() 
{
	var isWin=(navigator.appVersion.indexOf("Win")!=-1)? true : false;
	var isIE=(navigator.appVersion.indexOf("MSIE")!=-1)? true : false;
	var notIE7 = (navigator.appVersion.indexOf("MSIE 7.0")!=-1)? false : true;

	if(isWin&&isIE&&notIE7)
	{
		var fullwindow = window.open("http://photo.choongsoo.com/",'포토갤러리',"fullscreen=1, scrollbars=0");
		fullwindow.focus();
	}
	else
	{
		// 	for non-ie browsers, specify width and height instead of using fullscreen 
		var fullwindow = window.open("http://photo.choongsoo.com/","포토갤러리","width="+screen.availWidth+",height="+screen.availHeight);
		fullwindow.moveTo(0,0);
		fullwindow.focus();
	}	
}

// =============================================
// 레이어 (div) 처리
// 2008.03.02 추가
// =============================================
function div_switch(obj) 
{
	/*
	var obj = document.getElementById(obj);

	if (obj.style.display == "none") obj.style.display = "block";
	else obj.style.display = "none"; 
	*/

	if (obj.style.display == "")
	{
		obj.style.display = "none";
	}
	else
	{
		obj.style.display = "";
	}
}


// =============================================
// 검색 버튼 on/off 처리
// 2008.03.05 추가
// =============================================
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
if(browserName == "Netscape" && browserVer >= 3){ init = "net"; }
else { init = "ie"; }


if(((init == "net")&&(browserVer >=3))||((init == "ie")&&(browserVer >= 4))){

 sn_on=new Image;
 sn_off=new Image;
 sn_on.src= "/board/images/name_on.gif";
 sn_off.src= "/board/images/name_off.gif";

 ss_on=new Image;
 ss_off=new Image;
 ss_on.src= "/board/images/subject_on.gif";
 ss_off.src= "/board/images/subject_off.gif";

 sc_on=new Image;
 sc_off=new Image;
 sc_on.src= "/board/images/content_on.gif";
 sc_off.src= "/board/images/content_off.gif";

}

function OnOff(name) 
{
	if(((init == "net")&&(browserVer >=3))||((init == "ie")&&(browserVer >= 4))) 
	{
		if(document.search[name].value=='on')
		{
		   document.search[name].value='off';
		   ImgSrc=eval(name+"_off.src");
		   document[name].src=ImgSrc;
		}
		else
		{
		   document.search[name].value='on';
		   ImgSrc=eval(name+"_on.src");
		   document[name].src=ImgSrc;
		}
	}
}



// =============================================
// 롤오버 버튼  처리
// 2008.03.05 추가
// =============================================
<!-- 롤오버버튼 -->
imag = new Array()

imag[10] = "/images/topmenu_life_off.gif"			// 첫번째 이미지
imag[11] = "/images/topmenu_life_on.gif"			// 두번째 이미지

imag[20] = "/images/topmenu_study_off.gif"		// 첫번째 이미지
imag[21] = "/images/topmenu_study_on.gif"		// 두번째 이미지

imag[30] = "/images/topmenu_work_off.gif"		// 첫번째 이미지
imag[31] = "/images/topmenu_work_on.gif"		// 두번째 이미지

imag[40] = "/images/topmenu_interest_off.gif"	// 첫번째 이미지
imag[41] = "/images/topmenu_interest_on.gif"	// 두번째 이미지

imag[50] = "/images/topmenu_joy_off.gif"			// 첫번째 이미지
imag[51] = "/images/topmenu_joy_on.gif"			// 두번째 이미지

imag[60] = "/images/topmenu_family_off.gif"		// 첫번째 이미지
imag[61] = "/images/topmenu_family_on.gif"		// 두번째 이미지

imag[70] = "/images/topmenu_data_off.gif"		// 첫번째 이미지
imag[71] = "/images/topmenu_data_on.gif"		// 두번째 이미지


function swtch(num,imgname){
     imgname.src = im[num].src
}

im = new Array()
for (var i = 0; i < imag.length; i++){
       im[i] = new Image()
       im[i].src = imag[i]
}


<!-- 서브 메뉴 레이어 -->
function menuOn(name) {
 submenu = eval("submenu"+name+".style");
 submenu.visibility = "visible";
}
function menuOff(name) {
 submenu = eval("submenu"+name+".style");
 submenu.visibility = "hidden";
}
//->

<!-- 서브 메뉴 레이어 -->
<!--
function MM_findObj(n, d) { //v3.0
  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); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

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_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_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];}
}
//-->



