﻿//기본 플레쉬 열때
function script_flash2(flash_root,w,h){
	flash_str=" <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='"+w+"' height='"+h+"'> ";
	flash_str=flash_str+" <param name='movie' value='"+flash_root+"'> ";
	flash_str=flash_str+" <param name='quality' value='high'> ";
	flash_str=flash_str+" <param name='wmode' value='transparent' /> ";
	flash_str=flash_str+" <embed src='"+flash_root+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+w+"' height='"+h+"'></embed> ";
	flash_str=flash_str+" </object> ";

	document.write(flash_str);
}

//플레쉬 위치지정해서 열때
function script_flash(flash_root,w,h,left,top){
	flash_str=" <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='"+w+"' height='"+h+"' style='position:absolute; left:"+left+"px; top:"+top+"px;'> ";
	flash_str=flash_str+" <param name='movie' value='"+flash_root+"'> ";
	flash_str=flash_str+" <param name='quality' value='high'> ";
	flash_str=flash_str+" <param name='wmode' value='transparent' /> ";
	flash_str=flash_str+" <embed src='"+flash_root+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+w+"' height='"+h+"'></embed> ";
	flash_str=flash_str+" </object> ";

	document.write(flash_str);
}

//검색조건 확인 : ~_list.asp
function search_sendit(on,sd,ed) {

	//시작날짜 형식 검사
	if (check_date(on.s_year1,on.s_month1,on.s_day1)==false) {
		on.s_day1.focus();
		return false;
	} else {
		start_date=on.s_year1.value+"-"+on.s_month1.value+"-"+on.s_day1.value;
	}

	//끝날짜 형식 검사
	if (check_date(on.s_year2,on.s_month2,on.s_day2)==false) {
		on.s_day2.focus();
		return false;
	} else {
		end_date=on.s_year2.value+"-"+on.s_month2.value+"-"+on.s_day2.value;
	}

	//시작날짜 ~ 끝날짜 비교
	if (start_date>end_date) {
		alert("검색기간이 올바르지 않습니다. 다시 선택하세요.");
		return false;
	}

	//시작날짜 확인
	if (start_date<sd) {
		alert(sd+" 이후부터 검색이 가능합니다. 다시 선택하세요.");
		return false;
	}

	//끝날짜 확인
	if (end_date>ed) {
		alert("오늘 이후의 날짜는 검색할 수 없습니다. 다시 선택하세요.");
		return false;
	}

	on.action=on.action+"&start_date="+start_date+"&end_date="+end_date;
}

// 색상 정의
var bgcolor_on="#E8F4FF";
var bgcolor_off="";

// 정규식 정의
var regular_name=/^[가-힣]+$/;
var regular_id=/^[a-zA-Z0-9_]+$/;


// ---------------------------------------------------------------------- //


// 정규식 검사
function check_regular(on,str,n,reg) {
	str_value=on.value;
	str_value=str_value.replace(/ /g,"");
	str_value=str_value.replace(/\r\n/g,"");

	if (str_value.length==0) {
		alert(str + " 입력하세요.");
		on.value="";
		on.focus();
		return false;
	} else if (reg.test(on.value)==false) {
		alert("사용할 수 없는 문자가 포함되어 있습니다. 다시 입력하세요.");
		on.focus();
		return false;
	} else if (str_value.length<n) {
		alert(str + " " + n + "글자 이상 입력하세요.");
		on.focus();
		return false;
	}
}


// 입력값 길이 검사
function check_value(on,str,n) {
	str_value=on.value;
	str_value=str_value.replace(/ /g,"");
	str_value=str_value.replace(/\r\n/g,"");

	if (str_value.length==0) {
		alert(str);
		on.value="";
		on.focus();
		return false;
	} else if (str_value.length<n) {
		alert(str + " " + n + "字以上入力して下さい。");
		on.focus();
		return false;
	}
}

