﻿function Go_URL(f_url) {
	document.location.href = f_url;
}

function NewWin_Go_URL(f_url) {
	window.open(f_url, 'nw', '');
}

function MsgBox(msg, obj) {
	alert(msg);
	obj.focus();	
}

function isNumber(obj){	
	if (event.keyCode < 48 && event.keyCode > 57) {
		if (event.keyCode > 26) {
			MsgBox("숫자만 입력할 수 있습니다.", obj);
			event.returnValue = false;
		}	
	}
}

function vComma(obj) {     
	var str    = "" + obj.value.replace(/,/gi,''); // 콤마 제거 
    var regx    = new RegExp(/(-?\d+)(\d{3})/); 
    var bExists = str.indexOf(".",0); 
    var strArr  = str.split('.'); 
    while(regx.test(strArr[0])){ 
        strArr[0] = strArr[0].replace(regx,"$1,$2"); 
    } 
    if (bExists > -1) {
        obj.value = strArr[0] + "." + strArr[1]; 
	}
    else {
        obj.value = strArr[0]; 
	}
}

function delComma(obj) { 
	var str    = "" + obj.value.replace(/,/gi,''); // 콤마 제거 

	return str;
}

function ID_Check(obj) {
	chkID = /^[A-Za-z0-9]+$/;

	if (!chkID.test(obj.value)) {
		obj.value = "";
		alert("아이디는 영문자와 숫자 조합만 가능합니다.");
		obj.focus();
		return false;
	}
	return true;
}

function NewWin(url, x, y) {
	window.open(url, 'nw' + x + y, 'left=0,top=0,width='+x+',height='+y+',scrollbars=yes,resizable=no');
}

function Jumin_Chk()
{
	var f = document.MForm;

	if (f.p_id1.value.length < 6)
	{
		MsgBox("주민등록번호 앞자리 입력이 틀렸습니다.", f.p_id1); 
		return false;
	}
	if (f.p_id2.value.length < 7)
	{
		MsgBox("주민등록번호 뒷자리 입력이 틀렸습니다.", f.p_id2); 
		return false;
	}
	for (i = 0; i < f.p_id1.value.length; i++){
		if (f.p_id1.value.charAt(i)  >= '0' && f.p_id1.value.charAt(i)  <= '9') 
			continue;
		else {
			MsgBox("주민등록번호 앞자리는 숫자값만 넣을수 있습니다.", f.p_id1); 
			return false;
		}
	}

	for (i = 0; i < f.p_id2.value.length; i++){
		if (f.p_id2.value.charAt(i)  >= '0' && f.p_id2.value.charAt(i)  <= '9')
			continue;
		else { 
			MsgBox("주민등록번호 뒷자리는 숫자값만 넣을수 있습니다.", f.p_id2); 
			return false;
		}
	}
	var i;
	var IDtot = 0;
	var IDAdd = "234567892345";
	var p_id1 = f.p_id1.value;
	var p_id2 = f.p_id2.value;
	var strName = f.p_name.value;	

	for (i=0 ; i<=5 ; i++)
		IDtot = IDtot + ((i%8+2) * parseInt(p_id1.substring(i,i+1))) ;  

	for (i=6 ; i<=11 ; i++)
		IDtot = IDtot + ((i%8+2) * parseInt(p_id2.substring(i-6,i-5))) ;  
	
	IDtot = 11 - (IDtot % 11);
	IDtot = IDtot % 10;

	if (IDtot != p_id2.substring(6,7)) {
		msg = strName + " 님 유효한 주민등록 번호가 아닙니다.\r\n\r\n  다시 한번 확인해 주십시오.";
		MsgBox(msg, f.p_id1);
		return false;
	}
	return true;
}

