﻿  //**************************************************************************//
  //  ModuleName  : OpenEBook.js                                              //
  //                                                                          //
  //  Last Update : 2010.11.11 by tews                                        //
  //**************************************************************************//
  //  History                                                                 //
  //      2004_06_11  : IE 이외 Browser 도서 오픈시 Redirection               //
  //      2004_06_11  : IE 5.0 도서 오픈 Bug Fixed                            //
  //      2004_07_08  : Window 2003 FullScreen 모탛EBug Fixed                 //
  //      2004_07_22  : TaskBar가 페이햨E넘콅E가림 현퍊EFixed                 //
  //      2004_08_14  : GotoPage 반올림처리                                   //
  //      2010.11.11  : Add function GetWndStyleType for AllInOne             //
  //                    -> GetWinStyle simular but find optimized size for OS, browser  // 
  //      2010.11.11  : Add function GetMargins for AllInOne                  //
  //                    -> find adjusted margin size for OS, browser          // 
  //      2010.11.11  : Change function name SetLaunchHTMLForSelf             //
  //                    -> from SetLaunchHTML to SetLaunchHTMLForSelf for SelfOpen   // 
  //      2010.11.11  : Add Object BrowserDetect Obj                          //
  //                    -> Detact OS, Browser for AllInOne                    //
  //      2010.11.11  : Modify function OpenBook for AllInOne                 // 
  //                    -> Branch host for two (old, new) services            //
  //                       ( BookCode : 100000 )                              //     
  //      2010.11.11  : Modify function GetQuery for AllInOne                 //
  //                    -> added detect code for lagnuage                     //  
  //      2010.11.11  : Modify function SelfOpen                              //
  //                    -> call function SetLaunchHTMLForSelf for oldtype SelfOpen   //  
  //**************************************************************************//
                                                                                                                                                              
  function eBookOpener() {
    this.sNoteEnvURL      = "http://ebook.webcatalog.jp/skin/deco/7net/errorhtml/fortrueebook.html"     ;
    switch (BrowserDetect.browser ) {
      case "Opera" : ; //  
                        this.sNoteEnvStyle    =  "top=" + parseInt((innerHeight - 380 ) / 2 )  + ", left=" + parseInt(( innerWidth  - 426 ) / 2 ) + ", width=426, height=380, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no"   ;
                        break;
      default         :
                        this.sNoteEnvStyle    =  "top=" + parseInt((screen.availHeight - 380 ) / 2 )  + ", left=" + parseInt((screen.availWidth  - 426 ) / 2 ) + ", width=426, height=380, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no"   ;
                        break;
    }
    
    this.winLimitWidth   = 1024;
    this.winLimitHeight  = 768 ; 
    this.winWidth        = 0;
    this.winHeight       = 0;
    this.winInnerWidth   = 0;
    this.winInnerHeight  = 0;
    
    this.winStyle        = null;
    this.OpenStyle       = null;
    this.winStyleName    = null;

    this.TitleBar         = 0 ; 
    this.UrlBar           = 0 ;
    this.Border           = 0 ;
    this.StatusBar        = 0 ;

    this.Port="80";
    this.eBookHost        = "http://main.netfly2.jp"
    this.eBookUrl         = this.eBookHost + ":" + this.Port + "/engine/isapi/frame.dll?";

    this.ParameterList    = new Array("bc", "co", "gp", "sbp", "sep", "ui", "ct");
    this.ViewerStyleList  = new Array("eBookFull", "eBookCustomer", "eBookDefault", "FullScreen");

    this.SetLaunchHTML          = SetLaunchHTML;  
                                                 
    this.GetWinStyle      = GetWinStyle ;        
    this.GetBorderSize    = GetBorderSize;       
    this.IsWinXP          = IsWinXP;             
    this.SelfOpen         = SelfOpen;            
                      
    // 수정된 함수
    this.OpenBook         = OpenBook;     // BookCode에 따라 Domain 선택          
    this.GetQuery         = GetQuery;     // Lagnuage Detect for AllInOne
                      
    // 추가된 함수                                                        
    this.GetWndStyleType        = GetWndStyleType;          // :  GetWinStyle 와 유사하지만 OS 및 Browser에 따른 Book Size Detect  
    this.GetMargins             = GetMargins;               // :  Browser에 따른 Book Margin Detect    
    this.SetLaunchHTMLForSelf   = SetLaunchHTMLForSelf;     // :  First_OpenEBook.js에서 사용하던 SetLaunchHTML , SelfOpen 호출시만 호출됨
    this.SetLaunchURL           = SetLaunchURL;  
    // 추가된 코드
    // BrowserDetect Obj 
  }

  
  function SetLaunchHTML(arg_URL) {  //  open window in HTML

    var sPostUrl = "" ;
    switch ( BrowserDetect.OS ) {
      case "iPhone/iPod"   : ; // iPod
                        this.eBookUrl   = this.eBookHost + ":" + this.Port + "/engine/php/mobile/index.php?";
                        sPostUrl  = "/engine/php/viewer2.php" ;
                        break;
      case "iPad"   : ; // iPad
                        this.eBookUrl   = this.eBookHost + ":" + this.Port + "/engine/php/mobile/index.php?";
                        sPostUrl  = "/engine/php/viewer2.php" ;
                        break;
      case "Android"   : ; // Android
                        this.eBookUrl   = this.eBookHost + ":" + this.Port + "/engine/php/mobile/index.php?";
                        sPostUrl  = "/engine/php/viewer2.php" ;
                        break;
      default         : ;
                        this.eBookUrl   = this.eBookHost + ":" + this.Port + "/engine/isapi/frame.dll?";
                        sPostUrl  = "/engine/php/viewer.php" ;
                        break;
    }

    var OpenHTML  = "<html>" + "\n"
           + "<meta http-equiv=Cache-Control content=No-Cache> " + "\n"
            + "<meta http-equiv=Pragma content=No-Cache /> " + "\n"
            + "<meta http-equiv=Expires content=now />  " + "\n"
            + "<script>" + "\n"
          
            + "document.onkeydown=KeyEventHandle;" + "\n"
            + "document.onkeyup=KeyEventHandle;" + "\n"
            + "function KeyEventHandle() {" + "\n"
            + "if((event.ctrlKey == true && (event.keyCode == 78 || event.keyCode == 82)) || (event.keyCode >= 112 && event.keyCode <= 123)) { " + "\n"
            + "event.keyCode = 0; event.cancelBubble = true; event.returnValue = false; }}" + "\n"
            
            + "var senditGO = function(){ document.theForm.submit(); }" + "\n"      
            + "<\/script>" + "\n"
            + "<body onload=\"senditGO();\" onkeydown=\"KeyEventHandle();\">" + "\n" 
            + "<form name=\"theForm\"method=\"post\" action=\""+this.eBookHost + sPostUrl + "\">" + "\n" 
            + "<input type=\"hidden\" name=\"param\" value=\""+this.eBookUrl+arg_URL+"\">" + "\n"
            + "</form>" + "\n" 
            + "\n" + "</body>" + "\n" + "</html>" ;
 
    return OpenHTML;  
  
  
  }

  function SetLaunchHTMLForSelf(arg_URL) {  //  open window in HTML
    var sPostUrl = "" ;
    switch ( BrowserDetect.OS ) {
      case "iPhone/iPod"   : ; // iPod
                        this.eBookUrl   = this.eBookHost + ":" + this.Port + "/engine/php/mobile/index.php?";
                        sPostUrl  = "/engine/php/viewer2.php" ;
                        break;
      case "iPad"   : ; // iPad
                        this.eBookUrl   = this.eBookHost + ":" + this.Port + "/engine/php/mobile/index.php?";
                        sPostUrl  = "/engine/php/viewer2.php" ;
                        break;
      case "Android"   : ; // Android
                        this.eBookUrl   = this.eBookHost + ":" + this.Port + "/engine/php/mobile/index.php?";
                        sPostUrl  = "/engine/php/viewer2.php" ;
                        break;
      default         : ;
                        this.eBookUrl   = this.eBookHost + ":" + this.Port + "/engine/isapi/frame.dll?";
                        sPostUrl  = "/engine/php/viewer2.php" ;
                        break;
    }

    //  for Hera Server  
    var OpenHTML  = "<html>" + "\n"
           + "<meta http-equiv=Cache-Control content=No-Cache> " + "\n"
            + "<meta http-equiv=Pragma content=No-Cache /> " + "\n"
            + "<meta http-equiv=Expires content=now />  " + "\n"
            + "<script>" + "\n"
          
            + "document.onkeydown=KeyEventHandle;" + "\n"
            + "document.onkeyup=KeyEventHandle;" + "\n"
            + "function KeyEventHandle() {" + "\n"
            + "if((event.ctrlKey == true && (event.keyCode == 78 || event.keyCode == 82)) || (event.keyCode >= 112 && event.keyCode <= 123)) { " + "\n"
            + "event.keyCode = 0; event.cancelBubble = true; event.returnValue = false; }}" + "\n"
            
            + "var senditGO = function(){ document.theForm.submit(); }" + "\n"      
            + "<\/script>" + "\n"
            + "<body onload=\"senditGO();\" onkeydown=\"KeyEventHandle();\">" + "\n" 
            + "<form name=\"theForm\"method=\"post\" action=\""+this.eBookHost + sPostUrl + "\">" + "\n" 
            + "<input type=\"hidden\" name=\"param\" value=\""+this.eBookUrl+arg_URL+"\">" + "\n"
            + "</form>" + "\n" 
            + "\n" + "</body>" + "\n" + "</html>" ;
    return OpenHTML;  
  }
  
  function SetLaunchURL(arg_URL) {  //  open window in HTML

    //  for Hera Server  
    var OpenHTML  = "<html>" + "\n"
           + "<meta http-equiv=Cache-Control content=No-Cache> " + "\n"
            + "<meta http-equiv=Pragma content=No-Cache /> " + "\n"
            + "<meta http-equiv=Expires content=now />  " + "\n"
            + "<script>" + "\n"
          
            + "document.onkeydown=KeyEventHandle;" + "\n"
            + "document.onkeyup=KeyEventHandle;" + "\n"
            + "function KeyEventHandle() {" + "\n"
            + "if((event.ctrlKey == true && (event.keyCode == 78 || event.keyCode == 82)) || (event.keyCode >= 112 && event.keyCode <= 123)) { " + "\n"
            + "event.keyCode = 0; event.cancelBubble = true; event.returnValue = false; }}" + "\n"
            
            + "var senditGO = function(){ document.theForm.submit(); }" + "\n"      
            + "<\/script>" + "\n"
            + "<body onload=\"senditGO();\" onkeydown=\"KeyEventHandle();\">" + "\n" 
            + "<form name=\"theForm\"method=\"post\" action=\""+this.eBookHost+"/engine/php/viewer2.php\">" + "\n" 
            + "<input type=\"hidden\" name=\"param\" value=\""+arg_URL+"\">" + "\n"
            + "</form>" + "\n" 
            + "\n" + "</body>" + "\n" + "</html>" ;
    return OpenHTML;  
  }
    

  function GetQuery(arg_Param) {
    var sParam    = "";
    var sLanguage = "en" ;
    if(arg_Param.length) {
      for(var i=0;i<arg_Param.length;i++) {
        if(arg_Param[i] != "") {
          // Section Confuse Error Process
          switch (this.ParameterList[i]) {
            case "gp"   :
            case "sbp"  : if(arg_Param[i] % 2 != 0) { arg_Param[i] = parseInt(arg_Param[i]) - 1;  } 
                          break;
            case "sep"  : if(arg_Param[i] % 2 == 0) { arg_Param[i] = parseInt(arg_Param[i]) + 1;  }
                          break;
          }
          sParam += this.ParameterList[i] + "=" + arg_Param[i]  + "&";           
        }      
      }
      
      // 2010.09.27.16.26 commented by tews for AllInOne 
      switch ( BrowserDetect.OS ) {
        case "iPhone/iPod"   : ; // iPad
        case "iPad"          : ; // iPad
        case "Android"  : ;
 
                                  switch (navigator.language) {
                                    case "ko-kr"  : sLanguage = "ko"     ;    break;  
                                    case "ko-KR"  : sLanguage = "ko"     ;    break;  
                                    case "ja-jp"  : sLanguage = "ja"     ;    break;
                                    case "ja-JP"  : sLanguage = "ja"     ;    break;
                                    default       : sLanguage = "en"     ;    break;
                                  }
                                  sParam += "ul=" + sLanguage ;
                                  break;

        case "Linux"    : ;
        case "Mac"      :  
                          switch (BrowserDetect.browser ) {
                            case "Explorer"   :
                                                sParam += "ul=" + navigator.browserLanguage;
                                                break;
                                                
                            case "Firefox"    :
                                                switch (navigator.language) {             
                                                  case "ko-kr-mac"  : sLanguage = "ko"    ;    break;  
                                                  case "ko-KR-mac"  : sLanguage = "ko"    ;    break;  
                                                  case "ja-jp-mac"  : sLanguage = "ja"    ;    break;
                                                  case "ja-JP-mac"  : sLanguage = "ja"    ;    break;
                                                  case "ko-kr"      : sLanguage = "ko"     ;    break;  
                                                  case "ko-KR"      : sLanguage = "ko"     ;    break;  
                                                  case "ja-jp"      : sLanguage = "ja"     ;    break;
                                                  case "ja-JP"      : sLanguage = "ja"     ;    break;
                                                  case "ja"         : sLanguage = "ja"     ;    break;
                                                  case "ko"         : sLanguage = "ko"     ;    break;
                                                  default           : sLanguage = "en"    ;    break;
                                                }
                                                sParam += "ul=" + sLanguage ;
                                                break;
                                                
                            case "Safari"     :
                                                switch (navigator.language) {
                                                  case "ko-kr"  : sLanguage = "ko"     ;    break;  
                                                  case "ko-KR"  : sLanguage = "ko"     ;    break;  
                                                  case "ja-jp"  : sLanguage = "ja"     ;    break;
                                                  case "ja-JP"  : sLanguage = "ja"     ;    break;
                                                  default       : sLanguage = "en"     ;    break;
                                                }
                                                sParam += "ul=" + sLanguage ;
                                                break;
                            default           :  // Chrome, Opera
                                                sParam += "ul=" + navigator.language ;
                                                break;
                          }
                          break;
  
        case "Windows"  : 
                          switch (BrowserDetect.browser ) {
                            case "Explorer"   :
                                                sParam += "ul=" + navigator.browserLanguage;
                                                break;
                            case "Safari"   :
                                                switch (navigator.language) {
                                                  case "ko-kr" : sLanguage = "ko"     ;    break;  
                                                  case "ko-KR" : sLanguage = "ko"     ;    break;  
                                                  case "ja-jp" : sLanguage = "ja"     ;    break;
                                                  case "ja-JP" : sLanguage = "ja"     ;    break;
                                                  default      : sLanguage = "en" ;    break;
                                                }
                                                sParam += "ul=" + sLanguage ;
                                                break;
                            default           : // Firefox, Chrome, Opera
                                                sParam += "ul=" + navigator.language ;
                                                break;
                          }
                          break;
      }
  
  


      return sParam;
    }  else {
      return false;
    }
  }
 
  
  function GetWndStyleType() {  
    
    var tmpFullScreen = ""  ;   

/*
  1. winStyle 이 지정이 되지 않았으면 1024 x 768를 기본으로 띄운다.
  2. 화면에서 사용할수 있는 역역의 크기가 1024x768 사이즈보다 작은경우 가용한 화면 사이즈에서 최대한 크게 보이도록 한다.
      
*/
    if ( this.winStyle == null ) { this.winStyle = 2 ; }
    if( ( screen.availWidth <= this.winLimitWidth || screen.availHeight <= this.winLimitHeight) ) {  this.winStyle = 0 ; }
     
/*
 
alert(
  "this.winStyle        : [" + this.winStyle + "]\n" + 
  "screen.WH            : " + screen.width + ","+  screen.height + "\n" + 
  "this.winWidth,Heihgt : " + this.winWidth + "," + this.winHeight
) ;  
*/


    this.winStyleName  = this.ViewerStyleList[this.winStyle]; 
    switch (this.winStyle) {              
      
      case 1  : // corporation customer window 
                // 사용자가 사이즈를 지정하고
                // 가용한 화면 사이즈가 1024x768 보다 큰경우
                if(this.winWidth < this.winLimitWidth)    {  this.winWidth  = this.winLimitWidth; }
                if(this.winHeight < this.winLimitHeight)  {  this.winHeight = this.winLimitHeight; }

                switch (BrowserDetect.browser ) {
                  
                  case "Explorer" :

                                    switch ( BrowserDetect.version ) {
                                      case 6  :
                                                this.winInnerWidth       = this.winWidth  ;
                                                this.winInnerHeight      = this.winHeight ;  
                                                break;
                                      default :
                                                this.winInnerWidth       = this.winWidth  - 2*this.Border ;  
                                                this.winInnerHeight      = this.winHeight - this.TitleBar - this.UrlBar - this.StatusBar - this.Border ;  
                                                break;
                                    }
                                    break;
                  
                  case "Chrome"   :  // 상태바가 없음
                                    this.winInnerWidth       = this.winWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = this.winHeight - this.TitleBar - this.UrlBar - this.Border ;  
                                    break;
                  case "Safari"   :  // UrlBar, StatusBar가 없음
                                    this.winInnerWidth       = this.winWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = this.winHeight - this.TitleBar - this.Border ;  
                                    break;
                  default         :
                                    this.winInnerWidth       = this.winWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = this.winHeight - this.TitleBar - this.UrlBar - this.StatusBar - this.Border ;  
                                    break;
                }
                
                this.winLeft    = (screen.availWidth  - this.winWidth ) / 2;
                this.winTop     = (screen.availHeight - this.winHeight) / 2;
                break;
    
      case 2 : // user customer window environemnt
                // 사용자가 사이즈를 지정하고
                // 가용한 화면 사이즈가 1024x768 보다 큰경우

                switch (BrowserDetect.browser ) {
                  case "Explorer" :
               
                                    switch ( BrowserDetect.version ) {
                                      case 6  :
                                                this.winInnerWidth       = this.winLimitWidth  ;  
                                                this.winInnerHeight      = this.winLimitHeight ;  
                                                break;
                                      default :
                                                this.winInnerWidth       = this.winLimitWidth  - 2*this.Border ;  
                                                this.winInnerHeight      = this.winLimitHeight - this.TitleBar - this.UrlBar - this.StatusBar - this.Border ;  
                                                break;
                                    }
                                    break;
                  
                  case "Chrome"   :  // 상태바가 없음
                                    this.winInnerWidth       = this.winLimitWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = this.winLimitHeight - this.TitleBar - this.UrlBar - this.Border ;  
                                    break;
                  case "Safari"   :  // UrlBar, StatusBar가 없음
                                    this.winInnerWidth       = this.winLimitWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = this.winLimitHeight - this.TitleBar - this.Border ;  
                                    break;
                  default         :
                                    this.winInnerWidth       = this.winLimitWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = this.winLimitHeight - this.TitleBar - this.UrlBar - this.StatusBar - this.Border ;  
                                    break;
                }
                
                this.winLeft       = (screen.availWidth  - this.winLimitWidth ) / 2;
                this.winTop        = (screen.availHeight - this.winLimitHeight) / 2;
                                                 
                
                break;
            
      case 3 :  // Full Screen  
                this.winLeft       = 0;
                this.winTop        = 0;

                
                switch (BrowserDetect.browser ) {
                  case "Explorer" : // IE는 Full Screen 모드를 지원하므로 Taskbar를 고려하지 않는다.
                                    this.winInnerWidth       = screen.width ;  
                                    this.winInnerHeight      = screen.height;  
                                    break;
                  case "Chrome"   :  // 상태바가 없음
                                    this.winInnerWidth       = screen.availWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = screen.availHeight - this.TitleBar - this.UrlBar - this.Border ;  

                                    break;
                  case "Safari"   :  // UrlBar, StatusBar가 없음
                                    this.winInnerWidth       = screen.availWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = screen.availHeight - this.TitleBar - this.Border ;  
                                    break;
                                    
                  default         :
                                    this.winInnerWidth       = screen.availWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = screen.availHeight - this.TitleBar - this.UrlBar - this.StatusBar - this.Border ;  
                                    break;
                }
                tmpFullScreen  = ", fullscreen=yes"; 
                break; 

      default : // case 0  Digitomi Default window
                this.winLeft       = 0;
                this.winTop        = 0;

                switch (BrowserDetect.browser ) {
                  case "Explorer" :
                                    switch ( BrowserDetect.version ) {
                                      case 6  :
                                                  this.winInnerWidth       = screen.availWidth  ;  
                                                  this.winInnerHeight      = screen.availHeight ;  
                                                  break;
                                      default   :
                                                  this.winInnerWidth       = screen.availWidth  - 2*this.Border ;  
                                                  this.winInnerHeight      = screen.availHeight - this.TitleBar - this.UrlBar - this.StatusBar - this.Border ;  
                                                  break;
                                    }
                                    break;
                  case "Chrome"   :  // 상태바가 없음
                                    this.winInnerWidth       = screen.availWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = screen.availHeight - this.TitleBar - this.UrlBar - this.Border ;  

                                    break;
                  case "Safari"   :  // UrlBar, StatusBar가 없음
                                    this.winInnerWidth       = screen.availWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = screen.availHeight - this.TitleBar - this.Border ;  
                                    break;

                  default         :
                                    this.winInnerWidth       = screen.availWidth  - 2*this.Border ;  
                                    this.winInnerHeight      = screen.availHeight - this.TitleBar - this.UrlBar - this.StatusBar - this.Border ;  
                                    break;
                }
                
//                this.winLeft    = (screen.availWidth  - this.winWidth ) / 2;
//                this.winTop     = (screen.availHeight - this.winHeight) / 2;
                break;
                       
    }

//     this.OpenStyle   = "top=" + this.winTop + ", left=" + this.winLeft + ", width=" + this.winInnerWidth + ", height=" + this.winInnerHeight + ", directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no" + tmpFullScreen ;
    
    switch (BrowserDetect.browser ) {
      case "Explorer" : ; 
      case "Opera"    : 
                        this.OpenStyle   = "top=" + this.winTop + ", left=" + this.winLeft + ", width=" + this.winInnerWidth + ", height=" + this.winInnerHeight + ", directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no" + tmpFullScreen ;
                        break;
      default         :
                        this.OpenStyle   = "top=" + this.winTop + ", left=" + this.winLeft + ", innerWidth=" + this.winInnerWidth + ", innerHeight=" + this.winInnerHeight + ", directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no" + tmpFullScreen ;
                        break;
    }
  }
  
  
  function GetMargins () {
    
// alert(BrowserDetect.OS);     
    switch ( BrowserDetect.OS ) {
      case "iPhone"   : ; // iPad
      case "Android"  : ;
                        break;
      case "Linux"    : ;
      case "Mac"      : ;

                        this.TitleBar         = 0 ;  
                        this.Border           = 0 ;
                        this.UrlBar           = 0 ;
                        this.StatusBar        = 0 ;
                        break;  

/*
                        switch ( BrowserDetect.OSversion ) {
                          default               :  // Macintosh 10
                                                  this.TitleBar         = 0 ;  
                                                  this.Border           = 0 ;
                                                  break;
                        }
                        
                        // Window 최신버전의 브라이저 기준임    
                        // 각 브라우저별로 수치를 확인해야함
                        switch (BrowserDetect.browser ) {
                          case "Firefox"  :
                                            this.UrlBar     = 0 ;
                                            this.StatusBar  = 0 ;    // 27 : Window 7 
                                            break;
                          case "Chrome"   :
                                            this.UrlBar     = 0 ;
                                            break;
                          case "Safari"   :
                                            break;

                          case "Opera"    :
                                            break;
                        }
                        break;
*/

                        

      case "Windows"  : ;
                        switch ( BrowserDetect.OSversion ) {
                          case "Windows 7"      :  
                          case "Windows Vista"  :  
                                                  this.TitleBar         = 29 ;  
                                                  this.Border           = 7 ;
                                                  break;

                          case "Windows Server 2003"   :  
                          case "Windows XP"     : 
                                                  this.TitleBar         = 26 ;  
                                                  this.Border           = 5 ;

                                                  break; 
                          case "Windows 2000"   :  
                                                  this.TitleBar         = 26 ;  
                                                  this.Border           = 5 ;
                                                  break;
                        }
                        
                        // Window 최신버전의 브라이저 기준임    
                        // 각 브라우저별로 수치를 확인해야함
                        switch (BrowserDetect.browser ) {
                          case "Explorer" : // 
                                            switch ( BrowserDetect.version ) {
                                              case  6   :
                                                          this.UrlBar     = 0 ;
                                                          this.StatusBar  = 24 ;     
                                                          break;

                                              default   :
                                                          this.UrlBar     = 27 ;
                                                          this.StatusBar  = 24 ;    
                                                          break;
                                            }
                          case "Firefox"  :
                                            this.UrlBar     = 27 ;
                                            this.StatusBar  = 24 ;    // 27 : Window 7 
                                            break;
                          case "Chrome"   :
                                            this.UrlBar     = 27 ;
                                            break;
                          case "Safari"   :
                                            this.UrlBar     = 0 ;
                                            this.StatusBar  = 0 ;     
                                            break;

                          case "Opera"    :
                                            this.UrlBar     = 0 ;
                                            this.StatusBar  = 0 ;     
                                            break;

                        }
                        break;
    }
  }

  //  Book open function : bc, co, gp, sbp, sep, ct, ui
  function OpenBook() {
 
    //*************************************************************************//
    // for domain replace
    //*************************************************************************//
    this.eBookHost  = "http://ebook2.webcatalog.jp"  ;
/*
    //  for Real Server  
    var iBookCode = parseInt(arguments[0]) ;
 
    if ( iBookCode <  100000 ) {  // bc 
      this.eBookHost  = "http://main2.netfly2.jp"   ;
    } else {
      this.eBookHost  = "http://ebook2.webcatalog.jp"  ;
    }
*/

    //  for Hera Server  
    var iBookCode = parseInt(arguments[0]) ;
 
    if ( iBookCode <  100000 ) {  // bc 
      this.eBookHost  = "http://ebook.webcatalog.jp"   ;
    } else {
      this.eBookHost  = "http://ebook2.webcatalog.jp"  ;
    }



 
    //  for test Server  
/*
    var iBookCode = parseInt(arguments[0]) ;
 
    if ( iBookCode <  100000 ) {  // bc 
      this.eBookHost  = "http://main.mars.jp"   ;
    } else {
      this.eBookHost  = "http://main2.mars.jp"  ;
    }
*/
 
    this.eBookUrl   = this.eBookHost + ":" + this.Port + "/engine/isapi/frame.dll?";
    
    // NOTE : process v1.6 , v1.8 param type for naver 
    if(arguments.length > 7){
      if(arguments.length >= 11) //We should call Open_eBook() with arg_bc, arg_ml, arg_vr. Because, Open_eBook() uses those parameter directly.
      Open_eBook(arguments[0], "", "", "", "", arguments[5], "", "fromv20", arguments, "tov16", arguments[10]);
      else Open_eBook(arguments[0], "", "", "", "", arguments[5], "", "fromv20", arguments, "tov16", "");
      return;
    }

    var sQuery = this.GetQuery(arguments);
  
    if(!sQuery) {
      alert("service fail!!");
      return false;
    }

  
    if ( iBookCode <  100000 ) {  // bc 
      this.GetWinStyle();
      var eBookClient = window.open("about:blank", this.winStyleName +"_"+ Math.round(Math.random() * 100), this.winStyle);
    } else {
      this.GetMargins() ;
      this.GetWndStyleType();
      var eBookClient = window.open("about:blank", this.winStyleName +"_"+ Math.round(Math.random() * 100), this.OpenStyle);
    }
    eBookClient.document.write(this.SetLaunchHTML(sQuery));
    eBookClient.document.close();
    
  }
  
  
  //*************************************************************************//
  // 이전버전에만 사용됨
  //*************************************************************************//
  function GetWinStyle() {  
    var tmpFullScreen = ""  ;   
    
    if ( this.winStyle == null ) { this.winStyle = 2 ; }
    if( ( screen.width <= this.winLimitWidth || screen.height <= this.winLimitHeight) ) {  this.winStyle = 0 ; }
     
// alert(this.winStyle) ;  
   
    switch ( this.winStyle ) {              
      case 0  : // Digitomi Default window 
                this.winStyleName  = this.ViewerStyleList[0]; 
                this.winTop     = 0 ;                                   
                this.winLeft    = 0 ;
                this.winWidth   =  screen.width  ;
                this.winHeight  =  screen.height ;
                if ( screen.width  != screen.availWidth  ) { this.winWidth  = screen.width  - 57 } // TaskBar Width
                if ( screen.height != screen.availHeight ) { this.winHeight = screen.height - 29 } // TaskBar Height

                break;
      
      case 1  : // corporation customer window 
                this.winStyleName  = this.ViewerStyleList[1]; 
                if(this.winWidth < this.winLimitWidth)    {  this.winWidth  = this.winLimitWidth; }
                if(this.winHeight < this.winLimitHeight)  {  this.winHeight  = this.winLimitHeight; }
                this.winLeft    = (screen.width  - this.winWidth) / 2;
                this.winTop     = (screen.height - this.winHeight) / 2;
                break;
    
      case 2 : // user customer window environemnt
                this.winStyleName  = this.ViewerStyleList[2]; 
                this.winWidth      = this.winLimitWidth;  
                this.winHeight     = this.winLimitHeight;  
                this.winLeft       = (screen.width  - this.winWidth) / 2;
                this.winTop        = (screen.height - this.winHeight) / 2;
                break;
            
      case 3 :  // Full Screen  
                this.winStyleName  = this.ViewerStyleList[3]; 
                this.winWidth      = screen.width;  
                this.winHeight     = screen.height;  
                this.winLeft       = 0;
                this.winTop        = 0;

                // Windows 2003 
                if( !(IsWin2k3()) ){ tmpFullScreen  = ", fullscreen=yes";    }
                break; 
      case 4  : // corporation customer window 
                this.winStyleName  = this.ViewerStyleList[1]; 
                if(this.winWidth < this.winLimitWidth)    {  this.winWidth  = this.winLimitWidth; }
                if(this.winHeight < this.winLimitHeight)  {  this.winHeight  = this.winLimitHeight; }
                this.winLeft    = 0;
                this.winTop     = 0;
                break;
                                
      default : ;                            
    }
    this.winStyle    = "top=" + this.winTop + ", left=" + this.winLeft + ", width=" + this.winWidth + ", height=" + this.winHeight + ", directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no" + tmpFullScreen ;
  }

  function GetBorderSize () {
    var aBorderInfo = new Array();
    if (this.IsWinXP() ) {
      aBorderInfo[0]  = 6 ;
      aBorderInfo[1]  = 32 ;
    } else {
      aBorderInfo[0]  = 5 ;
      aBorderInfo[1]  = 29 ;
    }
    return aBorderInfo;
  }  
  
  function IsWin2k3() {
    if ( navigator.userAgent.indexOf("Windows NT 5.2") > 1 ) { return true ; }
    return false // WinMe, Win9x, Win2k  
  }       
    
  function IsWinXP() {
    if ( navigator.userAgent.indexOf("Windows NT 5.1") > 1 ) { return true ; }
    return false ; // WinMe, Win9x, Win2k, Win2k  
  }    

  function SelfOpen() {

    var iBookCode = parseInt(arguments[0]) ;
 
    if ( iBookCode <  100000 ) {  // bc 
      switch (BrowserDetect.browser ) {
        case "Explorer" : ; //  
                          break;
        default         :
                          window.open( this.sNoteEnvURL  , "" , this.sNoteEnvStyle);
                          return ;
                          break;
      }
      
      this.eBookHost  = "http://ebook.webcatalog.jp"   ;
    } else {
      this.eBookHost  = "http://ebook2.webcatalog.jp"  ; 
    }

    var sQuery = this.GetQuery(arguments);

    if(!sQuery) {
      alert("service fail!!");
      return false;
    }

    this.GetWinStyle();
    var aBorderInfo = this.GetBorderSize();
    this.winWidth   += 2 * aBorderInfo[0];
    this.winHeight  += aBorderInfo[0] + aBorderInfo[1];

    var iRemovePosLeft  = (screen.width - this.winWidth) / 2;
    var iRemovePosTop   = (screen.height - this.winHeight) / 2;
    if(iRemovePosLeft < 0)  {  iRemovePosLeft = 0;  }
    if(iRemovePosTop < 0)   {  iRemovePosTop = 0;   }
    moveTo(iRemovePosLeft, iRemovePosTop);
    
//     document.open();
    document.write(this.SetLaunchHTMLForSelf(sQuery));
    document.close();
    window.name = this.winStyleName;
    resizeTo(this.winWidth, this.winHeight);
  }

  // 2010.09.27.16.26 commented by tews for AllInOne
  var BrowserDetect = {
    init: function () {
      this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
      this.version = this.searchVersion(navigator.userAgent)
        || this.searchVersion(navigator.appVersion)
        || "an unknown version";
      this.OS = this.searchString(this.dataOS) || "an unknown OS";
      this.OSversion = this.searchString(this.dataOSversion) || "an unknown version";

    },
    searchString: function (data) {
      for (var i=0;i<data.length;i++)  {
        var dataString = data[i].string;
        var dataProp = data[i].prop;
        this.versionSearchString = data[i].versionSearch || data[i].identity;
        if (dataString) {
          if (dataString.indexOf(data[i].subString) != -1)
            return data[i].identity;
        }
        else if (dataProp)
          return data[i].identity;
      }
    },
    searchVersion: function (dataString) {
      var index = dataString.indexOf(this.versionSearchString);
      if (index == -1) return;
      return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
    },
    
    dataBrowser: [
      {
        string: navigator.userAgent,
        subString: "Chrome",
        identity: "Chrome"
      },
      {   string: navigator.userAgent,
        subString: "OmniWeb",
        versionSearch: "OmniWeb/",
        identity: "OmniWeb"
      },
      {
        string: navigator.vendor,
        subString: "Apple",
        identity: "Safari",
        versionSearch: "Version"
      },
      {
        prop: window.opera,
        identity: "Opera"
      },
      {
        string: navigator.vendor,
        subString: "iCab",
        identity: "iCab"
      },
      {
        string: navigator.vendor,
        subString: "KDE",
        identity: "Konqueror"
      },
      {
        string: navigator.userAgent,
        subString: "Firefox",
        identity: "Firefox"
      },
      {
        string: navigator.vendor,
        subString: "Camino",
        identity: "Camino"
      },
      {    // for newer Netscapes (6+)
        string: navigator.userAgent,
        subString: "Netscape",
        identity: "Netscape"
      },
      {
        string: navigator.userAgent,
        subString: "MSIE",
        identity: "Explorer",
        versionSearch: "MSIE"
      },
      {
        string: navigator.userAgent,
        subString: "Gecko",
        identity: "Mozilla",
        versionSearch: "rv"
      },
      {     // for older Netscapes (4-)
        string: navigator.userAgent,
        subString: "Mozilla",
        identity: "Netscape",
        versionSearch: "Mozilla"
      }
    ],
    dataOS : [
      {
        string: navigator.platform,
        subString: "Win",
        identity: "Windows"
      },
      {
        string: navigator.platform,
        subString: "Mac",
        identity: "Mac"
      },
      {
           string: navigator.userAgent,
           subString: "iPhone",
           identity: "iPhone/iPod"
        },
    {
       string: navigator.userAgent,
       subString: "iPad",
       identity: "iPad"
    },
    {
       string: navigator.userAgent,
       subString: "Android",
       identity: "Android"
    },
      {
        string: navigator.platform,
        subString: "Linux",
        identity: "Linux"
      }
      
    ]
 , 
    dataOSversion : [
      {
        string: navigator.userAgent,
        subString: "Windows NT 6.1", 
        identity: "Windows 7"
      },
      {
        string: navigator.userAgent,
        subString: "Windows NT 6.0",
        identity: "Windows Vista"
      },      
      {
        string: navigator.userAgent,
        subString: "Windows NT 5.2",
        identity: "Windows Server 2003"
      },
      {
        string: navigator.userAgent,
        subString: "Windows NT 5.1",
        identity: "Windows XP"
      },
      {
        string: navigator.userAgent,
        subString: "Windows NT 5.0",
        identity: "Windows 2000"
      } ,

      {
        string: navigator.userAgent,
        subString: "Mac OS X",
        identity: "Macintosh 10"
      }    
    
    ]
  
  };
  
  BrowserDetect.init();



  OpenEBook = new eBookOpener();