// 공백제거
function trim_data(on) {
	var trim_string=on;

	trim_string +="";
	on=trim_string.replace(/^\s*|\s*$/g,"");
}

//숫자만 입력
function onlynum() {
	if ((((event.keyCode>=48)&&(event.keyCode<=57))||
	(event.keyCode==8)||(event.keyCode==13))==false) {
		event.returnValue=false;
	}
}

//숫자만 입력2
function onlynum2(on) {
	var str = document.all[on].value;
	for(var i=0; i<str.length; i++) {
		if(((str.charCodeAt(i))<48||(str.charCodeAt(i))>57)) {
		document.all[on].value = "";
		return false;
		} else {   } // 처리
	}
}

//숫자, 포인트 입력 : 시력
function onlypoint() {
	if ((((event.keyCode>=48)&&(event.keyCode<=57))||
	(event.keyCode==46)||(event.keyCode==13))==false) {
		event.returnValue=false;
	}
}

//문자만 입력 : 한글이름
function onlykorchar() {
	if ((((event.keyCode>=97)&&(event.keyCode<=122))||
	((event.keyCode>=65)&&(event.keyCode<=90))||
	(event.keyCode==13))==false) {
		event.returnValue=false;
	}
}

//영문만 입력 : 업무성과
function onlyenglish() {
	if ((
	((event.keyCode>=97)&&(event.keyCode<=100))||
	((event.keyCode>=65)&&(event.keyCode<=68))||
	(event.keyCode==83)||(event.keyCode==115)||(event.keyCode==13))==false) {
		event.returnValue=false;
	}
}

//문자, 숫자, 언더바 입력
function onlychar_underbar() {
	if ((((event.keyCode>=97)&&(event.keyCode<=122))||
	((event.keyCode>=65)&&(event.keyCode<=90))||
	((event.keyCode>=48)&&(event.keyCode<=57))||
	(event.keyCode==95)||(event.keyCode==13))==false) {
		event.returnValue=false;
	}
}

//문자, 숫자, 언더바 입력
function onlychar() {
	if ((((event.keyCode>=97)&&(event.keyCode<=122))||
	((event.keyCode>=65)&&(event.keyCode<=90))||
	((event.keyCode>=48)&&(event.keyCode<=57)))==false) {
		event.returnValue=false;
	}
}

//문자, 숫자 입력2
function onlychar2(on) {
	var str = document.all[on].value;
	for(var i=0; i<str.length; i++) {
		if(((str.charCodeAt(i) >= 48 && str.charCodeAt(i) <=57) || (str.charCodeAt(i) >=65 && str.charCodeAt(i) <= 90) || (str.charCodeAt(i) >= 97 && str.charCodeAt(i) <= 122))) {
		
		} else {
			document.all[on].value = "";
			return false;
		} // 처리
	}
}

//문자, 숫자, 공백, 따옴표 입력 : 영문이름
function onlyengchar() {
	if ((((event.keyCode>=97)&&(event.keyCode<=122))||
	((event.keyCode>=65)&&(event.keyCode<=90))||
	((event.keyCode>=48)&&(event.keyCode<=57))||
	(event.keyCode==32)||(event.keyCode==39)||
	(event.keyCode==13))==false) {
		event.returnValue=false;
	}
}

//문자, 숫자, 골뱅이, 포인트 입력 : 이메일
function onlyemail() {
	if ((((event.keyCode>=97)&&(event.keyCode<=122))||
	((event.keyCode>=65)&&(event.keyCode<=90))||
	((event.keyCode>=48)&&(event.keyCode<=57))||
	(event.keyCode==64)||(event.keyCode==46)||
	(event.keyCode==13))==false) {
		event.returnValue=false;
	}
}

