<!--
/*
common.lib.js
자바스크립트
기본라이브러리
*/


//<![CDATA[
//----------------------------------------------
// Floating v1.1 Source By Bermann
// dobermann75@gmail.com
// link : http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&amp;wr_id=55715
// Modified By ZnMee (2008-01-13)
// znmee@naver.com
// link : http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&amp;wr_id=58739
//----------------------------------------------

//new Floating(적용할개체 , 스크롤시 Y축여백 , 최상단시 Y축여백 , 미끄러지는속도:작을수록빠름..기본20 , 빠르기:작을수록부드러움..기본10);
/*
이용할때 태그
<style type="text/css">
#cTop { width: 650px; height: 30px; position: absolute; left: 900px; top: 100px; background-color: #f7f7f7; font: normal normal 12px/1.2 Gulim; color: 333533; }
/* 레이어 위치 표시 DIV의 스타일 (삭제해도 무방)
#rTop { width: 200px; height: 40px; position: fixed; left: 750px; top: 150px; background-color: #e7e7e7; font: normal normal 12px/1.2 Gulim; color: 333533; }

</style>
<div id="cTop"><a href="#" style="font-weight:bold">[top]</a></div>
<script type="text/javascript">
//new Floating(적용할개체 , 스크롤시 Y축여백 , 최상단시 Y축여백 , 미끄러지는속도:작을수록빠름..기본20 , 빠르기:작을수록부드러움..기본10);
new Floating(document.getElementById('cTop'),20,100,10,10);
</script>
*/



function Floating ( FloatingObj , MarginY , TopLimit , Percentage , setTime ) {
	this.FloatingObj = FloatingObj;
	this.MarginY = (MarginY) ? MarginY : 0;
	this.TopLimit = (TopLimit) ? TopLimit : 0;
	this.Percentage = (Percentage) ? Percentage : 20;
	this.setTime = (setTime) ? setTime : 10;
	this.FloatingObj.style.position = "absolute";
	this.Body = null;
	this.setTimeOut = null;
	this.Run();
}
Floating.prototype.Run = function () {
	this.Body = document.documentElement.scrollTop>document.body.scrollTop ? document.documentElement : document.body;
	var This = this;
	var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
	var DocTop = this.Body.scrollTop + this.MarginY;
	var MoveY = Math.abs(FloatingObjTop - DocTop);
	if ( DocTop > this.TopLimit ) {
		if ( FloatingObjTop < DocTop ) {
			this.FloatingObj.style.top = FloatingObjTop + Math.ceil( MoveY/this.Percentage ) + "px" ;
		} else {
			this.FloatingObj.style.top = DocTop + "px" ;
		}
	} else {
			this.FloatingObj.style.top = this.TopLimit + "px" ;
	}
	/* 레이어 위치 표시 (삭제해도 무방)
	document.getElementById('rTop').innerHTML = 'FloatingObjTop:'+FloatingObjTop+'<br />DocTop:'+DocTop +'<br />MoveY:'+MoveY ;
	*/
	window.clearTimeout(this.setTimeOut);
	this.setTimeOut = window.setTimeout( function () { This.Run(); } , this.setTime );
}
//]]>

/*============================================================================
 Function : telNoChk(objValue)
 Input    : objValue  : 전화 번호 
  Return   : boolean
  examples : 전화 번호 체크 
     전화 번호 타입 : '02-254-3342'
============================================================================*/

function telNoChk(objValue){  
    if(objValue == '') return true;
    
    var text = objValue.split('-');  
    var arrNo = new Array('02'    //서울 02
          ,'031'   //경기 031
          ,'032'     //인천 032  
          ,'033'  //강원 033
          ,'041'   //충남 041 
          ,'042'  //대전 042 
          ,'043'  //충북 043 
          ,'051'  //부산 051
          ,'052'  //울산 052 
          ,'053'  //대구 053 
          ,'054'  //경북 054 
          ,'055'   //경남 055  
          ,'061'  //전남 061 
          ,'062'  //광주 062  
          ,'063'  //전북 063  
          ,'064'  //제주 064 
          ,'010'  //핸펀
          ,'011'
          ,'016'
          ,'017'
          ,'018'
          ,'019');
          
    var newLen = objValue.length; 
    var flag = false;
    
     if(newLen  < 11 ||
       newLen  > 13 ||
       text.length != 3 || 
       text[1].length < 3 ||
       text[2].length != 4)   
     {
      //alert('전화번호의 형식이 맞지 않습니다. 다시 입력하세요.');
      return false;
     }     
     
     for(var i=0; i<arrNo.length; i++ )  {
      if(text[0] == arrNo[i]) {
       flag = true;
       break;
      }
     }
     if(!flag){
      //alert('전화번호의 형식이 맞지 않습니다. 다시 입력하세요.');
      return false;
     }
     return true;

}



