﻿/* Returns the swf file name to be used in homepage during the A/B testing of the new design */
/* Removeit44Block */
function GetFlashSrc(flashData) {
	// flashData is the virtual path which uses the swf file name from cms;
	// we expect it to be something like wp_<continent>2.swf
	if ((typeof Zoover != "undefined") && Zoover.EnableNewDesign) {
		// B variation - return the new swf (wp_<continent>3.swf); 
		return flashData.replace(/2.swf/i, "3.swf");
	}
	
	// we're on the A variation, which should render a wider old-style swf (wp_<continent>2a.swf)
	return flashData.replace(/2.swf/i, "2a.swf");
}

function CreateFlash(targetElement, flashData, flashWidth, flashHeight, flashParamsArray, alternativeHtmlArray) {
	var innerHtml;
	var i;
	var prevHTML;

	obj = document.getElementById(targetElement);
	prevHTML = obj.innerHTML;

	if (obj != null) {
		var flashParams = '<param name="menu" value="false"/><param name="quality" value="high"/><param name="wmode" value="transparent"/>';
		if (typeof (flashParamsArray) == 'object' && flashParamsArray != null && flashParamsArray.length > 0) {
			for (i = 0; i < flashParamsArray.length; i++) {
				flashParams += flashParamsArray[i];
			}
		}

		var alternativeHtml = "";
		if (typeof (alternativeHtmlArray) == 'object' && alternativeHtmlArray != null && alternativeHtmlArray.length > 0) {
			for (i = 0; i < alternativeHtmlArray.length; i++) {
				alternativeHtml += alternativeHtmlArray[i];
			}
		}

		innerHtml = '<object width="' + flashWidth + '" height="' + flashHeight + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">';

		innerHtml += '<param name="movie" value="' + flashData + '"/>'
		innerHtml += flashParams;
		innerHtml += '<!--[if !IE]>-->';
		innerHtml += '<object type="application/x-shockwave-flash" data="' + flashData + '" width="' + flashWidth + '" height="' + flashHeight + '">';
		innerHtml += flashParams;
		innerHtml += '<!--<![endif]-->';
		innerHtml += alternativeHtml;
		innerHtml += '<!--[if !IE]>-->';
		innerHtml += '</object>';
		innerHtml += '<!--<![endif]-->';

		innerHtml += '</object>';

		obj.innerHTML = innerHtml;

		if (obj.innerHTML == "") {
			obj.innerHTML = prevHTML;
		}
	}
}
