/*
	file name 	:	flash_check.js
	
 	Script for flash detection and redirection in 4+ browsers.

 	Author		: 	Ivo Dimitrov - Studio VISIA Inc.
 	Revision	: 	1.00;

	Date		:	2001/04/11
	Note		:   Litle bit modified by Georgi Mungov - Studio VISIA Inc.
*/

//--------- constants and variables

var required_version		= ( (typeof required_version) == "undefined" ) ? 5 : required_version	;
																				// if undefined set default to 4
var use_redirect			= ( (typeof use_redirect) == "undefined" ) ? true : use_redirect		;
																				// if undefined set default to true
var has_flash					;
var flash2installed		= false	;		//*** variables for detected version
var flash3installed		= false	;
var flash4installed		= false	;
var flash5installed		= false	;
var max_version			= 5		;		// last version of flash avalible
var has_right_version	= false	;
var is_version2					;
var flash_description			;
var flash_version				;
var actual_version		= 0		;
var isIE	= (navigator.appVersion.indexOf("MSIE") != -1)	? true : false;		//'IExplorer' browser detected
var isMac	= (navigator.appVersion.indexOf("Mac") != -1)	? true : false;		//'Mac' computer detected

// ------- public script data

if(isIE && !isMac) {															// if IExplorer on non-Mac mashine

	//*** creating test objects in VBScript, IsObject returns state of objects
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');									// if error go to next
	document.write('flash2installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	document.write('flash3installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('flash4installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('</SCR' + 'IPT\> \n');
}

if (navigator.plugins)	{ 														//'Netscape' browser detected						
	if (navigator.plugins["Shockwave Flash 2.0"]
	|| navigator.plugins["Shockwave Flash"]) {									// Shockwave plug-in installed
		is_version2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";	// if Flash 2.0 -> is_version2=" 2.0"
		flash_description = navigator.plugins["Shockwave Flash" + is_version2].description;
																				// geting description property
		flash_version = parseInt(flash_description.charAt(flash_description.indexOf(".") - 1));
																				// saving version number
		eval("flash" +flash_version+ "installed = true;")						// setting flash installed variable
	}
}

for (var i = 2; i <= max_version; i++)	{
	if (eval("flash" + i + "installed") == true) actual_version = i;
}

//*** redirecting to preset pages if use_redirect == true

has_flash = actual_version >= required_version;


