/******************************************************************************************
 * @Description 
 *		- js function util 모음 
 * @modified on : 2008.09.30
 ******************************************************************************************/

//------ IE 패치를 위한 스크립트
function printHTML(str) {
	var strHTML=str; 
	document.write(strHTML);
}

//------ 새창 열기 
function open_window(theURL,winName,features) {
  	window.open(theURL,winName,features);
}

//------ 새로운 윈도우창 열기 
function fnWindowOpenMethodPost(alignParam, obj, windowName, url, w, h, mw, mh, b, s, r){
	var l=0, t=0;

	if (alignParam == "center") {
		l = (screen.width - w) >>1;
		t = (screen.height - h) >>2;
	}

	var newWin = window.open("", windowName, "left=" + l + ",top=" + t + ",width=" + w + ",height=" + h + ",marginwidth=" + mw + ", marginheight=" + mh + ", menubar=" + b + ",scrollbars=" + s + ", resizable=" + r);
 
	obj.action = url;
	obj.method = 'post';
	obj.target = windowName;
	obj.submit();
	obj.target = '';	
}

//------ 한글 한글자를 2byte로 인식하여, IE/Netscape byte길이를 구함
function getByteLength(s){
   var len = 0;
   if ( s == null ) return 0;
   for(var i=0;i<s.length;i++){
      var c = escape(s.charAt(i));
      if ( c.length == 1 ) len ++;
      else if ( c.indexOf("%u") != -1 ) len += 2;
      else if ( c.indexOf("%") != -1 ) len += c.length/3;
   }
   return len;
}

//------ 공백 문자 확인 
function removeBlank(obj){
  if(obj.value.charAt(obj.value.length-1) == ' '){
    alertDiv("공백문자는 사용할 수 없습니다.", 0);
    obj.value=obj.value.substr(0,obj.value.length-1);

    obj.focus();
    return true;
  }
  return false;
}

//------ 대문자로 변경 
function toUpperCase(obj){
  if(!removeBlank(obj)) {
    obj.value = obj.value.toUpperCase();
  }
}

//------ str안에 compStr가 존재하면 참, 아니면 거짓 반환 
function isExistsWord(str, compStr) {

	var newCompStr = compStr.toLowerCase();
	var newStr = str.toLowerCase();

	if( str.indexOf(newCompStr) == -1 ) {
		return false;
	} else {
		return true;
	}
}

//------ HTML tag가 있다면 true, 없다면 false 반환
function AAisHTMLTag(str) {
	var newStr = str.replace(/<(.*).*>(.*)<\/\1>/,"");
	if( newStr != str) return true;
	else false;
}

//------ 숫자만 필터링 
function removeNoneNum(val){    
    var reg=/[^\d]/;
    while(reg.test(val)){
        val=val.replace(reg,"");
    }    
    return val;
}

//------ trim 함수 
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

//------ 글자 byte 확인 
String.prototype.bytes = function() {
	var str = this;
	var l = 0;
	for (var i=0; i<str.length; i++) 
		l += (str.charCodeAt(i) > 128) ? 2 : 1;
	return l;
}

//------ file object 의 readonly 처리 del, back space 제외 
function fileKeyCK(obj) {
   if(event.keyCode != 8) {
        event.returnValue=false;
        
   }
}

function gameMouseOut(obj){
	var tempName = document.getElementById(obj);
	tempName.style.fontWeight="bold";
	tempName.style.color="#0f59af";
}

function gameMouseOver(obj){
	var tempName = document.getElementById(obj);
	tempName.style.fontWeight="bold";
	tempName.style.color="#ec513d";
}

function flashMouseOut(obj){
	var tempName = document.getElementById(obj);
	tempName.style.color="#0F59AF";
}

function flashMouseOver(obj){
	var tempName = document.getElementById(obj);
	tempName.style.color="#EC513D";
}

//------ 배경 이미지 없애기
function fnBgImageNone(obj){
	obj.style.backgroundImage = ''; 
}

//------ 배경 이미지 삽입
function fnBgImageInsert(obj, path){
	if(obj.value == ""){
		obj.style.backgroundImage = 'url('+ path +')'; 
	}
}

//------ 태그를 체크 
function isHtmlBracketsTag(str) {
	var result = false;
	if (str.indexOf('<') != -1) {
		result = true;
	}
	else if (str.indexOf('>') != -1) {
		result = true;
	}
	else if (str.indexOf('&') != -1) {
		result = true;
	}
		
	return result;
}

//------ 시간 정보 확인 
function mktime(h, i, s, m, d, y){
	var mkt = new Date(y, m-1, d, h, i, s);
	if( mktime.arguments.length == 0 ) mkt = new Date();
	return Math.floor(mkt.getTime()/1000);
}

//------ 쿠키 정보 확인 
function getCookie(name) {
    var nameOfCookie = name + '=';
    var x = 0;
    while ( x <= document.cookie.length ){
        var y = (x+nameOfCookie.length);
        if ( document.cookie.substring( x, y ) == nameOfCookie ) {
        if ( (endOfCookie=document.cookie.indexOf( ';', y )) == -1 )
                endOfCookie = document.cookie.length;
                return unescape( document.cookie.substring( y, endOfCookie ) );
                alert(unescape( document.cookie.substring( y, endOfCookie ) ));
        }
        x = document.cookie.indexOf( ' ', x ) + 1;
        if ( x == 0 )
                break;
    }
    return '';
}

