//=================================================================================================
// 프로젝트 : 10억홈피 WCMS
// 파 일 명 : /common/js/ajax.js
// 처리내용 : Ajax를 jQuery와 연동
// 작 성 자 : 2009-07-07 이성준
//=================================================================================================
(function($)
{
  if (!$) { return; }

  //-------------------------------------------------------------------------------------
  // 함수명 : $.hiddenPost 
  // 기  능 : Form submit(hidden frame)
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pForm:폼, pFile:실행파일
  // ------------------------------------------------------------------------------------
  $.hiddenPost = function(pForm, pFile)
  {
    pForm.action = pFile;
    pForm.method = "post";
    pForm.target = "hdFrame";
    pForm.submit();
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.ajaxPost 
  // 기  능 : ajax 전송 
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pDivName:DIV명, pFile:실행파일명, pData:파라메타
  // ------------------------------------------------------------------------------------
  $.ajaxPost = function(pDivName, pFile, pData)
  {
    var req = $.xmlRequest();
    if ( req ) 
    {
      req.open("POST", pFile, true);
      req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=uft-8");
      req.onreadystatechange = function()  
      {
        if ( 4 == req.readyState )
        {
          $(pDivName).html(req.responseText);
        }
      }
      //var pData = (pData) ? $.uriEncode(pData) : null;
      var pData = (pData) ? pData : null;
      req.send(pData);
    }
  };
  //-------------------------------------------------------------------------------------
  // 함수명 : $.xmlRequest
  // 기  능 : XMLHTTP OBJ 생성
  // 작성일 : 2009-07-07 이성준
  // 참  조 : 
  // ------------------------------------------------------------------------------------
  $.xmlRequest = function()
  {
    var req = null;
    if (window.XMLHttpRequest)
    {
      req = new XMLHttpRequest();
      if (req.overrideMimeType)
      {
        req.overrideMimeType('text/xml');
      }
    } 
    else if ( window.ActiveXObject )
    {
      try 
      {
        req = new ActiveXObject("Msxml2.XMLHTTP");
      } 
      catch (e1) 
      {
        try        { req = new ActiveXObject("Microsoft.XMLHTTP"); }
        catch (e2) { }
      }
    }
    return req;
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.uriEncode
  // 기  능 : 데이터 체크
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pData:체크데이타
  // ------------------------------------------------------------------------------------
  $.uriEncode = function(pData)
  {
    if( "" != pData )
    {
      //&와=로 일단 분해해서 encode
      var encdata = '';
      var datas   = pData.split('&');
      for(loop=1;loop<datas.length;loop++)
      {
        var dataq = datas[loop].split('=');
        encdata += '&'+encodeURIComponent(dataq[0])+'='+encodeURIComponent(dataq[loop]);
      }
    } 
    else 
    {
      encdata = "";
    }
    return encdata;
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.insert
  // 기  능 : 페이지 insert
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pDiv:DIV명, pFile:실행파일명, pData:파라메타, pHeight:높이
  // ------------------------------------------------------------------------------------
  $.insert = function(pDiv, pFile, pData, pHeight)
  {
    var h = (pHeight-16)/2;
    var html = '<div style="height:'+pHeight+'px;"><div style="padding-top:'+h+'px;text-align:center;"><img src="/image/ajax_small.gif" width="16" height="16" /></div></div>';
    $(pDiv).html(html);
    $.ajaxPost(pDiv, pFile, pData);
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.cell
  // 기  능 : 셀 insert
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pDiv:DIV명, pEl:엘리먼트명, pFile:실행파일명, pData:파라메타
  // ------------------------------------------------------------------------------------
  $.cell = function(pDiv, pEl, pFile, pData)
  {
    var el = toGetElementById(pEl).getElementsByTagName("DIV");
    for (var loop=0; loop<el.length; loop++) 
    {
      el[loop].style.display = "none";
    }
    $(pDiv).toggle();
    $.ajaxPost(pDiv, pFile, pData);
  }

  //-------------------------------------------------------------------------------------
  // 함수명 : $.dialog
  // 기  능 : 다이알로그창
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pFile:실행파일명, pData:파라메타, pW:폭, pH:높이, pT:탑마진
  // ------------------------------------------------------------------------------------
  $.dialog = function(pFile, pData, pW, pH ,pT,pSkin)
  {
    var scrollTop = getScrollTop();
    var winLeft   = parseInt(getClientWidth() - pW - 8) / 2;
    var winTop    = parseInt(getClientHeight() - pH - 35) / 2 + scrollTop; // 상단31,하단4 를 높이에 포함
    var html      = '<img src="/image/ajax_small.gif" width="16" height="16" style="width:16px;height:16px;margin-top:'+parseInt((pH/2)-8)+'px" />';

    if ( null == pSkin ) { pSkin = ""; }

    if      ("black" == pSkin.toLowerCase()) { pSkin = "Black"; }
    else if ("red"   == pSkin.toLowerCase()) { pSkin = "Red";   }
    else if ("blue"  == pSkin.toLowerCase()) { pSkin = "Blue";  }
    else if ("green" == pSkin.toLowerCase()) { pSkin = "Green"; }
    else                                     { pSkin = "Black"; }

    $.dialogRemove();
    $('<div id="idAjaxHeader"></div>').css('height',getBodyHeight()).appendTo('body');
    $('<div id="idAjaxBody">'+
      '  <div class="ssAjax'+pSkin+'TopLeft"></div>'+
      '  <div class="ssAjax'+pSkin+'TopCenter" style="width:'+pW+'px;">'+
      '    <div id="idAjaxTitleText" class="ssAjax'+pSkin+'TitleText" style="float:left;"></div>'+
      '    <div id="idAjaxClose" class="ssAjax'+pSkin+'Close" onclick="$.dialogRemove()" style="float:right;margin:5px 5px 0 0;" alt="닫기"></div>'+
      '    <div class="ssClear"></div>'+
      '  </div>'+
      '  <div class="ssAjax'+pSkin+'TopRight"></div>'+
      '  <div class="ssAjax'+pSkin+'Middle" style="height:'+pH+'px;"></div>'+
      '  <div id="idAjaxDisplay"></div>'+
      '  <div class="ssAjax'+pSkin+'Middle" style="height:'+pH+'px;"></div>'+
      '  <div class="ssAjax'+pSkin+'BottomLeft"></div>'+
      '  <div class="ssAjax'+pSkin+'BottomCenter" style="width:'+pW+'px;"></div>'+
      '  <div class="ssAjax'+pSkin+'BottomRight"></div>')
      .css({
        'position'     : 'absolute',
          'top'        : winTop+'px',
          'left'       : winLeft+'px',
          'border'     : '0',
          'width'      : (parseInt(pW)+8)+'px',
          'height'     : (parseInt(pH)+35) +'px',
          'text-align' : 'center',
          'background' : '#e5e5e5',
          'z-index'    : '998'
      }).appendTo('body');

    $('#idAjaxDisplay').css({'width' : pW+'px',  'height' : pH+'px', 'text-align' : 'center', 'overflow' : 'auto'}).html(html);

    $.ajaxPost('#idAjaxDisplay', pFile, pData);

    $("#idAjaxBody").draggable();
    $("#idAjaxClose").bind('mouseover',function(event) { $(this).addClass("ssAjax"+pSkin+"CloseOn"); } );
    $("#idAjaxClose").bind('mouseout' ,function(event) { $(this).removeClass("ssAjax"+pSkin+"CloseOn"); } );
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.message
  // 기  능 : 메세지창
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pFile:실행파일명, pData:파라메타
  // ------------------------------------------------------------------------------------
  $.message = function(pFile, pData,pSkin )
  {
    var pW = 400;
    var pH = 130;
    var scrollTop = getScrollTop();
    var winLeft   = parseInt(getClientWidth() - pW - 8) / 2;
    var winTop    = parseInt(getClientHeight() - pH - 35) / 2 + scrollTop; // 상단31,하단4 를 높이에 포함
    var html = '<div class="ssCenter" style="margin:30px 0"><img src="/image/ajax_large.gif" style="width:150px;height:13px;margin:5px;" /><br />Wait...</div>';

    if ( null == pSkin ) { pSkin = ""; }

    if      ("black" == pSkin.toLowerCase()) { pSkin = "Black"; }
    else if ("red"   == pSkin.toLowerCase()) { pSkin = "Red";   }
    else if ("blue"  == pSkin.toLowerCase()) { pSkin = "Blue";  }
    else if ("green" == pSkin.toLowerCase()) { pSkin = "Green"; }
    else                                     { pSkin = "Black"; }

    $.dialogRemove();
    $('<div id="idAjaxHeader"></div>').css('height', getBodyHeight()+'px').appendTo('body');

    $('<div id="idAjaxBody">'+
      '  <div class="ssAjax'+pSkin+'TopLeft"></div>'+
      '  <div class="ssAjax'+pSkin+'TopCenter" style="width:'+pW+'px;">'+
      '    <div id="idAjaxTitleText" class="ssAjax'+pSkin+'TitleText" style="float:left;">Message</div>'+
      '    <div id="idAjaxClose" class="ssAjax'+pSkin+'Close" onclick="$.dialogRemove()" style="float:right;margin:5px 5px 0 0;" alt="닫기"></div>'+
      '    <div class="ssClear"></div>'+
      '  </div>'+
      '  <div class="ssAjax'+pSkin+'TopRight"></div>'+
      '  <div class="ssAjax'+pSkin+'Middle" style="height:'+pH+'px;"></div>'+
      '  <div id="idAjaxDisplay"></div>'+
      '  <div class="ssAjax'+pSkin+'Middle" style="height:'+pH+'px;"></div>'+
      '  <div class="ssAjax'+pSkin+'BottomLeft"></div>'+
      '  <div class="ssAjax'+pSkin+'BottomCenter" style="width:'+pW+'px;"></div>'+
      '  <div class="ssAjax'+pSkin+'BottomRight"></div>')
      .css({
        'position'   : 'absolute',
        'top'        : winTop+'px',
        'left'       : winLeft+'px',
        'border'     : '0',
        'width'      : (parseInt(pW)+8)+'px',
        'height'     : (parseInt(pH)+35)+'px',
        'text-align' : 'center',
        'background' : '#e5e5e5',
        'z-index'    : '998'
      }).appendTo('body');

    $('#idAjaxDisplay').css({'width' : pW+'px', 'height' : pH+'px', 'text-align' : 'center', 'vertical-align' : 'middle'}).html(html);
    $.ajaxPost('#idAjaxDisplay', pFile, pData);

    //$("#idAjaxBody").draggable();
    $("#idAjaxClose").bind('mouseover',function(event) { $(this).addClass("ssAjax"+pSkin+"CloseOn"); } );
    $("#idAjaxClose").bind('mouseout' ,function(event) { $(this).removeClass("ssAjax"+pSkin+"CloseOn"); } );
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.tabs
  // 기  능 : 탭방식
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pObj:객체, pDiv:DIV명, pFile:실행파일, pData:파라메타, pHeight:높이
  // ------------------------------------------------------------------------------------
  $.tabs = function(pObj, pDiv, pFile, pData, pHeight)
  {
    var tab_id = pObj.id;
    var cObj   = pObj.parentNode.firstChild;

    while(cObj) 
    {
      if(cObj.nodeName == "LI" && cObj.id) 
      {
        var cTabID= cObj.id;
        if( cTabID.indexOf('tab')<0 ) { continue; }
        var cContentID = cTabID.replace(/^tab/,'idTabBody');
        if( tab_id == cTabID ) { cObj.className = "ssTab ssOn"; toGetElementById(cContentID).className = "ssTabBody ssShow"; } 
        else                   { cObj.className = "ssTab";      toGetElementById(cContentID).className = "ssTabBody ssHide"; }
      }
      cObj = cObj.nextSibling;
    }
    var h = (pHeight-16)/2;
    var html = '<div style="height:'+pHeight+'px;"><div style="padding-top:'+h+'px;text-align:center;"><img src="/image/ajax_small.gif" width="16" height="16" /></div></div>';
    $(pDiv).html(html);
    $.ajaxPost(pDiv, pFile, pData);
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.menus
  // 기  능 : 메뉴방식
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pDiv:DIV명, pFile:실행파일, pSize:파라메타
  // ------------------------------------------------------------------------------------
  $.menus = function(pDiv, pFile, pSize)
  {
    $("#idContainer > .ssSnb > .ssCube > .ssLine > .ssSub").animate({height : "0px"}, 200);
    $(pDiv).animate({height : pSize}, 500);
    $.insert(pDiv, pFile, null, pSize);
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.checkFarm
  // 기  능 : 폼전송
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pForm:폼명, pFile:실행파일, pType:전송타입, pDiv:DIV명, pW:폭, pH:높이
  // ------------------------------------------------------------------------------------
  $.checkFarm = function(pForm, pFile, pType, pDiv, pW, pH, pChkFields)
  {
    var data = '';
    if( checkForm(pForm,pChkFields) == true ) 
    {
      for( var loop=0; loop<pForm.elements.length; loop++ )
      {
        var e = pForm.elements[loop];
        if ( false == e.disabled && 'checkbox' != e.type.toLowerCase() && 'radio' != e.type.toLowerCase()) { data += "&"+e.name+"="+e.value; }
        if ( true  == e.checked  && 'checkbox' == e.type.toLowerCase())                                    { data += "&"+e.name+"="+e.value; }
        if ( true  == e.checked  && 'radio'    == e.type.toLowerCase())                                    { data += "&"+e.name+"="+e.value; }
      }

      switch( pType ) 
      {
        case "dialog" : $.dialog(pFile, data, pW, pH);   break; // DIV 팝업창표시
        case "insert" : $.insert(pDiv, pFile, data, pH); break; // DIV 인서트(메시지표시)
        case "msg"    : $.message(pFile, data);          break; // 메시지창표시
        case "post"   : $.hiddenPost(pForm, pFile);      break; // 히든프레임으로 submit
        default       : $.message(pFile, data);          break;
      }
      return false;
    }
    return false;
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.dialogRemove
  // 기  능 : 다이알로그창 없애기
  // 작성일 : 2009-07-07 이성준
  // 참  조 : 
  // ------------------------------------------------------------------------------------
  $.dialogRemove = function()
  {
    $("#idAjaxBody").remove();
    $("#idAjaxClose").remove();
    $("#idAjaxHeader").remove();
    return true;
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.dialogScroll
  // 기  능 : 다이알로그 스크롤
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pName:엘리먼트명, pTopMargin:top margin
  // ------------------------------------------------------------------------------------
  $.dialogScroll = function(pName, pTopMargin)
  {
    if( toGetElementById(pName) )
    {
      var el = toGetElementById(pName);
      var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;

      yMenuFrom = parseInt(getTop(pName), 10);
      yMenuTo   = getScrollTop() + pTopMargin;

      if( yMenuTo <0 ) { yMenuTo = 0; }
      timeoutNextCheck = 100;

      if( yMenuFrom > parseInt(yMenuTo + 10) || yMenuFrom < parseInt(yMenuTo - 10) ) 
      {
        yOffset = Math.ceil(Math.  abs(yMenuTo - yMenuFrom) / 5);
        if (yMenuTo < yMenuFrom) { yOffset = -yOffset; }
        el.style.top  = parseInt (el.style.top, 10) + yOffset;
        timeoutNextCheck = 0;
      }
      setTimeout ("$.dialogScroll('"+pName+"', "+pTopMargin+")", timeoutNextCheck);
    } 
    else
    {
      false;
    }
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.dialogScroll2
  // 기  능 : 다이알로그 스크롤
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pName:엘리먼트명, pTopMargin:top margin
  // ------------------------------------------------------------------------------------
  $.dialogScroll2 = function(pName, pTopMargin)
  {
    var center  = size / 2;
    var right_v = getScrollTop() + top + "px";
    var right_h = size + left + "px";
    $(el).css({"top":right_v, "left":right_h, "display":"block"});
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.quickScrolls
  // 기  능 : 퀵 스크롤
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pName:엘리먼트명, pSize:size, pTop:top, pLeft:left
  // ------------------------------------------------------------------------------------
  $.quickScrolls = function(pName, pSize, pTop, pLeft)
  {
    var center  = pSize / 2;
    var right_v = getScrollTop() + pTop + "px";
    var right_h = pSize + pLeft + "px";
    $(pName).css({"top":right_v, "left":right_h, "display":"block"});
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.changeTopMenu
  // 기  능 : TOP 메뉴
  // 작성일 : 2009-07-07 이성준
  // 참  조 : 
  // ------------------------------------------------------------------------------------
  $.changeTopMenu = function()
  {
    $(".top_menu > ul > .tab").bind("mouseenter", function(e){
      $(this).addClass("on");
    });
    $(".top_menu > ul > .tab").bind("mouseleave", function(e){
      $(this).removeClass("on");
    });
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.changeLang
  // 기  능 : 언어설정 : select 메뉴
  // 작성일 : 2009-07-07 이성준
  // 참  조 : 
  // ------------------------------------------------------------------------------------
  $.changeLang = function()
  {
    $(".langBtn").bind("mouseenter", function(e){
      $(".langBtn > span").css("color","#990000");
      $(".lang").toggle("fast");
    });
    $(".langBtn").bind("mouseleave", function(e){
      $(".langBtn > span").css("color","#444");
      $(".lang").hide("fast");
    });
    $(".langItem").bind("mouseenter", function(e){
      $(this).css({"background":"#666", "color":"#fff"});
    });
    $(".langItem").bind("mouseleave", function(e){
      $(this).css({"background":"#fff", "color":"#444"});
    });
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.checkTidOverLap
  // 기  능 : 통합회원 아이디 체크
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pType : 체크타입
  // ------------------------------------------------------------------------------------
  $.checkTidOverLap = function(pType)
  {
    $("#checkId").html('<img src="/image/ajax_small.gif" width="16" height="16" align="absmiddle" />');
    $.post("/modules/mdMember/addon/check_tid.asp", {sh_type:pType, idx:$("#userid").val()}, function(data){
      $("#checkId").html(data);
    });
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.checkIdOverLap
  // 기  능 : 회원아이디 체크
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pType : 체크타입
  // ------------------------------------------------------------------------------------
  $.checkIdOverLap = function(pType)
  {
    $("#checkId").html('<img src="/image/ajax_small.gif" width="16" height="16" align="absmiddle" />');
    $.post("/modules/mdMember/addon/check_id.asp", {sh_type:pType, idx:$("#userid").val()}, function(data){
      $("#checkId").html(data);
    });
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.checkNickOverLap
  // 기  능 : 회원닉네임 체크
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pType : 체크타입
  // ------------------------------------------------------------------------------------
  $.checkNickOverLap = function(pType)
  {
    $("#checkNick").html('<img src="/image/ajax_small.gif" width="16" height="16" align="absmiddle" />');
    $.post("/modules/mdMember/addon/check_nick.asp", {sh_type:pType, idx:$("#nick").val()}, function(data){
      $("#checkNick").html(data);
    });
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.checkCateOverLap
  // 기  능 : 카테고리 체크
  // 작성일 : 2009-07-07 이성준
  // 참  조 : 
  // ------------------------------------------------------------------------------------
  $.checkCateOverLap = function()
  {
    $("#checkCate").html('<img src="/image/ajax_small.gif" width="16" height="16" align="absmiddle" />');
    $.post("./modules/category_check.asp", {parent:$("#cateCode1").val(), cate:$("#cateCode2").val(), cated:$("#cated").val()}, function(data){
      $("#checkCate").html(data);
    });
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.insertAddress
  // 기  능 : 주소검색
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pZip  : 우편번호, pAddr : 기본주소
  // ------------------------------------------------------------------------------------
  $.insertAddress = function(pZip, pAddr, pFldZip, pFldAddr1, pFldAddr2)
  {
    $.dialogRemove();
    $("#"+pFldZip).val(pZip);
    $("#"+pFldAddr1).val(pAddr);
    $("#"+pFldAddr2).focus();
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.setComma
  // 기  능 : 콤마찍기
  // 작성일 : 2009-07-07 이성준
  // 참  조 : pStr : 문자열
  // ------------------------------------------------------------------------------------
  $.setComma = function(pStr)
  {
    pStr = ""+pStr+"";
    var rtnValue = "";
    for(loop=0; loop<pStr.length; loop++) 
    {
      if(loop > 0 && (loop%3)==0) { rtnValue = pStr.charAt(str.length - loop -1) + "," + rtnValue; }
      else                        { rtnValue = pStr.charAt(str.length - loop -1) + rtnValue; }
    }
    return rtnValue;
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.selSeq
  // 기  능 : 상품관리 : select 메뉴
  // 작성일 : 2009-07-07 이성준
  // 참  조 : 
  // ------------------------------------------------------------------------------------
  $.selSeq = function()
  {
    $(".selseq").bind("mouseenter", function(e){
      $(".selseq > span").css("color","#990000");
      $(".sel").toggle("fast");
    });
    $(".selseq").bind("mouseleave", function(e){
      $(".selseq > span").css("color","#444");
      $(".sel").hide("fast");
    });
    $(".selItem").bind("mouseenter", function(e){
      $(this).css({"background":"#666", "color":"#fff"});
    });
    $(".selItem").bind("mouseleave", function(e){
      $(this).css({"background":"#fff", "color":"#444"});
    });
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.selCnt
  // 기  능 : 
  // 작성일 : 2009-07-07 이성준
  // 참  조 : 
  // ------------------------------------------------------------------------------------
  $.selCnt = function()
  {
    $(".selcnt").bind("mouseenter", function(e){
      $(".selcnt > span").css("color","#990000");
      $(".cnt").toggle("fast");
    });
    $(".selcnt").bind("mouseleave", function(e){
      $(".selcnt > span").css("color","#444");
      $(".cnt").hide("fast");
    });
    $(".selItem").bind("mouseenter", function(e){
      $(this).css({"background":"#666", "color":"#fff"});
    });
    $(".selItem").bind("mouseleave", function(e){
      $(this).css({"background":"#fff", "color":"#444"});
    });
  };

  //-------------------------------------------------------------------------------------
  // 함수명 : $.sms
  // 기  능 : 
  // 작성일 : 2009-07-07 이성준
  // 참  조 : 
  // ------------------------------------------------------------------------------------
  $.sms = function()
  {
    var w         = 220;
    var h         = 440;
    var topMargin = 120;
    var winh      = parseInt(getClientWidth() - w) / 2;
    var winv      = parseInt(getClientHeight() - h) / 2;
    var html      = '<img src="/image/ajax_small.gif" width="16" height="16" style="margin-top:'+parseInt((h/2)-8)+'px" />';

    $.dialogRemove();
    $('<div id="idAjaxHeader"></div>').css('height',getBodyHeight()).appendTo('body');
    $('<div id="idAjaxBody"><div id="idAjaxDisplay" ></div></div>')
      .css({
        'position'  : 'absolute',    'top'        : winv+'px',      'left'      : winh+'px',
        'width'      : w+'px',        'height'    : h+'px',    'text-align': 'center',  'z-index' : '998'
      }).appendTo('body');
    $('<div id="idAjaxClose" onclick="$.dialogRemove()"><img src="/image/icon/icon_close.gif" width="15" height="14" alt="close" /></div>')
      .css({'top' : '-3px', 'right' : '-2px'}).appendTo('#idAjaxBody');

    $('#idAjaxDisplay').css({'width' : w+'px',  'height' : h+'px', 'text-align' : 'center', 'overflow' : 'auto'}).html(html);
    $.ajaxPost('#idAjaxDisplay', '/modules/mdSms/addon/sms_div.asp', '');
    $("#idAjaxBody").draggable();
    $.dialogScroll("idAjaxBody", topMargin);
  };
})(jQuery);