function Comp_No_Check(no1, no2, no3)
{
 	biz_value = new Array(10);
 
 	var objstring = no1 + "-" + no2 + "-" + no3;
	var li_temp, li_lastid;

	if ( objstring.length == 12 ) {
		biz_value[0] = ( parseFloat(objstring.substring(0 ,1)) * 1 ) % 10;
		biz_value[1] = ( parseFloat(objstring.substring(1 ,2)) * 3 ) % 10;
		biz_value[2] = ( parseFloat(objstring.substring(2 ,3)) * 7 ) % 10;
		biz_value[3] = ( parseFloat(objstring.substring(4 ,5)) * 1 ) % 10;
		biz_value[4] = ( parseFloat(objstring.substring(5 ,6)) * 3 ) % 10;
		biz_value[5] = ( parseFloat(objstring.substring(7 ,8)) * 7 ) % 10;
		biz_value[6] = ( parseFloat(objstring.substring(8 ,9)) * 1 ) % 10;
		biz_value[7] = ( parseFloat(objstring.substring(9,10)) * 3 ) % 10;
		li_temp = parseFloat(objstring.substring(10,11)) * 5 + "0";
		biz_value[8] = parseFloat(li_temp.substring(0,1)) + parseFloat(li_temp.substring(1,2));
		biz_value[9] = parseFloat(objstring.substring(11,12));
		li_lastid = (10 - ( ( biz_value[0] + biz_value[1] + biz_value[2] + biz_value[3] + biz_value[4] + biz_value[5] + biz_value[6] + biz_value[7] + biz_value[8] ) % 10 ) ) % 10;

		if (biz_value[9] != li_lastid)
			return false;
		else 
			return true;
	} else {
		return false;
	}
}

function All_Search() {	
	var f = document.TopForm;

	if (f.sh_type.value == "") {
		MsgBox("검색 조건을 입력 해주세요.", f.sh_type);
		return;
	}

	if (f.sh_str.value == "") {
		MsgBox("검색어를 입력해 주세요.", f.sh_str);
		return;
	} else {
		f.action = "Main_Disp.Asp?menu=search";
		f.submit();
	}
}

function EnterCheck(){
	if (event.keyCode == 13) {
		All_Search();
	}
}

function Copy_Addr() {
	var f = document.MForm;
	
	if (f.cpaddr.checked) {
		f.set_post.value = f.post.value;
		f.set_addr1.value = f.addr1.value;
		f.set_addr2.value = f.addr2.value;
	} else {
		f.set_post.value = "";
		f.set_addr1.value = "";
		f.set_addr2.value = "";
	}	
}

function get_radio(obj) {
	var i;

	for (i = 0 ; i < obj.length; i++) {
		if(obj[i].checked) {
			return obj[i].value;
		}
	}
	return false;
}

function Image_SmallSize(setSize, obj) {		// 작은 이미지 인경우 가로 세로 크기 같게 하기 위해서
	var SetW = setSize;
	var SetH = setSize;
	var newX;
	var newY;
	var newHeight;
	var newWidth;
	var newImg = new Image();

	newImg.src = obj.src;
	imgw = newImg.width;
	imgh = newImg.height;

	if (imgw > SetW || imgh > SetH) {	// 설정 값과 기존 이미지 크기 비교
		if (imgw < imgh) {				// 가로가 큰경우
			if (imgw > SetW) newWidth = SetW;	// 가로가 설정 값보다 큰경우
			else newWidth = imgw;
			
			newHeight = Math.round((imgh * newWidth) / imgw);		// 가로 사이즈 비율로 높이 구하기			
		} else {						// 세로가 큰경우
			if (imgh > SetH) newHeight = SetH;
			else newHeight = imgh;

			newWidth = Math.round((imgw * newHeight) / imgh);
		}
	} else {
		newWidth = imgw;
		newHeight = imgh;
	}

	obj.onload = null;

	obj.src = newImg.src;
	obj.width = newWidth;
	obj.height = newHeight;

}

