function checkSpace(frm,strMsg){
	var str = frm.value
	if (str.search(/\S/)<0){			
		alert (strMsg);
		frm.value = "";
		frm.focus();
		return false;
	}
	var temp=str.replace(' ','');
	if (temp.length == 0){
		alert (strMsg);
		frm.value = "";
		frm.focus();
		return false;
	}
	return true;
}

function popwin(Address,name,w,h,scroll){
	var popwindow = null;	 
	var LeftPosition = (screen.width) ? (screen.width-w)/2:0;
	var TopPosition = (screen.height) ? (screen.height-h)/2:0;   
	var Settings = 'height='+ h +',width='+ w +',top='+ TopPosition +',left='+ LeftPosition +',scrollbars='+ scroll +',resizable=no'
				   
	popwindow = window.open(Address,name,Settings);
	popwindow.focus();

}

	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;
	}
	
	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;
		}
	}
		
function windowOpen(pUrl,pName,pW,pH,val){
	var winWidth  = window.screen.width;    
	var winHeight  = window.screen.height;     
	
	
	var pLeft,pTop;
	pLeft = parseInt((winWidth-pW)/2);
	pTop = parseInt((winHeight-pH)/2);
	
	var newWin=window.open(pUrl,pName,"width="+pW+",height="+pH+",left="+pLeft+",top="+pTop+" "+ val );
	newWin.focus(); 
}



	function checkImg(obj)
	{
		if(obj.value!=""){		
			if (!checkFileName(obj)){
				return false;
			}else{	
				return true;
			}
		}else{	
			return true;
		}		
	}
	
	function checkFileName(el) {
		var _regExp=/\\\w+\.(gif|jpg)/ig;
		var _filter = el.value.match(_regExp);
		var _fileName = null;

		if (_filter == null){
			_fileName = el.value.toUpperCase();
			if (_fileName.indexOf("JPG") == -1 || _fileName.indexOf("GIF") == -1){
				alert("ÆÄÀÏ¸íÀ» [¿µ¹®][¼ýÀÚ]·Î¸¸ ÀÛ¼ºÇØÁÖ½Ã°í,\n\nÀÌ¹ÌÁö Çü½ÄÀº [JPG] ÀÌ°Å³ª [GIF] ÀÌ¾î¾ß ÇÕ´Ï´Ù.");
			}else{
				alert("[ÆÄÀÏ¸í]À» [¿µ¹®][¼ýÀÚ]·Î¸¸ ÀÛ¼ºÇØ ÁÖ½Ê½Ã¿ä.\n\n"
					+"(¿¹) È«±æµ¿_0.gif (X), hong_gil_dong.gif(O)"
				);
			}
			return false;
		}
		return true;
	}

	
	function popImgWin(imgSrc){

		var viewSrc;
		var src1,src2;
		if( imgSrc.lastIndexOf("/")>-1 ){
			src1 = imgSrc.substring(0, imgSrc.lastIndexOf("/")+1 );
			src2 = imgSrc.slice(imgSrc.lastIndexOf("/")+1);
		}else{
			src1 = "";
			src2 = imgSrc;
		}
		
		viewSrc = src1+escape(src2);
		
		var strhtml = "";
		
		var w = 100;
		var h = 100;
		
		var pattern = /\.(swf|asx)$/ig;
		var imgPattern = /\.(jpg|gif)$/ig;
	
		if( pattern.test( imgSrc ) ){
			w = 400;
			h = 400;

			strhtml +="<html><head><title>È®´ëº¸±â</title><style>body{margin:0;}</style>";
			strhtml +="</head><body>";
			strhtml +="<table width='100%' height='100%' cellspacing='0' cellpadding='0'><tr>";
			strhtml +="<td align='center' valign='center'>";
			strhtml +="<embed src='"+viewSrc+"' width='100%'>";
			strhtml +="</td></tr></table></body></html>";
			
		}else if( imgPattern.test( imgSrc ) ){
		
			strhtml +="<html><head><title>ÀÌ¹ÌÁöÈ®´ëº¸±â</title><style>body{margin:0;}</style>";
			strhtml +="<s"+"cript language=\"JavaScript\">";
			strhtml +="function win_resize(){";
			strhtml +="var imgWidth  = parseInt(document.content_img.offsetWidth);";
			strhtml +="var imgHeight = parseInt(document.content_img.offsetHeight);";
			strhtml +="var winWidth  = window.screen.width;";
			strhtml +="var winHeight  = window.screen.height;";
			strhtml +="var reWidth,reHeight;";
			strhtml +="if(imgWidth>winWidth-100){";
			strhtml +="reWidth  = winWidth-100;";
			strhtml +="}else{";
			strhtml +="reWidth = imgWidth+30;";
			strhtml +="}";
			strhtml +="if(imgHeight>winHeight-100){";
			strhtml +="reHeight = winHeight-100;";
			strhtml +="}else{";
			strhtml +="reHeight = imgHeight+35;";
			//strhtml +="if(window.navigator.userAgent.indexOf(\"SV1\") != -1)reHeight+=29;";
			strhtml +="}";
			strhtml +="window.resizeTo(reWidth,reHeight);";
			strhtml +="window.moveTo(parseInt((winWidth-reWidth)/2),parseInt((winHeight-reHeight)/2));";
			strhtml +="window.focus();";
			strhtml +="}";
			strhtml +="</s"+"cript>";
			strhtml +="</head><body onload='win_resize()'>";
			strhtml +="<table width='100%' height='100%' cellspacing='0' cellpadding='0'><tr>";
			strhtml +="<td align='center' valign='center'>";
			strhtml +="<img src='"+viewSrc+"' name='content_img' id='content_img' border=0 onclick='window.close();' style='cursor:hand;'>";
			strhtml +="</td></tr></table></body></html>";
		}else{
			location.href = "/etc/down.aspx?sfname="+viewSrc+"&ofname="+src2;
			return;
		}
		
		var imageWin = window.open('', "imageWin", "width="+ w +", height="+ h +", top=100,left=100,scrollbars=1,resizable=1,toolbar=0,menubar=0,location=0,directories=0,status=0"); 
		imageWin.document.open(); 
		imageWin.document.write(strhtml);
		imageWin.document.close();
		imageWin.focus();
	}




