﻿	/*******************************************************
	작 성 자 		: 전남대 포탈 여민호(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월 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 OpenPopup2(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;	
		
		window.open(argSrc,argName,properties);
	}

	
	/*******************************************************
	작 성 자 	: 전남대 포탈 여민호(2007년 10월 30일)
	작성목적     	:  조직도 트리 창을 띄운다.
	Parameter   :	strName		:	이름 텍스트박스 ID
					strCode		:	코드 텍스트박스 ID
					strUserId	:	Id 텍스트박스  ID
	반환 값      :  	None
	사용예       :	OpenModalPopup('txtItemName','txtItemCode','')
	1차 수정		: 
	*******************************************************/

	function uOpenModalPopup(strName,strCode,strUserId){
		var strResult = window.showModalDialog("/Common/OrgTree/OrgTree.aspx?Name="+strName+"&Code="+strCode+"&UserId="+strUserId, self, "dialogWidth:715px; dialogHeight:500px");
	}


	function uOpenModal(strUrl,strWidth,strHeight){
		var strResult = window.showModalDialog(strUrl, self, "dialogWidth:"+strWidth+"px; dialogHeight:"+strHeight+"px");
		return strResult;
	}

	/*******************************************************
	작 성 자 	: 전남대 포탈 여민호(2007년 10월 30일)
	작성목적     	:  XP홈인 경우 안내메시지를 새창에 띄운다.
	Parameter   :	argUrl
	반환 값      :  	None
	사용예       :	
	1차 수정		: 
	*******************************************************/
	///이 스크립트는 로그인된 상태에서 체크하는 것이므로 로그인컨트롤이 정상동작하지 않는 OS에 대한 처리는 배제한다.
	function uAuthCheckUrl(argUrl){
		var arsam = document.getElementById("ArsamCheck");
		if(arsam){
      	    switch(arsam.GetOSProductType){
	        	case 7:		//WINXP_H
	        	case 31:	//WINVISTA_HOME_PREMIUM
	        	case 32:	//WINVISTA_HOME_BASIC
	        		if(uGetCookie('oscheck') != "yes"){//확인안함
						var rtnVal = uOpenModal('/Common/Login/HomeUser.aspx',428,620);
						if(rtnVal == "OK"){
							uSetCookie('oscheck','yes');
							location.href = argUrl;
						}
					}else{//확인함
						location.href = argUrl;
					}
					break;
	        	default : 
					location.href = argUrl;	
				break;
	      	}
	    }
	}
	
	/*******************************************************
	작 성 자 	: 전남대 포탈 여민호(2007년 10월 30일)
	작성목적     	:  XP홈인 경우 안내메시지를 새창에 띄운다.
	Parameter   :	argUrl - 이동할 페이지
					argSite - 이동할 사이트명
	반환 값      :  	None
	사용예       :	
	1차 수정		: 
	*******************************************************/
	///이 스크립트는 로그인된 상태에서 체크하는 것이므로 로그인컨트롤이 정상동작하지 않는 OS에 대한 처리는 배제한다.
	function uAuthCheckUrl2(argUrl,argSite){
		var arsam = document.getElementById("ArsamCheck");
		argSite = encodeURIComponent(argSite);
		if(arsam){
      	    switch(arsam.GetOSProductType){
	        	case 7:		//WINXP_H
	        	case 31:	//WINVISTA_HOME_PREMIUM
	        	case 32:	//WINVISTA_HOME_BASIC
	        		if(uGetCookie('oscheck') != "yes"){//확인안함
						var rtnVal = uOpenModal('/Common/Login/HomeUser.aspx?site='+argSite,428,620);
						if(rtnVal == "OK"){
							uSetCookie('oscheck','yes');
							location.href = argUrl;
						}
					}else{//확인함
						location.href = argUrl;
					}
					break;
	        	default : 
					location.href = argUrl;	
				break;
	      	}
	    }
	}
	
	/*******************************************************
	작 성 자 	: 전남대 포탈 여민호(2008년 06월 17일)
	작성목적     	:  OS에 따라 메일페이지를 다르게 링크한다.(포털 대메뉴의 커뮤니케이션-메일 메뉴에서 사용)
	Parameter   :	
	반환 값      :  	None
	사용예       :	
	1차 수정		: 
	*******************************************************/

	function uCheckOSLinkOwa(argUrl){
		var arsam = document.getElementById("ArsamCheck");
		var src = 'https://imail.jnu.ac.kr/owa';
		if(arsam){
			try{
				if(arsam.GetOSProductType > 0){
		      	    switch(arsam.GetOSProductType){
			        	case 7:		//WINXP_H
			        	case 31:	//WINVISTA_HOME_PREMIUM
			        	case 32:	//WINVISTA_HOME_BASIC
			        		OpenPopup2(src,'nowa','800','700','','','no','yes','yes','yes','yes','yes','yes','yes');
			        		break;
			        	default : 
							location.href = argUrl;	
						break;
			      	}
		      	}else{
			      		location.href = argUrl;
			    }
	      	}catch(err){
	      		location.href = argUrl;
	      	}
	    }else{
	    	location.href = argUrl;
	    }
	}

	
	
	
	/*******************************************************
	작 성 자 	: 전남대 포탈 여민호(2007년 10월 30일)
	작성목적     	:  OWA 페이지를 새창으로 연다.(로그인페이지에서 사용)
	Parameter   :	argUrl - 이동할 페이지
					argSite - 이동할 사이트명
	반환 값      :  	None
	사용예       :	
	1차 수정		: 
	*******************************************************/
	///이 스크립트는 로그인된 상태에서 체크하는 것이므로 로그인컨트롤이 정상동작하지 않는 OS에 대한 처리는 배제한다.
	function uOpenPopOwa(){
		var src = 'https://imail.jnu.ac.kr/owa';
		OpenPopup2(src,'nowa','800','700','','','no','yes','yes','yes','yes','yes','yes','yes');
		return;
	
	/*
		var arsam = document.getElementById("ArsamCheck");
		var src = 'https://imail.jnu.ac.kr/owa';
		if(arsam){
		try{
				if(arsam.GetOSProductType > 0){
		      	    switch(arsam.GetOSProductType){
			        	case 7:		//WINXP_H
			        	case 31:	//WINVISTA_HOME_PREMIUM
			        	case 32:	//WINVISTA_HOME_BASIC
			        		alert('XP 홈 또는 Vista 홈 사용자입니다.');
			        		OpenPopup2(src,'nowa','800','700','','','no','yes','yes','yes','yes','yes','yes','yes');
							break;
			        	default : 
							alert('로그인 후 이용하십시요.');
						break;
			      	}
		      	}else{
		      		alert('ArsamCheck 컨트롤이 설치되지 않았습니다.');
		    		OpenPopup2(src,'nowa','800','700','','','no','yes','yes','yes','yes','yes','yes','yes');
		      	}
	      	}catch(err){
	      		alert('ArsamCheck 컨트롤이 설치되지 않았습니다.');
	    		OpenPopup2(src,'nowa','800','700','','','no','yes','yes','yes','yes','yes','yes','yes');
	      	}
	    }else{
	    	alert('ArsamCheck 컨트롤이 설치되지 않았습니다.');
	    	OpenPopup2(src,'nowa','800','700','','','no','yes','yes','yes','yes','yes','yes','yes');
	    }*/
	}



	/*******************************************************
	작 성 자 	: 전남대 포탈 여민호(2007년 10월 25일)
	작성목적     	:  신분목록 Bubble을 보여준다.
	Parameter   :	
	반환 값      :  None
	사용예       :
	1차 수정		: 
	*******************************************************/

	function DutyListView(objID,bWidth, bHeight){
		//object mapping
		var objDiv = document.getElementById(objID);
		
		//Div Style
		objDiv.style.borderStyle = 'solid';
		objDiv.style.borderWidth = '1';
		objDiv.style.borderColor = '#6F9DD9';
		objDiv.style.left = uFindPosX(event.srcElement);
		objDiv.style.top = 5; /* uFindPosY(event.srcElement) + bHeight;  */
		objDiv.style.width = bWidth;
		objDiv.style.zIndex = 2;
		objDiv.style.position = 'absolute';
		
		//Div Display
	    if(objDiv.style.display == 'none')
	        objDiv.style.display = '';
	    else
	        objDiv.style.display = 'none'; 
	    
 	}



	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;
	}

	/*******************************************************
	작 성 자 	: 전남대 포탈 여민호(2007년 12월 30일)
	작성목적     	:  오류보고 함수
	Parameter   :	argType 	: 오류 보고 타입( 이메일, SMS)
					argSource 	: 오류 보고 소스 페이지명
	반환 값      :  None
	사용예       : uSendError('SMS','error');
	1차 수정		: 
	*******************************************************/

	function uSendError(argType, argSource){
		var strUrl = location.href;
		var strOnlyUrl = '';
		var strQueryString = '';
		
		if(strUrl.indexOf('?') > 0){
		    strOnlyUrl = strUrl.substring(0,strUrl.indexOf('?'));
			strOnlyUrl = strOnlyUrl.replace('http://devarsam.jnu.ac.kr','');
			strOnlyUrl = strOnlyUrl.replace('http://arsam.jnu.ac.kr','');
			strQueryString = strUrl.substring(strUrl.indexOf('?') + 1);
		}
	    if(strQueryString == ''){
			strQueryString = 'id=';
		}else{
			if(strQueryString.indexOf('id=') < 0){
				strQueryString = strQueryString + '&id=';
			}
		}
		
		//오류 보고 페이지를 띄운다.
		OpenPopup('/Service/ErrorReport/ErrorReporting.aspx?Type='+argType+'&Source='+argSource+'&'+strQueryString+'&SiteUrl='+strOnlyUrl,'ErrorReporting',500,400,0,0,'yes');
	}
	
	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 uSetCookie(name,value) {
		document.cookie = name+"="+escape(value)+";path=/;domain=.jnu.ac.kr;";
	}

	function locationmove(url) {
		location.href = url;
	}
	
	/*******************************************************
	작 성 자 	: 전남대 포탈 여민호(2008년 02월 29일)
	작성목적     	:  스테이징, 운영서버 주소 구분
	Parameter   :	argID	: Iframe ID
					argSrc1	: 원래 문자열
					argSrc2	: 바꿀 문자열
	반환 값      :  None
	사용예       : uChangeIFSrc('ifrWeb','http://devhak.jnu.ac.kr','http://hak.jnu.ac.kr')
	1차 수정		: 
	*******************************************************/
	function uChangeIFSrc(argID,argSrc1,argSrc2){
		if(ToLower(location.href).indexOf('devarsam') < 0){
			document.getElementById(argID).src = document.getElementById(argID).src.replace(argSrc1,argSrc2);
		}
	}


	/*******************************************************
		작 성 자 	: 전남대 포탈 여민호(2008년 07월 11일)
		작성목적     	:  OS타입 구분
		Parameter   :	
		반환 값      :  OS 이름
		사용예       : getOSInfoStr()
		1차 수정		: 
		*******************************************************/
	function getOSInfoStr()
	{
	    var ua = navigator.userAgent;
	
	    if(ua.indexOf("NT 6.0") != -1) return "Windows Vista/Server 2008";
	    else if(ua.indexOf("NT 5.2") != -1) return "Windows Server 2003";
	    else if(ua.indexOf("NT 5.1") != -1) return "Windows XP";
	    else if(ua.indexOf("NT 5.0") != -1) return "Windows 2000";
	    else if(ua.indexOf("NT") != -1) return "Windows NT";
	    else if(ua.indexOf("9x 4.90") != -1) return "Windows Me";
	    else if(ua.indexOf("98") != -1) return "Windows 98";
	    else if(ua.indexOf("95") != -1) return "Windows 95";
	    else if(ua.indexOf("Win16") != -1) return "Windows 3.x";
	    else if(ua.indexOf("Windows") != -1) return "Windows";
	    else if(ua.indexOf("Linux") != -1) return "Linux";
	    else if(ua.indexOf("Macintosh") != -1) return "Macintosh";
	    else return "";
	}

	/*******************************************************
		작 성 자 	: 전남대 포탈 여민호(2008년 07월 11일)
		작성목적     	:  OS타입 구분
		Parameter   :	
		반환 값      :  OS 타입 구분 1은 SSO컨트롤 지원, 2는 미지원
		사용예       : getOSInfoType()
		1차 수정		: 
		*******************************************************/
	function getOSInfoType()
	{
	    var ua = navigator.userAgent;

	    if (ua.indexOf("NT 6.0") != -1) return "1"; //"Windows Vista/Server 2008";
	    else if (ua.indexOf("NT 5.2") != -1) return "1"; //"Windows Server 2003";
	    else if (ua.indexOf("NT 5.1") != -1) return "1"; //"Windows XP";
	    else if (ua.indexOf("NT 6.1") != -1) return "1"; //"Windows 7";
	    else if (ua.indexOf("NT 5.0") != -1) return "2"; //"Windows 2000";
	    else if (ua.indexOf("NT") != -1) return "2"; //"Windows NT";
	    else if (ua.indexOf("9x 4.90") != -1) return "2"; //"Windows Me";
	    else if (ua.indexOf("98") != -1) return "2"; //"Windows 98";
	    else if (ua.indexOf("95") != -1) return "2"; //"Windows 95";
	    else if (ua.indexOf("Win16") != -1) return "2"; //"Windows 3.x";
	    else if (ua.indexOf("Windows") != -1) return "2"; //"Windows";
	    else if (ua.indexOf("Linux") != -1) return "2"; //"Linux";
	    else if (ua.indexOf("Macintosh") != -1) return "2"; //"Macintosh";
	    else return "1";

	}