//영숫자 체크
function check_char(str)
{

	var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var numeric = '1234567890';
	var nonkorean = alpha+numeric; 

	for (var i=0; i < str.length; i++ )  {
		if( nonkorean.indexOf(str.substring(i,i+1)) < 0) {
		break ; 
		}
	}

	if ( i != str.length ) {
		return false ; 
	}
	else{
		return true ;
	} 

	return true;
}

//영문자 체크
function check_alpha(str)
{
	var alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

	for (var i=0; i < str.length; i++ )
	{
		if( alpha.indexOf(str.substring(i,i+1)) < 0)
		{
			break ; 
		}
	}

	if ( i != str.length )
	{
		return false ; 
	}
	else
	{
		 return true ;
	} 

	return true;
}

//길이체크
function check_length(str,slen,elen)
{
	var result=true;
	if (str.length< slen || str.length>elen) {
		result=false;
	}
	return result;
} 

//숫자만 사용
function check_num(str)
{
	var result=true;

	for(var i=0;i<str.length;i++)
	{
		var codenum=str.charCodeAt(i);
		if(codenum > 58 || codenum<47)
		{
		 result=false;
		 }
	}
	return result;
}
 
//한글 사용금지
function check_not_allowed_korean(str)
{
	

	var result=false;
	for(var i=0;i<str.length;i++)
	{
		var codenum=str.charCodeAt(i);
		if(codenum < 128)
		{
			result=true;
		}
	}
	return result;
}

//한글 사용가능
function check_allowed_korean(str)
{

	var result=false;
	for(i=0;i<str.length;i++)
	{

		var codenum=str.charCodeAt(i);

		if(codenum > 128)
		{
			result=true;
		}
	}
	return result;
}

//특수문자 체크
function check_nonchar(str)
{
	var nonchar='~`!@#$%^&*()=+\|<>?,/;:"';

	for(var i=0;i<str.length;i++)
	{
		if(nonchar.indexOf(str.substring(i,i+1))>0){
		break;
	}
	 
	}
	if(i!=str.length){
		return false;
	}
	else{
		 return true;
	}

	return false;
}

//공백 체크
//왼쪽부터 문자열 중에 공백의 위치를 찾아서
//그 리턴값이 0이상이면 false를 반환
function fnCheckSpace(chChar)
{
	if(chChar.indexOf(" ") >= 0) {
		return false;
	}
	else {
		return true;
	}
}


//공백체크2 
//공백을 기준으로 문자열을 배열로 만든 후
//다시 하나의 문자열로 합쳐서 입력값의 유무를 확인한다.
//입력값이 없으면 false 반환
function fnCheckSpace2(chchar2)
{
	if(chchar2.split(" ").join("") == "")
	{
		return false;
	}
	else
	{
		return true;
	}
}

// a 태그에서 onclick 이벤트를 사용하지 않기 위해
function win_open(url, name, option)
{
	var popup = window.open(url, name, option);
	popup.focus();
}

//주민번호체크 (보강 3,4번까지)
function Jumin_chk(it)
{

	var pattern = /(^[0-9]{13}$)/;
	var jumin = it;


	var sum_1 = 0;
	var sum_2 = 0;
	var at=0;
	var juminno = jumin;
	sum_1 = (juminno.charAt(0)*2)+(juminno.charAt(1)*3)+(juminno.charAt(2)*4)+(juminno.charAt(3)*5)+(juminno.charAt(4)*6)+(juminno.charAt(5)*7)+(juminno.charAt(6)*8)+(juminno.charAt(7)*9)+(juminno.charAt(8)*2)+(juminno.charAt(9)*3)+(juminno.charAt(10)*4)+(juminno.charAt(11)*5);sum_2=sum_1 % 11;

	if (sum_2 == 0)
		at = 10;
	else
	{
		if (sum_2 == 1)
			at = 11;
		else
			at = sum_2;
	}
	
	att = 11 - at;
	// 1800 년대에 태어나신 분들은 남자, 여자의 구분이 9, 0 이라는
	// 얘기를 들은적이 있는데 그렇다면 아래의 구문은 오류이다.
	// 하지만... 100살넘은 분들이 주민등록번호를 과연 입력해볼까?
	if (juminno.charAt(12) != att || juminno.substr(2,2) < '01' || juminno.substr(2,2) > '12' || juminno.substr(4,2) < '01' ||juminno.substr(4,2) > '31' || juminno.charAt(6) > 4)
	{
		return false;
	}
	else
	{
		return true;
	}
}



