﻿
  function InitParameters(AVO) {
    Targethandle = AVO.Targethandle;
  }

  function RestoreParameters(AVO) {
    AVO.Targethandle = Targethandle;
  }


  function Run() {

    if ((document.all.LiveScanObject != null)) {
    
      if (typeof(document.all.LiveScanObject.ElevateX9) == 'undefined') {
        alert(typeof(document.all.LiveScanObject.ElevateX9));
      }else{    
      
        if (UploaderStarted) {return}    
        if (TimerID != 0) { clearInterval(TimerID); TimerID = 0};    
        UploaderStarted = true;
        
        
        InitParameters(document.all.LiveScanObject);
        
        xUpload = document.all.LiveScanObject.ElevateX9();
        

        if (xUpload == null) {
          alert("권한 상승을 실패 해서 GG");
        } else {
          
          RestoreParameters(xUpload);
          xUpload.StartRun9();  
        }
      }
    }
  }

   function StartScan()
   {
    //ActiveX 실행
      
      try 
      {
           // var request_os = window.navigator.appVersion;
           // var str14;
             
           // str14 = request_os.substring(request_os.indexOf("Windows"),request_os.indexOf("Windows")+14);

           // if(str14=="Windows NT 6.0") 
           // {
               // document.all.LiveScanObject.ScanCreate(); 
           // }
           // else
           // {
           // 타이머에 의해 1번만 실행이 되도록
          
            UploaderStarted = false;
            TimerID = setInterval("Run()", 1000);

              //document.all.LiveScanObject.ExecuteScan(); 
           //}
      }
      catch(e)
      {
           if(e="[object Error]")
           {
               location.reload();  
               alert("화면 상단의 ActiveX를 설치하시기 바랍니다.");
           }
      }
      finally
      {
         return false; 
      }
   }
    
   function DetectActiveXControl()
   {
       try
       {
           //var request_os = window.navigator.appVersion;
           //var str14;
           var xObj;  
           //str14 = request_os.substring(request_os.indexOf("Windows"),request_os.indexOf("Windows")+14);
           
           //if(str14=="Windows NT 6.0") 
           //{
           //     xObj = new ActiveXObject("APOLiveScanViewer.LiveScanViewer");
           //}
           //else 
           //{
                xObj = new ActiveXObject("APOLiveSCAN.APOLiveScanCtrl.1");
           //}

           if(xObj)
               return true;
           else
               return false;
       }
       catch(ex)
       {
           return false;
       }
   }
  
//  function  EmbedObject()
//  {
//       var str = "";
//       var request_os = window.navigator.appVersion;
//       var str14;
//         
//       str14 = request_os.substring(request_os.indexOf("Windows"),request_os.indexOf("Windows")+14);
//       
//       if(str14=="Windows NT 6.0") 
//       {
//            str = "<OBJECT ID='LiveScanObject' WIDTH=0 HEIGHT=0 CODEBASE='http://livescan.duzonapo.co.kr/livescan/APOLiveScanViewer.cab#Version=1,0,0,5' CLASSID='CLSID:165161CB-5DDD-42FD-8E6F-56C1937F98B7'>"+"</OBJECT>"
//       }
//       else
//       {
//            str = "<OBJECT ID='LiveScanObject' WIDTH=420 HEIGHT=153 codebase='http://livescan.duzonapo.co.kr/livescan/APOLiveScan.cab#Version=2008,7,24,4' CLASSID='CLSID:F16CB82D-7B61-4C81-9656-0E8A20E29843'> "+                   
//                                "<PARAM NAME='_Version' VALUE='65536'>"+
//                                "<PARAM NAME='_ExtentX' VALUE='2646'>"+
//                                "<PARAM NAME='_ExtentY' VALUE='1323'>"+
//                                "<PARAM NAME='_StockProps' VALUE='0'>"+
//                         "</OBJECT>";
//       }
//         document.write(str);
//  }
  
  function OS_Object()
  {
       var tmp = "";
       //var request_os = window.navigator.appVersion;
       //var str14;
         
       //str14 = request_os.substring(request_os.indexOf("Windows"),request_os.indexOf("Windows")+14);
       //if(str14=="Windows NT 6.0") 
       //{
       //     tmp = "<table width='447' border='0' cellspacing='0' cellpadding='0'>"+
       //           "<tr><td><img src='images/Livesan_but01.gif' /></td></tr>"+
       //           "<tr><td align='center' valign=top><div>"+
       //           "<OBJECT ID='LiveScanObject' WIDTH=0 HEIGHT=0 CODEBASE='http://livescan.duzonapo.co.kr/livescan/APOLiveScanViewer.cab#Version=1,0,0,8' CLASSID='CLSID:165161CB-5DDD-42FD-8E6F-56C1937F98B7'>"+"</OBJECT>"+
       //           "</div></td></tr>"+
       //           "<tr><td><img src='images/Livesan_but02.gif' onClick='ScanStart();' style=\"cursor:pointer\"></td></tr></table>";
       //}
       //else
       //{//"<OBJECT ID='LiveScanObject' WIDTH=416 HEIGHT=153 codebase='http://172.16.1.132/livescan/dzLiveScan3.cab#Version=1,0,0,57' CLASSID='CLSID:8DBB7B0B-4DA0-4F7C-8E6D-EC7A68A9EB22'> "+                   
            tmp = "<table width='444' border='0' cellspacing='0' cellpadding='0' background='images/05sub03_09.gif'>" +
                  "<tr><td><img src='images/05sub03_07.gif'></td></tr>" +
                  "<tr><td align='center' valign=top><div>"+
                  "<OBJECT ID='LiveScanObject' WIDTH=416 HEIGHT=153 codebase='http://livescan.duzonapo.co.kr/livescan/dzLiveScan3.cab#Version=1,0,1,1' CLASSID='CLSID:8DBB7B0B-4DA0-4F7C-8E6D-EC7A68A9EB22'> "+                   
                                "<PARAM NAME='_Version' VALUE='65536'>"+
                                "<PARAM NAME='_ExtentX' VALUE='2646'>"+
                                "<PARAM NAME='_ExtentY' VALUE='1323'>"+
                                "<PARAM NAME='_StockProps' VALUE='0'>"+
                         "</OBJECT>"+
                  "</div></td></tr>" +
                  "<tr><td><img src='images/05sub03_08.gif'></td></tr>" +
                  "<tr><td background='images/05sub03_10.gif'>"+
                  "<div style='text-align:right; height:23px; padding-top:5px; padding-right:20px'> "+
                  "<img src='images/scan_ok.gif' onClick='ScanStart();' class=btn onMouseOver='javascript:this.src=\"images/scan_ok_ovr.gif\"' onMouseOut='javascript:this.src=\"images/scan_ok.gif\"' /> "+
                  "<img src='images/scan_cancel.gif' onClick='StopScan();' class=btn onMouseOver='javascript:this.src=\"images/scan_cancel_ovr.gif\"' onMouseOut='javascript:this.src=\"images/scan_cancel.gif\"' /> </div></td></tr>"+
                  "<tr><td><img src='images/05sub03_11.gif'></td></tr>"+
                  "</table>";
       //}
       document.write(tmp);
  }


