// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var TF_requiredMajorVersion = 8;
// Minor version of Flash required
var TF_requiredMinorVersion = 0;
// Revision of Flash required
var TF_requiredRevision = 0;
// -----------------------------------------------------------------------------

var TFclick = "TFclick" + tf_id;
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var tf_agt = navigator.userAgent.toLowerCase();
var is_mozilla = ((tf_agt.indexOf('mozilla') != -1) && (tf_agt.indexOf('spoofer') == -1) && (tf_agt.indexOf('compatible') == -1) && (tf_agt.indexOf('opera') == -1) && (tf_agt.indexOf('webtv') == -1) && (tf_agt.indexOf('hotjava') == -1));
var totalVideos = 1;
if(typeof(tf_impression) != "undefined") {
	var img = new Image();
	img.src = tf_impression;
}
var i = 1;
while (eval("typeof(tf_impression" + i + ")") != "undefined") {
	var img = new Image();
	img.src = eval("tf_impression" + i);
	i++;
}
if (typeof(tf_FEVTestMode) != "undefined" && tf_FEVTestMode == true) {
	if(typeof(tf_impression_test) != "undefined") {
		var img = new Image();
		img.src = tf_impression_test + new Date().getTime();
	}
}

if (tf_floatingAdType == "FEV" || tf_floatingAdType == "InterstitialFEV") {
	var videoEvents = ["creativeView", "start", "midpoint", "firstQuartile", "thirdQuartile", "complete", "mute", "unmute", "pause", "rewind", "resume", "replay", "fullscreen", "expand", "collapse", "acceptInvitation", "close"];
	var totalClickTags = 1;
	if (typeof(tf_VASTXmlFEV) == "undefined" || tf_VASTXmlFEV == "") {
		while (eval("typeof(tf_FEVVideoFile" + totalVideos + ")") != "undefined") {
			totalVideos++;
		}
		while (eval("typeof(tf_clickTag" + totalClickTags + ")") != "undefined") {
			totalClickTags++;
		}
	} else {
		var params = tf_getParams(tf_VASTXmlFEV);
		if(typeof(params.LR_CREATIVE_ID) != "undefined") {
			totalVideos = params.LR_CREATIVE_ID.split(",").length;
		}
		var i = 1;
		while (eval("typeof(tf_VASTXmlFEV" + i + ")") != "undefined") {
			params = tf_getParams(eval("tf_VASTXmlFEV" + i));
			if(typeof(params.LR_CREATIVE_ID) != "undefined") {
				totalVideos += params.LR_CREATIVE_ID.split(",").length;
			} else {
				totalVideos++;
			}
			i++;
		}
		totalClickTags = totalVideos;
	}
	var videoTrackings = new Array();
	var varName;
	for (var i = 0; i < totalVideos; i++) {
		videoTrackings[i] = new Object();
		for (var k = 0; k < videoEvents.length; k++) {
			var j = 0;
			while (true) {
				varName = "tf_video" + ((i != 0)?i:"") + "_";
				varName += videoEvents[k] + ((j != 0)?j:"");
				if (eval("typeof(" + varName + ")") != "undefined") {
					var parts = videoEvents[k].split("");
					parts[0] = parts[0].toString().toUpperCase().split("")[0];
					var myEvent = parts.join("");
					if(myEvent == "AcceptInvitation") {
						myEvent = "Start"; //todo: revert this
					}
					tf_insertTextNodeFEV(videoTrackings[i], myEvent + ".URL", eval(varName));
				} else {
					break;
				}
				j++;
			}
			if(typeof(tf_FEVTestMode) != "undefined" && tf_FEVTestMode == true) {
				varName = "tf_video" + ((i != 0)?i:"") + "_";
				varName += videoEvents[k] + "_test";
				if (eval("typeof(" + varName + ")") != "undefined") {
					var parts = videoEvents[k].split("");
					parts[0] = parts[0].toString().toUpperCase().split("")[0];
					var myEvent = parts.join("");
					if(myEvent == "AcceptInvitation") {
						myEvent = "Start"; //todo: revert this
					}
					tf_insertTextNodeFEV(videoTrackings[i], myEvent + ".URL", eval(varName)).mode = "test";
				}
			}
		}
	}
	setVariableValue(tf_id, "videoTrackings", videoTrackings);

	var clickTrackings = new Array();
	var varName;
	for (var i = 0; i < totalClickTags; i++) {
		clickTrackings[i] = new Object();
		clickTrackings[i].ClickTag = new Object();
		var j = 0;
		while (true) {
			varName = "tf_clickTag" + ((i != 0)?i:"") + "_";
			varName += "clickTracking" + ((j != 0)?j:"");
			if (eval("typeof(" + varName + ")") != "undefined") {
				tf_insertTextNodeFEV(clickTrackings[i], "ClickTag.Track", eval(varName));
			} else {
				break;
			}
			j++;
		}
		if (typeof(tf_FEVTestMode) != "undefined" && tf_FEVTestMode == true) {
			varName = "tf_clickTag" + ((i != 0)?i:"") + "_";
			varName += "clickTracking" + "_test";
			if (eval("typeof(" + varName + ")") != "undefined") {
				tf_insertTextNodeFEV(clickTrackings[i], "ClickTag.Track", eval(varName)).mode = "test";
			}
		}
	}
	setVariableValue(tf_id, "clickTrackings", clickTrackings);
}

