
var     browser=0;
if ( document.all ) browser=1; else if ( document.layers ) browser=2;

  function pluginDetected() {
    if ( browser == 1 ) { 
      document.writeln('<SCRIPT LANGUAGE="VBScript"\>');
      document.writeln('on error resume next');
      document.writeln('ipix1 = IsObject(CreateObject("IPIX.Viewers.5"))');
      document.writeln('ipix2 = IsObject(CreateObject("IPIX.ActiveXCtrl.2"))');
      document.writeln('ipix3 = IsObject(CreateObject("IPIX.ActiveXCtrl.5"))');
      document.writeln('If ipix1 = True or ipix2 = True or ipix3 = True Then');
      document.writeln('ipixmode = 1');
      document.writeln('Else');
      document.writeln('ipixmode = 0');
      document.writeln('End if');
      document.writeln('</SCRIPT\>');
      return ipixmode;
    } else if ( browser == 2 ) { 
      navigator.plugins.refresh(true);
      numPlugins = navigator.plugins.length;
      if (numPlugins > 0) {
        for (k = 0; k < numPlugins; k++) {
          plugin = navigator.plugins[k];
          if (plugin.description.indexOf("IPIX") != -1) {
            numTypes = plugin.length;
            for (j = 0; j < numTypes; j++) {
              mimetype = plugin[j];
              if (mimetype)       {
                if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("ipx") != -1)) {
                  return 1;
                }
              }
            }
          }
        }
      }
      return 0;
    }
  }

  function putIPX(fname,width,height){
//	  alert('put iPIX');
    if ( browser == 1 ) { 
      document.writeln('      <object id="IpixX1" width="' + width + '" height="' + height + '"');
      document.writeln('        classid="clsid:11260943-421B-11D0-8EAC-0000C07D88CF"');
      document.writeln('        codebase="http://www.ipix.com/download/ipixx.cab#version=6,2,0,5" name="ipix" vspace="0" hspace="0"');
      document.writeln('        border="0">');
      document.writeln('        <param name="_Version" value="65536">');
      document.writeln('        <param name="_ExtentX" value="11924">');
      document.writeln('        <param name="_ExtentY" value="9278">');
      document.writeln('        <param name="_StockProps" value="0">');
      document.writeln('        <param name="IPXFILENAME" value="' + fname +'">');
      document.writeln('      </object>');
    } else if ( browser == 2 ) { 
      document.writeln('      <embed src="' + fname + '"');
      document.writeln('        width="' + width + '" height="' + height + '" palette="FOREGROUND"');
      document.writeln('        type="application/x-ipix"');
      document.writeln('        pluginspage="http://www.ipix.com/cgi-bin/download.cgi"');
      document.writeln('        name="ipix" vspace="0" hspace="0" border="0"');
      document.writeln('        _version="65536" _extentx="11924" _extenty="9278"');
      document.writeln('        _stockprops="0" ipxfilename="' + fname + '">');
      document.writeln('      </embed>');
    }
  }

  function putJava(fname,width,height){
    document.writeln('      <applet archive="/images/ipix/IpixViewer.jar" name="IpixViewer" code="IpixViewer.class" codebase="/ipx"');
    document.writeln('        width="' + width + '" height="' + height + '" vspace="0" hspace="0">');
    document.writeln('        <param name="URL" value="' + fname + '">');
    document.writeln('        <param name="SpinSpeed" value="5">');
    document.writeln('        <param name="SpinStyle" value="flat">');
    document.writeln('        <param name="Toolbar" value="off">');
    document.writeln('        <param name="splash" value="ipx/ipix_bg_logo.gif">');
    document.writeln('      </applet>');
  }
  
  
  
  
  function putError(message,width,height) {
	document.writeln('        <table width="'+width+'" cellpadding=0 cellspacing=0 border=0><tr>');
    document.writeln('        <td><img src="img/empty.gif" width=1 height='+height+'></td>');
    document.writeln('        <td><b>Ошибка:</b>' + message + '</b></td>');
    document.writeln('        </tr></table>');
  }

function putipx(fname,width,height, msg) 
{
//	if ( browser>0 ) 
	if ( 1 ) 
	{
		if ( navigator.javaEnabled() ) 
			putJava(fname,width,height);
		else 
			if ( pluginDetected() ) 
			{
				putIPX(fname,width,height);
			} 
			else  
			{ 
				if(msg!='') alert(msg); 
//				alert('runaway');
				putIPX(fname,width,height); 
				open('/alterhome/','_self','');
			}
    } 
	else putError("Не удалось определить тип броузера",width,height);
}

function putstatipx(fname,width,height, msg) 
{
    browser=0;

    if ( document.all ) browser=1; else if ( document.layers ) browser=2;
//    if ( browser>0 ) {
    if ( 1 ) {
      if ( pluginDetected() ) {
        putIPX(fname,width,height);
      } else if ( navigator.javaEnabled() ) {
        putJava(fname,width,height);
//	    document.writeln('      <div style="visibility:hidden">');
//	    putIPX(fname,width,height); 
//	    document.writeln('      </div>');

      } else  {
        putIPX(fname,width,height);
	if(msg!='') alert(msg); 
      }
    } else {
      putError("Не удалось определить тип броузера",width,height);
    }
}

