var detectedVersion = -1;
var detectedMinorVersion = -1;

function getFlashVersion (baseVersion) {

	if (detectedVersion != -1) return detectedVersion;
	if (baseVersion == null) baseVersion = 10;

	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var pluginRef = navigator.plugins['Shockwave Flash'];
		if (pluginRef != null) {
			var verIndex = pluginRef.description.indexOf (".");
			var minorIndex = pluginRef.description.indexOf ("r");
			//alert (pluginRef.description.length);
			//alert (minorIndex);
			//alert(pluginRef.description);
			detectedVersion = parseInt (pluginRef.description.substr (verIndex - 2, 2));
			//alert(detectedVersion);
			detectedMinorVersion = parseInt (pluginRef.description.substr (minorIndex - 1, pluginRef.description.length - 1));
		}
	}
	else if (navigator.userAgent.indexOf("MSIE") != -1 && parseInt(navigator.appVersion) >= 4 && navigator.platform == "Win32") {
		document.write('<scr' + 'ipt language="VBScript"\> \nPrivate i, x\nOn Error Resume Next\n controlPresent = False\nFor i = ' + baseVersion + ' To 1 Step -1\n');
		document.write('Set x = CreateObject("ShockwaveFlash.ShockwaveFlash." & i)\n controlPresent = IsObject(x)\nIf controlPresent Then\ndetectedVersion = CStr(i)\nExit For\nEnd If\nNext\n');		
		document.write('</scr' + 'ipt\> \n');
	}
	return detectedVersion;
}

/*
  * Params :
  * objectID - the ID of the flash movie or image
  * movieName - the name of the flash movie to embed (flash.swf)
  * failOverImage - The image that is displayed in place of the flash movie if the player is not detected
  * failOverURL - the URL for the fail over graphic
  * failOverTitle - the title/alt for the fail over graphic
  * width - the width of the flash movie in pixels
  * height - the height of the flash movie in pixels
  * baseVersion - the version of the plugin to test for. If the detected plugin version is less than the
  *              baseVersion specified, the fail over graphic will be displayed in place of the flash movie
  * bgcolor - the background color for the flash movie eg. #FFFFFF
  */

function flashEmbed (objectID, movieName, failOverImage, failOverURL, failOverTitle, failOverUsemap, width, height, baseVersion, bgcolor) {
	var version = getFlashVersion (baseVersion);
	if ((version != -1) && (version >= baseVersion)) {
		writeFlashTag (objectID, movieName, width, height, baseVersion, bgcolor);
	}
	else {
		if (failOverUsemap != "") {
			document.write ('<img id="' + objectID + '" src = "' + failOverImage + '" width="' + width + '" height="' + height + '" border="0" usemap="#' + failOverUsemap + '">');
		}
		else
		{
		    if (failOverURL != "") {
			    document.write ('<a href = "' + failOverURL + '"><img id="' + objectID + '" src = "' + failOverImage + '" width="' + width + '" height="' + height + '" border="0" title="' + failOverTitle + '"></a>');		
			}
			else
			{
			    document.write ('<img id="' + objectID + '" src = "' + failOverImage + '" width="' + width + '" height="' + height + '" border="0" title="' + failOverTitle + '">');		
			}
		}
	}
}

function flashEmbedDivisions (objectID, movieName, width, height, baseVersion, bgcolor) {
	var version = getFlashVersion (baseVersion);
	if ((version != -1) && (version >= baseVersion)) {
		writeFlashTag (objectID, movieName, width, height, baseVersion, bgcolor);
	}
	else {
	    document.write('<a href="od_inventiv_clinical.aspx"><img id="btnBannerClinical" src="../images/aboutUs/subpages/divisions_btn_ClinicalOff_148x219.jpg" width="148" height="219" alt="inVentiv Clinical" title="inVentiv Clinical" onmouseover="javascript:this.src=btnBannerClinical_Over.src;" onmouseout="javascript:this.src=btnBannerClinical_Off.src;" /></a>' +
            '<a href="od_inventiv_communications.aspx"><img id="btnBannerCommunications" src="../images/aboutUs/subpages/divisions_btn_CommOff_148x219.jpg" width="148" height="219" alt="inVentiv Communications" title="inVentiv Communications" onmouseover="javascript:this.src=btnBannerCommunications_Over.src;" onmouseout="javascript:this.src=btnBannerCommunications_Off.src;" /></a>' +
            '<a href="od_inventiv_advance_insights.aspx"><img id="btnBannerStrategy" src="../images/aboutUs/subpages/divisions_btn_StrategyOff_148x219.jpg" width="148" height="219" alt="inVentiv Strategy &amp; Analytics" title="inVentiv Strategy &amp; Analytics" onmouseover="javascript:this.src=btnBannerStrategy_Over.src;" onmouseout="javascript:this.src=btnBannerStrategy_Off.src;" /></a>' +
            '<a href="od_inventiv_selling_solutions.aspx"><img id="btnBannerSelling" src="../images/aboutUs/subpages/divisions_btn_SSOff_148x219.jpg" width="148" height="219" alt="inVentiv Selling Solutions" title="inVentiv Selling Solutions" onmouseover="javascript:this.src=btnBannerSelling_Over.src;" onmouseout="javascript:this.src=btnBannerSelling_Off.src;" /></a>' +
            '<a href="od_inventiv_patient_outcomes.aspx"><img id="btnBannerPatient" src="../images/aboutUs/subpages/divisions_btn_PatOutOff_148x219.jpg" width="148" height="219" alt="inVentiv Patient Outcomes" title="inVentiv Patient Outcomes" onmouseover="javascript:this.src=btnBannerPatient_Over.src;" onmouseout="javascript:this.src=btnBannerPatient_Off.src;" /></a>');
	}
}


function writeFlashTag (objectID, movieName, width, height, baseVersion, bgcolor) {
	document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + baseVersion + ',0,0,0" width="' + width + '"height="' + height + '" id="' + objectID + '" name="' + objectID + '">\n<param name="allowScriptAccess" value="sameDomain">\n<param name="movie" value="' + movieName + '">\n<param name="quality" value="high">\n<param name="bgcolor" value="' + bgcolor + '">\n');
	document.write ('<embed src="' + movieName + '"  allowScriptAccess="sameDomain" TYPE="application/x-shockwave-flash" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="' + width + '" height="' + height + '" bgcolor="' + bgcolor + '" id="' + objectID + '" name="' + objectID + '"></embed></object>');		
	}

getFlashVersion ();