//날짜 형식 검사 : 07-08
function check_date(date_year,date_month,date_day) {
	if (
			((date_month.value=="02")&&(date_day.value>29))
			||((date_month.value=="04")&&(date_day.value>30)) || ((date_month.value=="06")&&(date_day.value>30))
			||((date_month.value=="09")&&(date_day.value>30)) || ((date_month.value=="11")&&(date_day.value>30))
		) {
		alert("잘못된 날짜입니다. 다시 선택하세요.");
		return false;
	}
}

//날짜 형식 검사 : 07-08
function verify_date(date_month,date_day) {
	var reg = /^(01|02|03|04|05|06|07|08|09|10|11|12)+$/;

	if (reg.test(date_month)==false) {
		alert("잘못된 날짜입니다. 다시 선택하세요.");
		return false;
	}

	if (date_day !="") {
		if (
				(date_day<1)||(date_day>31)||((date_month=="02")&&(date_day>29))
				||((date_month=="04")&&(date_day>30)) || ((date_month=="06")&&(date_day>30))
				||((date_month=="09")&&(date_day>30)) || ((date_month=="11")&&(date_day>30))
			) {
			alert("잘못된 날짜입니다. 다시 선택하세요.");
			return false;
		}
	}
}

//페이지 이동
function move_location(on) {
	location=on;
}



//사업자등록번호 체크
function check_companynum(on){
	var checkID = new Array(1, 3, 7, 1, 3, 7, 1, 3, 5, 1);
	var bizID = on;
	var i, Sum=0, c2, remander;
	 
	for (i=0; i<=7; i++) Sum += checkID[i] * bizID.charAt(i);

	c2 = "0" + (checkID[8] * bizID.charAt(8));
	c2 = c2.substring(c2.length - 2, c2.length);

	Sum += Math.floor(c2.charAt(0)) + Math.floor(c2.charAt(1));

	remander = (10 - (Sum % 10)) % 10 ;
 
	if (Math.floor(bizID.charAt(9)) != remander){
		alert("잘못된 사업자 등록번호입니다. \n다시 작성하세요.");
		return false;
	}else{
		return true;
	}
}




var showFlashObject=function(objID,objSource,objWidth,objHeight,objQuality,objWmode,objBgcolor,objXML){
if(objXML){var chkMovie=0;if(objSource.match(/=/))objSource=objSource+"&server="+objXML+"&chkMovie="+chkMovie;else objSource=objSource+"?server="+objXML+"&chkMovie="+chkMovie;}
var pageUrl=self.window.location.href;
if(pageUrl.substring(0,5)=="https") swfUrl="https";
else swfUrl="http";
if(!objID)objID="ShockwaveFlash1";
if(!objWidth)objWidth="0";
if(!objHeight)objHeight="0";
if(!objQuality)objQuality="high";
if(!objWmode)objWmode="transparent";
document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+swfUrl+'://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" width="'+objWidth+'" height="'+objHeight+'" id="'+objID+'" type="application/x-shockwave-flash" data="'+objSource+'">');
document.writeln('<param name="movie" value="'+objSource+'" />');
document.writeln('<param name="allowFullScreen" value="false" />');
document.writeln('<param name="scale" value="noscale" />');
document.writeln('<param name="allowScriptAccess" value="always" />');
document.writeln('<param name="menu" value="false" />');
document.writeln('<param name="quality" value="high" />');
document.writeln('<param name="bgcolor" value="'+objBgcolor+'" />');
document.writeln('<param name="wmode" value="'+objWmode+'" />');
document.writeln('<embed src="'+objSource+'" allowScriptAccess="always" menu="false" quality="high" bgcolor="'+objBgcolor+'" wmode="'+objWmode+'" width="'+objWidth+'" height="'+objHeight+'" name="'+objID+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.writeln('</object>');};



//이미지 파일 검사
function check_image(on) {
	extension=on.substr(on.length-3,3);
	extension=extension.toLowerCase();

	if (((extension=="jpg")||(extension=="gif"))==false) {
		alert("JPG 또는 GIF 이미지를 선택하세요.");
		return false;
	}
}