function tf_FEV3_VAST2(xmls, width, height, id) {
	this.xmls = xmls;
	var obj = null;
	var extraObjs = [];
	if(xmls != null) {
		obj = xmlToObject(xmls[0]);
		for (var i = 1; i < xmls.length; i++) {
			extraObjs.push(xmlToObject(xmls[i]));
		}
	}

	var allExtraObjs = [];
	var parser = parserTF1;
	if (obj != null) {
		obj = getProperty(getRootNode(obj), "Ad", {});
		if(typeof(obj.length) != "undefined") {
			for (var i = 1; i < obj.length; i++) {
				var adSystemType = getProperty(obj[i], "InLine.AdSystem");
				if(adSystemType == null || typeof(adSystemType) == "undefined" || adSystemType["#text"] != "LiveRail") {
					break;
				}
				allExtraObjs.push(obj[i]);
			}
			obj = obj[0];
		}
		obj = getProperty(obj, "InLine");
		parser = parserVersion1;
		if (getProperty(obj, "Creatives") != null) {
			parser = parserVersion2;
		}
	}

	this.customObj = new Object();
	this.customObj.Root = parser(obj, width, height);

	for (var i = 0; i < extraObjs.length; i++) {
		extraObjs[i] = getProperty(getRootNode(extraObjs[i]), "Ad", {});
		if(typeof(extraObjs[i].length) != "undefined") {
			for (var j = 0; j < extraObjs[i].length; j++) {
				if(j != 0) {
					var adSystemType = getProperty(extraObjs[i][j], "InLine.AdSystem");
					if(adSystemType == null || typeof(adSystemType) == "undefined" || adSystemType["#text"] != "LiveRail") {
						break;
					}
				}
				allExtraObjs.push(extraObjs[i][j]);
			}
		} else {
			allExtraObjs.push(extraObjs[i]);
		}
	}
	for (var i = 0; i < allExtraObjs.length; i++) {
		allExtraObjs[i] = getProperty(allExtraObjs[i], "InLine");
		parser = parserVersion1;
		if (getProperty(allExtraObjs[i], "Creatives") != null) {
			parser = parserVersion2;
		}
		allExtraObjs[i] = parser(allExtraObjs[i], width, height);
		var myid = i + 2;

		var clickObj = getProperty(allExtraObjs[i], "ClickTag");
		clickObj.id = myid.toString();
		if (typeof(this.customObj.Root.ClickTag.length) == "undefined") {
			this.customObj.Root.ClickTag = [this.customObj.Root.ClickTag];
		}
		this.customObj.Root.ClickTag.push(clickObj);

		var videoObj = getProperty(allExtraObjs[i], "Video");
		videoObj.id = myid.toString();
		if (typeof(this.customObj.Root.Video.length) == "undefined") {
			this.customObj.Root.Video = [this.customObj.Root.Video];
		}
		this.customObj.Root.Video.push(videoObj);

		var array = getProperty(this.customObj.Root, "Impression.URL", {});
		if(array == null) {
			delete this.customObj.Root.Impression;
		}
		array = getProperty(allExtraObjs[i], "Impression.URL", {});
		if(array != null) {
			if (typeof(array.length) == "number") {
				for (var j = 0; j < array.length; j++) {
					tf_insertTextNodeFEV(this.customObj.Root, "Impression.URL", array[j]);
				}
			} else {
				tf_insertTextNodeFEV(this.customObj.Root, "Impression.URL", array);
			}
		}
		this.customObj.Root.Impression.tf_ignore = "1";
	}

	var videoTrackings = getVariableValue(id, "videoTrackings");
	var totalVids = 1;
	if (typeof(this.customObj.Root.Video.length) != "undefined") {
		totalVids = this.customObj.Root.Video.length;
	}

	var tempNode;
	for (var i = 0; i < totalVids; i++) {
		var videoObj = this.customObj.Root.Video;
		if (totalVids != 1) {
			videoObj = videoObj[i];
		}
		for (var m in videoTrackings[i]) {
			var urls = videoTrackings[i][m].URL;
			if (typeof(urls.length) != "undefined") {
				for (var j = 0; j < urls.length; j++) {
					tempNode = tf_insertTextNodeFEV(videoObj, "Tracking." + m + ".URL", urls[j]);
					if(typeof(urls[j].mode) != "undefined") {
						tempNode.mode = urls[j].mode;
					}
				}
			} else {
				tempNode = tf_insertTextNodeFEV(videoObj, "Tracking." + m + ".URL", urls);
				if(typeof(urls.mode) != "undefined") {
					tempNode.mode = urls.mode;
				}
			}
		}
	}

	var clickTrackings = getVariableValue(id, "clickTrackings");
	var totalClickTags = 1;
	if (typeof(this.customObj.Root.ClickTag.length) != "undefined") {
		totalClickTags = this.customObj.Root.ClickTag.length;
	}

	for (var i = 0; i < totalClickTags; i++) {
		var clickObj = this.customObj.Root.ClickTag;
		if (totalClickTags != 1) {
			clickObj = clickObj[i];
		}

		var urls = clickTrackings[i].ClickTag.Track;
		if (typeof(urls) == "undefined") {
			continue;
		}
		if (typeof(urls.length) != "undefined") {
			for (var j = 0; j < urls.length; j++) {
				tempNode = tf_insertTextNodeFEV(clickObj, "Track", urls[j]);
				if(typeof(urls[j].mode) != "undefined") {
					tempNode.mode = urls[j].mode;
				}
			}
		} else {
			tempNode = tf_insertTextNodeFEV(clickObj, "Track", urls);
			if(typeof(urls.mode) != "undefined") {
				tempNode.mode = urls.mode;
			}
		}
	}

	this.customXml = objectToXml(this.customObj);

	function parserTF1(obj, width, height) {
		var tempObj = new Object();
		tempObj.FEVType = "TF1.0";
		tf_insertTextNodeFEV(tempObj, "Title", null);
		tf_insertTextNodeFEV(tempObj, "Description", null);
		tf_insertTextNodeFEV(tempObj, "ErrorUrl", null);
		var videos = new Array();
		videos[0] = new Object();
		videos[0].id = "1";
		tf_insertTextNodeFEV(videos[0], "LocationUrl", tf_FEVVideoFile);
		tf_insertTextNodeFEV(videos[0], "AdParameters", null);
		var i = 1;
		while (eval("typeof(tf_FEVVideoFile" + i + ")") != "undefined") {
			var id = i + 1;
			videos[i] = new Object();
			videos[i].id = id.toString();
			tf_insertTextNodeFEV(videos[i], "LocationUrl", eval("tf_FEVVideoFile" + i));
			tf_insertTextNodeFEV(videos[i], "AdParameters", null);
			i++;
		}

		if (videos.length == 1) {
			tempObj.Video = videos[0];
		} else {
			tempObj.Video = new Array();
			for (i = 0; i < videos.length; i++) {
				tempObj.Video.push(videos[i]);
			}
		}

		tempObj.ClickTag = new Object();
		tempObj.ClickTag.id = "1";
		tf_insertTextNodeFEV(tempObj.ClickTag, "URL", tf_clickTag);

		i = 1;
		while (eval("typeof(tf_clickTag" + i + ")") != "undefined") {
			var id = i + 1;
			var clickObj = new Object;
			clickObj.id = id.toString();
			tf_insertTextNodeFEV(clickObj, "URL", eval("tf_clickTag" + i));
			if (typeof(tempObj.ClickTag.length) == "undefined") {
				tempObj.ClickTag = [tempObj.ClickTag];
			}
			tempObj.ClickTag.push(clickObj);
			i++;
		}

		tf_insertTextNodeFEV(tempObj, "Data", null);
		tf_insertTextNodeFEV(tempObj, "SurveyUrl", null).tf_ignore = "1";
		tf_insertTextNodeFEV(tempObj, "Impression", null);
		tempObj.Impression.tf_ignore = "1";

		if (tf_floatingAdType != 2 && typeof(tf_flashfile) != "undefined") {
			tf_insertTextNodeFEV(tempObj, "Banner.Flash.URL", tf_flashfile + ".swf");
			tf_insertTextNodeFEV(tempObj, "Banner.Flash.Tracking", null);
			tf_insertTextNodeFEV(tempObj, "Banner.Flash.ClickThrough.URL", tf_clickTag).id = "1";
			i = 1;
			while (eval("typeof(tf_clickTag" + i + ")") != "undefined") {
				var id = i + 1;
				tf_insertTextNodeFEV(tempObj, "Banner.Flash.ClickThrough.URL", eval("tf_clickTag" + i)).id = id.toString();
				i++;
			}
			tf_insertTextNodeFEV(tempObj, "Banner.Flash.AdParameters", null);
			tf_insertTextNodeFEV(tempObj, "Banner.Image.URL", tf_imagefile);
			tf_insertTextNodeFEV(tempObj, "Banner.Image.ClickThrough.URL", tf_clickTag);
			tf_insertTextNodeFEV(tempObj, "Banner.Image.AltText", "");
			tempObj.Banner.tf_ignore = "1";
		}
		return tempObj;
	}

	function parserVersion1(obj, width, height) {
		var tempObj = new Object();
		tempObj.FEVType = "VAST1.0";
		tf_insertTextNodeFEV(tempObj, "Title", getProperty(obj, "AdTitle"));
		tf_insertTextNodeFEV(tempObj, "Description", getProperty(obj, "Description"));
		tf_insertTextNodeFEV(tempObj, "ErrorUrl", getProperty(obj, "Error.URL"));

		//Video details
		var array = getProperty(obj, "Video.MediaFiles.MediaFile", {delivery:"progressive"});
		var videoLocation = null;
		var bitrates = [];
		var bitrateUrlMap = {};
		if (typeof(array.length) == "number") {
			for (var i = 0; i < array.length; i++) {
				if (/[.]flv$/.test(array[i].URL["#text"]) || array[i].type == "video/x-flv") {
					bitrates.push(Number(array[i].bitrate));
					bitrateUrlMap["bitrate" + array[i].bitrate] = getProperty(array[i], "URL");
				}
			}
			bitrates.sort(function(a, b) {
				return a - b
			});
			videoLocation = bitrateUrlMap["bitrate" + bitrates[Math.floor(bitrates.length / 2)]];
		} else {
			videoLocation = getProperty(array, "URL");
		}
		tf_insertTextNodeFEV(tempObj, "Video.LocationUrl", videoLocation);
		getProperty(tempObj, "Video").id = "1";
		array = getProperty(obj, "TrackingEvents.Tracking", new Object());
		if (array != null) {
			if (typeof(array.length) == "number") {
				for (var i = 0; i < array.length; i++) {
					var parts = array[i].event.split("");
					parts[0] = parts[0].toString().toUpperCase().split("")[0];
					var myEvent = parts.join("");
					if(myEvent == "AcceptInvitation") {
						myEvent = "Start"; //todo: revert this
					}
					tf_insertTextNodeFEV(tempObj, "Video.Tracking." + myEvent + ".URL", getProperty(array[i], "URL"));
				}
			} else {
				var parts = array.event.split("");
				parts[0] = parts[0].toString().toUpperCase().split("")[0];
				var myEvent = parts.join("");
				if(myEvent == "AcceptInvitation") {
					myEvent = "Start"; //todo: revert this
				}
				tf_insertTextNodeFEV(tempObj, "Video.Tracking." + myEvent + ".URL", getProperty(array, "URL"));
			}
		}

		tempObj.ClickTag = new Object();
		tempObj.ClickTag.id = "1";
		tf_insertTextNodeFEV(tempObj.ClickTag, "URL", getProperty(obj, "Video.VideoClicks.ClickThrough.URL"));

		array = getProperty(obj, "Video.VideoClicks.ClickTracking", new Object());
		if (array != null) {
			if (typeof(array.length) == "number") {
				for (var i = 0; i < array.length; i++) {
					tf_insertTextNodeFEV(tempObj.ClickTag, "Track", getProperty(array[i], "URL"));
				}
			} else {
				tf_insertTextNodeFEV(tempObj.ClickTag, "Track", getProperty(array, "URL"));
			}
		} else {
		}
		tf_insertTextNodeFEV(tempObj, "Video.AdParameters", getProperty(obj, "Video.AdParameters", {apiFramework:"FlashVars"}));
		tf_insertTextNodeFEV(tempObj, "Data", null);

		//nodes to be ignored while convering to xml
		tf_insertTextNodeFEV(tempObj, "SurveyUrl", getProperty(obj, "Survey.URL")).tf_ignore = "1";
		array = getProperty(obj, "Impression", new Object());
		if (array != null) {
			if (typeof(array.length) == "number") {
				for (var i = 0; i < array.length; i++) {
					var id = i + 1;
					tf_insertTextNodeFEV(tempObj, "Impression.URL", getProperty(array[i], "URL"));
				}
			} else {
				tf_insertTextNodeFEV(tempObj, "Impression.URL", getProperty(array, "URL"));
			}
		} else {
			tf_insertTextNodeFEV(tempObj, "Impression", null);
		}

		tempObj.Impression.tf_ignore = "1";

		var resourceTypes = ["static", "other"];
		//, "iframe", "script", "HTML", "html"];
		for (var i = 0; i < resourceTypes.length; i++) {
			var companion = getProperty(obj, "CompanionAds.Companion", {resourceType:resourceTypes[i],width:width,height:height});
			if (companion != null) {
				if (/[.]swf$/.test(getProperty(companion, "URL")["#text"])) {
					tf_insertTextNodeFEV(tempObj, "Banner.Flash.URL", getProperty(companion, "URL"));
					tf_insertTextNodeFEV(tempObj, "Banner.Flash.Tracking", null);
					tf_insertTextNodeFEV(tempObj, "Banner.Flash.ClickThrough.URL", getProperty(companion, "CompanionClickThrough.URL")).id = "1";
					tf_insertTextNodeFEV(tempObj, "Banner.Flash.AdParameters", getProperty(companion, "AdParameters", {apiFramework:"FlashVars"}));
				} else {
					tf_insertTextNodeFEV(tempObj, "Banner.Image.URL", getProperty(companion, "URL"));
					tf_insertTextNodeFEV(tempObj, "Banner.Image.Tracking", null);
					tf_insertTextNodeFEV(tempObj, "Banner.Image.ClickThrough", getProperty(companion, "CompanionClickThrough.URL"));
					tf_insertTextNodeFEV(tempObj, "Banner.Image.AltText", getProperty(companion, "AltText"));
				}
			}
		}
		if(typeof(tempObj.Banner) != "undefined") {
			tempObj.Banner.tf_ignore = "1";
		}
		return tempObj;
	}

	function parserVersion2(obj, width, height) {
		var tempObj = new Object();
		tempObj.FEVType = "VAST2.0";
		tf_insertTextNodeFEV(tempObj, "Title", getProperty(obj, "AdTitle"));
		tf_insertTextNodeFEV(tempObj, "Description", getProperty(obj, "Description"));
		tf_insertTextNodeFEV(tempObj, "ErrorUrl", getProperty(obj, "Error"));

		//Video details
		var array = getProperty(obj, "Creatives.Creative", new Object());
		var linearAd, companionAds = null;
		if (typeof(array.length) == "number") {
			for (var i = 0; i < array.length; i++) {
				if (typeof(array[i].Linear) == "object") {
					linearAd = array[i].Linear;
				} else if (typeof(array[i].CompanionAds) == "object") {
					companionAds = array[i].CompanionAds;
				}
			}
		} else {
			if (typeof(array.Linear) == "object") {
				linearAd = array.Linear;
			} else if (typeof(array.CompanionAds) == "object") {
				companionAds = array.CompanionAds;
			}
		}
		array = getProperty(linearAd, "MediaFiles.MediaFile", {delivery:"progressive"});
		var videoLocation = null;
		var bitrates = [];
		var bitrateUrlMap = {};
		if (typeof(array.length) == "number") {
			for (var i = 0; i < array.length; i++) {
				if (/[.]flv$/.test(array[i]["#text"]) || array[i].type == "video/x-flv") {
					bitrates.push(Number(array[i].bitrate));
					bitrateUrlMap["bitrate" + array[i].bitrate] = array[i];
				}
			}
			bitrates.sort(function(a, b) {
				return a - b
			});
			videoLocation = bitrateUrlMap["bitrate" + bitrates[Math.floor(bitrates.length / 2)]];
		} else {
			videoLocation = array["#text"];
		}
		tf_insertTextNodeFEV(tempObj, "Video.LocationUrl", videoLocation);
		getProperty(tempObj, "Video").id = "1";
		array = getProperty(linearAd, "TrackingEvents.Tracking", new Object());
		if (array != null) {
			if (typeof(array.length) == "number") {
				for (var i = 0; i < array.length; i++) {
					if (typeof(array[i].event) != "undefined") {
						var parts = array[i].event.split("");
						parts[0] = parts[0].toString().toUpperCase().split("")[0];
						var myEvent = parts.join("");
						if(myEvent == "AcceptInvitation") {
							myEvent = "Start"; //todo: revert this
						}
						tf_insertTextNodeFEV(tempObj, "Video.Tracking." + myEvent + ".URL", array[i]);
					}
				}
			} else {
				var parts = array.event.split("");
				parts[0] = parts[0].toString().toUpperCase().split("")[0];
				var myEvent = parts.join("");
				if(myEvent == "AcceptInvitation") {
					myEvent = "Start"; //todo: revert this
				}
				tf_insertTextNodeFEV(tempObj, "Video.Tracking." + myEvent + ".URL", array);
			}
		}

		tempObj.ClickTag = new Object();
		tempObj.ClickTag.id = "1";
		tf_insertTextNodeFEV(tempObj.ClickTag, "URL", getProperty(linearAd, "VideoClicks.ClickThrough"));

		array = getProperty(linearAd, "VideoClicks.ClickTracking", new Object());
		if (array != null) {
			if (typeof(array.length) == "number") {
				for (var i = 0; i < array.length; i++) {
					tf_insertTextNodeFEV(tempObj.ClickTag, "Track", array[i]);
				}
			} else {
				tf_insertTextNodeFEV(tempObj.ClickTag, "Track", array);
			}
		} else {
		}

		tf_insertTextNodeFEV(tempObj, "Video.AdParameters", getProperty(linearAd, "AdParameters", {apiFramework:"FlashVars"}));
		tf_insertTextNodeFEV(tempObj, "Data", null);

		//nodes to be ignored while convering to xml
		tf_insertTextNodeFEV(tempObj, "SurveyUrl", getProperty(obj, "Survey")).tf_ignore = "1";
		array = getProperty(obj, "Impression", new Object());
		if (array != null) {
			if (typeof(array.length) == "number") {
				for (var i = 0; i < array.length; i++) {
					var id = i + 1;
					tf_insertTextNodeFEV(tempObj, "Impression.URL", array[i]);
				}
			} else {
				tf_insertTextNodeFEV(tempObj, "Impression.URL", array);
			}
		} else {
			tf_insertTextNodeFEV(tempObj, "Impression", null);
		}

		tempObj.Impression.tf_ignore = "1";

		var resourceType = "StaticResource";
		//, "IFrameResource", "HTMLResource"
		array = getProperty(companionAds, "Companion", {width:width,height:height});
		var companion = null;
		if (array != null) {
			if (typeof(array.length) != "undefined") {
				for (var i = 0; i < array.length; i++) {
					if (typeof(array[i][resourceType]) != "undefined") {
						companion = array[i];
					}
				}
			} else {
				if (typeof(array[resourceType]) != "undefined") {
					companion = array;
				}
			}
			if (companion != null) {
				if (/[.]swf$/.test(getProperty(companion, resourceType)["#text"])) {
					tf_insertTextNodeFEV(tempObj, "Banner.Flash.URL", getProperty(companion, resourceType));
					array = getProperty(companion, "TrackingEvents.Tracking", new Object());
					if (array != null) {
						if (typeof(array.length) == "number") {
							for (var i = 0; i < array.length; i++) {
								var parts = array[i].event.split("");
								parts[0] = parts[0].toString().toUpperCase().split("")[0];
								tf_insertTextNodeFEV(tempObj, "Banner.Flash.Tracking." + parts.join("") + ".URL", array[i]);
							}
						} else {
							var parts = array.event.split("");
							parts[0] = parts[0].toString().toUpperCase().split("")[0];
							tf_insertTextNodeFEV(tempObj, "Banner.Flash.Tracking." + parts.join("") + ".URL", array);
						}
					} else {
						tf_insertTextNodeFEV(tempObj, "Banner.Flash.Tracking", null);
					}
					tf_insertTextNodeFEV(tempObj, "Banner.Flash.ClickThrough.URL", getProperty(companion, "CompanionClickThrough")).id = "1";
					tf_insertTextNodeFEV(tempObj, "Banner.Flash.AdParameters", getProperty(companion, "AdParameters", {apiFramework:"FlashVars"}));
				} else {
					tf_insertTextNodeFEV(tempObj, "Banner.Image.URL", getProperty(companion, resourceType));
					array = getProperty(companion, "TrackingEvents.Tracking", new Object());
					if (array != null) {
						if (typeof(array.length) == "number") {
							for (var i = 0; i < array.length; i++) {
								var parts = array[i].event.split("");
								parts[0] = parts[0].toString().toUpperCase().split("")[0];
								tf_insertTextNodeFEV(tempObj, "Banner.Image.Tracking." + parts.join("") + ".URL", array[i]);
							}
						} else {
							var parts = array.event.split("");
							parts[0] = parts[0].toString().toUpperCase().split("")[0];
							tf_insertTextNodeFEV(tempObj, "Banner.Image.Tracking." + parts.join("") + ".URL", array);
						}
					} else {
						tf_insertTextNodeFEV(tempObj, "Banner.Image.Tracking", null);
					}
					tf_insertTextNodeFEV(tempObj, "Banner.Image.ClickThrough", getProperty(companion, "CompanionClickThrough"));
					tf_insertTextNodeFEV(tempObj, "Banner.Image.AltText", getProperty(companion, "AltText"));
				}
			}
			if(typeof(tempObj.Banner) != "undefined") {
				tempObj.Banner.tf_ignore = "1";
			}
		}

		return tempObj;
	}

	function getRootNode(obj) {
		var count = 0;
		var rootNode;
		for (var m in obj) {
			if (typeof(obj[m]) == "object") {
				if (count == 0) {
					rootNode = obj[m];
				}
				count++;
			}
		}
		if (count == 1) {
			return rootNode;
		}

		return null;
	}

	function getProperty(obj, property, atrributeMap) {
		if (obj == null) {
			return null;
		}
		var tempObj = obj;
		parts = property.split(".");
		for (var i = 0; i < parts.length; i++) {
			if (typeof(tempObj[parts[i]]) != "undefined") {
				tempObj = tempObj[parts[i]];
				if (typeof(tempObj.length) == "number") {
					if (i < parts.length - 1 || typeof(atrributeMap) == "undefined") {
						tempObj = tempObj[0];
					} else {
						var array = new Array();
						for (var j = 0; j < tempObj.length; j++) {
							var flag = true;
							for (var m in atrributeMap) {
								if (typeof(tempObj[j][m]) == "undefined" || tempObj[j][m] != atrributeMap[m]) {
									flag = false;
									break;
								}
							}
							if (flag == true) {
								array.push(tempObj[j]);
							}
						}
						if (array.length == 0) {
							return null;
						}
						if (array.length == 1) {
							return array[0];
						}
						return array;
					}
				}
			} else {
				return null;
			}
		}
		return tempObj;
	}

	function createObject(xmlNode) {
		var allTextNodes = true;
		if (xmlNode.attributes != null) {
			for (var j = 0; j < xmlNode.attributes.length; j++) {
				var attribute = xmlNode.attributes[j];
				this[attribute.nodeName] = attribute.nodeValue;
			}
		}
		for (var i = 0; i < xmlNode.childNodes.length; i++)
		{
			var childNode = xmlNode.childNodes[i];
			if (childNode.nodeType != 1) {
				continue;
			}
			allTextNodes = false;

			var nodeName = childNode.nodeName;
			var nodeValue = new createObject(childNode);

			if (typeof(this[nodeName]) == 'undefined') {
				this[nodeName] = nodeValue;
			} else if ((typeof(this[nodeName]) == 'object') && typeof(this[nodeName].length) == 'undefined') {
				this[nodeName] = [ this[nodeName], nodeValue ];
			} else if (typeof(this[nodeName]) == 'object' && typeof(this[nodeName].length) == 'number') {
				this[nodeName].push(nodeValue);
			}
		}

		if (allTextNodes) {
			if (typeof(xmlNode.textContent) != "undefined") {
				this["#text"] = xmlNode.textContent.replace(/^\s*/, "").replace(/\s*$/, "");
			} else {
				this["#text"] = xmlNode.text.replace(/^\s*/, "").replace(/\s*$/, "");
			}
		}
	}

	function xmlToObject(text) {
		if (text == null) {
			return null;
		}
		if (window.DOMParser)
		{
			var parser = new DOMParser();
			xmlDoc = parser.parseFromString(text, "text/xml");
			return new createObject(xmlDoc);
		}
		else
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async = "false";
			xmlDoc.loadXML(text);
			return new createObject(xmlDoc);
		}
	}

	function objectToXml(obj, nodeName) {
		var xml = "";
		if (typeof(obj.tf_ignore) != "undefined" && obj.tf_ignore == 1) {
			return xml;
		}
		var text = null;
		if (typeof(nodeName) != "undefined") {
			xml = "<" + nodeName;
			for (var m in obj) {
				if (typeof(obj[m]) == "string") {
					if (m == "#text") {
						text = obj[m];
						if (text != "") {
							text = "<![CDATA[" + text + "]]>";
						}
					} else {
						xml += " " + m + "='" + obj[m] + "'";
					}
				}
			}
			xml += ">";
		} else {
			xml += "<?xml version='1.0' encoding='UTF-8'?>";
		}

		if (text == null) {
			for (var m in obj) {
				if (typeof(obj[m]) == "object") {
					if (typeof(obj[m].length) == "number") {
						for (var i = 0; i < obj[m].length; i++) {
							xml += objectToXml(obj[m][i], m);
						}
					} else {
						xml += objectToXml(obj[m], m);
					}
				}
			}
		} else {
			xml += text;
		}

		if (typeof(nodeName) != "undefined") {
			xml += "</" + nodeName + ">";
		}
		return xml;
	}

	function escapeXml(str) {
		str = str.replace(/\&/g, "&amp;");
		str = str.replace(/</g, "&lt;");
		str = str.replace(/>/g, "&gt;");
		str = str.replace(/'/g, "&apos;");
		str = str.replace(/"/g, "&quot;");
		return str;
	}
}

function tf_insertTextNodeFEV(obj, property, fromObj) {
	var value = "";
	if (fromObj != null) {
		if (typeof(fromObj) == "string") {
			value = fromObj;
		} else {
			value = fromObj["#text"];
		}
	}
	var parts = property.split(".");
	var tempObj = obj;
	var parent, current;
	for (var i = 0; i < parts.length; i++) {
		current = parts[i];
		if (typeof(tempObj[current]) == "undefined") {
			tempObj[current] = new Object();
		}
		parent = tempObj;
		tempObj = tempObj[current];
	}

	if (typeof(tempObj.length) == "number") {
		var temp = new Object();
		temp["#text"] = value;
		tempObj.push(temp);
		return temp;
	} else if (typeof(tempObj["#text"]) != "undefined") {
		var temp = tempObj;
		tempObj = new Array();
		tempObj.push(temp);
		temp = new Object();
		temp["#text"] = value;
		tempObj.push(temp);
		parent[current] = tempObj;
		return temp;
	}
	tempObj["#text"] = value;
	return tempObj;
}

function TF_ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful.

			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}

	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function TF_GetSwfVer() {
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;

	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if (isIE && isWin && !isOpera) {
		flashVer = TF_ControlVersion();
	}
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function TF_DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = TF_GetSwfVer();
	if (versionStr == -1) {
		return false;
	} else if (versionStr != 0) {
		if (isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray = versionStr.split(" ");
			// ["WIN", "2,0,0,11"]
			tempString = tempArray[1];
			// "2,0,0,11"
			versionArray = tempString.split(",");
			// ['2', '0', '0', '11']
		} else {
			versionArray = versionStr.split(".");
		}
		var versionMajor = versionArray[0];
		var versionMinor = versionArray[1];
		var versionRevision = versionArray[2];

		// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function TF_AC_AddExtension(src, ext)
{
	if (src.indexOf('?') != -1)
		return src.replace(/\?/, ext + '?');
	else
		return src + ext;
}

function TF_AC_Generateobj(objAttrs, params, embedAttrs)
{
	var str = '';
	if (isIE && isWin && !isOpera)
	{
		str += '<object ';
		for (var i in objAttrs)
		{
			str += i + '="' + objAttrs[i] + '" ';
		}
		str += '>';
		for (var i in params)
		{
			str += '<param name="' + i + '" value="' + params[i] + '" /> ';
		}
		str += '</object>';
	}
	else
	{
		str += '<embed ';
		for (var i in embedAttrs)
		{
			str += i + '="' + embedAttrs[i] + '" ';
		}
		str += '> </embed>';
	}

	document.write(str);
}

function TF_AC_FL_RunContent() {
	var ret =
			TF_AC_GetArgs
					(arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
							, "application/x-shockwave-flash"
							);
	TF_AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function TF_AC_GetArgs(args, ext, srcParamName, classid, mimeType) {
	var ret = new Object();
	ret.embedAttrs = new Object();
	ret.params = new Object();
	ret.objAttrs = new Object();
	for (var i = 0; i < args.length; i = i + 2) {
		var currArg = args[i].toLowerCase();

		switch (currArg) {
			case "classid":
				break;
			case "pluginspage":
				ret.embedAttrs[args[i]] = args[i + 1];
				break;
			case "src":
			case "movie":
				args[i + 1] = TF_AC_AddExtension(args[i + 1], ext);
				ret.embedAttrs["src"] = args[i + 1];
				ret.params[srcParamName] = args[i + 1];
				break;
			case "onafterupdate":
			case "onbeforeupdate":
			case "onblur":
			case "oncellchange":
			case "onclick":
			case "ondblclick":
			case "ondrag":
			case "ondragend":
			case "ondragenter":
			case "ondragleave":
			case "ondragover":
			case "ondrop":
			case "onfinish":
			case "onfocus":
			case "onhelp":
			case "onmousedown":
			case "onmouseup":
			case "onmouseover":
			case "onmousemove":
			case "onmouseout":
			case "onkeypress":
			case "onkeydown":
			case "onkeyup":
			case "onload":
			case "onlosecapture":
			case "onpropertychange":
			case "onreadystatechange":
			case "onrowsdelete":
			case "onrowenter":
			case "onrowexit":
			case "onrowsinserted":
			case "onstart":
			case "onscroll":
			case "onbeforeeditfocus":
			case "onactivate":
			case "onbeforedeactivate":
			case "ondeactivate":
			case "type":
			case "codebase":
			case "id":
				ret.objAttrs[args[i]] = args[i + 1];
				break;
			case "width":
			case "height":
			case "align":
			case "vspace":
			case "hspace":
			case "class":
			case "title":
			case "accesskey":
			case "name":
			case "tabindex":
				ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i + 1];
				break;
			default:
				ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i + 1];
		}
	}
	ret.objAttrs["classid"] = classid;
	if (mimeType) ret.embedAttrs["type"] = mimeType;
	return ret;
}

if (typeof(tf_floatingAdType) == "string") {
	tf_floatingAdType = {
		OutOfBanner : 0,
		FEV : 1,
		InterstitialFEV : 2,
		Interstitial : 4
	}[tf_floatingAdType];
	if (typeof(tf_floatingAdType) == "undefined") {
		tf_floatingAdType = 0;
	}
}

function tf_getParams(value) {
	var params = {};
	value = value.split("?");
	if(value.length == 2) {
		value = value[1];
	} else {
		value = value[0];
	}
	value = value.split("&");
	for(var i = 0; i < value.length; i++) {
		var keyValue = value[i].split("=");
		if(keyValue.length == 2) {
			params[keyValue[0]]= unescape(keyValue[1]);
		}
	}
	return params;
}

function tf_flashVarHasKey(extraFlashVars, key) {
	var obj;
	if(typeof(extraFlashVars) == "object") {
		obj = extraFlashVars;
	} else {
		obj = tf_getParams(extraFlashVars);
	}

	for(var m in obj) {
		if(m == key){
			return true;
		}
	}

	return false;
}

function tf_addFlashVar(key, value) {
	if(typeof(tf_extraFlashVars) != "undefined") {
		if(tf_flashVarHasKey(tf_extraFlashVars, key) ==  false) {
			if(typeof(tf_extraFlashVars) == "object"){
				tf_extraFlashVars[key] = value;
			} else if(typeof(tf_extraFlashVars) == "string") {
				tf_extraFlashVars += "&" + key + "=" + escape(value);
			}
		}
	} else {
		tf_extraFlashVars = key + "=" + escape(value);
	}
}

function tf_addFlashVarFloating(key, value) {
	if(typeof(tf_extraFlashVarsFloating) != "undefined") {
		if(tf_flashVarHasKey(tf_extraFlashVarsFloating, key) ==  false) {
			if(typeof(tf_extraFlashVarsFloating) == "object"){
				tf_extraFlashVarsFloating[key] = escape(value);
			} else if(typeof(tf_extraFlashVarsFloating) == "string") {
				tf_extraFlashVarsFloating += "&" + key + "=" + escape(value);
			}
		}
	} else {
		tf_extraFlashVarsFloating = key + "=" + escape(value);
	}
}

if (tf_floatingAdType == 1 && (typeof(tf_VASTXmlFEV) == "undefined" || tf_VASTXmlFEV == "") && typeof(tf_flashfile) != "undefined") {
	var locations = new Array();
	locations.push(tf_flashfile);
	i = 1;
	while (eval("typeof(tf_flashfile" + i + ")") != "undefined") {
		locations.push(eval("tf_flashfile" + i));
		i++;
	}

	var videoIndex = parseInt(Math.random() * 100000, 10) % locations.length;
	tf_flashfile = locations[videoIndex];
	if(totalVideos != locations.length) {
		videoIndex = 0;
	}

	tf_addFlashVarFloating("videoIndex", videoIndex);
}

function TF_GetFlashVars3(extraVars) {
	var flashVars = "";
	flashVars = "clickTag=" + escape(tf_clickTag);
	flashVars += "&clickTAG=" + escape(tf_clickTag);
	flashVars += "&clicktag=" + escape(tf_clickTag);

	var i = 1;
	while (eval("typeof(tf_clickTag" + i + ")") != "undefined") {
		flashVars += "&clickTag" + i + "=" + escape(eval("tf_clickTag" + i));
		i++;
	}

	flashVars += "&tf_flash=" + TF_AC_AddExtension(tf_adBanner, ".swf");
	flashVars += "&tf_button=" + tf_button;
	flashVars += "&tf_state=" + tf_state;
	flashVars += "&tf_city=" + tf_city;
	flashVars += "&tf_zipcode=" + tf_zipcode;
	flashVars += "&tf_gender=" + tf_gender;
	flashVars += "&tf_location=" + tf_location;
	flashVars += "&tf_id=" + tf_id;

	if (typeof(extraVars) == "object") {
		for (i in extraVars) {
			flashVars += "&" + i + "=" + escape(extraVars[i]);
		}
	} else if (typeof(extraVars) == "string") {
		flashVars += "&" + extraVars;
	}
	return flashVars;
}

if (tf_floatingAdType != 2 && tf_floatingAdType != 4 && typeof(tf_flashfile) != "undefined") {
	tf_adBanner = tf_flashfile;
}

if (typeof(tf_use_flash_wrapper) == "undefined") {
	tf_use_flash_wrapper = false;
}

if (tf_use_flash_wrapper) {
	tf_flashfile = tf_loaderFlash;
}

//if (typeof(tf_allowScriptAccess) == "undefined") {
	tf_allowScriptAccess = "always";
//}

if (typeof(tf_salign) == "undefined") {
	tf_salign = "lt";
}

if (typeof(tf_bgcolor) == "undefined") {
	tf_bgcolor = "#ffffff";
}

if (typeof(tf_wmode) == "undefined") {
	if (tf_floatingAdType == 1 && typeof(tf_VASTXmlFEV) != "undefined" && tf_VASTXmlFEV != "") {
		tf_wmode = "transparent";
	} else {
		tf_wmode = "opaque";
	}
}

tf_addFlashVar("tf_flashLoaded", "_FEVLL2");
tf_addFlashVar("tf_sendData", "_FEVflashToJS2");
tf_addFlashVar("tf_show", "_showFloating3");
tf_addFlashVar("tf_clickEvent", "_fireEngagementPixelFEV3");
tf_addFlashVarFloating("tf_flashLoaded", "_FEVMainFL");
tf_addFlashVarFloating("tf_close", "_hideFloating3");

function tf_FEVLL2(id) {
	if (getVariableValue(id, "tf_FEVLL") == false) {
		setVariableValue(id, "tf_FEVLL", true);
		try {
			var flash_object;
			if (getVariableValue(id, "tf_floatingAdType") == 1) {
				flash_object = tf_thisMovie("TFclick" + id);
			} else {
				flash_object = tf_thisMovie(getVariableValue(id, "flashId"));
			}
			if (flash_object) {
				i = 1;
				var additionalVASTXmls = new Array(getVariableValue(id, "tf_VASTXmlFEV"));
				while (typeof(getVariableValue(id, "tf_VASTXmlFEV" + i)) != "undefined") {
					additionalVASTXmls.push(getVariableValue(id, "tf_VASTXmlFEV" + i));
					i++;
				}
				flash_object.fevMode(0, additionalVASTXmls);
			}
		} catch (ex) {
		}
	}
}

function tf_FEVflashToJS2(id, status, xmls) {
	if (status == 1) {
		if (typeof(getVariableValue(id, "tf_FEVTestMode")) != "undefined" && getVariableValue(id, "tf_FEVTestMode") == true) {
			if(typeof(getVariableValue(id, "tf_xmlsLoadedFEV_test")) != "undefined") {
				var img = new Image();
				img.src = getVariableValue(id, "tf_xmlsLoadedFEV_test") + new Date().getTime();
			}
		}
		tf_fevObj = new tf_FEV3_VAST2(xmls, getVariableValue(id, "tf_width"), getVariableValue(id, "tf_height"), id);
		setVariableValue(id, "tf_fevObj", tf_fevObj);
		if (typeof(tf_fevObj.customObj.Root.Banner.Flash) != "undefined") {
			document.getElementById("TFFEVBannerDiv" + id).innerHTML = getVariableValue(id, "VASTFlash").replace("tf_flashfile.swf", tf_fevObj.customObj.Root.Banner.Flash.URL["#text"]).replace("tf_flashVars", tf_fevObj.customObj.Root.Banner.Flash.AdParameters["#text"]);
			window.setTimeout("tf_fireImpressionPixelsFEV('" + id + "', 'Flash');", 1000);
		} else if (typeof(tf_fevObj.customObj.Root.Banner.Image) != "undefined") {
			document.getElementById("TFFEVBannerDiv" + id).innerHTML = getVariableValue(id, "VASTImage").replace("tf_imagefile", tf_fevObj.customObj.Root.Banner.Image.URL["#text"]);
			window.setTimeout("tf_fireImpressionPixelsFEV('" + id + "', 'Image');", 1000);
		}
		document.getElementById("TFFEVTeaserDiv" + id).style.display = "none";
		document.getElementById("TFFEVBannerDiv" + id).style.display = "";
		document.getElementById("TFFEVBannerDiv" + id).onmouseover = function() {
			//document.getElementById("TFFEVBannerDiv" + id).style.display = "none";
			document.getElementById("TFFEVTeaserDiv" + id).style.display = "";
			if (getVariableValue(id, "tf_floatingAdType") == 1) {
				if (isIE) {
					try {
						var flash_object = tf_thisMovie("TFclick" + id);
						if (flash_object) {
							flash_object.Play();
						}
					} catch (ex) {
					}
				}
				window.setTimeout("tf_FEVTeaserAnimate('" + id + "')", 100);
			} else {
				tf_FEVMainFL(id);
			}
		}
		document.getElementById("TFFEVTeaserDiv" + id).onmouseout = function() {
			document.getElementById("TFFEVTeaserDiv" + id).style.display = "none";
			//document.getElementById("TFFEVBannerDiv" + id).style.display = "";
		}
	} else {
		if (typeof(getVariableValue(id, "tf_FEVTestMode")) != "undefined" && getVariableValue(id, "tf_FEVTestMode") == true) {
			if(typeof(getVariableValue(id, "tf_error_test")) != "undefined") {
				var img = new Image();
				img.src = getVariableValue(id, "tf_error_test") + "Error loading xml";
			}
		}
	}
}

function tf_FEVTeaserAnimate(id) {
	try {
		var flash_object = tf_thisMovie("TFclick" + id);
		if (flash_object) {
			flash_object.fevMode(1);
		}
	} catch (ex) {
	}
}

function tf_FEVMainFL(id) {
	var flash_object = tf_thisMovie(getVariableValue(id, "flashId"));
	try {
		if (flash_object) {
			flash_object.sendXMLData(getVariableValue(id, "tf_fevObj").customXml);
		}
	} catch (ex) {
	}
}

function tf_FEVErrorHandling(status) {

}

var TF_hasRightVersionFloating = TF_DetectFlashVer(TF_requiredMajorVersion, TF_requiredMinorVersion, TF_requiredRevision);

if (tf_floatingAdType != 2 && tf_floatingAdType != 4 && typeof(tf_flashfile) != "undefined")
{
	if (TF_hasRightVersionFloating) {  // if we've detected an acceptable version
		if (tf_floatingAdType == 1 && typeof(tf_VASTXmlFEV) != "undefined" && tf_VASTXmlFEV != "") {
			document.write("<div id='TFFEVMainDiv" + tf_id + "' style='position:relative;width:" + tf_width + "px;height:" + tf_height + "px;'><div id='TFFEVTeaserDiv" + tf_id + "' style='z-index:2;position:absolute;width:" + tf_width + "px;height:" + tf_height + "px;'>");
		}
		var tf_flashVars = "";
		if (typeof(tf_extraFlashVars) != "undefined") {
			tf_flashVars = TF_GetFlashVars3(tf_extraFlashVars);
		} else {
			tf_flashVars = TF_GetFlashVars3();
		}

		// embed the flash movie
		TF_AC_FL_RunContent(
				'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
				'width', tf_width,
				'height', tf_height,
				'src', 'banner',
				'quality', 'high',
				'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'play', 'true',
				'loop', 'true',
				'scale', 'showall',
				'wmode', tf_wmode,
				'devicefont', 'false',
				'id', TFclick,
				'bgcolor', tf_bgcolor,
				'name', TFclick,
				'menu', 'false',
				'allowFullScreen', 'false',
				'allowScriptAccess', tf_allowScriptAccess,
				'movie', tf_flashfile,
				'salign', tf_salign,
				'flashVars', tf_flashVars
				);
		//end AC code
		if (tf_floatingAdType == 1 && typeof(tf_VASTXmlFEV) != "undefined" && tf_VASTXmlFEV != "") {
			document.write("</div><div id='TFFEVBannerDiv" + tf_id + "' style='z-index:1;position:absolute;width:" + tf_width + "px;height:" + tf_height + "px;display:none;'></div></div>");
		}
	} else {  // flash is too old or we can't detect the plugin
		document.write('<a href="' + tf_clickTag + '" target="_blank">');
		document.write('<img src="' + tf_imagefile + '" style="width:' + tf_width + 'px;height:' + tf_height + 'px;" border="0px"></a>');
	}

}

if (tf_floatingAdType == 1 && typeof(tf_flashfile) != "undefined") {
	setVariableValue(tf_id, "VASTFlash", TF_AC_FL_RunContentFloating3(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', tf_width,
			'height', tf_height,
			'src', 'banner',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'opaque',
			'devicefont', 'false',
			'id', TFclick + "2",
			'bgcolor', tf_bgcolor,
			'name', TFclick + "2",
			'menu', 'false',
			'allowFullScreen', 'false',
			'allowScriptAccess', 'never',
			'movie', 'tf_flashfile',
			'salign', tf_salign,
			'flashVars', 'tf_flashVars'
			));
	setVariableValue(tf_id, "VASTImage", '<img src="tf_imagefile" style="width:' + tf_width + 'px;height:' + tf_height + 'px;" border="0px">');
}

function TF_AC_GenerateobjFloating3(objAttrs, params, embedAttrs)
{
	var str = '';
	if (isIE && isWin && !isOpera)
	{
		str += '<object ';
		for (var i in objAttrs)
		{
			str += i + '="' + objAttrs[i] + '" ';
		}
		str += '>';
		for (var i in params)
		{
			str += '<param name="' + i + '" value="' + params[i] + '" /> ';
		}
		str += '</object>';
	}
	else
	{
		str += '<embed ';
		for (var i in embedAttrs)
		{
			str += i + '="' + embedAttrs[i] + '" ';
		}
		str += '> </embed>';
	}

	return str;
}

function TF_AC_FL_RunContentFloating3() {
	var ret =
			TF_AC_GetArgs
					(arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
							, "application/x-shockwave-flash"
							);
	return TF_AC_GenerateobjFloating3(ret.objAttrs, ret.params, ret.embedAttrs);
}

function getVariableValue(id, name) {
	if (typeof(tf_variableManager) != "undefined") {
		return tf_variableManager[id][name];
	}
}

function setVariableValue(id, name, value) {
	if (typeof(tf_variableManager) == "undefined") {
		tf_variableManager = new Object();
	}
	if (typeof(tf_variableManager[id]) == "undefined") {
		tf_variableManager[id] = new Object();
	}
	tf_variableManager[id][name] = value;
}

var flashId = "TFFloatingFlash" + tf_id;
var divFixedId = "TFFloatingFixedDiv" + tf_id;
var dummyIFrameId = "TFFloatingDummyIFrame" + tf_id;
setVariableValue(tf_id, "flashId", flashId);
setVariableValue(tf_id, "divFixedId", divFixedId);
setVariableValue(tf_id, "dummyIFrameId", dummyIFrameId);

if (typeof(tf_floatingPosition) != "undefined") {
	setVariableValue(tf_id, "tf_floatingPosition", tf_floatingPosition);
} else {
	setVariableValue(tf_id, "tf_floatingPosition", "cc");
}

if (typeof(tf_floatingPreLoaded) != "undefined") {
	setVariableValue(tf_id, "tf_floatingPreLoaded", tf_floatingPreLoaded);
} else {
	setVariableValue(tf_id, "tf_floatingPreLoaded", true);
}

if (typeof(tf_floatingDelay) != "undefined") {
	setVariableValue(tf_id, "tf_floatingDelay", tf_floatingDelay * 1000);
} else {
	setVariableValue(tf_id, "tf_floatingDelay", 10000);
}

if (typeof(tf_hidden_floatingReLoadByPlay) != "undefined") {
	setVariableValue(tf_id, "tf_hidden_floatingReLoadByPlay", tf_hidden_floatingReLoadByPlay);
} else {
	setVariableValue(tf_id, "tf_hidden_floatingReLoadByPlay", 1);
}

if (typeof(tf_hidden_floatingHideByStop) != "undefined") {
	setVariableValue(tf_id, "tf_hidden_floatingHideByStop", tf_hidden_floatingHideByStop);
} else {
	setVariableValue(tf_id, "tf_hidden_floatingHideByStop", 1);
}

if (typeof(tf_engagementPixelFEV_TF) != "undefined") {
	setVariableValue(tf_id, "tf_engagementPixelFEV_TF", tf_engagementPixelFEV_TF);
} else {
	setVariableValue(tf_id, "tf_engagementPixelFEV_TF", "");
}

if (typeof(tf_FEVTestMode) != "undefined" && tf_FEVTestMode == true) {
	setVariableValue(tf_id, "tf_FEVTestMode", true);
	if (typeof(tf_engagementPixelFEV_TF_test) != "undefined") {
		setVariableValue(tf_id, "tf_engagementPixelFEV_TF_test", tf_engagementPixelFEV_TF_test);
	}
	if (typeof(tf_xmlsLoadedFEV_test) != "undefined") {
		setVariableValue(tf_id, "tf_xmlsLoadedFEV_test", tf_xmlsLoadedFEV_test);
	}
	if (typeof(tf_error_test) != "undefined") {
		setVariableValue(tf_id, "tf_error_test", tf_error_test);
	}	
}

if (typeof(tf_engagementPixelFEV_TP) != "undefined") {
	setVariableValue(tf_id, "tf_engagementPixelFEV_TP", tf_engagementPixelFEV_TP);
} else {
	setVariableValue(tf_id, "tf_engagementPixelFEV_TP", "");
}

i = 1;
while (eval("typeof(tf_engagementPixelFEV_TP" + i + ")") != "undefined") {
	setVariableValue(tf_id, "tf_engagementPixelFEV_TP" + i, eval("tf_engagementPixelFEV_TP" + i));
	i++;
}

if (typeof(tf_FEVVideoFile) != "undefined") {
	setVariableValue(tf_id, "tf_FEVVideoFile", tf_FEVVideoFile);
} else {
	setVariableValue(tf_id, "tf_FEVVideoFile", "");
}

if (typeof(tf_floatingAdType) == "undefined") {
	tf_floatingAdType = 0;
}

setVariableValue(tf_id, "tf_floatingAdType", tf_floatingAdType);

if (typeof(tf_videoBackgroundColorFEV) != "undefined") {
	setVariableValue(tf_id, "tf_videoBackgroundColorFEV", tf_videoBackgroundColorFEV);
} else {
	setVariableValue(tf_id, "tf_videoBackgroundColorFEV", "#000000");
}

if (typeof(tf_videoBackgroundOpacityFEV) != "undefined") {
	setVariableValue(tf_id, "tf_videoBackgroundOpacityFEV", tf_videoBackgroundOpacityFEV);
} else {
	setVariableValue(tf_id, "tf_videoBackgroundOpacityFEV", 50);
}

if (typeof(tf_showFloatingCallback) != "undefined") {
	setVariableValue(tf_id, "tf_showFloatingCallback", tf_showFloatingCallback);
}

if (typeof(tf_hideFloatingCallback) != "undefined") {
	setVariableValue(tf_id, "tf_hideFloatingCallback", tf_hideFloatingCallback);
}

if (TF_hasRightVersionFloating) {
	if (tf_floatingAdType == 1 || tf_floatingAdType == 2) {
		if (typeof(tf_VASTXmlFEV) == "undefined" || tf_VASTXmlFEV == "") {
			setVariableValue(tf_id, "tf_fevObj", new tf_FEV3_VAST2(null, (typeof(tf_width) != "undefined")?tf_width:null, (typeof(tf_height) != "undefined")?tf_height:null, tf_id));
		} else {
			setVariableValue(tf_id, "tf_VASTXmlFEV", tf_VASTXmlFEV);
			i = 1;
			while (eval("typeof(tf_VASTXmlFEV" + i + ")") != "undefined") {
				setVariableValue(tf_id, "tf_VASTXmlFEV" + i, eval("tf_VASTXmlFEV" + i));
				i++;
			}
			setVariableValue(tf_id, "tf_FEVLL", false);
			if (tf_floatingAdType != 2) {
				setVariableValue(tf_id, "tf_width", tf_width);
				setVariableValue(tf_id, "tf_height", tf_height);
			}
		}
	}

	document.write("<!--[if gte IE 5]><script type='text/javascript'>var tf_oldIE = true;</script><![endif]-->");
	document.write("<!--[if gt IE 6]><div style='width:2px;height:2px;position:absolute;visibility:hidden;top:-100px;left:-100px' id='dummyAbsDiv" + tf_id + "'><div style='width:1px;height:1px'></div><div style='width:1px;height:1px;top:0px;left:0px;position:fixed' id='dummyFixedDiv" + tf_id + "'></div></div><![endif]-->");

	if (is_mozilla) {
		document.write("<div style='overflow:scroll;width:150px;height:150px;position:absolute;top:-250px;left:-250px' id='dummyScrollDiv" + tf_id + "'></div>");
	}

	var tf_new_load = new Function("tf_floatingLoad3('" + tf_id + "');");
	if (window.attachEvent) {
		window.attachEvent("onload", tf_new_load);
	} else {
		window.addEventListener("load", tf_new_load, false);
	}

	if (tf_floatingAdType == 1 || tf_floatingAdType == 2) {
		var tf_keydown = new Function("event", "tf_keydownFloating(event, '" + tf_id + "');");
		if (window.attachEvent) {
			document.body.attachEvent("onkeydown", tf_keydown);
		} else {
			window.addEventListener("keydown", tf_keydown, false);
		}
	}
}

function tf_keydownFloating(e, id) {
	if (e.keyCode == 27) {
		try {
			var flash_object = tf_thisMovie(getVariableValue(id, "flashId"));
			if (flash_object) {
				flash_object.goBack();
			}
		} catch (ex) {
		}
	}
}

if (tf_floatingAdType == 2 || tf_floatingAdType == 4) { //Interstitial
	if (document.body) {
		setVariableValue(tf_id, "tf_floatingOnClickSet", true);
		if (document.body.onclick) {
			setVariableValue(tf_id, "tf_bodyClickFloatingPub", document.body.onclick);
		}
		if (isIE) {
			document.body.onclick = new Function("return tf_bodyClickFloating3(event, '" + tf_id + "');");
		} else {
			document.body.onclick = new Function("event", "return tf_bodyClickFloating3(event, '" + tf_id + "');");
		}
	} else {
		setVariableValue(tf_id, "tf_floatingOnClickSet", false);
	}
}

function tf_floatingLoad3(id) {
	if (typeof(getVariableValue(id, "tf_floatingLoaded")) != "undefined" && getVariableValue(id, "tf_floatingLoaded") == true) {
		return;
	}
	setVariableValue(id, "tf_floatingLoaded", true);
	var div_Element = document.getElementById(getVariableValue(id, "divFixedId"));
	var dummy_IFrameElement = document.getElementById(getVariableValue(id, "dummyIFrameId"));
	if (dummy_IFrameElement) {
		var oDoc = dummy_IFrameElement.contentWindow || dummy_IFrameElement.contentDocument;
		if (typeof(oDoc) != "undefined") {
			if (oDoc.document) {
				oDoc = oDoc.document;
			}
			try {
				oDoc.body.attachEvent("onkeydown", new Function("event", "parent.tf_keydownFloating(event, '" + id + "');"));
			} catch (e) {
			}
		}
		if (dummy_IFrameElement.parentNode != document.body) {
			document.body.appendChild(dummy_IFrameElement);
		}
	} else {
		dummy_IFrameElement = new Object();
		dummy_IFrameElement.style = new Object();
	}
	if (div_Element.parentNode != document.body) {
		document.body.appendChild(div_Element);
	}
	var position = getVariableValue(id, "tf_floatingPosition").split("");
	var x = position[0];
	var y = position[1];
	if (document.getElementById("dummyFixedDiv" + id)) {
		if (parseInt(document.getElementById("dummyFixedDiv" + id).offsetTop, 10) == 0) {
			tf_oldIE = false;
		}
		document.getElementById("dummyFixedDiv" + id).style.display = "none";
		document.getElementById("dummyAbsDiv" + id).style.display = "none";
	}
	if (typeof(tf_oldIE) != "undefined" && tf_oldIE == true) {
		div_Element.className = tf_getNewCss(id, x, y);
		dummy_IFrameElement.className = div_Element.className;
	} else {
		div_Element.style.position = "fixed";
		dummy_IFrameElement.style.position = "fixed";
		if (x == "l") {
			div_Element.style.left = "0px";
			dummy_IFrameElement.style.left = "0px";
		} else if (x == "r") {
			div_Element.style.right = "0px";
			dummy_IFrameElement.style.right = "0px";
		} else {
			div_Element.style.left = "50%";
			div_Element.style.marginLeft = (-1) * parseInt(div_Element.style.width, 10) / 2 + "px";
			dummy_IFrameElement.style.left = "50%";
			dummy_IFrameElement.style.marginLeft = (-1) * parseInt(div_Element.style.width, 10) / 2 + "px";
		}

		if (y == "t") {
			div_Element.style.top = "0px";
			dummy_IFrameElement.style.top = "0px";
		} else if (y == "b") {
			div_Element.style.bottom = "0px";
			dummy_IFrameElement.style.bottom = "0px";
		} else {
			div_Element.style.top = "50%";
			div_Element.style.marginTop = (-1) * parseInt(div_Element.style.height, 10) / 2 + "px";
			dummy_IFrameElement.style.top = "50%";
			dummy_IFrameElement.style.marginTop = (-1) * parseInt(div_Element.style.height, 10) / 2 + "px";
		}
	}

	var tf_floatingAdType = getVariableValue(id, "tf_floatingAdType");
	if (tf_floatingAdType == 0) {
		if (getVariableValue(id, "tf_floatingPreLoaded") == true) {
			tf_showFloating3(id);
		}
	} else if (tf_floatingAdType == 1 || tf_floatingAdType == 2) {
		var videoDiv = document.createElement("div");
		var videoDivId = "TFFloatingVideoDiv" + id;
		videoDiv.id = videoDivId;
		if (isOpera) {
			videoDiv.style.zIndex = 2147483583;
		} else if (typeof(navigator.vendor) == "string" && navigator.vendor.indexOf("Apple") != -1) {
			videoDiv.style.zIndex = 16777269;
		}
		else {
			videoDiv.style.zIndex = 2147483645;
		}
		if (typeof(tf_oldIE) != "undefined" && tf_oldIE == true) {
			videoDiv.className = tf_getNewCss(id + "2", "r", "b");
			videoDiv.style.width = screen.width + "px";
			videoDiv.style.height = screen.height + "px";
			dummy_IFrameElement.className = videoDiv.className;
			dummy_IFrameElement.width = screen.width + "px";
			dummy_IFrameElement.height = screen.height + "px";
		} else {
			if (is_mozilla) {
				videoDiv.style.position = "absolute";
				videoDiv.style.left = "0px";
				videoDiv.style.top = "0px";
				var dimensions = tf_floatingGetDimensions(id);
				videoDiv.style.width = dimensions[0] + "px";
				videoDiv.style.height = dimensions[1] + "px";
				window.addEventListener("resize", new Function("var videoDiv = document.getElementById('TFFloatingVideoDiv' + '" + id + "');videoDiv.style.width='0px';videoDiv.style.height='0px';window.setTimeout('var dimensions = tf_floatingGetDimensions(\\'" + id + "\\');var videoDiv = document.getElementById(\\'TFFloatingVideoDiv\\' + \\'" + id + "\\');videoDiv.style.width = dimensions[0] + \\'px\\';videoDiv.style.height = dimensions[1] + \\'px\\';', 100);"), false);
			} else {
				videoDiv.style.position = "fixed";
				videoDiv.style.left = "0px";
				videoDiv.style.top = "0px";
				videoDiv.style.width = "100%";
				videoDiv.style.height = "100%";
				dummy_IFrameElement.style.position = "fixed";
				dummy_IFrameElement.style.left = "0px";
				dummy_IFrameElement.style.top = "0px";
				dummy_IFrameElement.width = "100%";
				dummy_IFrameElement.height = "100%";
			}
		}

		videoDiv.style.backgroundColor = getVariableValue(id, "tf_videoBackgroundColorFEV");
		videoDiv.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + getVariableValue(id, "tf_videoBackgroundOpacityFEV") + ")";
		videoDiv.style.opacity = getVariableValue(id, "tf_videoBackgroundOpacityFEV") / 100;
		videoDiv.style.MozOpacity = getVariableValue(id, "tf_videoBackgroundOpacityFEV") / 100;
		videoDiv.style.display = "none";
		setVariableValue(id, "videoDivId", videoDivId);
		document.body.appendChild(videoDiv);
	}

	if ((tf_floatingAdType == 2 || tf_floatingAdType == 4) && getVariableValue(id, "tf_floatingOnClickSet") == false) {
		if (document.body.onclick) {
			setVariableValue(id, "tf_bodyClickFloatingPub", document.body.onclick);
		}
		if (isIE) {
			document.body.onclick = new Function("return tf_bodyClickFloating3(event, '" + id + "');");
		} else {
			document.body.onclick = new Function("event", "return tf_bodyClickFloating3(event, '" + id + "');");
		}
	}
}

function tf_floatingGetDimensions(id) {
	var scrollDiv = document.getElementById("dummyScrollDiv" + id);
	var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
	var mywidth = Math.max(document.body.scrollWidth, window.innerWidth);

	if (document.body.scrollHeight > window.innerHeight) { //vertical srollbar
		mywidth -= scrollbarWidth;
	}

	var myheight = Math.max(document.body.scrollHeight, window.innerHeight);

	if (document.body.scrollWidth > window.innerWidth) { //horizontal srollbar
		myheight -= scrollbarWidth;
	}
	return [mywidth, myheight];
}

function tf_bodyClickFloating3(e, id) {
	if (typeof(getVariableValue(id, "tf_bodyClickFloatingPub")) == "function") {
		try {
			getVariableValue(id, "tf_bodyClickFloatingPub")();
		} catch(e) {
		}
	}
	var el;
	if (e.target)
		el = e.target;
	else
		el = e.srcElement;
	if ((el.tagName == 'A' || el.tagName == 'AREA') && el.href && tf_targetIsTopFloating(el.target)) { // consider target
		if (el.href.indexOf("javascript:") != -1 || el.href.indexOf("mailto:") != -1 || el.href == "#") {
			return true;
		}
		if (el.onclick)
			return true;
		setVariableValue(id, "href", el.href)
		tf_showFloating3(id);
		return false;
	}
	return true;
}

function tf_targetIsTopFloating(target) {
	if (!target) {
		var t = document.getElementsByTagName("BASE");
		if (t && t.length > 0 && t[0].target) {
			return targetIsTop(t[0].target);
		}
		return window == top;
	}
	if (target == '_top') {
		return true;
	}
	if (target == '_parent') {
		return window.parent == top;
	}
	if (target == '_self') {
		return window == top;
	}
	for (w = window; w && w != w.top; w = w.parent) {
		if (w.name == target) {
			return w == w.top;
		}
	}
	return false;
}

function tf_hideFloating3(id) {
	var div_Element = document.getElementById(getVariableValue(id, "divFixedId"));
	var tf_floatingAdType = getVariableValue(id, "tf_floatingAdType");
	if (tf_floatingAdType == 1 || tf_floatingAdType == 2) {
		var videoDiv = document.getElementById(getVariableValue(id, "videoDivId"));
		videoDiv.style.display = "none";
	}

	if (tf_floatingAdType == 2 || tf_floatingAdType == 4) {
		window.location = getVariableValue(id, "href");
	}

	div_Element.style.display = "none";

	var dummy_IFrameElement = document.getElementById(getVariableValue(id, "dummyIFrameId"));
	if (dummy_IFrameElement) {
		dummy_IFrameElement.style.display = "none";
	}

	var flash_object = tf_thisMovie(getVariableValue(id, "flashId"));
	if (getVariableValue(id, "tf_hidden_floatingHideByStop") == 1) {
		window.setTimeout("document.getElementById(getVariableValue('" + id + "', 'divFixedId')).innerHTML = ''", 100);
	} else if (getVariableValue(id, "tf_hidden_floatingHideByStop") == 2) {
		try {
			flash_object.StopPlay();
		} catch (e) {
		}
	}

	if (typeof(getVariableValue(id, "tf_hideFloatingCallback")) == "function") {
		getVariableValue(id, "tf_hideFloatingCallback")();
	}
}

function tf_showFloating3(id, type, doReload) {
	tf_floatingLoad3(id);
	var div_Element = document.getElementById(getVariableValue(id, "divFixedId"));

	if (getVariableValue(id, "tf_floatingAdType") == 0) {
		var t = getVariableValue(id, "tf_hideFloating3");
		if (typeof(t) != "undefined") {
			window.clearTimeout(t);
		}
	} else if (getVariableValue(id, "tf_floatingAdType") == 1 || getVariableValue(id, "tf_floatingAdType") == 2) {
		var videoDiv = document.getElementById(getVariableValue(id, "videoDivId"));
		videoDiv.style.display = "";
	}

	if (typeof(doReload) == "undefined" || doReload == true) {
		var innerHTML = getVariableValue(id, "innerHTML");
		if (getVariableValue(id, "tf_hidden_floatingReLoadByPlay") == 1) {
			div_Element.innerHTML = innerHTML;
		} else if (getVariableValue(id, "tf_hidden_floatingReLoadByPlay") == 2) {
			var flash_object = tf_thisMovie(getVariableValue(id, "flashId"));
			if (flash_object) {
				try {
					flash_object.GotoFrame(1);
					flash_object.Play();
				} catch (e) {
				}
			}
		}
	}

	div_Element.style.display = "";

	var dummy_IFrameElement = document.getElementById(getVariableValue(id, "dummyIFrameId"));
	if (dummy_IFrameElement) {
		dummy_IFrameElement.style.display = "";
	}

	var tf_floatingAdType = getVariableValue(id, "tf_floatingAdType");
	if (tf_floatingAdType == 0) {
		var delay = getVariableValue(id, "tf_floatingDelay");
		if (delay != 0) {
			setVariableValue(id, "tf_hideFloating3", window.setTimeout("tf_hideFloating3('" + id + "');", delay));
		}
	}

	if (tf_floatingAdType == 1 || tf_floatingAdType == 2) {
		window.setTimeout("tf_fireEngagementPixelFEV3('" + id + "'," + type + ");", 1000);
	}

	if (typeof(getVariableValue(id, "tf_showFloatingCallback")) == "function") {
		getVariableValue(id, "tf_showFloatingCallback")();
	}
}

function tf_getNewCss(id, x, y) {
	var left;
	var top;
	if (x == "l") {
		left = "expression(((ignoreMe=document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft))+'px')";
	} else if (x == "r") {
		left = "expression((0-this.offsetWidth+(document.documentElement.clientWidth?document.documentElement.clientWidth:document.body.clientWidth)+(ignoreMe=document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft))+'px')";
	} else {
		left = "expression((0+((document.documentElement.clientWidth?document.documentElement.clientWidth:document.body.clientWidth)-this.offsetWidth)/2+(ignoreMe=document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft))+'px')";
	}

	if (y == "t") {
		top = "expression(((ignoreMe=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop))+'px');";
	} else if (y == "b") {
		top = "expression((0-this.offsetHeight+(document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight)+(ignoreMe=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop))+'px')";
	} else {
		top = "expression((0+((document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight)-this.offsetHeight)/2+(ignoreMe=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop))+'px')";
	}

	var style = document.createElement('style');
	var cssClassName = "TFFloatingCSSClassName" + id.replace(/\$/g, "");
	style.setAttribute("type", "text/css");
	var def = "." + cssClassName + "{position: absolute;top:" + top + ";left:" + left + "}";
	if (style.styleSheet) {
		style.styleSheet.cssText = def;
	} else {
		style.appendChild(document.createTextNode(def));
	}
	document.getElementsByTagName('head')[0].appendChild(style);
	return cssClassName;
}

function tf_fireEngagementPixelFEV3(id, type) {
	var firePixel = function(url) {
		var img = new Image();
		img.src = url;
	}
	firePixel(getVariableValue(id, "tf_engagementPixelFEV_TF"));
	if (typeof(getVariableValue(id, "tf_engagementPixelFEV_TF_test")) != "undefined") {
		firePixel(getVariableValue(id, "tf_engagementPixelFEV_TF_test") + new Date().getTime() + "&engagementType=" + type);
	}
	if (typeof(getVariableValue(id, "tf_VASTXmlFEV")) == "undefined") {
		firePixel(getVariableValue(id, "tf_engagementPixelFEV_TP"));
		var i = 1;
		while (typeof(getVariableValue(id, "tf_engagementPixelFEV_TP" + i)) != "undefined") {
			firePixel(getVariableValue(id, "tf_engagementPixelFEV_TP" + i));
			i++;
		}
	}
}

function tf_fireImpressionPixelsFEV(id, type) {
	var firePixel = function(url) {
		var img = new Image();
		img.src = url;
	}

	var tf_fevObj = getVariableValue(id, "tf_fevObj");
	var urls = tf_fevObj.customObj.Root.Impression.URL;
	if (typeof(urls) != "undefined") {
		if (typeof(urls.length) == "number") {
			for (var i = 0; i < urls.length; i++) {
				firePixel(urls[i]["#text"]);
			}
		} else {
			firePixel(urls["#text"]);
		}
	}

	urls = tf_fevObj.customObj.Root.Banner[type].Tracking;
	if (typeof(urls) != "undefined") {
		for (var m in urls) {
			if (m == "CreativeView") {
				var finalurls = urls[m].URL;
				if (typeof(finalurls) != "undefined") {
					if (typeof(finalurls.length) == "number") {
						for (var i = 0; i < finalurls.length; i++) {
							firePixel(finalurls[i]["#text"]);
						}
					} else {
						firePixel(finalurls["#text"]);
					}
				}
				break;
			}
		}
	}
}
function tf_thisMovie(movieName) {
	if (isIE) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function TF_GetFlashVarsFloating3(extraVars) {
	var flashVars = "";

	if (tf_floatingAdType != 1 && tf_floatingAdType != 2) {
		flashVars = "clickTag=" + escape(tf_clickTagFloating);
		flashVars += "&clickTAG=" + escape(tf_clickTagFloating);
		flashVars += "&clicktag=" + escape(tf_clickTagFloating);

		var i = 1;
		while (eval("typeof(tf_clickTagFloating" + i + ")") != "undefined") {
			flashVars += "&clickTag" + i + "=" + escape(eval("tf_clickTagFloating" + i));
			i++;
		}
	} else {
		flashVars = "clickTag=" + escape(tf_clickTag);
		flashVars += "&clickTAG=" + escape(tf_clickTag);
		flashVars += "&clicktag=" + escape(tf_clickTag);

		var i = 1;
		while (eval("typeof(tf_clickTag" + i + ")") != "undefined") {
			flashVars += "&clickTag" + i + "=" + escape(eval("tf_clickTag" + i));
			i++;
		}
	}

	flashVars += "&tf_flash=" + TF_AC_AddExtension(tf_adBannerFloating, ".swf");
	flashVars += "&tf_button=" + tf_button;
	flashVars += "&tf_state=" + tf_state;
	flashVars += "&tf_city=" + tf_city;
	flashVars += "&tf_zipcode=" + tf_zipcode;
	flashVars += "&tf_gender=" + tf_gender;
	flashVars += "&tf_location=" + tf_location;
	flashVars += "&tf_id=" + tf_id;

	if (typeof(extraVars) == "object") {
		for (i in extraVars) {
			flashVars += "&" + i + "=" + escape(extraVars[i]);
		}
	} else if (typeof(extraVars) == "string") {
		flashVars += "&" + extraVars;
	}
	return flashVars;
}

var tf_adBannerFloating = tf_flashfileFloating;

if (typeof(tf_use_flash_wrapperFloating) == "undefined") {
	tf_use_flash_wrapperFloating = false;
}

if (tf_use_flash_wrapperFloating) {
	tf_flashfileFloating = tf_loaderFlash;
}

if (typeof(tf_allowScriptAccessFloating) == "undefined") {
	tf_allowScriptAccessFloating = "always";
}

if (typeof(tf_salignFloating) == "undefined") {
	tf_salignFloating = "lt";
}

if (typeof(tf_bgcolorFloating) == "undefined") {
	tf_bgcolorFloating = "#ffffff";
}

if (typeof(tf_wmodeFloating) == "undefined") {
	tf_wmodeFloating = "transparent";
}

var tf_text = "";
var tf_write = function(text) {
	document.write(text);
};
if (!TF_hasRightVersionFloating) {
	tf_write = function(text) {
		tf_text += text;
	};
}

if (TF_hasRightVersionFloating) {
	document.write("<!--[if lt IE 7]><IFRAME id='" + dummyIFrameId + "' style='border:none;display: none; position: absolute; z-index:2147483646;filter:alpha(opacity=0);' src='javascript:false;' frameBorder='0' scrolling='no' width='" + tf_widthFloating + "px' height='" + tf_heightFloating + "px' hSpace = '0' vSpace = '0' marginHeight = '0' marginWidth = '0'></IFRAME><![endif]-->");
}

tf_write("<div id='" + divFixedId + "' style='width:" + tf_widthFloating + "px;height:" + tf_heightFloating + "px;z-index:2147483647;padding:0px;display:none;'>");
if (TF_hasRightVersionFloating) {  // if we've detected an acceptable version
	var tf_flashVars = "";
	if (typeof(tf_extraFlashVarsFloating) != "undefined") {
		tf_flashVars = TF_GetFlashVarsFloating3(tf_extraFlashVarsFloating);
	} else {
		tf_flashVars = TF_GetFlashVarsFloating3();
	}

	var innerHTML = TF_AC_FL_RunContentFloating3(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', tf_widthFloating,
			'height', tf_heightFloating,
			'src', 'banner',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', tf_wmodeFloating,
			'devicefont', 'false',
			'id', flashId,
			'bgcolor', tf_bgcolorFloating,
			'name', flashId,
			'menu', 'false',
			'allowFullScreen', tf_floatingAdType == 1 || tf_floatingAdType == 2,
			'allowScriptAccess', tf_allowScriptAccessFloating,
			'movie', tf_flashfileFloating,
			'salign', tf_salignFloating,
			'flashVars', tf_flashVars
			);
	if (getVariableValue(tf_id, "tf_hidden_floatingReLoadByPlay") == 1) {
		setVariableValue(tf_id, "innerHTML", innerHTML);
	} else {
		tf_write(innerHTML);
	}

} else {  // flash is too old or we can't detect the plugin
	//tf_write('<a href="' + tf_clickTagFloating + '" target="_blank">');
	//tf_write('<img src="' + tf_imagefileFloating + '" style="width:' + tf_widthFloating + 'px;height:' + tf_heightFloating + 'px;" border="0px"></a>');
}
tf_write("</div>");
if (!TF_hasRightVersionFloating) {
	//document.write(tf_text);
}
//Clean up
var tf_use_flash_wrapper = undefined;
var tf_allowScriptAccess = undefined;
var tf_salign = undefined;
var tf_extraFlashVars = undefined;
var tf_bgcolor = undefined;
var tf_wmode = undefined;

i = 1;
while (eval("typeof(tf_clickTag" + i + ")") != "undefined") {
	eval("tf_clickTag" + i + " = undefined");
	i++;
}
//----------------------------------
var tf_floatingPosition = undefined;
var tf_floatingPreLoaded = undefined;
var tf_use_flash_wrapperFloating = undefined;
var tf_allowScriptAccessFloating = undefined;
var tf_salignFloating = undefined;
var tf_extraFlashVarsFloating = undefined;
var tf_bgcolorFloating = undefined;
var tf_wmodeFloating = undefined;
var tf_floatingDelay = undefined;
var tf_hidden_floatingReLoadByPlay = undefined;
var tf_hidden_floatingHideByStop = undefined;
var tf_floatingAdType = undefined;
var tf_videoBackgroundColorFEV = undefined;
var tf_videoBackgroundOpacityFEV = undefined;
var tf_engagementPixelFEV_TF = undefined;
var tf_engagementPixelFEV_TP = undefined;
var tf_showFloatingCallback = undefined;
var tf_hideFloatingCallback = undefined;
var tf_VASTXmlFEV = undefined;

i = 1;
while (eval("typeof(tf_FEVVideoFile" + i + ")") != "undefined") {
	eval("tf_FEVVideoFile" + i + " = undefined");
	i++;
}

i = 1;
while (eval("typeof(tf_clickTagFloating" + i + ")") != "undefined") {
	eval("tf_clickTagFloating" + i + " = undefined");
	i++;
}

tf_flashfile = undefined;
i = 1;
while (eval("typeof(tf_flashfile" + i + ")") != "undefined") {
	eval("tf_flashfile" + i + " = undefined");
	i++;
}

i = 1;
while (eval("typeof(tf_engagementPixelFEV_TP" + i + ")") != "undefined") {
	eval("tf_engagementPixelFEV_TP" + i + " = undefined");
	i++;
}
