
var qscroll;
var setPoint;
/*[2010-04-02] 메인에서 옮기*/
function notice_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 jsp_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 flashResize(hesize){
	getEi('navigation').style.height = hesize + 'px';
}

// IE 6.0 백그라운드 이미지 캐쉬
try {document.execCommand('BackgroundImageCache', false, true); } catch(e) {}

// ID로 오브젝트 픽업
function getEi(n) { return document.getElementById(n); }

// Name으로 오브젝트 픽업
function getEn(n) { return document.getElementsByName(n); }

// 지정한 문자를 클립보드로 복사
function clipboard(txt,alt) {
 window.clipboardData.setData("Text",txt);
 alert(alt);
}
// rollover [투명처리된 png 체크 포함]
function over(imgName) {
	if(imgName.src) if(imgName.src.indexOf('_s.') != "-1") return;
	if(imgName.style.filter) imgName.style.filter = imgName.style.filter.replace("off.", "on."); 
	else imgName.src = imgName.src.replace("off.", "on.");
}
// rollout [투명처리된 png 체크 포함]
function out(imgName) {
	if(imgName.src) if(imgName.src.indexOf('_s.') != "-1") return;
	if(imgName.style.filter) imgName.style.filter = imgName.style.filter.replace("on.", "off."); 
	else imgName.src = imgName.src.replace("on.", "off.");
}
// 관심제품 quick list 열기
function overQp(imgName) {
	if(imgName.style.filter) imgName.style.filter = imgName.style.filter.replace("off.", "on."); 
	else imgName.src = imgName.src.replace("off.", "on.");
	if(getEi('quickProduct')) getEi('quickProduct').style.display = "block";
}
// 관심제품 quick list 닫기
function outQp(imgName) {
	if(imgName.style.filter) imgName.style.filter = imgName.style.filter.replace("on.", "off."); 
	else imgName.src = imgName.src.replace("on.", "off.");
	if(getEi('quickProduct')) getEi('quickProduct').style.display = "none";
}
// 탭 체인지 ( lid 컨트롤 할 레이어 이름 / tno 선택된 탭 번호 / tname 활성화시킬 탭 오브젝트)
function  tabChange(lid,tno) {
	if (!lid || !tno) { alert('탭이 지정되지 않았습니다.'); return; }
	if (!getEi(lid + '_1') || !getEi(lid + '_tab_1')) { alert('지정한 명칭 "' + lid + '" 과(와) 일치하는 오브젝트가 없습니다.'); return; }
	for(var i=1;getEi(lid + '_' + i);i++) {	getEi(lid + '_' + i).style.display = "none"; }
	for(var i=1;getEi(lid + '_tab_' + i);i++) {	getEi(lid + '_tab_' + i).src = getEi(lid + '_tab_' + i).src.replace("s.gif", "off.gif"); }
	getEi(lid + '_tab_' + tno).src = getEi(lid + '_tab_' + tno).src.replace("on.", "s.");
	getEi(lid + '_tab_' + tno).src = getEi(lid + '_tab_' + tno).src.replace("off.", "s.");
	getEi(lid + '_' + tno).style.display = "block";
}
// 포스터 뷰 셋팅
function setAd(tit,img,zoom,txt) {
	getEi('poster_Title').innerHTML = tit;
	getEi('poster_Zoom').innerHTML = '<img src="/img/ls/ad/brn_zoom.gif" width="41" height="12" alt="크게보기" onclick="zoom(\'' + zoom + '\')" />';
	getEi('poster_Img').innerHTML = '<img src="' + img + '" alt="" />';
	getEi('poster_Txt').innerHTML = txt;
}

function viewChange (vn,v1,v2,e) {
	var e = e ? e : window.event;
	var view = getEi("viewbox_" + vn);
	for(i=0;i<view.childNodes.length;i++) {
		view.childNodes[i].className = false;
	}
	if (e.target) e.target.parentNode.className = "selected";
	else e.srcElement.parentNode.className = "selected";
	
	// ↓ 아래는 컨텐츠 박스 내용 변경 예문입니다.
	getEi("viewbox_" + vn + "_up").innerHTML = v1; // v1에 해당하는 검색결과 ajax 연동 [상단 박스]
	getEi("viewbox_" + vn + "_down").innerHTML = v2; // v2에 해당하는 검색결과 ajax 연동 [하단 박스]
}

