﻿	/*******************************************************
	작 성 자 		: 전남대 포탈 여민호(2007년 10월 01일)
	작성목적     		:  팝업창을 오픈한다.
	Parameter     	:	argSrc			: 팝업에 표시할 페이지(value)
						argName			: 팝업창 이름(value)
						argWidth		: 팝업창 가로길이
						argHeight		: 팝업창 세로길이
						argTop			: 팝업창 상단여백
						argLeft			: 팝업창 왼쪽여백
						argCenterYN		: 팝업창을 화면 중앙에 띄울지 여부
						argMenubar		: 메뉴바 표시여부
						argToolbar		: 툴바 표시여부
						argDirectories	: 디렉토리바 표시여부
						argScrollbars	: 스크롤바 표시여부
						argStatus		: 상태바 표시여부
						argLocation		: 주소표시줄 표시여부
						argResizable	: 크기조정 가능여부
						argFullscreen	: 전체화면으로 표싱부
	반환 값       	: 	None
	사용예       	:	OpenPopup('http://devarsam.jnu.ac.kr','TEST',200,200,50,50,'no','no','no','no','no','no','no','no','no')
						OpenPopup('http://devarsam.jnu.ac.kr','TEST',200,200,50,50,'yes')
						OpenPopup('http://devarsam.jnu.ac.kr','TEST',200,200,50,50)
	1차 수정			: 
	*******************************************************/
	function OpenPopup(argSrc, argName, argWidth, argHeight, argTop, argLeft, argCenterYN, argMenubar, argToolbar, argDirectories, argScrollbars, argStatus, argLocation, argResizable, argFullscreen ){
		var properties = "width="+argWidth+",height="+argHeight;
		if(argCenterYN == 'yes') {
			var sw = screen.availWidth;
			var sh = screen.availHeight;
			var left = (sw - argWidth)/2;
			var top = (sh - argHeight)/2;
			if(argTop != null) properties += ",top="+top;
			if(argLeft != null) properties += ",left="+left;
		}else{
			if(argTop != null) properties += ",top="+argTop;
			if(argLeft != null) properties += ",left="+argLeft;
		}

		if(argMenubar != null) properties += ",menubar="+argMenubar;
		if(argToolbar != null) properties += ",toolbar="+argToolbar;
		if(argDirectories != null) properties += ",directories="+argDirectories;
		if(argScrollbars != null) properties += ",scrollbars="+argScrollbars;
		if(argStatus != null) properties += ",status="+argStatus;
		if(argLocation != null) properties += ",location="+argLocation;
		if(argResizable != null) properties += ",resizable="+argResizable;
		if(argFullscreen != null) properties += ",fullscreen="+argFullscreen;	
		
		var openPop = window.open(argSrc,argName,properties);
	}
	
	/*******************************************************
	작 성 자 	: 전남대 포탈 여민호(2007년 10월 30일)
	작성목적     	:  모달 창을 띄운다.
	Parameter   :	strUrl		:	주소
					strWidth	:	너비
					strHeight	:	높이
	반환 값      :  	None
	사용예       :	uOpenModal('/',200,200)
	1차 수정		: 
	*******************************************************/

	function uOpenModal(strUrl,strWidth,strHeight){
		var strResult = window.showModalDialog(strUrl, self, "dialogWidth:"+strWidth+"px; dialogHeight:"+strHeight+"px");
		return strResult;
	}

	function uFindPosX(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;
	}

 

	function uFindPosY(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;
	}
	

	function ToLower(arg){
	 var str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	 var str2 = "abcdefghijklmnopqrstuvwxyz";
	 return alterString(arg,str1,str2);
	}
	
	function alterString(str, before, after){
	 var returnStr = "";
	 for(i = 0;i < str.length;i++){
	  value = str.charAt(i);
	  index = before.indexOf(value);
	  if(index >= 0) value = after.charAt(index);
	  returnStr += value;
	 }
	  return returnStr;
	}

	function uGetCookie( 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 uGetMOSSCookie( name, value )
	{
		var nameOfCookie = name + "=";		
		var x = 0;
		while( x <= value.length )	
		{
			var y = (x + nameOfCookie.length);
			if( value.substring( x, y ) == nameOfCookie ) {
				if( ( endOfCookie = value.indexOf("&", y)) == -1 ) 
					endOfCookie = value.length;
				return unescape( value.substring( y ,endOfCookie ));
			}
			x = x + 1;
		}
		return "";
	}
	
	function locationmove(url) {
		location.href = url;
	}
	function openwinkuy(linkURL) {
		if (linkURL!="") { 
		    window.open(linkURL) ;
		}
	}

	function uChangeLoginBtn(){
		//로그인 된 상태
		if(document.cookie.indexOf('SSOValidate') >= 0){
			if(document.getElementById('td_login'))
				document.getElementById('td_login').style.display = 'none';
			if(document.getElementById('td_logout'))
				document.getElementById('td_logout').style.display = 'block';
		}
		//로그아웃 상태
		else{
			if(document.getElementById('td_login'))
				document.getElementById('td_login').style.display = 'block';
			if(document.getElementById('td_logout'))
				document.getElementById('td_logout').style.display = 'none';
		}
	}
	
	var oPrintWindow  ;
	var oTimer ;
	var bw = navigator.appName.toLowerCase();

	function print_out(){
		try{
			//table id : MSO_ContentTable
			var oIframe = document.getElementById('_MossContentFrame');
			var oOpenUrl;
			if(oIframe){
				oIframe.src = oIframe.contentWindow.location.href;
				oOpenUrl = "/inc/print_.html";
			}else{
				oOpenUrl = "/inc/print_2.html";
			}

			var subHTML = document.getElementById('MSO_ContentTable').parentNode.innerHTML;
		
			oPrintWindow  =  window.open(oOpenUrl, 'jnuprints', 'toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=750, height=500'); 
	
			printBoxHTML   = "<html><head><title>"+document.title+"</title>\n";
			printBoxHTML  += "<link rel=\"stylesheet\" href=\"/css/main.css\" type=\"text/css\" />\n";
			printBoxHTML  += "<link rel=\"stylesheet\" href=\"/css/menu.css\" type=\"text/css\" />\n";
			printBoxHTML  += "<link rel=\"stylesheet\" href=\"/css/Contents.css\" type=\"text/css\" />\n";
			printBoxHTML  += "<link rel=\"stylesheet\" href=\"/css/Default.css\" type=\"text/css\" />\n";
			printBoxHTML  += '<object id=factory viewastext style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="/~cba/inc/smsx.cab#Version=6,3,435,20"><param name="template" value="MeadCo://IE7" /></object>';
			printBoxHTML  += subHTML;
			printBoxHTML  += "<"+"script type=\"text/javascript\">\n";
			printBoxHTML  += "//<![CDATA[\n";
			printBoxHTML  += "window.print();\n";
			/*printBoxHTML  += "factory.printing.header = \"\";\n";
			printBoxHTML  += "factory.printing.footer = \"\";\n";
			printBoxHTML  += "factory.printing.portrait = true;\n";
			printBoxHTML  += "factory.printing.leftMargin = 1.0;\n";
			printBoxHTML  += "factory.printing.topMargin = 1.0;\n";
			printBoxHTML  += "factory.printing.rightMargin = 1.0;\n";
			printBoxHTML  += "factory.printing.bottomMargin = 1.0;\n";
			printBoxHTML  += "factory.printing.Print(false, window);\n";*/
			printBoxHTML  += "//]]>\n";
			printBoxHTML  += "</script>\n";
			printBoxHTML  += "\n</body>\n</html>";
			
			oTimer = setInterval("print_out_sub()",2000);	//2초간 슬립, 화면이 로딩되는 시간
		}catch(err){
			alert(err.message);
			oPrintWindow.close();
		}
}

function print_out_sub()
{
	var oMossFrame = document.getElementById('_MossContentFrame');
	if(oMossFrame)
	{
		orgSrc = oMossFrame.src;
		newSrc = oMossFrame.contentWindow.location.href;
		
		printBoxHTML = printBoxHTML.replace(orgSrc,newSrc);
	}


	oPrintWindow.document.write(printBoxHTML);	
	
	if(bw.indexOf('explorer') > 0){oPrintWindow.location.reload();}	

	if(oTimer) clearInterval(oTimer);

}
