/* 이미지 오버아웃 */
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* 레이어 오버아웃 */
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

/* 점프 메뉴 */
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/* 팝업창 띄우기 */
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/* alert 창 띄우기 */
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

/* 탑버튼 */
function topPage() { 
document.body.scrollTop = 0; 
} 

/* 클립보드 복사 */
function setClip(st){
	alert("복사되었습니다");
	window.clipboardData.setData("Text",st);
}

/* FAQ */
var preNum;
var flag=1;
function changeLayer(sNum){
	if(sNum==preNum && flag==1){
		//alert('a');
		temp = eval("document.all."+sNum);
		if(temp){
			temp.style.display='none';
			flag=0;
		}
	}else if(sNum==preNum && flag==0){
		//alert('b');
		temp = eval("document.all."+sNum);
		if(temp){
			temp.style.display='';
			flag=1;
		}
	}else if(sNum!=preNum){
		//alert('c');
		temp = eval("document.all."+preNum);
		if(temp)
			temp.style.display='none';

		temp1 = eval("document.all."+sNum);
		if(temp1)
			temp1.style.display='';
		flag=1;
	}
	preNum=sNum;
}

/* flashWrite(파일경로, 가로, 세로[, 변수][,배경색][,윈도우모드]) */
function flashWrite(url,w,h,vars,bg,win){
	
	var id=url.split("/")[url.split("/").length-1].split(".")[0]; //id는 파일명으로 설정
	if(vars==null) vars='';
	if(bg==null) bg='#FFFFFF';
	if(win==null) win='transparent';


	// 플래시 코드 정의
	var flashStr= "	<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'";
		flashStr+="			codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'";
		flashStr+="			width='"+w+"'";
		flashStr+="			height='"+h+"'";
		flashStr+="			id='"+id+"'";
		flashStr+="			align='middle'>";

		flashStr+="		<param name='allowScriptAccess' value='always' />";
		flashStr+="		<param name='movie' value='"+url+"' />";
		flashStr+="		<param name='FlashVars' value='"+vars+"' />";
		flashStr+="		<param name='wmode' value='"+win+"' />";
		flashStr+="		<param name='menu' value='false' />";
		flashStr+="		<param name='quality' value='high' />";
		flashStr+="		<param name='bgcolor' value='"+bg+"' />";
	
	
		flashStr+="		<embed src='"+url+"'";
		flashStr+="		       flashVars='"+vars+"'";
		flashStr+="		       wmode='"+win+"'";
		flashStr+="		       menu='false'";
		flashStr+="		       quality='high'";
		flashStr+="		       bgcolor='"+bg+"'";
		flashStr+="		       width='"+w+"'";
		flashStr+="		       height='"+h+"'";
		flashStr+="		       name='"+id+"'";
		flashStr+="		       align='middle'";
		flashStr+="		       allowScriptAccess='always'";
		flashStr+="		       type='application/x-shockwave-flash'";
		flashStr+="		       pluginspage='http://www.macromedia.com/go/getflashplayer' />";
		flashStr+=" </object>";

	// 플래시 코드 출력
	document.write(flashStr);
}


/* 미디어플래이어 */
inputMOV = function(id, src, width, height, autostart, loop, showaudiocontrols, showcontrols, showpositioncontrols, showtracker){
	document.write('<object id="'+id+'" name="MediaPlayer" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" width="'+width+'" height="'+height+'" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" align="center">');
	document.write('  <param name="Filename" value="'+src+'">');
	document.write('  <param name="AutoStart" value="'+autostart+'">');
	document.write('  <param name="loop" value="'+loop+'">');
	document.write('  <param name="ShowAudioControls" value="'+showaudiocontrols+'">');
	document.write('  <param name="ShowControls" value="'+showcontrols+'">');
	document.write('  <param name="ShowPositionControls" value="'+showpositioncontrols+'">');
	document.write('  <param name="ShowTracker" value="'+showtracker+'">');
	document.write('  <embed id="'+id+'" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" width="'+width+'" height="'+height+'" src="'+src+'" AutoStart="'+autostart+'" loop="'+loop+'" ShowAudioControls="'+showaudiocontrols+'" ShowControls="'+showcontrols+'" ShowPositionControls="'+showpositioncontrols+'" ShowTracker="'+showtracker+'"></embed>');
	document.write('</object>');
};


