/** 인쇄 **/
function printcontentHome() 
{
	window.open("/print/printcontentHome.jsp","print","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=700");
}

function printcontentHome(getUrl) 
{
	window.open("/print/printcontentHome.jsp?getUrl="+getUrl,"print","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=700");
}

/**** onload 추가실행 ****/
function addLoadEvent(funct) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = funct;
  } else {
    window.onload = function() {
		oldonload();	  
		funct();
	}
  }
}

/**** 이벤트리스너 등록 ****/
function addEvent(obj,event,func){
	var obj = document.getElementById(obj);
	if(!obj) return false;
	if(obj.addEventListener) obj.addEventListener(event, func); // 브라우저가 IE인 경우 처리
	else obj.attachEvent(event, func);
}

// 값의 공백여부 확인
function isEmptyForm(obj, len, nm)
{
	var maxlen = 1;
	maxlen = parseInt(len);
	if(obj && obj.rel !='nochk'){ //해당 객체가 있고 rel 값이 nochk 가 아닐경우에만 체크
		if(obj.value.length <maxlen) 
		{
			alert(nm+" 확인해 주세요");
			if(obj.type !='hidden') obj.focus();
			return true;
		}
	}
	return false;
}

//다른 자바스크립트 파일 인클루드 시키기
var jsload = function(src){
	var src = src;
	return{
		insSrc:function(src){
			var script = document.createElement('script'); 
			script.type = 'text/javascript'; 
			script.src = src;
			document.getElementsByTagName('head')[0].appendChild(script);
		},
		insCss:function(src){
			var css = document.createElement('link'); 
			css.type = 'text/css'; 
			css.href = src;
			css.rel = 'stylesheet';
			css.media = 'all';
			document.getElementsByTagName('head')[0].appendChild(css);
		}
	}
}();

//jsload.insSrc('/js/jquery.js');//jQuery load

//jquery lightbox 관련 파일
//jsload.insSrc('/js/ajax/lightbox/js/jquery.lightbox.js');//js load
//jsload.insCss('/js/ajax/lightbox/css/jquery.lightbox.css');//css load

//jquery facebox 관련 파일
//jsload.insSrc('/js/ajax/facebox/facebox.js');//js load
//jsload.insCss('/js/ajax/facebox/facebox.css');//css load

//웹접근성 체크
//jsload.insSrc('/js/webinspector.js');//js load

//팝업창 체크
jsload.insSrc('/js/ajax/popChk/popChk.js');//js load

//이미지 천천히 로딩
jsload.insSrc('/js/ajax/lazyload/jquery.lazyload.mini.js');//js load

//첨부이미지 미리보기
jsload.insSrc('/js/ajax/prevImg/humanmsg.js');//js load
jsload.insCss('/js/ajax/prevImg/humanmsg.css');//css load
//twit
//jsload.insSrc('/js/mayor/common/twitjson.js');//




/*********팝업관련 자바스크립트 소스****************/
function close_layer(num){
	document.getElementById(num).style.display = 'none';

	//쿠키굽기
	setCookie(num, 'done' , 1); 
}
function close_layer2(num){
	document.getElementById(num).style.display = 'none';

}
function link_target(url,target){	
	if(url != '#' && url != ''){
		url = url.replace("http://","");
		url = "http://"+url;
		if(target=='_blank'){
			window.open(url);
		}else if(target=='_self'){
			location.href=url;
		}else{
			opener.location.href=url;
		}
	}else{
		return false;
	}
}
/*********팝업관련 자바스크립트 소스****************/

