/* ********* Flash Detection and Version Check (start) **************** */

// finally created: 28.07.2003

// author: David Bary, TIMETOACT Software & Consulting GmbH

// this is an additional js-file, only needed for Flash detection and including Flash movies or - depending on browser and Flash version - display an alternative image.

// F : Flash

// V : Version

// M : Movie



function FlashCheck() {

	var F = FlashDetection(-1);

	this.fv = F[0];

	this.fd = F[1];

	this.fi = F[2];

}



function DisplayFlashInfo() {

	Flash = new FlashCheck();

	alert ( "Flash installed: " + Flash.fi + "\n" +

		"Flash Version: " + Flash.fv + "\n" + 

		"Flash Description: " + Flash.fd + "\n");

}

var FlashLoad = false;



//initialising global variables

var FMV="" , FSrc="" , FHeight="" , FWidth="" , FPosTop="" , FPosLeft="" , FPrintPosTop="", FPrintPosLeft="",  FPlay="" , FLoop="" , FQuality="" , FMenu="" , FWmode="" , FScale="" , FBgColor="" , AddFCode="" , FObjLayerId="" , NoFImgSrc="" , NoFHtml="";



function InitFlash(FlashVersion, FlashSrc, FlashHeight, FlashWidth, FlashPositionTop, FlashPositionLeft, FlashPrintPosTop, FlashPrintPosLeft, FlashPlay, FlashLoop, FlashQuality, FlashMenu, FlashWmode, FlashScale, FlashBgColor, AdditionalFlashCode, FlashObjectLayerId, NoFlashImgSrc, NoFlashHtml) {

	FlashLoad = true; //detects if InitFlash was loaded, prevents creating a flashObject without initialising the variables, e.g. if someone forgets to call the initFlash function in the HTML head

	LatestFV = 6; // manually enter the latest available flash version actually this is 6 (july 2003)

	UsrFV = 0;	//User Flash Version

	

	//assigns the parameter to the global varaibles

	FMV = (FlashVersion=="")?3:FlashVersion; //the flash version of the movie that should be included

	FSrc = FlashSrc;

	FHeight = FlashHeight;

	FWidth = FlashWidth;

	FPosTop = FlashPositionTop;

	FPosLeft = FlashPositionLeft;

	FPrintPosTop = FlashPrintPosTop;

	FPrintPosLeft = FlashPrintPosLeft;

	FPlay = FlashPlay;

	FLoop = FlashLoop;

	FQuality = FlashQuality;

	FMenu = FlashMenu;

	FWmode = FlashWmode;

	FScale = FlashScale;

	FBgColor = FlashBgColor;

	AddFCode = AdditionalFlashCode;

	FObjLayerId = FlashObjectLayerId;

	NoFImgSrc = NoFlashImgSrc;

	NoFHtml = NoFlashHtml;



	UsrFV = FlashDetection(0); //with the value 0 the flash detection returns only the flash version found on the users sytem

}



function FlashDetection(ReturnArrayValue) { //can return all available or specific information about the flash capability of the browser

	// this flash detection handles almost every browser or os, in some cases by ignoring them ; ) and displaying the alternative image

	

	//FlashInfo[0] -> number:Flash version

	//FlashInfo[1] -> text:  Flash description

	//FlashInfo[2] -> bool:  Flash detected?



	var FlashInfo = new Array();

	FlashInfo[0] = -1;

	FlashInfo[1] = "No flashinfo available";

	FlashInfo[2] = false;



	aFV = new Array();

	for(var i = 2; i <= 6; i++) aFV[i] = false;

	FV2 = false; FV3 = false; FV4 = false; FV5 = false; FV6 = false; //for vbscript, because doesn't accept array's (???)

	FDetails = FlashInfo[1];

	// flash detection for all browsers that know the plugins object and can handle this array (ie knows it but can not work with it!)

	if (navigator.plugins) {

		if (navigator.plugins["Shockwave Flash 2.0"]) var FDetails = navigator.plugins["Shockwave Flash 2.0"].description;

		if (navigator.plugins["Shockwave Flash"]) var FDetails = navigator.plugins["Shockwave Flash"].description;

		if(FDetails != FlashInfo[1]) {

			FlashInfo[0] = FDetails.charAt(FDetails.indexOf(".") - 1);

			FlashInfo[1] = FDetails;

			FlashInfo[2] = true;

		}

	}

	// flash detection for windows and internet explorer environment

	if(navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.indexOf("Windows")!=-1){

		document.writeln("<script language=\"VBScript\"> \n");


		document.writeln("on error resume next \n");

		for(var i=2; i<=6; i++) {

			document.write("FV"+i+" = IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash."+i+"\")) \n");

		}

		document.writeln("</script>\n");

		aFV[2] = FV2; aFV[3] = FV3; aFV[4] = FV4; aFV[5] = FV5; aFV[6] = FV6; //IE doesn't accept array's in vbscript, so have to ship around ; )

		for(var i = 2; i<=6; i++) {

			if(aFV[i]==true) {

				FlashInfo[0] = i;

				FlashInfo[2] = true;

			}

		}

	}

	if(ReturnArrayValue == -1) return FlashInfo;

	else return FlashInfo[ReturnArrayValue];

}