/*
 * 팝업 자동 리사이징
 *  - 윈도 환경에 따라 사이즈가 다를 수 있습니다.
 *  - 팝업페이지의 스크립트 최하단에서 실행하십시오.
 *
 * (ex.) window.onload = function(){popupAutoResize();}
*/


// 플래쉬 호출
function Flash( src,width,height )
{
 html = '';
 html += '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="param" width="'+width+'" height="'+height+'">';
 html += '<param name="movie" value="'+src+'">';
 html += '<param name="quality" value="high">';
 html += '<param name="bgcolor" value="#ffffff">';
 html  +='<param name="wmode" value="transparent">';
 html += '<param name="swliveconnect" value="true">';
 html += '<embed src="'+src+'" quality=high bgcolor="#ffffff" width="'+width+'" height="'+height+'" swliveconnect="true" id="param" name="param" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
 html += '</object>';
 document.write(html);
}


function popupAutoResize() {
    var thisX = parseInt(document.body.scrollWidth);
    var thisY = parseInt(document.body.scrollHeight);
    var maxThisX = screen.width - 50;
    var maxThisY = screen.height - 50;
    var marginY = 0;
 //   alert(thisX + "===" + thisY);
    //alert("임시 브라우저 확인 : " + navigator.userAgent);
    // 브라우저별 높이 조절. (표준 창 하에서 조절해 주십시오.)

    if (navigator.userAgent.indexOf("MSIE 6") > 0) marginY = 45;        // IE 6.x
    else if(navigator.userAgent.indexOf("MSIE 7") > 0) marginY = 75;    // IE 7.x
    else if(navigator.userAgent.indexOf("MSIE 8") > 0) marginY = 79;    // IE 8.x
    else if(navigator.userAgent.indexOf("Firefox") > 0) marginY = 87;   // FF
    else if(navigator.userAgent.indexOf("Opera") > 0) marginY = 30;     // Opera
    else if(navigator.userAgent.indexOf("Netscape") > 0) marginY = -2;  // Netscape


    if (navigator.userAgent.indexOf("MSIE 6") > 0) marginX = 10;        // IE 6.x
    else if(navigator.userAgent.indexOf("MSIE 7") > 0) marginX = 6;    // IE 7.x
    else if(navigator.userAgent.indexOf("MSIE 8") > 0) marginX = 6;    // IE 8.x
    else if(navigator.userAgent.indexOf("Firefox") > 0) marginX = 10;   // FF
    else if(navigator.userAgent.indexOf("Opera") > 0) marginX = 10;     // Opera
    else if(navigator.userAgent.indexOf("Netscape") > 0) marginX = 10;  // Netscape


    if (thisX > maxThisX) {
        window.document.body.scroll = "yes";
        thisX = maxThisX;
    }
    if (thisY > maxThisY - marginY) {
        window.document.body.scroll = "yes";
        thisX += 19;
        thisY = maxThisY - marginY;
    }
    window.resizeTo(thisX+marginX, thisY+marginY);

    // 센터 정렬
    // var windowX = (screen.width - (thisX+10))/2;
    // var windowY = (screen.height - (thisY+marginY))/2 - 20;
    // window.moveTo(windowX,windowY);
}



function Allchk(){
	if (document.all.chkAll.checked==true){
		chkType=true;
	}else{
		chkType=false;	
	}
	if (document.all.chk.length>0) {
		for (i=0;i<document.all.chk.length;i++)
			eval("document.all.chk["+i+"].checked=chkType")
	} else {
		eval("document.all.chk.checked=chkType")
	}
}


function Space_All(str){
    var index,len;
    while(true){
        index = str.indexOf(" ");
        //공백이 없으면 종료 합니다.
        if(index == -1)break;
        //문자열 길이를 구합니다.
        len = str.length;
        //공백을 잘라 냅니다.
        str = str.substring(0,index) + str.substring((index+1),len);
    }
    return str;
} 
