//Portions are Copyright (c) 2000-2005, Mobular Technologies&#174;, Inc.  All Rights Reserved.
//Mobular and Mobular Technologies are Registered Trademarks of Mobular
//Technologies, Inc.
//All rights reserved.  Unauthorized reproduction prohibited.
//http://www.mobular.com/
//
 
function I2U_gotoS2D2(theForm, event) {
  var downloadType = "";
 
  // ALWAYS check to see which one was checked FIRST
  var pos = 0;  
  for ( var i=0; i < theForm.s2d_option.length; i++ ) {
     if ( theForm.s2d_option[i].checked  ) {
          pos = i;
     }
  }
  
  // get the value of that array position and see if its an exe
  if ( theForm.s2d_option[pos].value.indexOf( ".exe" ) != -1  ) {
    this.gotoS2D(theForm, event);
    return false;
  } else {     
      // we've got a non standard result for s2d here.. handle it
  
      this.eLdCno(0);
      this.zapPrintFrame(0);
      var pRng2 = "";
      var _p = 1;  
      var _si = 0;
      if ( theForm.doclist ) {
        _si = parseInt( theForm.doclist.options[theForm.doclist.options.selectedIndex].value, 10 );    
      }  
      
      _cd = _si-1;
      var _dl = this.prtDocs[_cd].split('|');
      this.rAr[0] = _dl[2];
      this.rAr[1] = _dl[3];
      if(_p == 1) {
        var _r =  this.rAr[0]+","+this.rAr[1];        
        this._pdf = 1;
        this.trackS2D();
        var _t_exe = this.exe;
        this.exe = 0;
        this.doClickThrough("about:blank", this.ifr_h, this.ifr_w, 1);
        this.exe = _t_exe;
        this.v_pg = 0;        
        this.doClickThrough(this.qualifyUrl("print/" + _dl[6]), this.ifr_h, this.ifr_w, 1);
      }
      this._pdf = 0;
      return false;      
   
      downloadType = theForm.s2d_option[pos].value;    
  
      this.trackS2D();
      if (this.is_mac) {
        if (!event.ctrlKey) {
          return this.shwEr(this.erMsg[4], -1);
        } else {
          return true;
        }
      } else if (this.is_linux) {
        if (event.modifiers != "12") {
          return this.shwEr(this.erMsg[5], -1);
        } else {
          return true;
        }
      } else {
        self.location.href = downloadType;
        return false;
      }
  
  }
  
}

function I2U_showS2D2() {
   this.showS2D();
   
   var html = document.getElementById('showFrame').innerHTML;
   
   html = html.replace(/\n/gi, "<newline>");
   
   html = html.replace(/onFocusHere/gi, 'onFocus="document.s2dForm.s2d_option[document.s2dForm.s2d_option.length-1].checked = true;"');
   
   html = html.replace(/\<newline\>/gi,'\n');
   
   document.getElementById('showFrame').innerHTML = html;
}

function I2U_switchLayout2() {  

  this.switchLayout();
  eengine.swapLabel("mobularFlashLabel", this.flashObj.useFlash, eengine.eeLabels.flashOff,eengine.eeLabels.flashOn);

}

function I2U_writePage2(n) {

  this.writePage(n);
  eengine.swapLabel("mobularFlashLabel", this.flashObj.useFlash, eengine.eeLabels.flashOff,eengine.eeLabels.flashOn);

}

function initializeCover()
{

  var divName = "showFrame";

  if ( ( g_ekitCover != "" ) && ( prtDocs.length > 1 ) ) 
  {

    // Modify g_showShow so that when the user goes back to the kit cover they
    // do not see the single page.

    var new_cover = "";
    
    new_cover += "\n<table width=\"814\" height=\"500\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
    new_cover += "\n  <tr valign=\"middle\">";
    new_cover += "\n    <td align=\"center\" valign=\"middle\">";
    new_cover += "\n  	   <h2>";
    new_cover += g_engineTitle;
    new_cover += "\n  	   </h2>";
    new_cover += "\n  	   <br />";
    new_cover += "\n  	   is loading.  Please be patient.";
    new_cover += "\n  	   <br />";
    new_cover += "\n  	   <br />";
    new_cover += "\n  	   <br />";
    new_cover += "\n  	   <img src=\"images/loading.gif\" alt=\"\" />";
    new_cover += "\n    </td>";
    new_cover += "\n  </tr>";
    new_cover += "\n  <tr>";
    new_cover += "\n    <td><img src=\"images/c.gif\" alt=\"\" width=\"1\" height=\"10\" border=\"0\" /></td>";
    new_cover += "\n  </tr>";
    new_cover += "\n</table>";

    g_showShow = new_cover;
    document.getElementById(divName).innerHTML = new_cover;

  }

  document.getElementById(divName).style.visibility = "VISIBLE";
  
}