function MovieObject(src,w,h,control) {
	document.write('	<OBJECT ID="MediaPlayer" Name="MoviePlayer"  CLASSID="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" TYPE="application/x-oleobject" width="'+w+'" height="'+h+'"  STANDBY="Loading Microsoft Windows Media Player components..." VIEWASTEXT> ');
	document.write('      <PARAM NAME="FileName" VALUE="'+src+'"> ');
	document.write('	  <PARAM NAME="PlayCount" VALUE="0"> ');
	document.write('      <PARAM NAME="ShowControls" VALUE="'+control+'"> ');
	document.write('      <PARAM NAME="ShowStatusBar" VALUE="0"> ');
	document.write('      <PARAM NAME="AutoRewind" VALUE="True"> '); 
	document.write('      <PARAM NAME="EnableTracker" VALUE="True"> ');
	document.write('      <PARAM NAME="AutoStart" VALUE="True"> ');
	document.write('      <param name="AutoSize" value="True"> ');
	document.write('      <PARAM NAME="ShowCaptioning" VALUE="False"> ');
	document.write('      <param name="CurrentMarker" value="1"> ');
	document.write('      <param name="EnablePositionControls" value="0"> ');
	document.write('      <param name="EnableFullScreenControls" value="0"> ');
	document.write('      <param name="EnableTracker" value="0"> ');
	document.write('	  <param name="TransparentAtStart" value="1"> ');
	document.write('	  <param name="AnimationAtStart" value="0">	 ');				  
	document.write('    </OBJECT> ');
}

function swfView2(url,width,height){
 document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' ");
 document.write("  codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' ");
 document.write("  width='"+width+"' height='"+height+"' align='middle'>");
 document.write(" <param name='allowScriptAccess' value='always' /> ");
 document.write(" <param name='movie'    value='"+url+"' /> ");
 document.write(" <param name='quality'   value='high' /> ");
 document.write(" <param name='wmode'  value='transparent'/> ");
 document.write(" <param name='wmode'    value=''> ");
 document.write(" <embed src='"+url+"' quality='high' width='"+width+"' height='"+height+"' align='middle' ");
 document.write("  allowScriptAccess='sameDomain' type='application/x-shockwave-flash' ");
 document.write("  pluginspage='http://www.macromedia.com/go/getflashplayer' />");
 document.write("</object>");
}

function swfView_3(url,width,height){
 document.write("<noscript>");
 document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 ");
 document.write("codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' ");
 document.write("width='"+width+"' height='"+height+"' id='atlas' align='middle'> ");
 document.write("<param name='allowScriptAccess' value='sameDomain' />");
 document.write("<param name='allowFullScreen' value='false' /> ");
 document.write("<param name='movie' value='"+url+"' /><param name='quality' value='high' /> ");
 document.write("<param name='bgcolor' value='#cccccc' /> ");
 document.write("<embed src='"+url+"' quality='high' bgcolor='#cccccc' width='"+width+"' height='"+height+"' ");
 document.write("name='atlas' align='middle' allowScriptAccess='sameDomain' allowFullScreen='false' ");
 document.write("type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /> ");
 document.write("</object> ")
 document.write("</noscript> ");
}

/* Change Over Row Class */
function rollOverClass(elId, tagName, searchClass) {
	var el = document.getElementById(elId).getElementsByTagName(tagName);

	for (i=0; i<el.length; i++) {
		if (el[i].className == searchClass || el[i].className == searchClass + " on") {
			el[i].onmouseover = changeOverRowClassOver;
			el[i].onmouseout = changeOverRowClassOut;
		}
	}
}
function changeOverRowClassOver() {
	if (this.className == "") {
		this.className = this.className + " on";
	} else {
		this.className = "on";
	}
}
function changeOverRowClassOut() {
	if (this.className == "on") {
		this.className = "";
	} else {
		this.className = this.className.replace(" on", "");
	}
}