function reSizeIF(Id)	// iFream 사이즈 다시 설정
{
	var obj = document.getElementById(Id);
	var Body;
	var H, Min;

	// 최소 높이 설정 (너무 작아지는 것을 방지)
	Min = 1;

	// DOM 객체 할당
	try	{
		if (!document.all && obj.contentWindow.document.location.href == 'about:blank') {
			setTimeout("reSizeIF('"+Id+"')", 10);
			return;
		}

		Body = obj.contentWindow.document.getElementsByTagName('BODY');
		Body = Body[0];

		if (this.Location != obj.contentWindow.document.location.href) {
			H = Body.scrollHeight;
			obj.style.height = H + 'px';

			this.Location = obj.contentWindow.document.location.href;
		}
	} catch(e) {
		setTimeout("reSizeIF('"+Id+"')", 10);
		return;
	}

	setTimeout("reSizeIF('"+Id+"')", 100);
}

function setCookie(name, value) {
	document.cookie = name + "=" + escape (value) + "; "
}

function getCookie(Name) {
	var search = Name + "="

	if (document.cookie.length > 0) { // 쿠키가 설정되어 있다면
		offset = document.cookie.indexOf(search)
		if (offset != -1) { 
			offset += search.length
			end = document.cookie.indexOf(";", offset)

			if (end == -1)
				end = document.cookie.length
				return unescape(document.cookie.substring(offset, end))
		}
	}
	return "";
}

function Hidden_SelectS(flg) {
	var selects = [];
	if (document.all) selects = document.all.tags("SELECT");
	var cnt = selects.length;
	for (var i = 0; i < cnt; i++) {
		selects[i].runtimeStyle.visibility = flg ? "": "hidden";
	}
}

function Hidden_EmbedS(flg) {
	var embed = [];
	if (document.all) embed = document.all.tags("EMBED");
	var cnt = embed.length;

	for (var i = 0; i < cnt; i++) {
		embed[i].runtimeStyle.display = flg ? "" : "none";		
	}
}

function View_BackGround() {	
	Hidden_SelectS(false);		// 화면의 Select 박스 숨기기
	
	var obj = document.all.Background_Layer;

	obj.style.width = document.body.offsetWidth-20;
	obj.style.left = "0px";
	obj.style.top = "0px";
	if (document.body.offsetHeight > document.body.scrollHeight) {
		obj.style.height = document.body.offsetHeight - 5;
	} else {
		obj.style.height = document.body.scrollHeight;
	}
	obj.style.visibility = "visible";
}

function HIdden_BackGround() {

	var obj = document.all.Background_Layer;

	obj.style.height = 10;
	obj.style.visibility = "hidden";

	Hidden_SelectS(true);		// 화면의 Select 박스 보이기	
}

function View_Layer_Write(tp, lp, wp, url) {	// 해당 위치에 입력창 보이기
	
	View_BackGround();	
			
	var dobj = document.all.Div_Write;
	var fobj = document.all.Frm_Write;
		
	dobj.style.top = (document.body.scrollTop + tp);
	dobj.style.left = (document.body.scrollLeft + lp);
	
	fobj.width = wp + "px";
	dobj.style.visibility = "visible";
	Frm_Write.document.URL = url;
}

function New_Layer_View(tp, wp, url) {
		
	var lp = (document.body.offsetWidth / 2) - (wp / 2);

	View_Layer_Write(tp, lp, wp, url);	
}

function View_Layer_Calendar(url) {	// 해당 위치에 입력창 보이기
	
	View_BackGround();	
		
	var dobj = document.all.Div_Write;
	var fobj = document.all.Frm_Write;
	
	dobj.style.visibility = "visible";
	dobj.style.top = (event.clientY + document.body.scrollTop);
	dobj.style.left = (event.clientX - 100 + document.body.scrollLeft);
	fobj.width = "205px";
	Frm_Write.document.URL = url;
}

function Hidden_Layer_Write() {		// 입력창 숨기기
	
	var dobj = document.all.Div_Write;
	var fobj = document.all.Frm_Write;

	dobj.style.visibility = "hidden";
	fobj.src = "about:blank";
	
	HIdden_BackGround();

}

function Hidden_Popup(id) {		// 입력창 숨기기
	
	var dobj = eval('document.all.Div_Popup_' + id);
	var fobj = eval('document.all.Frm_Popup_' + id);
	
	dobj.style.visibility = "hidden";
	fobj.src = "about:blank";

}

