﻿function GetTypeAction(gURL, gQueryString) {
	if (gQueryString != "") {
			var QueryString = "?" + gQueryString.replace(/\|/gi, "&");
		} else {
				var QueryString = "";
			}
	var SuccessUrl = gURL + QueryString     
	location.href = SuccessUrl;
}

function iFrameGetTypeAction(gURL, iFrameId, gQueryString) {
	if (gQueryString != "") {
			var QueryString = "?" + gQueryString.replace(/\|/gi, "&");
		} else {
				var QueryString = "";
			}
	var SuccessUrl = gURL + QueryString
	document.getElementById(iFrameId).src = SuccessUrl;
}

function PostTypeAction(FormName,actionUrl,ActionType,targetType,ParaMether_Accretion) {
	var form = eval('document.' + FormName);
	switch (ActionType) {
		case "D" : {
			encodingType = 'application/x-www-form-urlencoded'
		break;}
		case "F" : {
			encodingType = 'multipart/form-data'
		break;}

	}
	if (ParaMether_Accretion !=	"")	{
		var	arrPa	=	ParaMether_Accretion.split('|');
		for	(i=0;i<arrPa.length;i++) {
		var	ReSplit_arrPa	=	arrPa[i].split('=')
		var	HiddenParaMeter	=	document.createElement("input");
			HiddenParaMeter.setAttribute("type","hidden");
			HiddenParaMeter.setAttribute("name",ReSplit_arrPa[0]);
			HiddenParaMeter.setAttribute("value",ReSplit_arrPa[1]);
			form.appendChild(HiddenParaMeter);
		}
	}
	
	form.encoding		=		encodingType;
	form.method			=		'post';
	form.target			=		targetType;
	form.action			=		actionUrl;
	form.submit();
}

function PathParaMeterAction(FormName,actionUrl,ActionType,targetType,ParaMether_Accretion) {
	PostTypeAction(FormName,actionUrl,ActionType,targetType,ParaMether_Accretion + '|bPath=' + location)
}

function CommonFormReset(FormName, NextFocusElement) {
		var f = eval('document.' + FormName)
		f.reset();
		eval ('f.' + NextFocusElement + '.focus()')
}

function TextIs(FormName) {
	//	Null 을 허용하는 필드를 제외하는 로직이 필요함.
	var	f	=	eval('document.' + FormName);
	var	Result = 0;
	var	ReturnIs = '';
	for	(i=0;i<f.elements.length;i++)	{
		if ((f.elements[i].type == 'text') || (f.elements[i].type == 'password'))	{
			if (f.elements[i].value	== "") {
				Result +=	1;
				document.getElementById(f.elements[i].id).select();
				break;
			}
		}
	}
	if (Result > 0)	{
		ReturnIs = false;
	}	else {
		ReturnIs = true;
	}
	return ReturnIs;
}

function TextIs_Single(FormName, ElementsName) {
	var f = eval('document.' + FormName);
	var s = eval('f.' + ElementsName);
	var ReturnIs = '';
	if (s.value == "") {
		ReturnIs = false;
	} else {
		ReturnIs = true;
	}
	return ReturnIs;
}

function CheckedIs(FormName, ElementsName) {
	var	f	=	eval('document.' + FormName)
	var	c	=	eval('f.'	+	ElementsName);
	var	Result = 0;
	var	ReturnIs = '';
	if (c.length == undefined) {	// 체크 엘리먼트가 단수(배열이 아닐)때
		if (c.checked == true) {
			Result += 1;
		} else {
			Result += 0;
		}
	}
	if (c.length > 0) {	// 체크 엘리먼트가 복수(배열)일때
		for (i=0; i<c.length; i++) {
			if (c[i].checked == true) {
				Result += 1;
			}
		}
	}
	if (Result > 0) {
		ReturnIs = true;
	} else {
		ReturnIs = false;
	}
	return ReturnIs;
}

function SelectIs(FormName, ElementsName) {
	var f = eval('document.' + FormName);
	var s = eval('f.' + ElementsName);
	var ReturnIs = '';
	if (s.value == "") {
		ReturnIs = false;
	} else {
		ReturnIs = true;
	}
	return ReturnIs;
}