// 탭 체인지
function tabAction(tn,ti) {
	var tabBox = getEi(tn);
	var tab = new Array();
	var n = 0;
	for(i=0;i < tabBox.childNodes.length;i++) { // 브라우져별로 다른 childNodes를 동일하게 재배열
		if (tabBox.childNodes[i].innerHTML) {
			tab[n] = tabBox.childNodes[i];
			n++
		}
	}
	for(i=0;tab[i];i++) { // childNodes값이 새로 배열된 tab을 이용하여 탭액션 시도
		if(i+1 == ti) {
			tab[i].className = "selected";
			getEi(tn + '_view_' + (i+1)).style.display = "block";
		} else {
			tab[i].className = false;
			getEi(tn + '_view_' + (i+1)).style.display = "none";
		}
	}
}


// 플래쉬파일 삽입
function writeSwf (files, name, width, height) {
	var sTag = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ width + '" height="'+ height + '" id="'+ name +'" name="' + name + '" align="middle">'
		+ '<param name="allowScriptAccess" value="always" />'
		+ '<param name="movie" value="' + files + '" />'
		+ '<param name="quality" value="high" />'
		+ '<param name="wmode" value="transparent">'
		+ '<embed wmode="transparent" src="' + files + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="'+ height +'" name="'+ name +'" id="' + name + '" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always" swLiveConnect="true" /></object>';
	document.write (sTag);
}

// 플래쉬파일 픽업
function innerSwf (files, name, width, height) {
	var sTag = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ width + '" height="'+ height + '" id="'+ name +'" name=' + name + '" align="middle">'
		+ '<param name="allowScriptAccess" value="always" />'
		+ '<param name="movie" value="' + files + '" />'
		+ '<param name="quality" value="high" />'
		+ '<param name="wmode" value="transparent" />'
		+ '<embed wmode="transparent" src="' + files + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="'+ height +'" name="'+ name +'" id="' + name + '" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always" swLiveConnect="true" /></object>';
	return sTag;
}

// 동영상 삽입
function writeMov (files, name, width, height, auto) {
	if(auto == "1" || !auto) auto = "true"; else if (auto == "0") auto = "-1";
	var mov = '<embed src="' + files + '"  displaysize="0" showcontrols="0" loop="false" autostart="' + auto + '" width="' + width + '" height="' + height + '" name="' + name + '" id="' + name + '" type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"></embed>'
  document.write (mov);
}

// 동영상 변경
function movie(files, pt, pb) {
	document.documentElement.scrollTop = 0;
	document.body.scrollTop = 0;
	var mov = '<embed src="/movie/' + files + '"  displaysize="0" showcontrols="0" loop="false" autostart="true" width="320" height="240" name="cf" id="cf" type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"></embed>'
	getEi('movTitle').innerHTML = '<p>' + pt + '</p>';
	getEi('movBody').innerHTML = pb;
	getEi('btnDownload').innerHTML = '<a href="/ls/ad/ad_download.asp?c_file=' + files + '"><img src="/img/ls/ad/btn_movdown.gif" width="79" height="20" alt="동영상 다운로드" /></a>';
  getEi('movie').innerHTML = mov;
}

// 동영상 변경
function movie_susol(no,files, pt, pb) {
	document.documentElement.scrollTop = 0;
	document.body.scrollTop = 0;
	var mov = '<embed src="/upload/susol/movie/'+ no +'/' + files + '"  displaysize="0" showcontrols="0" loop="false" autostart="true" width="320" height="240" name="cf" id="cf" type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"></embed>'
	getEi('movTitle').innerHTML = '<p>' + pt + '</p>';
	getEi('movBody').innerHTML = pb;
 //	getEi('btnDownload').innerHTML = '<a href="/ls/ad/ad_download_susol.asp?c_no='+no+'&c_file=' + files + '"><img src="/img/ls/ad/btn_movdown.gif" width="79" height="20" alt="동영상 다운로드" /></a>';
  getEi('movie').innerHTML = mov;
}
 

function fdown(files) {
	
}

// 동영상 컨트롤
function mControl(nm,a) {
	if (!getEi(nm)) return;
	switch(a) {
		case "play" : 
			getEi(nm).style.display = "block";
			eval(nm).play(); 
			break;
		case "pause" : 
			eval(nm).pause(); 
			break;
		case "stop" : 
			eval(nm).stop(); 
			getEi(nm).style.display = "none";
			break;
		default : break;
	}
}
// 토글 레이어
function toggle(cid) {
	if (!getEi(cid)) return;
	getEi(cid).style.display = (getEi(cid).style.display == "block") ? "none" : "block";
}

