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)
{

	if (browser == 1)
	{
		document.writeln('      <object id="IpixX1" width="' + width + '" height="' + height + '"');
		document.writeln('        classid="clsid:11260943-421B-11D0-8EAC-0000C07D88CF"');
		document.writeln('        codebase="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="IpixViewer.jar" name="IpixViewer" code="IpixViewer.class"');
    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.write('      </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 style="text-align:center"><b>Error:&nbsp;</b>' + message + '</b></td>');
	document.writeln('        </tr></table>');
}

function putipx(fname, width, height, size)
{

	browser = 0
	fname = "http://www.katerina.msk.ru/v2/ipix/" + fname + size;
	if (document.all || document.getElementById)
		browser = 1;
	else if (document.layers)
		browser = 2;
    alert(browser)
	if ( browser > 0 )
	{
	
		if (pluginDetected())
		{
					putIPX(fname + ".ips", width, height);
		}
		else if (navigator.javaEnabled())
		{
			putJava(fname + ".ipx", width, height);
		}
		else
		{
			putIPX(fname + ".ips", width, height);
		}
	}
	else
	{
	  putError("The \"Virtual Tour\" requires Internet Explorer...", width, height);
	}
}

function puttext(id)
{
	if ( browser > 0 )
	{
		if (pluginDetected())
		{
			document.write("<a href=\"javascript: openBigIpix('" + id + "')\" class=a3>Full</a>");
		}
		else
		{
			document.write('<img src="pic/null.gif" width=1 height=1 border=0 alt="">');
		}
	}
	else
	{
	  putError("Unknown browser", width, height);
	}
}

function puttext1()
{
	if ( browser > 0 )
	{
		if (pluginDetected())
		{
			document.write('<img src="pic/null.gif" width="1" height="1" border=0 alt="">');
		}
		else
		{
			document.write("<p align=justify><small>For viewing Panoramic Images, please load the <a href=\"javascript: void(0);\" onclick=\"window.open('plugin.html', 'plugin', 'width=640,height=500,scrollbars=1')\"><small>Plug-in</small></a>. It will allow you, to have a comfortable tour through the hotel images and navigate inside images with minimal requirements of your PC.</small>");
		}
	}
	else
	{
	  putError("Не удалось определить тип броузера", width, height);
	}
}