function TextAreaIs(FormName, ElementsName) {
	var f = eval('document.' + FormName);
	var s = eval('f.' + ElementsName);
	var ReturnIs = '';
	if (s.value == "") {
		ReturnIs = false;
	} else {
		ReturnIs = true;
	}
	return ReturnIs;
}

function MailRegExpIs(FormName, ElementName) {
	var ChkResult;
	var MailExp = /[a-z0-9]{2,}@[a-z0-9-]{2,}\.[a-z0-9]{2,}/i;
	var f = eval('document.' + FormName);

	if (MailExp.test(f.ElementName.value) == true) {
		ChkResult = true;
	} else {
		ChkResult = false;
	}
	return ChkResult;
}


/*
위 태그 입력 체크 함수들을 적용한 체크스크립트
		var	Result = 0;
		var	CheckedNullIs	=	new	Array();
			CheckedNullIs[0] = TextIs('frm')
			CheckedNullIs[1] = CheckedIs('frm','BOARD_WRITE_LEVEL')
			CheckedNullIs[2] = CheckedIs('frm','HTML_USE_CONFIRM')
			CheckedNullIs[3] = CheckedIs('frm','FILE_UPLOAD_CONFIRM')
			CheckedNullIs[4] = CheckedIs('frm','BACKUP_DATE')
			CheckedNullIs[5] = CheckedIs('frm','FILE_DELETE_TYPE')

			for	(i=0;i<CheckedNullIs.length;i++) {
				if (CheckedNullIs[i] ==	false) {
					Result +=	1;
				}
			}
			if (Result > 0)	{
				alert('입력정보를 확인해주세요')
			}	else {
				PostTypeAction("frm","/JkunBoard/DeviceAdmin/jb_SetBoard.asp","D","","setmode=new")
			}
*/


function pressEnter(ExecuteFunction){ // Explorer Key Event
 	if (event.keyCode == 13) {
 		eval(ExecuteFunction);
  }
}

function OpenWindow(UrlIs,UrlQueryString,WindowNameIs,BrowserPosition,WidthIs,HeightIs,ScrollIs) {
	var ReDirectUrl = '';
	if (UrlQueryString != '') {
		ReDirectUrl = UrlIs + '?' + UrlQueryString;
	} else {
		ReDirectUrl = UrlIs;
	}
	var sBrowserPosition = BrowserPosition.split('|');
	var OpenOption = 'left='+sBrowserPosition[0]+',top='+sBrowserPosition[1]
			OpenOption += ',width='+WidthIs+',height='+HeightIs+',scrollbars='+ScrollIs+'toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no';
	window.open (ReDirectUrl,WindowNameIs,OpenOption);
}

//	POST 타입으로 팝업창에 데이터 전송
function PostTypeOpenWindow(opFormName, opActionUrl, FormTarget, opBrowserPosition, opWidthIs, opHeightIs, opScrollIs, opParaMether_Accretion) {
	OpenWindow ('', '', FormTarget, opBrowserPosition, opWidthIs, opHeightIs, opScrollIs)
	PostTypeAction(opFormName, opActionUrl, 'D', FormTarget, opParaMether_Accretion)

}

function FlashMovieLoader(FilePath, SizeWidth, SizeHeight) {
	var ObjectScript = '';
		ObjectScript += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width='+SizeWidth+' height='+SizeHeight+'>';
		ObjectScript += '<param name="movie" value="'+FilePath+'">';
		ObjectScript += '<param name="wmode" value="transparent">';
		ObjectScript += '<embed src="'+FilePath+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+SizeWidth+'" height='+SizeHeight+'></embed>';
		ObjectScript += '</object>';
		document.write(ObjectScript);
}

function MediaFileLoader(FilePath, PlayLoop, AutoStart, wSize, hSize) {//	미디어 파일로드
	document.write('<EMBED src="'+FilePath+'" width="'+wSize+'" height="'+hSize+'" type="text/plain; charset=utf-8" loop="'+PlayLoop+'" AllowScriptAccess="on3" autostart="'+AutoStart+'" invokeURLs="false"></EMBED>');
	//alert('<EMBED src="'+FilePath+'" width="'+wSize+'" height="'+hSize+'" type="text/plain; charset=EUC-KR" loop="'+PlayLoop+'" AllowScriptAccess="on3" autostart="'+AutoStart+'" invokeURLs="false"></EMBED>');
}