//프린트페이지
function printPage() { 
        var t_url = document.URL; // 현재 페이지의 url을 얻어냄
        
        // url중 불필요한 부분은 잘라냄
        t_url = t_url.substr(t_url.indexOf('/')+1); 
        t_url = t_url.substr(t_url.indexOf('/')+1); 
        t_url = t_url.substr(t_url.indexOf('/')); 
        
        // 현재 파일명과 뒤의 파라메터부분을 분리함
        opt = t_url.substr(t_url.indexOf('?')+1); 
        fn = t_url.substr(0,t_url.lastIndexOf('?')); 

// & 로 되어있는 파라메터 구분자를 | 로 바꿈
// 이는 새로운페이지로 넘길때 파라메터값을 충돌(?)을 방지하기 위함 
        add = '|'; 
        out = '&'; 
        temp = opt; 
         
        while (temp.indexOf(out)>-1) { 
                pos= temp.indexOf(out); 
                temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + out.length), temp.length));
        } 

        opt=temp; 
         
        if( fn.length == 0 )fn=opt; 

// 새창을열고 파일명과 request 값을 넘겨줌
        link_page = "/include/print_contents.php?opt="+opt+"&fn="+fn;
		window.open(link_page,"print","width=720,height=700,left=200,top=50,scrollbars=yes,toolbar=no");
} 
//프린트페이지


function openwin(code,linkurl,width,height,scroll)
{		
	/*** 팝업 창 화면 중앙에 오픈시키기**/
	
	if ( getCookie(code) != "done" )	{
	    var str;
	    
	    str = "height=" + height + ",innerHeight=" + height;
	    str += ",width=" + width + ",innerWidth=" + width;
	    if(scroll==1) str += ",scrollbars=yes";
	
	    if (window.screen) {
	        var ah = screen.availHeight - 30;
	        var aw = screen.availWidth - 10;
	        var xc = (aw - width) / 2;
	        var yc = (ah - height) / 2;
	
	        str += ",left=" + xc + ",screenX=" + xc;
	        str += ",top=" + yc + ",screenY=" + yc;

	    }
		//팝업이 없을시 아래 2줄 앞부분을 "//"으로 가려줌
	    noticeWindow = window.open(linkurl, code , str);
	    //noticeWindow.opener = self;
	    noticeWindow.focus();
	}
}

function openwin1(code,linkurl,width,height,scroll)
{		
	/*** 팝업 창 화면 중앙에 오픈시키기**/
	
	if ( getCookie(code) != "done" )	{
	    var str;
	    
	    str = "height=" + height + ",innerHeight=" + height;
	    str += ",width=" + width + ",innerWidth=" + width;
	    if(scroll==1) str += ",scrollbars=yes";
	
	    if (window.screen) {
	        var ah = screen.availHeight - 30;
	        var aw = screen.availWidth - 10;
	        var xc = (aw - width) / 2;
	        var yc = (ah - height) / 2;
	
	        str += ",left=" + xc + ",screenX=" + xc;
	        str += ",top=" + yc + ",screenY=" + yc;

	    }
		//팝업이 없을시 아래 2줄 앞부분을 "//"으로 가려줌
	    noticeWindow = window.open(linkurl, code , str);
	    //noticeWindow.opener = self;
	    noticeWindow.focus();
	}
}


//새창 뛰우기 
function openwin1(code,linkurl,width,height,scroll)
{		
	/*** 팝업 창 화면 중앙에 오픈시키기**/
	
	if ( getCookie(code) != "done" )	{
	    var str;
	    
	    str = "height=" + height + ",innerHeight=" + height;
	    str += ",width=" + width + ",innerWidth=" + width;
	    if(scroll==1) str += ",scrollbars=yes";
	
	    if (window.screen) {
	        var ah = screen.availHeight - 30;
	        var aw = screen.availWidth - 10;
	        var xc = (aw - width) / 2;
	        var yc = (ah - height) / 2;
	
	        str += ",left=" + xc + ",screenX=" + xc;
	        str += ",top=" + yc + ",screenY=" + yc;

	    }
		//팝업이 없을시 아래 2줄 앞부분을 "//"으로 가려줌
	    noticeWindow = window.open(linkurl, code , str);
	    //noticeWindow.opener = self;
	    noticeWindow.focus();
	}
}


