//==========================================================
//
// Changed on 27th of March 2007
//
//==========================================================
//
// Code Author: Carsten Meiselbach, c.meiselbach@namics.com
// Change Author: Elsa Quentin, elsa.quentin@namics.com
//	-> inserted flash version detection
// Change Author: Heiko Rybarczyk, heiko.rybarczyk@namics.com
// -> inserted redirect to flash version
//
//==========================================================

var FlashMode 		= false;
var FlashVersion 	= 7;

var isMac 			= (navigator.userAgent.indexOf("Mac") != -1) ? true : false;
var isWin 			= (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; 
var isMSIE 			= navigator.userAgent.indexOf("MSIE") ? true : false;
var isNetscape 		= navigator.appName.indexOf("Netscape") ? true : false;	

var flashplugintype = "Shockwave Flash";
var flashmimetype 	= "application/x-shockwave-flash";
var flashclassid 	= "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
var flashcodebase 	= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,21,0";
var flashpluginpage = "http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";
var flashdownload 	= "http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";
var flashfaq 		= "http://www.adobe.com/products/flashplayer/productinfo/faq/";

if (navigator.mimeTypes && navigator.mimeTypes[flashmimetype] && navigator.mimeTypes[flashmimetype].enabledPlugin) {

    if (navigator.plugins && navigator.plugins[flashplugintype] && (versionIndex = navigator.plugins[flashplugintype].description.indexOf(".")) != - 1) {
		var versionStartIndex = versionIndex - 1;
		if(navigator.plugins[flashplugintype].description.substring(versionIndex - 2, versionIndex -1) !=" ");
			versionStartIndex = versionIndex - 2;
    	var versionString = navigator.plugins[flashplugintype].description.substring(versionStartIndex, versionIndex);
    	versionIndex = parseInt( versionString );
    	
		if ( versionIndex >= FlashVersion ) {
    		FlashMode = 1;
    	} // if

    } // if
} // if

else if (navigator.userAgent && isMSIE >=0 && isWin >= 0) {
    document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
    document.write('on error resume next \n');
    document.write('FlashMode = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & FlashVersion))) \n');
    document.write('</SCR' + 'IPT\> \n');
} // else if

// else {}

function insertFlash( strSrc, intWidth, intHeight, strAlt, strID )
{
	if ( FlashMode != 0) {	
		var strFlash	=  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"';
		strFlash		+= 'width="' + intWidth + '" height="' + intHeight + '" title="' + strAlt + '">';
		strFlash		+= '<param name="movie" value="' + strSrc + '" />';
		strFlash		+= '<param name="quality" value="high" />';
		strFlash		+= '<param name="menu" value="false" />';
		strFlash		+= '<embed src="' + strSrc + '" width="' + intWidth + '" height="' + intHeight + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false"></embed>';
		strFlash		+= '</object>';

		document.write( strFlash );
		document.close( );	
	}

	else 
	{
		document.write('<br /><br /><br />');
		document.write('<a class="link" target="_blank" href="' + flashdownload + '"><img alt="" src="/images/arrows/blue.gif" width="8" height="7" border="0" />Please download a newer Flash plugin (version ' + FlashVersion + ' or later) to view this page.</a>');
		document.write('<br /><br />');
		document.write('<a class="link" target="_blank" href="' + flashfaq + '"><img alt="" src="/images/arrows/blue.gif" width="8" height="7" border="0" />If you have problems downloading or installing the Flash plugin, please consult the Adobe FAQ page.</a>');
	}
}

function insertFlashMicrosite( strSrc, intWidth, intHeight, strAlt, strID )
{
	if ( FlashMode != 0) {
		var strFlash	=  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"';
		strFlash		+= 'width="' + intWidth + '" height="' + intHeight + '" title="' + strAlt + '">';
		strFlash		+= '<param name="movie" value="' + strSrc + '" />';
		strFlash		+= '<param name="quality" value="best" />';
		strFlash		+= '<param name="menu" value="false" />';
		strFlash		+= '<param name="play" value="true" />';
		strFlash		+= '<param name="scale" value="noscale" />';
		strFlash		+= '<embed src="' + strSrc + '" width="' + intWidth + '" height="' + intHeight + '" quality="best" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" scale="noscale" play="true"></embed>';
		strFlash		+= '</object>';	

		document.write( strFlash );
		document.close( );	
	}

	else 
	{
		document.write('<br /><br /><br />');
		document.write('<a class="link" target="_blank" href="' + flashdownload + '"><img alt="" src="/images/arrows/blue.gif" width="8" height="7" border="0" />Please download a newer Flash plugin (version ' + FlashVersion + ' or later) to view this page.</a>');
		document.write('<br /><br />');
		document.write('<a class="link" target="_blank" href="' + flashfaq + '"><img alt="" src="/images/arrows/blue.gif" width="8" height="7" border="0" />If you have problems downloading or installing the Flash plugin, please consult the Adobe FAQ page.</a>');
	}
}

function redirectToFlash()
{
		
	if ( FlashMode != 0) {
		
		var url = window.location.href;
		var urlSplit = url.split("/");		
		var newUrl = "";
 		
	
		var urlSplitCounter = urlSplit.length;

		//build the new URL
		for (i = 0; i <= 4; i++){
			
			
			//insert a "/" befor the next value from the urlSplit arry will add 
			if(i!=0)
			{
				newUrl += "/";
			}		

			// Example for Array Positions [http:/] [10.70.35.68:5000] [de] [bodycruzer] [party] [grooming-weltweit] [gegroomte-germanen.html]
			if(i == 4)
			{
				//added the next urlSplit array value
				newUrl += urlSplit[i];

				newUrl += "/flash/" + urlSplit[i];

				//tempFileExtention should includess ".html"
				var dotIndex = urlSplit[urlSplitCounter-1].indexOf(".");
				var tempFileExtention = urlSplit[urlSplitCounter-1].substring(dotIndex);
				
				newUrl += tempFileExtention;

					
			}else
			{
				//added the next urlSplit array value
				newUrl += urlSplit[i];
			}	
			
		} // end for build the new URL

		
		//If no variable with the name 'deepLinkParam' exist make a redirect without a deplink parameter for the flash page.
 		//Should a parameter be added to the url, the variabel has to be added in the html page befor this javascript function will be called.
		if(typeof deepLinkParam == 'undefined') {					
			window.location.href = newUrl;

		}else{				

			window.location.href = newUrl + deepLinkParam; 
		}	

	
	} // end if FlashMode
	
	// stay on the HTML Fallback version if flash plugin is not installed
	
}