function Calendar(name, arr) {
	var url = "/Frm_Common/Frm_Calendar.Asp?name=" + name + "&arr=" + arr;

	View_Layer_Calendar(url);
}

function ClipBoard_CopyCode(id) {		// 클립보드에 복사하기
	var CopyStr = document.getElementById(id).value;

	if (CopyStr == "") {
		alert("복사할 내용이 없습니다.");
		return;
	}
	window.clipboardData.setData('Text', CopyStr);

	alert("Ctrl + V 눌러 붙여넣기 하시면 됩니다.");
}

function Str_Int(str) {
	if (str == "")
		return 0;
	else 
		return parseInt(str);
}

function Str_Float(str) {
	if (str == "")
		return 0.0;
	else 
		return parseFloat(str);
}

function RoundUp(val, len){
	var z = "1";
	if (len < 0) {
		alert('죄송합니다. 음수는 사용할 수 없습니다.');
		return val;
	}
	for (var i = 0; i < len; i ++) {
		z = z + "0";
	}

	val = (Math.ceil(val * Str_Int(z))) / Str_Int(z);
	return val;
}

function RoundDown(val, len){
	var z = "1";
	if (len < 0) {
		alert('죄송합니다. 음수는 사용할 수 없습니다.');
		return val;
	}
	for (var i = 0; i < len; i ++) {
		z = z + "0";
	}

	val = (Math.floor(val * Str_Int(z))) / Str_Int(z);
	return val;
}

function int(val) {
	val = Math.floor(val);
	return val;
}

function List_Cols_Move() {
	var f = document.all;
	
	f.divTop_Cols.scrollLeft = f.divList_Cols.scrollLeft;
}

var Event_XPoint;
var Event_YPoint;

function Move_Div_Frm() {
	var pf = parent.document.getElementById("Div_Write");

	if (event.button == 1) {
		pf.style.left =  Str_Int(pf.style.left) + (event.screenX - Event_XPoint);
		pf.style.top = Str_Int(pf.style.top) + (event.screenY - Event_YPoint);
		Event_XPoint = event.screenX;
		Event_YPoint = event.screenY;
	} else {
		Event_XPoint = event.screenX;
		Event_YPoint = event.screenY;
	}
}

function list_Detail_View(arr, obj) {
	var f = document.all.Detail_View[arr];
	var of = document.all;

	for (var i = 1; i < of.Detail_View.length; i++) {
		if (of.Detail_View[i].style.display == "" && i != arr)
		{
			of.Detail_View[i].style.display = "none";
		}
	}

	if (f.style.display == "") {
		f.style.display = "none";
		obj.style.backgroundColor = "#ffffff"
	} else {
		f.style.display = "";
		obj.style.backgroundColor = "#ffffff"
	}
}

function list_Change_Color(obj) {
	if (obj.style.backgroundColor != "#efefef") {
		obj.style.backgroundColor = "#efefef";
	} else {
		obj.style.backgroundColor = "#ffffff";
	}
}

function QA_Detail_View(arr) {
	var f = document.all.Detail_View[arr];
	var of = document.all;

	if (f.style.display == "") {
		f.style.display = "none";
	} else {
		f.style.display = "";
	}

	for (var i = 1; i < of.Detail_View.length; i++) {
		if (of.Detail_View[i].style.display == "" && i != arr)
		{
			of.Detail_View[i].style.display = "none";
		}		
	}

}

function DaySet(st, ed) {
	var f = document.MForm;

	f.st_day.value = st;
	f.ed_day.value = ed;
}


function flash(url,width,height,transparent){
	document.write('<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="'+width+'" height="'+height+'">');
	document.write('<param name="movie" value="'+url+'"');
	document.write('<param name="BGCOLOR" value="#000000">');
	document.write('<param name="quality" value="high">');
	if (transparent == "Y" ){
		document.write('<param name=wmode value=transparent>');
	}
	document.write('<embed src="'+url+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed></object>');
}