function popupWinWithScroll(sUrl, nWidth, nHeight) //스크롤 있는 팝업창 
{ 
nLeft = (window.screen.width - nWidth ) / 2; 
nTop  = (window.screen.height- nHeight) / 2; 
sF  = ""; 
sF += "toolbar=no,location=no,menubar=no,status=no,directories=no,resizable=no,scrollbars=yes"; 
sF += ",left=" + nLeft; 
sF += ",top=" + nTop; 
sF += ",width=" +  nWidth; 
sF += ",height=" + nHeight; 
window.open(sUrl, "", sF); 
} 



function openwin2(code,linkurl,width,height,top,left,scroll)
{		

	if ( getCookie(code) != "done" )
	{
		 //팝업이 없을시 아래 2줄 앞부분을 "//"으로 가려줌
		
		str = "scrollbars=yes,width=" + width +", height="+ height +", top="+ top +", left=" + left;
		
		if(scroll==1) str += ",scrollbars=yes";
		else  str += ",scrollbars=no";
		noticeWindow = window.open(linkurl, code , str);
		
		//noticeWindow.opener = self;
	}
}


//갤러리 게시판 이미지 확대
function viewImage1(img,W,H){ 
	str = 'height=' + H + ',innerHeight=' + H;
	str += ',width=' + W + ',innerWidth=' + W;
	
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - W) / 2;
		var yc = (ah - H) / 2;
		
		str += ',left=' + xc + ',screenX=' + xc;
		str += ',top=' + yc + ',screenY=' + yc;
		if(scroll==1) str += ',scrollbars=yes';
	}
	img = escape(img);            
	imgWin=window.open('/gallery/zoom.html?img='+img,'img',str); 
}

function viewImage2(img){ 
        W=document.imagezoom.winwidth.value; 
        H=document.imagezoom.winheight.value; 

	str = 'height=' + H + ',innerHeight=' + H;
	str += ',width=' + W + ',innerWidth=' + W;
	
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - W) / 2;
		var yc = (ah - H) / 2;
		
		str += ',left=' + xc + ',screenX=' + xc;
		str += ',top=' + yc + ',screenY=' + yc;
		if(scroll==1) str += ',scrollbars=yes';
	}
	img = escape(img);
	imgWin=window.open('zoom.html?img='+img,'img',str); 
}




/* 아이프레임 리사이즈 */
function reSize()
{
	var BoardMainFrame = main_contents.document.body;
	var ContentFrame = document.all["main_contents"];

	ContentFrame.style.height = BoardMainFrame.scrollHeight + (BoardMainFrame.offsetHeight - BoardMainFrame.clientHeight);
	ContentFrame.style.width = BoardMainFrame.scrollWidth + (BoardMainFrame.offsetWidth - BoardMainFrame.clientWidth); 

}
/* 리사이즈 끝 */


/* e-catalog */
function ecatalogOpen(url)
{
	if(screen.width>1024) openwin1('e_catalog',url,1000,675,0);
	else {
		if(screen.width==1024) window.open(url,"e_catalog","fullscreen,scrollbars=no");
		else alert('브로슈어는 해상도 1024×768 부터 지원이 됩니다.');
	}
	
}

/* e-catalog */
function ecatalogOpen2(url)
{
	if(screen.width>1024) openwin1('e_catalog',url,600,575,0);
	else {
		if(screen.width==1024) window.open(url,"e_catalog","fullscreen,scrollbars=no");
		else alert('브로슈어는 해상도 1024×768 부터 지원이 됩니다.');
	}
	
}
/* e-catalog 끝 */

//인쇄 페이지
function printContent(getUrl) 
{
	window.open("/_prog/print_contents.php?getUrl="+getUrl,"print","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=655,height=700");
}

//메일 보내기
function sendMail()
{
	m_gubun = bookmark_form.b_gubun.value;
	m_linkid = bookmark_form.b_linkid.value;
	window.open("/_prog/mail/mail.php?m_gubun="+m_gubun+"&m_linkid="+m_linkid,"mail","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=680,height=570");
}