function createFlashObject() {

	// call this function to create the flash object in the body of the document

	if(FlashLoad) { //is initFlash initialised?



		// replace the flash with the image if in printmode

		var loc = window.location.search;

		var printversion = false;

		if (loc) {

			if ( loc.indexOf ( 'setprintmode' ) != -1 ) {

			FPosTop = (FPrintPosTop=="")?FPosTop:FPrintPosTop;

			FPosLeft = (FPrintPosLeft=="")?FPosLeft:FPrintPosLeft;

			printversion = true;

			}

		}



		if(FObjLayerId!="") document.write('<div id="'+FObjLayerId+'">\n'); //creates a layer only if the parameter is filled

		if(UsrFV>=FMV && FSrc != "" && printversion == false) { //if the user's installed flashverison is above the included movie start creating the flash code

			var p = '<param name=\"';

			var v = '\" value=\"';

			var e = '\">\n';



			//the following blocks create the paramter for the flash object (<param ...>) and the embed-tag	(<embed ...param...>)

			//if the paramter is not specified (e.g ""=empty) it will not be added to the flash code

			strParam = p+'movie'+v+''+FSrc+''+e;

			strProp = 'src=\"'+FSrc+'\"';

			var inclParamFSrc = (FSrc == "")?"":strParam;

			var inclFSrc = (FSrc == "")?"":strProp;



			strParam = p+'play'+v+''+FPlay+''+e;

			strProp = 'play=\"'+FPlay+'\"';

			var inclParamFPlay = (FPlay == "")?"":strParam;

			var inclFPlay = (FPlay == "")?"":strProp;



			strParam = p+'loop'+v+''+FLoop+''+e;

			strProp = 'loop=\"'+FLoop+'\"';

			var inclParamFLoop = (FLoop == "")?"":strParam;

			var inclFLoop = (FLoop == "")?"":strProp;

	

			strParam = p+'quality'+v+''+FQuality+''+e;

			strProp = 'quality=\"'+FQuality+'\"';

			var inclParamFQuality = (FQuality == "")?"":strParam;

			var inclFQuality = (FQuality == "")?"":strProp;



			strParam = p+'menu'+v+''+FMenu+''+e;

			strProp = 'menu=\"'+FMenu+'\"';

			var inclParamFMenu = (FMenu == "")?"":strParam;

			var inclFMenu = (FMenu == "")?"":strProp;



			strParam = p+'wmode'+v+''+FWmode+''+e;

			strProp = 'wmode=\"'+FWmode+'\"';

			var inclParamFWmode = (FWmode == "")?"":strParam;

			var inclFWmode = (FWmode == "")?"":strProp;



			strParam = p+'scale'+v+''+FScale+''+e;

			strProp = 'scale=\"'+FScale+'\"';

			var inclParamFScale = (FScale == "")?"":strParam;

			var inclFScale = (FScale == "")?"":strProp;



			strParam = p+'bgcolor'+v+''+FBgColor+''+e;

			strProp = 'bgcolor=\"'+FBgColor+'\"';

			var inclParamFBgColor = (FBgColor == "")?"":strParam;

			var inclFBgColor = (FBgColor == "")?"":strProp;

			

			//concatinating the parameters

			var FObject = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/Flash/swFlash.cab" height=\"'+FHeight+'\" width=\"'+FWidth+'\">'

			+inclParamFSrc+''+inclParamFPlay+''+inclParamFLoop+''+inclParamFQuality+''+inclParamFMenu+''+inclParamFWmode+''+inclParamFScale+''+inclParamFBgColor+''

			+'<embed pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-Flash\" '+inclFSrc+' height=\"'+FHeight+'\" width=\"'+FWidth+'\" '+inclFPlay+' '+inclFLoop+' '+inclFQuality+' '+inclFMenu+' '+inclFWmode+' '+inclFScale+' '+inclFBgColor+' '+AddFCode+'>'

			+'</embed></object>';

			document.write(FObject+"\n");

		} 

		else  { //means: if UserFlashVersion < Flash Movie Version || Flash Source == "" || printversion == true -> create the alternative image

			if(NoFImgSrc!="") document.write('<img src=\"'+NoFImgSrc+'\" width=\"'+FWidth+'\" height=\"'+FHeight+'\" alt="Your Browser is not able to play Flash Movies, this is an alternative image, please install Flash to enjoy this page with all its components">');

			if(NoFHtml!="") document.write(NoFHtml);

		}

		if(FObjLayerId!="") { //creates the layer and tag and - if specified - moves the flash to a new position

			document.write('</div>\n');

			if(FPosTop!="" && FPosLeft!="") {

				if(document.layers) {

					document.layers[FObjLayerId].top = FPosTop;

					document.layers[FObjLayerId].left = FPosLeft;

				}

				else { if(document.all) {		  

						document.all[FObjLayerId].style.top = FPosTop;

						document.all[FObjLayerId].style.left = FPosLeft;

					}

					else {		  

						document.getElementById(FObjLayerId).style.top = FPosTop;

						document.getElementById(FObjLayerId).style.left = FPosLeft;

					}

				}

			}

		}

	}

}

/* ********* Flash Detection and Version Check (end) **************** */