// function from http://www-128.ibm.com/developerworks/kr/library/j-ajax1/index.html
function newXMLHttpRequest() {
	var xmlreq = false;
	if (window.XMLHttpRequest) {
		// Create XMLHttpRequest object in non-Microsoft browsers
		xmlreq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		// Create XMLHttpRequest via MS ActiveX
		try {
			// Try to create XMLHttpRequest in later versions
			// of Internet Explorer
			xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			// Failed to create required ActiveXObject
			try {
				// Try version supported by older versions
				// of Internet Explorer
				xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				// Unable to create an XMLHttpRequest with ActiveX
			}
		}
	}
	return xmlreq;
}


	function Numberchk(){
		if ((event.keyCode<48)||(event.keyCode>57)){
			alert("¼ýÀÚ¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.");
			event.returnValue=false;
		}
	}

	function checkHangul(hangul)
	{
		for(i=0;i<hangul.length; i++) {
			if((hangul.charAt(i) < '°¡')||(hangul.charAt(i) > 'Èþ'))
				return false;
		}	
		return true;
	}
	
	function checkRadio(InputName, strMsg){
		if(InputName){
			if(!InputName.length) {
				if(InputName.checked) {
					return true;
				}
			} else {
				for(i=0;i<InputName.length;i++) {
					if(InputName[i].checked) {
						return true;
					}
				}
			}
			alert (strMsg);
			InputName[0].focus();
		}
		return false;
	}

function checkDateStr(str) 
{
	var pattern = /^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/;
	if (!pattern.test(str)) return(false);
	else return(true);
}

function check_isnumber(str) 
{
	var pattern = /^[0-9]+$/;
	return(pattern.test(str));
}


var arrObjImg = new Array(); 

function set_onload_resize(img,resizeWidth){
	var imgLen = arrObjImg.length;
	arrObjImg[imgLen] = new imgClass(img, resizeWidth);
	resize_img(imgLen);
}

function imgClass(img,resizeWidth){
	this.img = img;
	this.resizeWidth = resizeWidth;
}

function resize_img(idx){
	var objImg = arrObjImg[idx].img;
	var resizeWidth = arrObjImg[idx].resizeWidth;
	if(objImg){
		if(objImg.complete == false){
			setTimeout("resize_img("+idx+")",100);
		}else{
			if(objImg.width>resizeWidth){
				objImg.height = parseInt((resizeWidth * objImg.height) / objImg.width);
				objImg.width = resizeWidth;
				objImg.onclick=function(){window.open(objImg.src);}
			}
		}
			
	}
}