// 모든 링크 onfocus 액션시에 oneblur 실행
function allblur() {
	pagestatus();
	if(document.listForm) loadCat_faq();
	for (i = 0; i < document.links.length; i++) {
		var obj = document.links[i];
		if(obj.addEventListener) obj.addEventListener("focus", oneblur, false);
		else if(obj.attachEvent) obj.attachEvent("onfocus", oneblur);
	}
}
function oneblur(e) {
  var evt = e ? e : window.event;
  if(evt.target) evt.target.blur();
  else if(evt.srcElement) evt.srcElement.blur();
}

// 퀵메뉴 오토스크롤
function scrollQuick() {
	if(getEi('quick')) {
		var tscroll = parseInt(getEi('quick').style.top, 10);
		var tplus = (setPoint - tscroll)/10;
		if (tplus < 1 && tplus > 0) tplus = 1;
		getEi('quick').style.top = tscroll + tplus + 'px';
		if (setPoint - tscroll == 0) clearInterval(qscroll);
	} else {
		clearInterval(qscroll);
	}
}

// 퀵메뉴 오토스크롤 목표치 설정
function setQuick() {
	clearInterval(qscroll);
	if(!document.body.scrollTop) setPoint = document.documentElement.scrollTop + 123; else setPoint = document.body.scrollTop + 123;
	qscroll = setInterval(scrollQuick, 10);
}

// png 클레스에 IE에서의 반투명 처리
function setPng24(obj) { 
 obj.width=obj.height=1; 
 obj.className=obj.className.replace(/\bpng24\b/i,''); 
 obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
 obj.src=""; 
 return ""; 
} 
/*function setPng24(myImage) {
	if (document.body.filters) {
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
		var imgTitle = (myImage.title) ? "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
		var imgStyle = "display:inline-block;" + myImage.style.cssText
		var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
		myImage.outerHTML = strNewHTML
	}
}*/

// 로그인 상태 변경
function setLogin(st) {
	switch(st) {
		case 'login' : 
			getEi('loginbtn').style.display = "none";
			getEi('logoutbtn').style.display = "block";
			break;
		case 'logout' : 
			getEi('loginbtn').style.display = "block";
			getEi('logoutbtn').style.display = "none";
			break;
		default : alert('잘못된 명령입니다.');
	}
}

//window.onload = allblur;
window.onscroll = setQuick;

// 롤오버 
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];}
}

//글자 사이즈 조절 
function setFontSize(a) {
	var defaultFontSize = 12;//px
	var minFontSize = 10;//px
	var maxFontSize = 18;//px
	obj = document.getElementById("sub_content");
	//obj2 = document.getElementById("submenu");
	var objFontSize = obj.style.fontSize;
	if (!objFontSize) { objFontSize = parseInt(defaultFontSize)+"px"; }
	var checkFontSize = parseInt(objFontSize)+(a);
	if (checkFontSize >= maxFontSize) { checkFontSize = maxFontSize; obj.style.fontSize = checkFontSize+"px"; alert("더이상 늘릴 수 없습니다."); }
	else if (checkFontSize <= minFontSize) { checkFontSize = minFontSize; obj.style.fontSize = checkFontSize+"px"; alert("더이상 줄일 수 없습니다."); }
	else { 
		obj.style.fontSize = checkFontSize+"px";
		//obj2.style.fontSize = checkFontSize+"px";
	}
	//alert(checkFontSize);
}
//글자 사이즈 조절 
function setFontSize2(a) {
	var defaultFontSize = 12;//px
	var minFontSize = 10;//px
	var maxFontSize = 18;//px
	obj = document.getElementById("container");
	//obj2 = document.getElementById("submenu");
	var objFontSize = obj.style.fontSize;
	if (!objFontSize) { objFontSize = parseInt(defaultFontSize)+"px"; }
	var checkFontSize = parseInt(objFontSize)+(a);
	if (checkFontSize >= maxFontSize) { checkFontSize = maxFontSize; obj.style.fontSize = checkFontSize+"px"; alert("더이상 늘릴 수 없습니다."); }
	else if (checkFontSize <= minFontSize) { checkFontSize = minFontSize; obj.style.fontSize = checkFontSize+"px"; alert("더이상 줄일 수 없습니다."); }
	else { 
		obj.style.fontSize = checkFontSize+"px";
		//obj2.style.fontSize = checkFontSize+"px";
	}
	//alert(checkFontSize);
}



// 셀렉트박스 새창이동
function quick(url){
if(url) 	window.open(url, '', '');
}	//SELECT JUMP

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
// 최근게시물 폴더S
function least_ch(n){
	document.getElementById("least_1").style.display = 'none';
	document.getElementById("least_2").style.display = 'none';
	document.getElementById("least_3").style.display = 'none';
	document.getElementById("least_4").style.display = 'none';

	tn = eval('document.getElementById("least_'+n+'")');
	tn.style.display = 'inline';
}
// 최근게시물 폴더E