function CommonTopMenu(MenuFilePath) {
	var ConvertWsize;
	var TopMenuWidth = window.screen.width;
	if (TopMenuWidth < 1024) {
		ConvertWsize = 1000
	} else {
		ConvertWsize = 1100
	}
	FlashMovieLoader(MenuFilePath, ConvertWsize, 419);
}

function MailRegExp(MailValue) {
	var ChkResult;
	var MailExp = /[a-z0-9]{2,}@[a-z0-9-]{2,}\.[a-z0-9]{2,}/i;
	if (MailExp.test(MailValue) == true) {
		ChkResult = true;
	} else {
		ChkResult = false;
	}
	return ChkResult;
}

function KeyUpStrFuckDefense(oElementId) {

}

function KeyUpStrFiltering(oElementId, oFilterLevel, DisplayElement) {
	var StrBoolean = StringFilter(oElementId, oFilterLevel);
	if (StrBoolean != false) {
		if (DisplayElement != '') {
			document.getElementById(DisplayElement).innerHTML = '허용할수 없는 문자열이 입력되었습니다';
		} else {
			alert('허용할수 없는 문자열이 입력되었습니다');
		}
		document.getElementById(oElementId).select();
		return;
	}
}

function StringFilter(ElementId, FilterLevel) {
	var eId = document.getElementById(ElementId);
	var LimitChkResult;
	var FilteringString;

	var ExpRule = new Array();
	ExpRule[0] = /[]\[ㄱ-힣!-.:-@\\^-`{-\s\n]/gi;					/* 영문과 숫자가 아닌 문자열(공백포함)이 들어왔을때 */
	ExpRule[1] = /[]\[!-.:-@\\^-`{-\s\n]/gi;								/* 한글과 영문과 숫자가 아닌 문자열(공백포함)이 들어왔을때 */
	ExpRule[2] = /[]\[!-.:-@\\^-`{-\n]/gi;									/* 한글과 영문과 숫자가 아닌 문자열이 들어왔을때 */
	ExpRule[3] = /[]\[a-zA-Z!-.:-@\\^-`{-\s\n]/gi;					/* 숫자를 제외한 문자가 들어왔을때 */
	ExpRule[4] = /[]\[ㄱ-힣!-.:-@\\^-`{-\s\n]/gi;					/* 영문과 숫자가 아닌 문자열(공백포함)이 들어왔을때 */
	ExpRule[5] = /[]\[a-zA-Z0-9!-.:-@\\^-`{-]/gi;					/* 한글과 아닌 문자열이 들어왔을때 */
	//	ExpRule[5] = /{}/gi;																/* 영숫자조합이 아닌 문자열(공백포함)이 들어왔을때 */
	if (eId != undefined) {
		LimitChkResult = ExpRule[FilterLevel].test(eId.value);
		return LimitChkResult;
	}
}

function cWidth() {
	return document.body.clientWidth;
}

function cHeight() {
	return document.body.clientHeight;
}


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 ImgLabelFocus(ElementId) {
	if (navigator.appVersion.indexOf('MSIE') != -1) {
		document.getElementById(ElementId).click();
		document.getElementById(ElementId).focus();
	}
}

function ContentsTargeting(ElementId) {
	location.href = '#' + ElementId;
}

//	아이프레임 자동 리사이즈
//	해당 엘리먼트 OnLoad 이벤트에 호출되어야 하며 해당 엘리먼트 Name 과 Id 가 필요하다
//	Ex :: onLoad='iFrameResize(this.name, this.id)'
function iFrameResize(iFrameName, iFrameId) {
	var iNameBody = eval('window.' + iFrameName +'.document.body');
	document.getElementById(iFrameId).style.height = iNameBody.scrollHeight;
}

/* 아이프레임 자동 resize */
function resizeFrame(ifr_id) {
	var ifr= document.getElementById(ifr_id) ;
	var innerBody = ifr.contentWindow.document.body;
	var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
	if (ifr.style.height != innerHeight) ifr.style.height = innerHeight;
}

function StrCounter(strValue, strId, FormElement) {
	var strChk = fnAbuseWord(strValue)
	if (strChk != undefined) {
		document.getElementById(strId).innerHTML = strChk;
		document.getElementById(FormElement).select();
		//document.getElementById(FormElement).focus();
		return;
	} else {
		document.getElementById(strId).innerHTML = strValue.length + ' 자를 입력하였습니다';
	}
}

/* 텍스트 박스 테두리 */
function focusBorderColor(BoxId, ColorCode) {
	var bId = document.getElementById(BoxId);
	bId.style.borderColor = ColorCode;	//	표시할 색상
}

function blurBorderColor(BoxId) {
	var bId = document.getElementById(BoxId);
	bId.style.borderColor = '';
}

/* 새로고침 막기 */
function LockF5() {
	if (event.keyCode == 116) {
		event.keyCode = 0;
		return false;
	}
	if (event.button == 2 || event.button == 2) {
		document.oncontextmenu = '';
	}
}

/* 메인 팝업창 띠우기 */

function PopGate(PopRowNo,PopFname,PopFpach,PopPlace,PopSize,PopImgXY,PopLayer,PopLink,PopTarget,TodayCk){
	if (PopRowNo != "" && PopFname != "" && PopFpach != "" && PopPlace != "" && PopSize != "" && PopImgXY != "" && PopLayer != "" && PopTarget != "" && TodayCk != ""){
		  PopPlace = PopPlace.split("|");
		  PopSize = PopSize.split("|");
		  PopImgXY = PopImgXY.split("|");
		  PopLayer = PopLayer.split("|");
		  PopX      = PopPlace[0];								                        //팝업창 위치 X좌표
		  PopY      = PopPlace[1];                                        //팝업창 위치 Y좌표
		  PopW      = parseInt(PopSize[0]) + 10;                          //팝업창 Width
		if(TodayCk == "Y"){
			PopH      = parseInt(PopSize[1]) + 50;                          //팝업창 Hegith
		}
		else{
			PopH      = parseInt(PopSize[1]) + 30;                          //팝업창 Hegith
		}
		  PopImgW   = parseInt(PopSize[0]);                               //백그라운드 이미지 Width
		  PopImgH   = parseInt(PopSize[1]);                               //백그라운드 이미지 Hegith
		  PopImgX   = parseInt(PopImgXY[0]);                              //이미지 X 좌표
		  PopImgY   = parseInt(PopImgXY[1]);                              //이미지 Y 좌표
		  PopLayW   = parseInt(PopLayer[0]);                              //링크 크기 Width
		  PopLayH   = parseInt(PopLayer[1]);                              //링크 크기 Hegith
		  PopImgUrl = "http://www.3online.co.kr/"+PopFpach+"/"+PopFname ; //이미지 경로
		  
		  var PopId     = "NewPop_"+PopRowNo;
		
		  PopContents = "";
		  PopContents += '<style type="text/css">';
		  PopContents += '#navbar span {width:'+PopLayW+'px;height:'+PopLayH+'px;display:inline;float:left;}';
		  PopContents += '.Link_'+PopRowNo+' {  margin-top:'+PopImgY+'px; margin-left:'+PopImgX+'px;}'
		  PopContents += '</style>';
		  PopContents += '<div style="background-image:url(\''+PopImgUrl+'\'); background-repeat:no-repeat; padding:0; margin:0; width:'+PopImgW+'px;height:'+PopImgH+'px;">'
		  PopContents += '<div id="navbar"><a href='+PopLink+' target='+PopTarget+'><span class="Link_'+PopRowNo+'" style="cursor:pointer;"></span></a></div>'
		  PopContents += '</div>';
		  createPopup2(PopId, '', PopW, PopH, PopX, PopY, true, '#c0c0c0' , '#555555' , '#c0c0c0' , PopContents , '#f3f3f3' , 10 , 'Arial',TodayCk);	
	}
}
function showDiv(opt_parent) {
	var e = document.createElement("div");
	    e.style.padding = "0";
	    e.style.margin = "0";
	    e.style.border = "0";
	    e.style.position = "relative";
	    if (opt_parent) {
	     opt_parent.appendChild(e);
	    } 
	 return e;
 }