//북마크
function bookMark(getUrl,Title) {

   bookmarkurl= getUrl
    bookmarktitle= Title
        if (document.all)
            window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

// 쿠키저장
function setCookie( name, value, expiredays ) { 
    var todayDate = new Date(); 
    todayDate.setDate( todayDate.getDate() + expiredays ); 
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 

function getCookie(name) 
{ 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; while(i< clen) 
	{ 
		var j = i + alen; 
		if(document.cookie.substring(i,j)==arg)
			{ 
			var end = document.cookie.indexOf(";",j); 
			if(end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(j,end)); 
			} 
		i=document.cookie.indexOf(" ",i)+1; 
		if (i==0) break; 
	} 
	return null; 
}

function skin_color(color)
{
	setCookie( "Skin_Color", color , 1); 	
	self.location.reload()
}

 /* 스킨저장  */
 function SetSkin(color){ 
	//alert(color);
	setCookie( "Skin_Color", color , 1); 	
	self.location.reload()
}

/* 
공통사용함수
셀렉트폼 이동함수 par1 : 폼 par1:셀렉트이름, par3:새창여부 (_blank :새창)
*/
function selectLinks(par1,par2,par3) {

	var Frm_name = par1; 
	var Frm_ele = par2; 
	var Target = par3; 
	var Linkurl = document.forms[Frm_name].elements[Frm_ele].value; 
   	var open_method = document.forms[Frm_name].target = Target; // 새창뜨기 속성

	if(Target == "_blank") {
		window.open(Linkurl); 
	}
	else
	{
		location.href=Linkurl;
	}
}


//바로가기 관련 스크립트
function select_link(id,data,target){
	if(data=='#') return false;
	if(!target){
		window.open(data);
	}else{
		location.href = data;
	}
}

/*********드래그 하여 체크박스 선택********/
downchk = 'off';
DragChk = function(){
	if(!document.getElementsByTagName) return false; //에러체크
	//모든 input 박스에 적용
	var obj = document.getElementsByTagName("input");
	for(i=0;i<obj.length;i++){
		if(obj[i].getAttribute('type') == 'checkbox'){
			obj[i].onmouseover = function(){
				if(downchk == 'off') return false;
				if(this.checked){
					this.checked = false;
				}else{
					this.checked = true;
				}		
			}
			//클릭시
			obj[i].onclick = function(){
				if(this.checked){
					this.checked = false;
				}else{
					this.checked = true;
				}		
			}
		}
	}	
	//마우스 down
	document.onmousedown = function(){
		downchk = 'on';
		var obj = window.event.srcElement;
		if(obj.checked){
			obj.checked = false;
		}else{
			obj.checked = true;
		}
	}
	//마우스를 up
	document.onmouseup = function(){
		downchk = 'off';
	}	
}
addLoadEvent(DragChk);

/********* input 박스 포커스 색상 변경 ********/
function inputfocus(){
	if(!document.getElementsByTagName) return false;
	var obj = document.getElementsByTagName('input');
	for(i=0;i<obj.length;i++){
		if(obj[i].getAttribute('type')!='button' && obj[i].getAttribute('type')!='img' && obj[i].getAttribute('type')!='radio'){
			obj[i].onfocus = function(){
				this.style.background = "RGB(250,250,250)";
			}
			obj[i].onblur = function(){
				this.style.background = "RGB(255,255,255)";
			}
		}
	}
}
//addLoadEvent(inputfocus);

//객체의 X 좌표값 구하기
function findPosX(obj){
 var curleft = 0;
 if(obj.offsetParent){
  while(obj.offsetParent){
   curleft += obj.offsetLeft;
   obj = obj.offsetParent;
  }
 }
 else if(obj.x) curleft += obj.x;
 
 return curleft;
}

//객체의 Y 좌표값 구하기
function findPosY(obj){
 var curtop = 0;
 if(obj.offsetParent){
  while(obj.offsetParent){
   curtop += obj.offsetTop;
   obj = obj.offsetParent;
  }
 }else if(obj.y) curtop += obj.y;

 return curtop;
}