// 로그인 뒷배경S
var c=false;
// 포커스가 인풋 박스안에 있을때 배경이미지 지우기
function ch (valueid) {
	if(valueid ==  'id')  document.loginFrm.id.style.backgroundImage="";
	else document.loginFrm.pwd.style.backgroundImage="";
	c=true;
}

// 포커스가 인풋 박스를 벗어났을때 배경이미지 살리기 (입력값이 있으면 살리지 않기)
function chout(valueid) {
	if(valueid ==  'id') {
		if(!document.loginFrm.id.value) document.loginFrm.id.style.backgroundImage="url(../images/inc/login_layer_id_bg.gif)";
	}
	else {
		if(!document.loginFrm.pwd.value) document.loginFrm.pwd.style.backgroundImage="url(../images/inc/login_layer_pw_bg.gif)";
	}
	c=true;
}
// 로그인 뒷배경E

// 폼 엔터 체크S
function chk_enter(e) 
{ 
  if(window.event.keyCode == 13) 
  loginFrm.submit(); 
}
// 폼 엔터 체크E

function jumpSelect_mode(f){
	var url = f.URL.options[f.URL.selectedIndex].value;	
	f.action=""; 

	if(f.jumpmode.value== "favorites"||f.jumpmode.value== "familysite"){		
		window.open(url,'_blank');	 
	}else{
		if(url == 'my_admin'){ 
			targetUrl = eval(url);
			window.open(targetUrl,'new');
		}else if (url == 'hosp_funeral' ){ 
			targetUrl = eval(url);
			window.open(targetUrl,"yumc", "width=1020,height=607,scrollbars=no,resizable=no,status=no");
		}else if (url == 'my_message' ){ 
			targetUrl = eval(url);
			window.open(targetUrl, 'message', 'top=100, left=100, width=700, height=500, channelmode=0, directories=0, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0');
		}else if (url == 'my_quick' ){ 
			targetUrl = eval(url);
			window.open(targetUrl, 'my_quick', 'top=50, left=50, width=720, height=700, channelmode=0, directories=0, location=0, menubar=0, resizable=0, scrollbars=yes, status=0, titlebar=0, toolbar=0');
		}else if (url == 'my_yeyak' ){ 
			targetUrl = eval(url);
			window.open(targetUrl, 'reserve', 'width=800,height=800,scrollbars=yes,resizable=no,status=no');
		//else if (url == 'my_yumc' ) window.open(targetUrl, 'issue', 'width=700,height=500,scrollbars=yes,resizable=no,status=no');
		}else if (url == 'cnc_yrc' ){ 
			targetUrl = eval(url);
			window.open(targetUrl, 'yrc');
		}else if (url == '' ){ 
		
		}else{ 
			window.location.href=url;
			
		}
	}
		return false;
}
function onoff(obj)
{
var obj=document.getElementById(obj); 
var obj2=document.getElementById("searchAreas"); 
	if(obj.style.display=="inline"){ 
		obj.style.display="none"; 
		obj2.style.display="inline"; 
	}else{ 
		obj.style.display="inline"; 
		obj2.style.display="none"; 

	}
} 



// Tab Content
function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_o.gif", ".gif");
				} else {
					currentmenu.className = currentmenu.className.replace(" selected", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_o.gif");
			} else {
				this.className += " selected";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

// 화면 확대 축소
var zoomRate = 10;
var curRate = 100;
var minRate = 100;
var maxRate = 200;

function zoomInOut(value) {
	var browserEl = navigator.userAgent.toLowerCase();
	if(browserEl.indexOf('firefox')!=-1) { location.href="/inc/no_zoom.php"; }
	else if(browserEl.indexOf('opera')!=-1) { location.href="/inc/no_zoom.php"; }
	else if(browserEl.indexOf('safari')!=-1) { location.href="/inc/no_zoom.php"; }
	if (((value == "plus")&&(curRate >= maxRate))||((value == "minus") && (curRate <= minRate))) {
	    return;
	}  
	if (value == "plus") {
		curRate = parseInt(curRate) + parseInt(zoomRate);
	} else if (value == "minus") {
		curRate = parseInt(curRate) - parseInt(zoomRate);
	} else if (value == "commo") {
		curRate = 100;
	} else {
		curRate = 100;
	}
	document.body.style.zoom = curRate + '%';
}