// Tab Content
function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabList = tabContainer.getElementsByTagName("li");
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabList.length; i++) {
		if (tabList.item(i).className == "")
			thismenu = tabList.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", ".gif");
				} else {
					currentmenu.className = currentmenu.className.replace("on", "");
				}
			}

			this.targetEl.style.display = "block";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
			} else {
				this.className += "on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}


// 스크롤바 있는 POP_UP
function f_open(url, win, w, h) 
{
   	win = window.open(url, win, 'resizable=no,scrollbars=yes,left=100,top=100,width=' + w + ',height=' + h);
}



// 스크롤바 없는 POP_UP
function f_open2(url, win, w, h) 
{
  	win = window.open(url, win, 'resizable=no,scrollbars=no,left=100,top=100,width=' + w + ',height=' + h);
  	win.focus();
}


// 공백체크
function CheckSpaces(strValue) 
{
	var flag=true;
	
	if (strValue!="") {
		for (var i=0; i < strValue.length; i++) {
			if (strValue.charAt(i) != " ") {
				flag=false;
				break;
			}
		}
	}
	return flag;
}

/************************************************************
설명 : 입력한 email이 영문자와 @값이 정확이 들어가 있는지 
예) checkEmail("test@test.co.kr")
결과) true
리턴 : 이메일이 맞다면  True , 틀리다면 false
************************************************************/
function checkEmail(email){
	var str='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
	var flag=0;
	var comma=0;
	for(i=0; i<email.length; i++) {
		for(j=0; j<str.length; j++) {
			if(email.charAt(i)==str.charAt(j)){
				break;
			}
		}
		if(j==str.length) {
			if(email.charAt(i)=='@'){
				flag++;
			}else if(email.charAt(i)=='.'){
				comma++;
			}else{
				return false;
			}
		}
	}
	if(flag!=1){
		return false;
	}else if((comma<1)||(comma>3)){
		return false;
	}else{
		return true;
	}
}



/************************************************************
설명 : 체크 박스, 라디오 버튼 선택 체크
예)checkRadio(폼.이름)
결과) 체크 한게 있다면 true 체크한게 없다면 false
************************************************************/
function checkRadio(InputName){
	if(InputName){
		if(!InputName.length) {
			if(InputName.checked) {
				return true;
			}
		} else {
			for(i=0;i<InputName.length;i++) {
				if(InputName[i].checked) {
					return true;
				}
			}
		}
	}
	return false;
}



/************************************************************
설명 : 주민번호 체크 함수
예)checkJumin(주민번호)
값이 잘못된게 있다면 false
값이 올바르다면 true
************************************************************/
function checkJumin(it){
	IDtot = 0;
	IDAdd = "234567892345";

	for(i=0; i<12; i++) IDtot = IDtot + parseInt(it.substring(i, i+1)) * parseInt(IDAdd.substring(i, i+1));
	IDtot = 11 - (IDtot%11);
	if (IDtot == 10) IDtot = 0;
	else if (IDtot == 11) IDtot = 1;

	if(parseInt(it.substring(12, 13)) != IDtot) return false;
	else return true;
}

/* 시작 - SP2 대비 resize 함수 */
var g_resizeWidth, g_resizeHeight;

////////////////////////////////////////////////////////////////////////////////
// 프레임 내에서 윈도우 사이즈 조절
// function resizeToTop(width, height)
// width : 폭
// height : 높이
// 작성자 : arcanian (2004-09-17)
////////////////////////////////////////////////////////////////////////////////
function resizeToTop(width, height)
{
	if (typeof(top.resizeToBody) == "function")
		top.resizeToBody(width, height);
}

////////////////////////////////////////////////////////////////////////////////
// body 기준 윈도우 사이즈 조절
// function resizeToBody(width, height)
// width : 폭
// height : 높이
// 작성자 : arcanian (2004-09-17)
////////////////////////////////////////////////////////////////////////////////
function resizeToBody(width, height)
{
	g_resizeWidth = width;
	g_resizeHeight = height;

	if (document.layers || document.body)
		resizeToBodyEx();
	else if (window.addEventListener)
		window.addEventListener("load", resizeToBodyEx, false);
	else if (window.attachEvent)
		window.attachEvent("onload", resizeToBodyEx);
}

////////////////////////////////////////////////////////////////////////////////
// Helper - body 기준 윈도우 사이즈 조절
// function resizeToBodyEx()
// 작성자 : arcanian (2004-09-17)
////////////////////////////////////////////////////////////////////////////////
function resizeToBodyEx()
{
	var sw, sh;

	if (document.layers)
	{
		sw = window.innerWidth;
		sh = window.innerHeight;
	}
	else
	{
		sw = document.body.clientWidth;
		sh = document.body.clientHeight;
	}

	window.resizeBy(g_resizeWidth - sw, g_resizeHeight - sh);
}

////////////////////////////////////////////////////////////////////////////////
// Overriding - window.resizeTo
// function resizeTo(width, height)
// width : 폭
// height : 높이
// 작성자 : arcanian (2004-09-17)
////////////////////////////////////////////////////////////////////////////////
function resizeTo(width, height)
{
	resizeToBody(width - 12, height - 31);
}
function resizeToBodyDlg(iWidth, iHeight) {
	window.dialogWidth = iWidth + "px";
	window.dialogHeight = iHeight + "px";

	window.dialogWidth = (iWidth * 2 - document.body.clientWidth) + "px";
	window.dialogHeight = (iHeight * 2 - document.body.clientHeight) + "px";
}