/* 문자열을 인코딩 할때 사용한다. 다음과 같이 디코딩 하여 사용한다. 
JAVA : URLEncoder.decode(str, "UTF-8") JS : decodeURL(str)*/
function encodeURL(str){
	return;
	var s0, i, s, u;    s0 = "";                // encoded str
	
	for (i = 0; i < str.length; i++){   // scan the source
		s = str.charAt(i); 
		u = str.charCodeAt(i);          // get unicode of the char
	
		if (s == " ")
			{s0 += "+";}       // SP should be converted to "+"
		else { 
			if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){       // check for escape
			s0 = s0 + s;            // don't escape 
			}	else {                  // escape
				
				if ((u >= 0x0) && (u <= 0x7f)){     // single byte format 
				s = "0"+u.toString(16); 
				s0 += "%"+ s.substr(s.length-2); 
				} 
				
				else if (u > 0x1fffff){     // quaternary byte format (extended) 
				s0 += "%" + (0xf0 + ((u & 0x1c0000) >> 18)).toString(16);   
				s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);    
				s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);      
				s0 += "%" + (0x80 + (u & 0x3f)).toString(16);   
				}    

				else if (u > 0x7ff){        // triple byte format 
				s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);     
				s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);       
				s0 += "%" + (0x80 + (u & 0x3f)).toString(16);       
				}            

				else {                      // double byte format 
				s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16); 
				s0 += "%" + (0x80 + (u & 0x3f)).toString(16);      
				}   
			}   
		}
	}  

	return s0;

}


/* 문자열을 디코딩 할때 사용한다. 다음과 같이 인코딩 하여 사용한다. 
JAVA : URLEncoder.encode(str, "UTF-8") 
JS : encodeURL(str)*/
function decodeURL(str){
	var s0, i, j, s, ss, u, n, f;
	s0 = "";                // decoded str
	for (i = 0; i < str.length; i++){   // scan the source str
		s = str.charAt(i); 
		if (s == "+")	{s0 += " ";}       // "+" should be changed to SP
		else {
			if (s != "%")	{s0 += s;}     // add an unescaped char
			else{               // escape sequence decoding                
				u = 0;          // unicode of the character
				f = 1;          // escape flag, zero means end of this sequence
				while (true) {                   
					ss = "";        // local str to parse as int
						for (j = 0; j < 2; j++ ) {  // get two maximum hex characters for parse
							sss = str.charAt(++i);
							if (((sss >= "0") && (sss <= "9")) || ((sss >= "a") && (sss <= "f"))  || ((sss >= "A") && (sss <= "F"))) {
								ss += sss;      // if hex, add the hex character
							} else {
								--i; 
								break;
							}    // not a hex char., exit the loop
						}                    
					n = parseInt(ss, 16);           // parse the hex str as byte 
					if (n <= 0x7f)	{u = n; f = 1;}   // single byte format
					if ((n >= 0xc0) && (n <= 0xdf))	{u = n & 0x1f; f = 2;}   // double byte format
					if ((n >= 0xe0) && (n <= 0xef))	{u = n & 0x0f; f = 3;}   // triple byte format
					if ((n >= 0xf0) && (n <= 0xf7))	{u = n & 0x07; f = 4;}   // quaternary byte format (extended) 
					if ((n >= 0x80) && (n <= 0xbf))	{u = (u << 6) + (n & 0x3f); --f;}         // not a first, shift and add 6 lower bits 
					if (f <= 1){break;}         // end of the utf byte sequence  
					if (str.charAt(i + 1) == "%"){ i++ ;}                   // test for the next shift byte 
					else {break;}                   // abnormal, format error 
				}            
				s0 += String.fromCharCode(u);           // add the escaped character 
			} 
		} 
	} 
	
	return s0;
}


function psFlash(url, w, h){
	var ws;
	var hs;
	
	if(w) ws = " width='"+w+"' ";
	if(h) hs = " height='"+h+"' ";
	
	var flashStr=
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' "+" "+ws+" "+hs+" id='flash00' align='middle'>"+
	"<param name='allowScriptAccess' value='always' />"+
	"<param name='movie' value='"+url+"' />"+
	"<param name='menu' value='false' />"+
	"<param name=SCALE value=exactfit>"+
	"<param name='quality' value='high' />"+
	"<param name='wmode' value='transparent' />"+
	"<embed src='"+url+"' menu='false' quality='high' "+ws+" "+hs+" name='flash00' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</embed></object>";

	document.write(flashStr);
}

//-->