function Request(valuename){
	var rtnval = "";
	var nowAddress = unescape(location.href);
	var parameters = (nowAddress.slice(nowAddress.indexOf("?")+1,nowAddress.length)).split("&");
    
	for(var i = 0 ; i < parameters.length ; i++){
		var varName = parameters[i].split("=")[0];
		if(varName.toUpperCase() == valuename.toUpperCase())
		{
			rtnval = parameters[i].split("=")[1];
			break;
		}
	}
	return rtnval;
}

function dw(str){
	document.write(str); 
}

function getStrNull(str) {
	for ( var i = 0; i < str.length; i++ ) {
		if ( str.charAt(i) == " " ) return false;
	}
	for ( var i = 0; i < str.length; i++ ) {
		chr1 = str.charAt(i);
		if ( !( ( chr1 >= 'A' && chr1 <= 'Z') || ( chr1 >= 'a' && chr1 <= 'z' ) || ( chr1 >= '0' && chr1 <= '9' ) || chr1 == '_' ) ) {
			return false;
		}
	}
	return true;
	}



function FlashObject(swf, width, height, bgcolor, id, flashvars)
{
    var strFlashTag = new String();
    
	strFlashTag += '<object id="c_player" width="'+width+'" height="'+height+'" align=ABSMIDDLE classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,5,0803" standby="Loading Windows Media Player components..." type="application/x-oleobject">';
	strFlashTag += '<PARAM NAME="FileName" VALUE="'+swf+'">';
	strFlashTag += '<PARAM NAME="transparentAtStart" VALUE="false">';
	strFlashTag += '<PARAM NAME="transparentAtStop" VALUE="False">';
	strFlashTag += '<PARAM NAME="AnimationAtStart" VALUE="False">';
	strFlashTag += '<PARAM NAME="AutoStart" VALUE="True">';
	strFlashTag += '<PARAM NAME="AutoSize" VALUE="0">';
	strFlashTag += '<PARAM NAME="AutoRewind" VALUE="true">';
	strFlashTag += '<PARAM name="AllowChangeDisplaySize" value=1>';
	strFlashTag += '<PARAM NAME="SendMouseClickEvents" VALUE="0">';
	strFlashTag += '<PARAM NAME="DisplaySize" VALUE="-1">';
	strFlashTag += '<PARAM NAME="ShowDisplay" VALUE="0">';
	strFlashTag += '<PARAM NAME="ShowStatusBar" VALUE="1">';
	strFlashTag += '<PARAM NAME="ShowControls" VALUE="0">';
	strFlashTag += '<PARAM NAME="ShowTracker" VALUE="0">';
	strFlashTag += '<PARAM NAME="Enabled" VALUE="1">';
	strFlashTag += '<PARAM NAME="EnableContextMenu" VALUE="0">';
	strFlashTag += '<PARAM NAME="EnablePositionControls" VALUE="0">';
	strFlashTag += '<PARAM NAME="EnableFullScreenControls" VALUE="0">';
	strFlashTag += '<PARAM NAME="ShowPositionControls" VALUE="0">';
	strFlashTag += '<PARAM NAME="SendKeyboardEvents" VALUE="1">';
	strFlashTag += '<PARAM NAME="Mute" VALUE="0">';
	strFlashTag += '<PARAM NAME="Rate" VALUE="1">';
	strFlashTag += '<PARAM NAME="SAMILang" VALUE="">';
	strFlashTag += '<PARAM NAME="SAMIStyle" VALUE="">';
	strFlashTag += '<PARAM NAME="SAMIFileName" VALUE="">';
	strFlashTag += '<PARAM NAME="ClickToPlay" VALUE="0">';
	strFlashTag += '<PARAM NAME="CursorType" VALUE="1">';
	strFlashTag += '<param name="Volume"  value="-1500">';
	strFlashTag += '</object>';

 document.write(strFlashTag);
}

function textHttp(setUrl,setQuery) {
var xh;
var rs;

if (window.ActiveXObject) {
	xh = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
	xh = new XMLHttpRequest();
}

xh.open("POST",setUrl,false);
xh.setRequestHeader('Accept-Language','ko');
xh.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
xh.setRequestHeader('Cache-Control','no-cache');
xh.send(setQuery);

if (xh.readyState == 4) {
	if (xh.status == 200) {
		rs = xh.responseText;
	} else {
		rs = xh.responseText;
	}
}

xh = null;
return rs;
}





