/**
 * @author Lee Yeong Cheon
 * @version 1.00, 07/01/03
 * @since javascript 1.5
 */

  // The JavaScript 1.5 specification defines six primary error types, as follows
  // EvalError - raised when the eval() functions is used in an incorrect manner
  // RangeError - raised when a numeric variable exceeds its allowed range
  //              허용 범위를 초과한 인수가 기능함수에 제공될 경우 발생한다. 예를 들어, 길이가 유효한 양의 정수가 아닌 Array 개체를 구성하려고 할 경우 발생한다.
  // ReferenceError - raised when an invalid reference is used
  //                  유효하지 않은 참조가 감지될 경우 발생한다. 예를 들어, 예상되는 참조가 null일 경우 발생한다.
  // SyntaxError - raised when a syntax error occurs while parsing JavaScript code
  //               원본 텍스트가 구문 분석되고 해당 원본 텍스트가 올바른 구문을 따르지 않을 경우 발생한다. 예를 들어, eval() 기능함수가 유효한 프로그램 텍스트가 아닌 인수로 호출될 경우 발생한다.
  // TypeError - raised when the type of a variable is not as expected
  //             피연산자의 실제 유형이 예상 유형과 일치하지 않을 때마다 발생한다. 예를 들어, 개체가 아니거나 호출을 지원하지 않는 곳에서 기능함수를 호출할 경우 발생한다.
  // URIError - raised when the encodeURI() or decodeURI() functions are used in an incorrect manner
  //            잘못된 URI(Uniform Resource Indicator)가 감지될 경우 발생한다. 예를 들어, 인코드되거나 디코드될 문자열에 잘못된 문자가 있을 경우 발생한다.
  // ConversionError - 변환 할 수 없는 것으로 개체를 변환하려고 할 때마다 발생한다.
  // RegExpError - 정규식에서 컴파일 오류가 있을 때 발생하지만 정규식이 컴파일되면 발생하지 않다.
  //               예를 들어, 정규식이 유효하지 않은 구문이나 플래그가 i, g, m이 아닌 패턴으로 선언되거나 같은 플래그가 두 개 이상 들어 있을 경우 발생한다.
  // Exception Define
  function Exception(name, message, description) {
    var error = new Error();
    //error.number = number;
    error.name = Validate.isNull(name, "");
    error.message = Validate.isNull(message, "");
    error.description = Validate.isNull(description, "");
    return error;
  }

  // arguments[0] 에서 %S 문자열을 순차적으로 arguments[]의 idx 값이 1보다 큰 요소 값으로 치환한다.
  function Printf() {
    for(var i = 1; i < arguments.length; i++) {
      arguments[0] = arguments[0].replace(/%S/i,arguments[i]);
    }
    return arguments[0];
  }

  // plain text(key1=value1&key2=value2...)형식으로 작성된 param 의 value 값만을 인코딩하여 반환한다.
  function Encode(param,charset) {
    var encParam = "";
    if(!Validate.isNull(param)) {
      param = param.replace(/&([^&=]+=)/g,Char.US+"$1");
      var params = param.split(Char.US);
      if(Validate.isNull(charset) || charset.toUpperCase() == "UTF-8") {
        for(i = 0; i < params.length; i++) {
          var index = params[i].indexOf("=");
          if(i != 0) encParam += "&";
          encParam += encodeURIComponent(params[i].substring(0,index))+"="+encodeURIComponent(params[i].slice(index+1));
        }
      } else {
        for(i = 0; i < params.length; i++) {
          var index = params[i].indexOf("=");
          if(i != 0) encParam += "&";
          encParam += escape(params[i].substring(0,index))+"="+escape(params[i].slice(index+1));
        }
      }
    }
    return encParam;
  }

  // form 객체를 통해 서비스 요청을 한다.
  // mothod   : 전송방식으로 "get" 또는 "post"을 사용 할 수 있으며, form 객체의 method 속성과 동일하게 동작한다.
  //          : 주의. post, get 방식을 제외한 어떠한 전송방식도 지원하지 않으며, 지원형식이 아닐 경우 기본 값으로 설정된다. 기본 값은 get 방식이다.
  // action   : 명시된 서비스 경로로 분기하며, form 객체의 action 속성과 동일하게 동작한다.
  // param    : 서비스에 전송할 파라미터이다.("key=value" 형식을 사용하며, 복수의 값을 전송할 경우 "key1=value1&key2=value2..."와 같이  & 문자로 연결해 준다.)
  // target   : 서비스 요청에 대한 응답 페이지를 출력할 목적지를 설정하며, form 객체의 target 속성과 동일하게 동작한다.
  // onSubmit : 서비스 요청 즉시(페이지 분기 전) 실행할 callback 함수를 정의한다. form 객체의 onSubmit 이벤트와 동일하게 동작한다.
  // include	: 생성된 form 객체에 include할 개체
  function Forward(method,action,param,target,onSubmit,include) {
    var inputCnt = 0;

    // hidden 타입의 input 객체를 생성한다.    
    var createInput = function(type, name, value) {
      var input = document.createElement("input");
      input.setAttribute("id", "tmp_"+inputCnt++);
      input.setAttribute("type", type);
      input.setAttribute("name", name);
      input.setAttribute("value", value);
      return input;
    }

    // form 객체를 생성한다.
    var createForm = function(method,action,target,onSubmit) {
      method = Validate.isNull(method.match(/^(get|post)$/gi)) ? "get" : method.match(/^(get|post)$/gi).toString().toLowerCase();
      var form = document.createElement("form");
      form.setAttribute("method", method);
      form.setAttribute("action", action);
      if(!Validate.isNull(target)) form.setAttribute("target", target);
      if(!Validate.isNull(onSubmit)) form.setAttribute("onSubmit", onSubmit);
      return form;
    }

    var form = createForm(method,action,target,onSubmit);
    if(!Validate.isNull(param)) {
      param = param.replace(/&([^&=]+=)/g,Char.US+"$1");
      var params = param.split(Char.US);
      for(var i = 0; i < params.length; i++) {
        var index = params[i].indexOf("=");
        form.appendChild(createInput("hidden",params[i].substring(0,index),params[i].slice(index+1)));
      }
    }
    if(!Validate.isNull(include)) form.appendChild(include);
    document.body.appendChild(form);
    form.submit();
  }

  // object 에 명시된 객체를 반환한다. 단, object 자신이 객체일 경우는 object 자신을 반환한다.
  // object 값이 id 속성의 값 또는 name 속성의 값 과 동일한 객체를 반환하며 우선순위는 id, name 순이다.
  // 반환되는 객체가 name 속성을 참조하여 얻어낸 것이면 index+1 번째 객체를 반환한하며 index 가 생략되면 Array 타입 객체를 반환한다.
  // object 값이 id 또는 name 속성과 일치하는 값이 없는 경우 null을 반환한다.
  function GetObject(object, index) {
    var retObj = null;
    if((typeof object) == Type.String) {
      retObj = document.getElementById(object);
      if(Validate.isNull(retObj.id)) {
        retObj = document.getElementsByName(object);
        if(!Validate.isNull(index)) retObj = retObj[index];
      }      
    } else {
      retObj = object;
    }
    return retObj;
  }

  // object 에 명시된 객체(id 속성이 object 이거나  object 가 객체 자신일 경우 object 객체)를 반환한다.
  function GetObjectById(object) {
    if((typeof object) == Type.String) return document.getElementById(object);
    else return object;
  }

  // object 에 명시된 객체(name 속성이 object 이거나  object 가 객체 자신일 경우 object 객체)를 반환한다.
  // object의 타입이 String 인 경우 반환하는 객체의 타입은 Array 이다.
  function GetObjectByName(object) {
    if((typeof object) == Type.String) return document.getElementsByName(object);
    else return object;
  }

  // object 에 명시된 객체(tag 이름이 object 이거나  object 가 객체 자신일 경우 object 객체)를 반환한다.
  // object의 타입이 String 인 경우 반환하는 객체의 타입은 Array 이다.
  function GetObjectByTagName(object) {
    if((typeof object) == Type.String) return document.getElementsByTagName(object);
    else return object;
  }

  // 명시된 객체(object)의 투명도를 opacity(0.0~1.0)값으로 설정한다.
  function SetOpacity(object, opacity) {
    if(Browser.isMsie) {
      object.style.filter = "alpha(opacity=0)";
      object.filters.alpha.Opacity = opacity * 100;
    } else if(Browser.isMozes) {
      object.style.MozOpacity = opacity;
    } else if(Browser.isOpera || Browser.isSafari || Browser.isKhtml) {
      object.style.opacity = opacity;
    }
    return opacity;
  }

  // 명시된 객체(object)의 투명도(0.0~1.0)를 반환한다. 속성값이 정의되어 있지 않은 경우 반환될 값을 두번째 인자에 선택적으로 반환값을 지정한다.
  function GetOpacity(object) {
    var nvl = arguments.length > 1 ? arguments[1] : 1;
    var retValue;
    if(Browser.isMsie) {
      object.style.filter = "alpha(opacity=0)";
      retValue = object.filters.alpha.Opacity ? object.filters.alpha.Opacity / 100 : nvl;
    } else if(Browser.isMozes) {
      retValue = object.style.MozOpacity ? parseFloat(object.style.MozOpacity) : nvl;
    } else if(Browser.isOpera || Browser.isSafari || Browser.isKhtml) {
      retValue = object.style.opacity ? parseFloat(object.style.opacity) : nvl;
    }
    return retValue;
  }

  // 명시된 객체(object)의 style attribute 에 해당하는  값을 가져온다.
  function GetStyle(object, attribute) {
    if(Validate.isNull(object.style[attribute]))
      object.style[attribute] = object.currentStyle ? object.currentStyle[attribute] : document.defaultView.getComputedStyle(object,null).getPropertyValue(attribute);
    return object.style[attribute];
  }

  // 명시된 객체(object)의 display 속성 값을 가져온다.
  function GetDisplay(object) {
    if(Validate.isNull(object.style.display))
      object.style.display = object.currentStyle ? object.currentStyle["display"] : document.defaultView.getComputedStyle(object,null).getPropertyValue("display");
    return object.style.display;
  }

  // 명시된 객체(object)의  Width 속성 값을 가져온다. 속성값이 정의되어 있지 않은 경우 반환될 값을 두번째 인자에 선택적으로 반환값을 지정한다.
  function GetWidth(object) {
    if(Validate.isNull(object.style.width)) {
      object.style.width = object.currentStyle ? object.currentStyle["width"] : document.defaultView.getComputedStyle(object,null).getPropertyValue("width");
      if(arguments.length > 1 &&  object.style.width == "auto") object.style.width = arguments[1];
    }
    return object.style.width;
  }

  // 명시된 객체(object)의  height 속성 값을 가져온다. 속성값이 정의되어 있지 않은 경우 반환될 값을 두번째 인자에 선택적으로 반환값을 지정한다.
  function GetHeight(object) {
    if(Validate.isNull(object.style.height)) {
      object.style.height = object.currentStyle ? object.currentStyle["height"] : document.defaultView.getComputedStyle(object,null).getPropertyValue("height");
      if(arguments.length > 1 &&  object.style.height == "auto") object.style.height = arguments[1];
    }
    return object.style.height;
  }

	// 팝업윈도우를 생성하며, 팝업차단기능이 설정되어 있는 경우는 경고메시지를 출력한다.
	function WinOpen(contextURL,name,width,height) {
		var object = null;
		if(!Validate.isNull(contextURL)) {
      var option = "scrollbars=no,directories=no,location=no,menubar=no,resizable=no,status=no,titlebar=no,toolbar=no";
      option += ",width="+width;
      option += ",height="+height;
			object = window.open(contextURL,name,option);
			if(Validate.isNull(object)) alert(Message.deniedWinOpen);
			else object.focus();
		}
		return object; 
	}

  // 인쇄용 팝업윈도우를 생성하며, 팝업차단기능이 설정되어 있는 경우는 경고메시지를 출력한다.
  function WinOpen_print(object,pageName) {
    if(window.print) {
      var option = "width=770,height=550,scrollbars=yes,directories=no,location=no,menubar=no,resizable=no,status=no,titlebar=no,toolbar=no";
			object = window.open("/common/print_view.jsp?print_area_id="+object+"&pageName="+pageName,"_print_preview",option);
			if(Validate.isNull(object)) alert(Message.deniedWinOpen);
    } else {
      alert("브라우저에서 기능을 지원하지 않습니다!");
    }
  }

  // iframe 내용 크기에 맞게 크기를 변경한다.
  // <iframe src="URL" onload="ResizeFrame(this)" scrolling="no" frameborder="0"></iframe>  
  function ResizeFrame(iframe) {
    var innerBody = iframe.contentWindow.document.body;
    var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
    var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);
    iframe.style.height = innerHeight;
    iframe.style.width = innerWidth;
  }

  // body 내용 크기에 맞게 윈도우 크기를 변경한다.
  function ResizeWindow(documentObj) {
    var innerBody = documentObj.body;
    var innerWidth = 0;
    var innerHeight = 0;
    if(Browser.isMsie) {
      innerWidth = innerBody.scrollWidth - innerBody.clientWidth;
      innerHeight = innerBody.scrollHeight - innerBody.clientHeight;
    } else {
      innerWidth = innerBody.scrollWidth - window.innerWidth;
      innerHeight = innerBody.scrollHeight - window.innerHeight;
    }
    top.resizeBy(innerWidth,innerHeight);
  }

  // resource 의 내용 중에서 tag 부분을 삭제한 결과물을 반환한다. *** 보완필요...
  function RemoveTag(resource) {
    return resource.replace(/<!--.*-->|<\s*script.*<\s*\/\s*script\s*>|<((\w+\s*=?\s*(('[^']*')|(\"[^\"]*\"))?)|[\s\/!-])+>/gi,'');
  }

  // flash movie 를 출력한다.
	function ShowSWF(movie,width,height,vars){
    
    var createParam = function(name,value) {
      var param = document.createElement("param");
      param.setAttribute("name", name);
      param.setAttribute("value", value);
      return param;
    }

    var codeWrapper = document.createElement("div");
    if(Browser.isMsie) {
      var object = document.createElement("object");;
      if(!Validate.isNull(width)) object.setAttribute("width", width);
      if(!Validate.isNull(height)) object.setAttribute("height", height);
      object.setAttribute("type", "application/x-shockwave-flash");
      object.setAttribute("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
      object.setAttribute("codebase", "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0");
      object.appendChild(createParam("movie", movie));
      object.appendChild(createParam("flashvars", vars));
      object.appendChild(createParam("menu", "false"));
      object.appendChild(createParam("quality", "high"));
      object.appendChild(createParam("wmode", "transparent"));
      object.appendChild(createParam("allowScriptAccess", "always"));
      object.appendChild(createParam("swliveconnect", "true"));
      codeWrapper.appendChild(object);
    } else {
      var object = document.createElement("embed");
      if(!Validate.isNull(width)) object.setAttribute("width", width);
      if(!Validate.isNull(height)) object.setAttribute("height", height);
      object.setAttribute("src", movie);
      object.setAttribute("flashvars", vars);
      object.setAttribute("menu", "false");
      object.setAttribute("quality", "high");
      object.setAttribute("wmode", "transparent");
      object.setAttribute("type", "application/x-shockwave-flash");
      object.setAttribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
      codeWrapper.appendChild(object);
    }
    document.write(codeWrapper.innerHTML);
	}

  function SetCookie(key, value, expirehours) {
  	var cookie = key + "=" + escape( value ) + "; ";
  	cookie += "path=/; ";
  	if(!Validate.isNull(expirehours)) {
	    var today = new Date();
	    today.setTime(today.getTime() + (1000*60*60*expirehours));
	    cookie += "expires=" + today.toGMTString() + ";";
  	}
    document.cookie = cookie;
  }
  
  function GetCookie(key) {
    var retValue = null;
    var start_idx = document.cookie.indexOf(key + "=");
    if(start_idx >= 0) {
      start_idx += key.length + 1;
      var end_idx = document.cookie.indexOf(";", start_idx);
      if(end_idx < 0) end_idx = document.cookie.length;
      retValue = unescape(document.cookie.substring(start_idx,end_idx));
    }
    return retValue;
  }
  
  function DelCookie(key) {
  	document.cookie= key + "=; expires=;";
  }
  
  // 숫자로 이루어진 문자를 통화표기법으로 치환
  function SetCurrencyFormat(object) {
    if(event.keyCode >= 37 && event.keyCode <= 40) return true;
    object.value = object.value.replace(/\D*/gi,"");
    var mod = object.value.length % 3;
    var grpCnt = object.value.length/3 + (mod > 0 ? 1 : 0);
    var regExp = "(\\d{"+(mod == 0 ? 3 : mod)+"})";
    var regExpOut = "$1";
    for(var i = 2; i <= grpCnt; i++) {
      regExp += "(\\d{3})";
      regExpOut += ",$"+i;
    }
    regExp = new RegExp(regExp+"$","gi");
    object.value = object.value.replace(regExp,regExpOut);
  }

  // 숫자로 이루어진 문자를 통화표기법으로 치환
  function SetCurrencyFormat(object) {
  	if(typeof object == Type.String) {
	    var mod = object.length % 3;
	    var grpCnt = object.length/3 + (mod > 0 ? 1 : 0);
	    var regExp = "(\\d{"+(mod == 0 ? 3 : mod)+"})";
	    var regExpOut = "$1";
	    for(var i = 2; i <= grpCnt; i++) {
	      regExp += "(\\d{3})";
	      regExpOut += ",$"+i;
	    }
	    regExp = new RegExp(regExp+"$","gi");
	    return object.replace(regExp,regExpOut);
  	} else {
	    if(event.keyCode >= 37 && event.keyCode <= 40) return true;
	    object.value = object.value.replace(/\D*/gi,"");
	    var mod = object.value.length % 3;
	    var grpCnt = object.value.length/3 + (mod > 0 ? 1 : 0);
	    var regExp = "(\\d{"+(mod == 0 ? 3 : mod)+"})";
	    var regExpOut = "$1";
	    for(var i = 2; i <= grpCnt; i++) {
	      regExp += "(\\d{3})";
	      regExpOut += ",$"+i;
	    }
	    regExp = new RegExp(regExp+"$","gi");
	    object.value = object.value.replace(regExp,regExpOut);
    }
  }

  // 숫자로 이루어진 문자를 전화번호 표기법으로 치환
  function SetTelFormat(object) {
    if(event.keyCode != Key.BACKSPACE && 
       event.keyCode != Key.TAB && 
       event.keyCode != Key.ENTER && 
       event.keyCode != Key.SHIFT && 
       event.keyCode != Key.LCTRL && 
       event.keyCode != Key.LALT && 
       event.keyCode != Key.RALT && 
       event.keyCode != Key.RCTRL && 
       event.keyCode != Key.ESC && 
       event.keyCode != Key.PAGEUP && 
       event.keyCode != Key.PAGEDOWN && 
       event.keyCode != Key.END && 
       event.keyCode != Key.HOME && 
       event.keyCode != Key.LEFT && 
       event.keyCode != Key.UP && 
       event.keyCode != Key.RIGHT && 
       event.keyCode != Key.DOWN && 
       event.keyCode != Key.INSERT && 
       event.keyCode != Key.DELETE
    ) {
      object.value = object.value.replace(/\D*/gi,"");
      switch(object.value.length) {
      case 1 : case 2 : case 4 : case 5 :
        regExpOut = "$1-$2";
        regExp = new RegExp("(\\d{3})(\\d*)","gi");
        object.value = object.value.replace(regExp,regExpOut);
        break;
      case 6 : case 7 : case 8 : case 9 : case 10 :
        regExpOut = "$1-$2-$3";
        regExp = new RegExp("(\\d{3})(\\d{3})(\\d*)","gi");
        object.value = object.value.replace(regExp,regExpOut);
        break;
      case 11 :
        regExpOut = "$1-$2-$3";
        regExp = new RegExp("(\\d{3})(\\d{4})(\\d{4})","gi");
        object.value = object.value.replace(regExp,regExpOut);
        break;
      }
    }
  }

  // 숫자로 이루어진 문자를 날짜 표기법으로 치환
  function SetCalendarFormat(object) {
    if(event.keyCode != Key.BACKSPACE && 
       event.keyCode != Key.TAB && 
       event.keyCode != Key.ENTER && 
       event.keyCode != Key.SHIFT && 
       event.keyCode != Key.LCTRL && 
       event.keyCode != Key.LALT && 
       event.keyCode != Key.RALT && 
       event.keyCode != Key.RCTRL && 
       event.keyCode != Key.ESC && 
       event.keyCode != Key.PAGEUP && 
       event.keyCode != Key.PAGEDOWN && 
       event.keyCode != Key.END && 
       event.keyCode != Key.HOME && 
       event.keyCode != Key.LEFT && 
       event.keyCode != Key.UP && 
       event.keyCode != Key.RIGHT && 
       event.keyCode != Key.DOWN && 
       event.keyCode != Key.INSERT && 
       event.keyCode != Key.DELETE
    ) {
      object.value = object.value.replace(/\D*/gi,"");
      switch(object.value.length) {
      case 1 : case 2 : case 3 : case 4 : case 5 : 
        regExpOut = "$1-$2";
        regExp = new RegExp("(\\d{4})(\\d*)","gi");
        object.value = object.value.replace(regExp,regExpOut);
        break;
      case 6 : case 7 : 
        regExpOut = "$1-$2-$3";
        regExp = new RegExp("(\\d{4})(\\d{2})(\\d*)","gi");
        object.value = object.value.replace(regExp,regExpOut);
        break;
      case 8 :
        regExpOut = "$1-$2-$3";
        regExp = new RegExp("(\\d{4})(\\d{2})(\\d{2})","gi");
        object.value = object.value.replace(regExp,regExpOut);
        break;
      }
    }
  }

  // 날짜 관련 객체
  function Calendar() {
    this.calendar = new Date();
    
    if(!Validate.isNull(arguments[5])) {
      this.calendar.setSeconds(arguments[5]);
    }
    if(!Validate.isNull(arguments[4])) {
      this.calendar.setMinute(arguments[4]);
    }
    if(!Validate.isNull(arguments[3])) {
      this.calendar.setHours(arguments[3]);
    }
    if(!Validate.isNull(arguments[2])) {
      this.calendar.setDate(arguments[2]);
    }
    if(!Validate.isNull(arguments[1])) {
      this.calendar.setMonth(arguments[1] - 1);
    }
    if(!Validate.isNull(arguments[0])) {
      this.calendar.setFullYear(arguments[0]);
    }
  
    this.getYear = function() { // 년도를 반환 한다.
      return this.calendar.getFullYear();
    };
  
    this.setYear = function() { // 년도를 설정 한다.
      return this.calendar.setFullYear(arguments[0]);
    };
  
    this.getMonth = function() { // 월을 반환 한다.
      return this.calendar.getMonth() + 1;
    };
  
    this.setMonth = function() { // 월을 설정 한다.
      return this.calendar.setMonth(arguments[0]-1);
    };
  
    this.getDate = function() { // 날짜를 반환 한다.
      return this.calendar.getDate();
    };
  
    this.setDate = function() { // 날짜를 설정 한다.
      return this.calendar.setDate(arguments[0]);
    };
  
    this.getHours = function() { // 시를 반환 한다.
      return this.calendar.getHours();
    };
  
    this.setHours = function() { // 시를 설정 한다.
      return this.calendar.setHours(arguments[0]);
    };
  
    this.getMinute = function() { // 분을 반환 한다.
      return this.calendar.getMinute();
    };
  
    this.setMinute = function() { // 분을 설정 한다.
      return this.calendar.setMinute(arguments[0]);
    };
  
    this.getSeconds = function() { // 초를 반환 한다.
      return this.calendar.getSeconds();
    };
  
    this.setSeconds = function() { // 초를 설정 한다.
      return this.calendar.setSeconds(arguments[0]);
    };
  
    this.getMilliseconds = function() { // 1/1000초를 반환 한다.
      return this.calendar.getMilliseconds();
    };
  
    this.setMilliseconds = function() { // 1/1000초를 설정 한다.
      return this.calendar.setMilliseconds(arguments[0]);
    };
  
    this.getFirstDay = function() { // 첫째날 요일을 반환 한다.
      var tempDate = new Date(this.calendar.getFullYear(), this.calendar.getMonth(), 1);
      return tempDate.getDay();
    };
    
    this.getLastDate = function() { // 마지막 날짜를 반환 한다.
      var tempDate = new Date(this.calendar.getFullYear(), this.calendar.getMonth()+1, 0);
      return tempDate.getDate();
    };
    
    this.getWeeks = function() { // 주의 갯수를 반환 한다.
      var lastPosition = this.getFirstDay() + this.getLastDate();
      return parseInt((lastPosition / 7) + (lastPosition % 7 != 0 ? 1 : 0));
    };
  }

  // 날짜 선택기
  function DateSelector() {
    var target = event.srcElement;
    var instance = document.getElementById("_dateSelector");
    if(!Validate.isNull(instance)) { document.body.removeChild(instance); }
    var calendar = null;
    if(arguments.length == 1) {
      calendar = new Calendar();
      target = GetObjectById(arguments[0]);
    } else {
      calendar = new Calendar(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]);
    }
    
    var getController = function(newYear, newMonth) {
      if(!Validate.isNull(newYear) && !Validate.isNull(newMonth)) {
        calendar.setDate(1);
        calendar.setMonth(newMonth);
        calendar.setYear(newYear);
      }
      var year = calendar.getYear();
      var month = calendar.getMonth();
      var table = document.createElement("table");
      var tbody = document.createElement("tbody");
      var tr = document.createElement("tr");
      var td = document.createElement("td");
      var img_left = document.createElement("img");
      var img_right = document.createElement("img");
      table.style.borderCollapse = "collapse";
      table.style.border = "solid #DBDBDB 1px";
      table.setAttribute("border", "1px");
      table.setAttribute("width", "100%");
      table.setAttribute("height", "20px");
      table.setAttribute("cellpadding", "0px");
      table.setAttribute("cellspacing", "0px");
      td.style.color = "#0066CC";
      td.style.fontSize = "12px";
      td.style.fontWeight = "bold";
      td.style.backgroundColor = "#FFFFFF";
      td.setAttribute("align", "center");
      img_left.style.cursor = "pointer";
      img_left.style.marginRight = "5px";
      img_left.setAttribute("align","absmiddle");
      img_left.setAttribute("src","/img/common/icon_arrow_left_01.gif");
      img_left.setAttribute("alt","<");
      img_right.style.cursor = "pointer";
      img_right.style.marginLeft = "5px";
      img_right.setAttribute("align","absmiddle");
      img_right.setAttribute("src","/img/common/icon_arrow_right_01.gif");
      img_right.setAttribute("alt",">");
      img_left.onclick = function() {
        if(--month == 0) {
          month = 12;
          --year;
        }
        var _new_controller = getController(year, month);
        var _new_calendar = getCalendar(year, month);
        div.replaceChild(_new_controller,_controller);
        div.replaceChild(_new_calendar,_calendar);
        _controller = _new_controller;
        _calendar = _new_calendar;
      };
      img_right.onclick = function() {
        if(++month == 13) {
          month = 1;
          ++year;
        }
        var _new_controller = getController(year, month);
        var _new_calendar = getCalendar(year, month);
        div.replaceChild(_new_controller,_controller);
        div.replaceChild(_new_calendar,_calendar);
        _controller = _new_controller;
        _calendar = _new_calendar;  
      };
      td.appendChild(img_left);
      td.appendChild(document.createTextNode(year + "년 " + (month <= 9 ? "0" : "") + month + " 월"));
      td.appendChild(img_right);
      tr.appendChild(td);
      tbody.appendChild(tr);
      table.appendChild(tbody);
      return table;
    };
    
    var getCalendar = function(newYear, newMonth) {
      var holiday = null; // 공휴일 리스트
      var day = new Array(
                  new Array("일","#CC0000"), 
                  new Array("월","#666666"), 
                  new Array("화","#666666"), 
                  new Array("수","#666666"), 
                  new Array("목","#666666"), 
                  new Array("금","#666666"), 
                  new Array("토","#3399CC"));
      if(!Validate.isNull(newYear) && !Validate.isNull(newMonth)) {
        calendar.setDate(1);
        calendar.setMonth(newMonth);
        calendar.setYear(newYear);
      }
      var year = calendar.getYear();
      var month = calendar.getMonth();
      var weeks = calendar.getWeeks();
      var firstDay = calendar.getFirstDay();
      var lastDate = calendar.getLastDate();
      var lastPosition = firstDay + lastDate;
      var table = document.createElement("table");
      table.style.borderCollapse = "collapse";
      table.style.border = "solid #DBDBDB 1px";
      table.setAttribute("border", "1px");
      table.setAttribute("width", "100%");
      table.setAttribute("cellpadding", "0px");
      table.setAttribute("cellspacing", "0px");
      var tbody = document.createElement("tbody");
      var tr_day = document.createElement("tr");
      for(var idx_td = 0; idx_td < 7; idx_td++) {
        var td = document.createElement("td");
        td.appendChild(document.createTextNode(day[idx_td][0]));
        td.style.width = "20px";
        td.style.color = day[idx_td][1];
        td.style.fontSize = "11px";
        td.style.backgroundColor = "#FFFFFF";
        td.setAttribute("align", "center");
        tr_day.appendChild(td);
      }
      tbody.appendChild(tr_day);
      for(var idx_tr = 0; idx_tr < weeks; idx_tr++) {
        var tr = document.createElement("tr");
        for(var idx_td = 0; idx_td < 7; idx_td++) {
          var td = document.createElement("td");
          var currentPosition = (idx_tr) * 7 + idx_td + 1;
          var currentDate = currentPosition - firstDay;
          td.style.color = day[idx_td][1];
          td.style.fontSize = "11px";
          td.style.backgroundColor = "#FFFFFF";
          td.setAttribute("align", "center");
          if(currentPosition > firstDay && currentPosition <= lastPosition) {
            var today = new Date();
            if(today.getFullYear() == year && today.getMonth() == month - 1 && today.getDate() == currentDate) td.style.fontWeight = "bold";
            td.appendChild(document.createTextNode(currentDate));
            td.onclick = function() {
              var date = this.firstChild.nodeValue;
              target.value = year + "-" + (month <= 9 ? "0" : "") + month + "-" + (date <= 9 ? "0" : "") + date;
            };
            td.onmouseover = function() {
              this.style.backgroundColor = "yellow";
            };
            td.onmouseout = function() {
              this.style.backgroundColor = "#FFFFFF";
            };
          }
          tr.appendChild(td);
        }
        tbody.appendChild(tr);
      }
      table.appendChild(tbody);
      return table;
    };
    
    var weeks = calendar.getWeeks();
    var div = document.createElement("div");
    var offset = 10;
    var width = Browser.isMozes ? 147 : 148;
    var height = new Array(116, 135, 154);
    var top = event.y;
    var left = event.x;
    var innerWidth = window.innerWidth ? window.innerWidth : document.body.clientWidth;
    var innerHeight = window.innerHeight ? window.innerHeight : document.body.clientHeight;
    div.style.top =  ((innerHeight > top + height[weeks-4] + offset) ? top : (innerHeight - height[weeks-4] - offset)) + (Browser.isMsie ? document.body.scrollTop : (Browser.isMozes ? window.pageYOffset : 0)) + "px";
    div.style.left = ((innerWidth > left + width + offset) ? left : (innerWidth - width - offset)) + (Browser.isMsie ? document.body.scrollLeft : (Browser.isMozes ? window.pageXOffset : 0)) + "px";
    div.style.width = width + "px";
    div.style.cursor = "default";
    div.style.position = "absolute";window.scr
    div.style.backgroundColor = "#FFFFFF";
    div.setAttribute("align", "center");
    div.setAttribute("id", "_dateSelector");
    div.onclick = function() {document.body.removeChild(document.getElementById("_dateSelector")); };
  
    var _controller = getController();
    var _calendar = getCalendar();
    div.appendChild(_controller);
    div.appendChild(_calendar);
    document.body.appendChild(div);
  }

  // flashWrite(파일경로, 가로, 세로, 아이디, 배경색, 변수)
  function flashWrite(movie,width,height,id,bg,vars){
    ShowSWF(movie,width,height,vars);
  }

  function generateExternalObject(html){document.write(html);}

  function ResizeFrameWFix(iframe) {
    var innerBody = iframe.contentWindow.document.body;
    var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
    //var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);
    iframe.style.height = innerHeight;
    //iframe.style.width = innerWidth;
  }

  /* ------------------------------------------------------------------------------------------------
   * 입력값 공백 제거
   * ------------------------------------------------------------------------------------------------ */
  function strAllTrim(strText) { // 자바 스크립트에서 공백을 삭제하는 사용자 정의 함수
    return strText.replace(/\s/g,"");
  }

	// 입력된 문자열 trim 해서 반환  
  function trim(str) {
  	return str.replace(/(^\s*)|(\s*$)/g, "");
  }