function I2U_launchVideo(url, _poph, _popw, _fw, st) {

  // Initialize the url to the php file that will launch the video file.
  var php_url = '';
  
  // Get the filename of the video file from the url
  var obj = /(https?|ftp):\/\/([-A-Z0-9.]+)(\/[-A-Z0-9+&@#\/%=~_|!:,.;]*)?(\?[-A-Z0-9+&@#\/%=~_|!:,.;]*)?/i;
  var file = url.replace(eval(obj), "$3");

  // Get the file extension from the filename
  obj = /.+\.([^.]{3})$/i;
  var file_extension = file.replace(eval(obj), "$1");

  // Check the file extension to see if it is a support video file to display

  switch (file_extension)
  {

    case 'wmv':
      this.launchVideoWMV (url, _poph, _popw);     
      break;
      
    case 'swf':
      this.launchVideoSWF (url, _poph, _popw);     
      break;

	  default:
      alert ('The selected video format (' + file_extension + ') is not currently supported.');
      return false;

  }
  
  if ( this.exe ) this.shwEr(this.erMsg[27], -1);

  // write tracking image if the path is not to a mobular perl file
  if ( ( url.indexOf("mobular.net") == -1 ) && ( url.indexOf(".pl") == -1 ) )
     if ( this._pdf == 0 )
        this.writeTrack("redir.gif", "url="+url.replace('?','&'), 1);
 
  this.cno++;
   
  return false;

}

function I2U_openVideoURL(html, _poph, _popw) {

  // Load the video player into the video object div tag
  var video_object = document.getElementById('video_object');  
  if (video_object) { video_object.innerHTML = html; }


  // Now that the player is loaded, size and display the window/widget into which the player 
  // was embedded.
  var video_div = document.getElementById('video');
  
  // Add an additional 20px for the height of the the "close [x]" bar
  _poph += 20;
  
  // Set the location of the video on the screen and then make it visible.

  var obj = video_div;
  if (obj)
  {
    var obj = video_div;
    if (obj.style)
    {
      y_scroll_offset = 0;
      if (document.all)
      {      
        // Add an additional 2px for the div tag border to the for IE only.
        _poph += 2;
        _popw += 2;
      
        y_scroll_offset = ( document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop );
        obj.style.top = y_scroll_offset + 100;
        obj.style.left = 0 + (document.getElementById('showFrame').offsetWidth/2) - (_popw/2);
        obj.style.width = _popw;
        obj.style.height = _poph;
      }
      else if (document.getElementById)
      {
        y_scroll_offset = window.pageYOffset;
        obj.style.top = y_scroll_offset + 100 + 'px';
        obj.style.left = 0 + (document.getElementById('showFrame').offsetWidth/2) - (_popw/2) + 'px';
        obj.style.width = _popw + 'px';
        obj.style.height = _poph + 'px';
     }

     obj.style.visibility='visible';
     
    }
  }       
}

function I2U_closeVideo() {

  var video_div = document.getElementById('video');
  var video_object = document.getElementById('video_object');
  
  if (video_object) { video_object.innerHTML = ""; }
  if (video_div) { video_div.style.visibility = 'hidden'; }
  
}

function I2U_launchVideoWMV(url, _poph, _popw) {

  // Add the height of the Windows Media Player
  _poph += 70;
  
  // Prep the video player for use
  var g_video = "";
      g_video += "\n<object id=\"video\" width=\"" + _popw + "\" height=\"" + _poph + "\"";
      g_video += "\n	classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\"";
      g_video += "\n	standby=\"Loading Windows Media Player components...\"";
      g_video += "\n	type=\"application/x-oleobject\">";
      g_video += "\n";
      g_video += "\n<param name=\"url\" value=\"" + url + "\">";
      g_video += "\n<param name=\"showcontrols\" value=\"true\">";
      g_video += "\n<param name=\"autostart\" value=\"true\">";
      g_video += "\n<param name=\"showstatusbar\" value=\"true\">";
      g_video += "\n<param name=\"stretchtofit\" value=\"false\">";
      g_video += "\n<param name=\"showdisplay\" value=\"false\">";
      g_video += "\n";
      g_video += "\n<embed type=\"application/x-mplayer2\" src=\"" + url + "\" width=\"" + _popw + "px\" height=\"" + _poph + "px\" showcontrols=\"1\" autostart=\"1\" stretchtofit=\"0\" showstatusbar=\"1\" showdisplay=\"0\" name=\"MediaPlayer\"></embed>";
      g_video += "\n";
      g_video += "\n</object>";

  this.openVideoURL(g_video, _poph, _popw)
  
}

function I2U_launchVideoSWF(url, _poph, _popw) {

  // Add the height of the Windows Media Player
  //_poph += 70;
  
  // Prep the video player for use
  var g_video = "";
      g_video += "\n<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"";
      g_video += "\n  codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\"";
      g_video += "\n  width=\"" + _popw + "\""; 
      g_video += "\n  height=\"" + _poph + "\""; 
      g_video += "\n  id=\"video\">";
      g_video += "\n";
      g_video += "\n<param name=movie value=\"" + url + "\">";
      g_video += "\n<param name=quality value=high>";
      g_video += "\n<param name=bgcolor value=#ffffff>";
      g_video += "\n";
      g_video += "\n<embed src=\"" + url + "\" quality=high bgcolor=#ffffff width=\"" + _popw + "\" height=\"" + _poph + "\" name=\"video\" align=\"\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>";
      g_video += "\n";
      g_video += "\n</object>";

	  this.openVideoURL(g_video, _poph, _popw)
  
}