//flash
function swfprint(furl,fwidth,fheight,transoption)	{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ fwidth +'" height="' + fheight +'" id="movie1" align="middle" allowScriptAccess="always">');
		document.write('<param name="allowScriptAccess" value="always"/>');
	document.write('<param name="movie" value="'+ furl +'"/>');
	if (transoption == "t")	{
		document.write('<param name="wmode" value="transparent"/>');
	} else if	(transoption == "o")	{
		document.write('<param name="wmode" value="opaque"/>');
	}
	document.write('<!-- Hixie method -->');
	document.write('<!--[if !IE]> <-->');
	document.write('<object type="application/x-shockwave-flash" allowScriptAccess="always" data="'+ furl +'" width="'+ fwidth +'" height="' + fheight +'" id="movie1"');
	if (transoption == "t")	{
		document.write(' wmode="transparent"');
	} else if	(transoption == "o")	{
		document.write(' wmode="opaque"');
	}
	document.write('<embed src="'+ furl +'" width="'+ fwidth +'" height="' + fheight +'" wmode="transparent"  allowScriptAccess="always" menu="false"/>');
	document.write('></object>');
	document.write('<!--> <![endif]-->');
	document.write('</object>');
}

function contChange(obj,num,total) {
 if ( document.getElementById(obj+num).style.display == '' ) {
   document.getElementById(obj+num).style.display = 'none';
   return;
  }
 for (i=1; i<=total; i++) {
  if (i==num) {
   document.getElementById(obj+i).style.display = '';
  }
  else {
   document.getElementById(obj+i).style.display = 'none';
  }
 }
}

function prdLyrView(lid,n,total) {
    var ht = document.body.clientHeight; // if DTD is xhtml, document.documentElement.clientHeight;
    var target = document.getElementById(lid+n);

    if (total != 0)    {
        for (var i=1; i<=total; i++) {
            document.getElementById(lid+i).style.display = (i==n ? 'block':'none');
        }
        target.style.display = 'block';
    } 
}
function prdLyrView_1990(lid,n,total) {
    var ht = document.body.clientHeight; // if DTD is xhtml, document.documentElement.clientHeight;
    var target = document.getElementById(lid+n);

    if (total != 0)    {
        for (var i=1; i<=total; i++) {
            document.getElementById(lid+i).style.display = (i==n ? 'block':'none');
        }
        target.style.display = 'block';
    } 
}



// quick_center
function initMoving(target, position, topLimit, btmLimit) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = position;
	obj.topLimit = topLimit;
	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;

	if (typeof(window.pageYOffset) == "number") {
		obj.getTop = function() {
			return window.pageYOffset;
		}
	} else if (typeof(document.documentElement.scrollTop) == "number") {
		obj.getTop = function() {
			return document.documentElement.scrollTop;
		}
	} else {
		obj.getTop = function() {
			return 0;
		}
	}

	if (self.innerHeight) {
		obj.getHeight = function() {
			return self.innerHeight;
		}
	} else if(document.documentElement.clientHeight) {
		obj.getHeight = function() {
			return document.documentElement.clientHeight;
		}
	} else {
		obj.getHeight = function() {
			return 500;
		}
	}

	obj.move = setInterval(function() {
		if (obj.initTop > 0) {
			pos = obj.getTop() + obj.initTop;
		} else {
			pos = obj.getTop() + obj.getHeight() + obj.initTop;
			//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		}

		if (pos > obj.bottomLimit)
			pos = obj.bottomLimit;
		if (pos < obj.topLimit)
			pos = obj.topLimit;

		interval = obj.top - pos;
		obj.top = obj.top - interval / 4;
		obj.style.top = obj.top + "px";
	}, 30)
}

function popupCenter(mypage,myname,w,h,scroll){
        LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
        TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
        settings =
        'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
        win = window.open(mypage,myname,settings)
}

var imgObj = new Image();
function showImgWin(imgName) {
  imgObj.src = imgName;
  setTimeout("createImgWin(imgObj)", 100);
}
function createImgWin(imgObj) {
  if (! imgObj.complete) {
    setTimeout("createImgWin(imgObj)", 100);
    return;
  }
  imageWin = window.open("", "imageWin",
    "width=" + imgObj.width + ",height=" + imgObj.height);
  imageWin.document.write("<html><body style='margin:0'>");
  imageWin.document.write("<a href=javascript:window.close()><img src='" + imgObj.src + "' border=0></a>");
  imageWin.document.write("</body><html>");
  imageWin.document.title = imgObj.src;
}

function layershow( icnt ) {
	document.getElementById("family"+icnt).style.display = "block";
}
function layerhidden( icnt ) {
	document.getElementById("family"+icnt).style.display = "none";
}