if(typeof(dartInstreamObjects)=="undefined"){
	dartInstreamObjects = new Array();
}

//////////////////////////////////////////////////////////////
// DartPlayer object
//////////////////////////////////////////////////////////////

function DartPlayer(playerHandle, pubReadyCallback, version, creativeInfo) {
	this.version = version;

	this.updateLatestDartPlayerVersion = function(targetWindow) {
		var dartPlayerVersion = Number(targetWindow["dartPlayerVersion"].replace("_", "."));

		if(typeof(targetWindow["latestDartPlayerVersion"]) == "undefined") {
			targetWindow["latestDartPlayerVersion"] = targetWindow["dartPlayerVersion"];
		}
		else {
			var latestDartPlayerVersion = Number(targetWindow["latestDartPlayerVersion"].replace("_", "."));
			if(latestDartPlayerVersion < dartPlayerVersion) {
				targetWindow["latestDartPlayerVersion"] = targetWindow["dartPlayerVersion"];
			}
		}
	}

	this.constructDartPlayerWithVersion = function(targetWindow) {
		if(typeof(this.version) == "undefined" || this.version == null) {
			this.version = targetWindow["latestDartPlayerVersion"];
		}
		var dartPlayerIdentifier = "return new DartPlayer_" + this.version;
		var dartPlayerFunction = new Function("playerHandle", "pubReadyCallback", "creativeInfo", dartPlayerIdentifier + "(playerHandle, pubReadyCallback, creativeInfo);");
		var dartInstance = dartPlayerFunction(playerHandle, pubReadyCallback, creativeInfo);
		return dartInstance;
	}

	this.updateLatestDartPlayerVersion(self);
	var versionedDartPlayer = this.constructDartPlayerWithVersion(self);
	versionedDartPlayer.register(playerHandle);
	return versionedDartPlayer;
}

function DartPlayer_03_24(playerHandle, pubReadyCallback, creativeInfo) {
	this.playerVersion = "03_24";
	this.playerIdentifier = "DartPlayer_" + (new Date()).getTime() + "_" + this.playerVersion;
	this.id = "Dart InStream Player";
	this.playerImpl = null;
	this.playerObject = null;
	this.backupPlayer = null;
	this.ad = null;
	this.commercial = false;
	this.customParameters = new Object();
	this.tileCntr = 1;
    this.deScriptURL = null;
    this.enableCustomMETReporting = false;
    this.isScriptParsed = false;
    this.MET_EVENT_IDS={PLAY:11,VIEW_TIME:12,COMPLETE:13,PAUSE:15,MUTE:16,REPLAY:17,MIDPOINT:18,FULL_SCREEN:19,STOP:20};

	this.extractPlayers = function(orig) {
		var players = new Array();
		var arr = orig.split(',');
		for(i=0; i<arr.length; i++) {
			var kv = arr[i].split('=');
			players[kv[0]] = kv[1];
		}
		return players;
	}

	// dfa
	this.isDfa = creativeInfo ? true : false;
	if(this.isDfa) {
		this.creativeInfo = creativeInfo ? creativeInfo: null;
		this.pubPlayers = this.extractPlayers(this.creativeInfo.customKeyValue);
	}
	// end dfa

	// handlers
	this.pubReadyCallback = pubReadyCallback;
	this.adStartHandler = null;
	this.adCompleteHandler = null;
	this.adMidpointHandler = null;
	this.adStopHandler = null;
	this.pauseHandler = null;
	this.restartHandler = null;
	this.muteHandler = null;
	this.fullscreenHandler = null;
	this.clickHandler = null;

	this.autoLogThirdPartyImpression = true;
	this.autoLogThirdPartyClick = true;
	this.autoLogThirdPartyComplete = true;
	this.autoLogThirdPartyMidpoint = true;
	this.initTimeoutId = null;
	this.clickThroughWindowBlocked=null;
	this.clickThroughWindowFeatures=null;


	this.getAd = function() { return this.ad } ;
	this.isCommercial = function() { return this.commercial };

	this.setAutoLogThirdPartyImpression = function(flag) { this.autoLogThirdPartyImpression = flag; }
	this.setAutoLogThirdPartyClick = function(flag) { this.autoLogThirdPartyClick = flag; }
	this.setAutoLogThirdPartyComplete = function(flag) { this.autoLogThirdPartyComplete = flag; }
	this.setAutoLogThirdPartyMidpoint = function(flag) { this.autoLogThirdPartyMidpoint = flag; }
	this.setClickThroughWindowBlocked = function(callback) { this.clickThroughWindowBlocked = callback; }
    this.setClickThroughWindowFeatures= function(windowFeatures) { this.clickThroughWindowFeatures=windowFeatures; }

	//***** callback handlers *****//
	this.getAdStartHandler = function() { return this.adStartHandler; }
	this.getAdCompleteHandler = function() { return this.adCompleteHandler; }
	this.getAdMidpointHandler = function() { return this.adMidpointHandler; }
	this.getPauseHandler = function() { return this.pauseHandler; }
	this.getRestartHandler = function() { return this.restartHandler; }
	this.getMuteHandler = function() { return this.muteHandler; }
	this.getFullscreenHandler = function() { return this.fullscreenHandler; }
	this.getClickHandler = function() {return this.clickHandler; }
	this.getAdStopHandler = function() { return this.adStopHandler; }

	//**** end callback handlers ***//

	//********* callbacks *********//
	this.attachOnAdStart = function(fName) { this.adStartHandler = fName; }
	this.attachOnAdComplete = function(fName) { this.adCompleteHandler = fName; }
	this.attachOnAdMidpoint = function(fName) { this.adMidpointHandler = fName; }
	this.attachOnPause = function(fName) { this.pauseHandler = fName; }
	this.attachOnRestart = function(fName) { this.restartHandler = fName; }
	this.attachOnMute = function(fName) { this.muteHandler = fName; }
	this.attachOnFullscreen = function(fName) { this.fullscreenHandler = fName; }
	this.attachOnClick = function(fName) { this.clickHandler = fName; }
	this.attachOnAdStop = function(fName) { this.adStopHandler = fName; }

	this.detachOnAdStart = function() { this.adStartHandler = null; }
	this.detachOnAdComplete = function() { this.adCompleteHandler = null; }
	this.detachOnAdMidpoint = function() { this.adMidpointHandler = null; }
	this.detachOnPause = function() { this.pauseHandler = null; }
	this.detachOnRestart = function() { this.restartHandler = null; }
	this.detachOnMute = function() { this.muteHandler = null; }
	this.detachOnFullscreen = function() { this.fullscreenHandler = null; }
	this.detachOnClick = function() { this.clickHandler = null; }
	this.detachOnAdStop = function() { this.adStopHandler = null; }

	//******* end callbacks *******//

	this.unregister = function() {
		this.playerImpl.unregister();
		this.playerImpl = null;
		this.ad = null;
		this.adStartHandler = null;
		this.adCompleteHandler = null;
		this.adMidpointHandler = null;
		this.pauseHandler = null;
		this.restartHandler = null;
		this.muteHandler = null;
		this.fullscreenHandler = null;
		this.adStopHandler = null;
	}


	this.setMetaProperties = function(args, createNew) {
		if(createNew) {
			this.customParameters = new Object();
		}
		var keyValues = args;
		for (var i=0; i<keyValues.length;++i) {
			var keyValueString = keyValues[i];
			var key = keyValueString.substring(0,keyValueString.indexOf("=")).toLowerCase();
			var value = keyValueString.substring(keyValueString.indexOf("=")+1, keyValueString.length);
			value = unescape(value);
			if (key == "customparams") {
				var customKeyValues = value.split(",");
				for (var j=0; j<customKeyValues.length;++j) {
					var customKeyValueString = customKeyValues[j];
					var customKey = customKeyValueString.substring(0,customKeyValueString.indexOf("=")).toLowerCase();
					var customValue = customKeyValueString.substring(customKeyValueString.indexOf("=")+1, customKeyValueString.length);
					this.customParameters[customKey] = customValue;
				}
			}
			else {
				this.customParameters[key] = value;
			}
		}
	}

	this.getMetaProperty = function(paramName) {
		return this.customParameters[paramName.toLowerCase()];
	}

	this.createGetCustomParameterFunction = function(dartplayer) {
		return  (function(param) {return dartplayer.getMetaProperty(param);});
	}




	this.flashAdStart = function() {
        if(this.isDEEventBinLoaded()) {
            this.enableCustomMETReporting = true;
        }
		var adObj = this.createInStreamAd();
		this.setMetaProperties(arguments, true);
		adObj.getCustomParameter = this.createGetCustomParameterFunction(this);
		this.ad = adObj;

		this.logUrl(this.getMetaProperty("dartImpURL"), true);
		if(this.isDefined(this.getMetaProperty("thirdPartyImpressionURL"))){
			this.logUrl(this.getMetaProperty("thirdPartyImpressionURL"), false);
		}
		this.flashAdFlushEvents(this.MET_EVENT_IDS.PLAY);
		if(this.adStartHandler) {
			this.adStartHandler(adObj);
		}

		this.writeSurveyUrl(this.ad.getSurveyURL());
	}

	this.flashAdComplete = function() {
        this.flashAdFlushEvents(this.MET_EVENT_IDS.MIDPOINT,this.MET_EVENT_IDS.COMPLETE);

		if(this.isDefined(this.getMetaProperty("thirdPartyCompleteURL"))){
			this.logUrl(this.getMetaProperty("thirdPartyCompleteURL"), false);
		}
		if(this.isDefined(this.getMetaProperty("thirdPartyMidpointURL"))){
			this.logUrl(this.getMetaProperty("thirdPartyMidpointURL"), false);
		}
		this.adCompleteHandler();
	}
	
	this.flashAdFlushEvents=function(){
		//it's ok to create new event bin instances, since they are temporary; they flush and are not used anymore.
		var eventBin = new EventBin(null, null, false, this.enableCustomMETReporting);
        eventBin.registerEventBinUrl(this.ad.getDartRenderingId(), this.ad.getMetPostingURL(), 0);
        for(var i=0; i<arguments.length; i++){
	        eventBin.logMetEvent("Count", arguments[i], this.ad.getDartRenderingId(), false);
        }
        eventBin.flushMetCounters(this.ad.getDartRenderingId());
	}

	this.isWindows = function() {
		return (navigator.appVersion.indexOf("Windows") != -1);
	}

	this.isFirefox = function() {
		var appUserAgent = navigator.userAgent.toUpperCase();
		if(appUserAgent.indexOf("GECKO") != -1) {
			if(appUserAgent.indexOf("FIREFOX") != -1) {
				var version = parseFloat(appUserAgent.substr(appUserAgent.lastIndexOf("/") + 1));
				return (version >= 1) ? true : false;
			}
			else if(appUserAgent.indexOf("NETSCAPE") != -1) {
				var version = parseFloat(appUserAgent.substr(appUserAgent.lastIndexOf("/") + 1));
				return (version >= 8) ? true : false;
			}
		}
		return false;
	}



	this.isMac = function() {
		return (navigator.appVersion.indexOf("Mac") != -1);
	}


	this.isInternetExplorer = function(version) {
		if (version == undefined) return (navigator.appVersion.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Opera") < 0);
		return (navigator.appVersion.indexOf("MSIE "+version) != -1 && navigator.userAgent.indexOf("Opera") < 0);
	}

	this.toObject = function(variableName) {
		if(document.layers) {
			return (document.layers[variableName]) ? eval(document.layers[variableName]) : null;
		}
		else if(document.all && !document.getElementById) {
			return (eval("window." + variableName)) ? eval("window." + variableName) : null;
		}
		else if(document.getElementById && document.body.style) {
			if (document.getElementById(variableName)) {
				var player = document.getElementById(variableName);
				if (typeof(player.CanPlay) == "function") return player;
				var child = player.firstChild;
				while (child != player.lastChild) {
					if (child.nodeName == 'EMBED')  {
						if (child.type == 'audio/x-pn-realaudio-plugin')
							return(eval(child));
					}
					child = child.nextSibling;
				}
			}
			return (document.getElementById(variableName)) ? eval(document.getElementById(variableName)) : null;
		}
	}


	this.logUrl = function(url, appendTimeStamp) {
		var logImage = document.createElement("IMG");
		logImage.height = "0";
		logImage.width = "0";
		logImage.style.visibility = 'hidden';
		logImage.src = (typeof(appendTimeStamp) == "undefined" || appendTimeStamp) ? (url + "&ts=" + new Date().getTime() + ";") : url;
		document.body.appendChild(logImage);
	}


	this.writeSurveyUrl = function(scriptUrl) {
		if(scriptUrl) {
			var scriptElement = document.createElement("Script");
			scriptElement.src = scriptUrl;
			document.body.appendChild(scriptElement);
		}
	}



	this.logThirdPartyImpressionURL = function() {
		if(this.isDefined(this.ad.getThirdPartyImpressionURL())){
			this.logUrl(this.ad.getThirdPartyImpressionURL(), false);
		}
	}


	this.logThirdPartyClickURL = function() {
		if(this.isDefined(this.ad.getThirdPartyClickURL())){
			this.logUrl(this.ad.getThirdPartyClickURL(), false);
		}
	}


	this.logThirdPartyCompleteURL = function() {
		if(this.isDefined(this.ad.getThirdPartyCompleteURL())){
			this.logUrl(this.ad.getThirdPartyCompleteURL(), false);
		}
	}


	this.logThirdPartyMidpointURL = function() {
		if(this.isDefined(this.ad.getThirdPartyMidpointURL())){
			this.logUrl(this.ad.getThirdPartyMidpointURL(), false);
		}
	}


	this.logImpression = function() {
		this.logUrl(this.ad.getImpressionURL(), true);
	}


	this.isDefined = function(obj) {
		return obj ? true : false;
	}


	this.storePlayer = function() {
		dartInstreamObjects[this.playerIdentifier] = this;
	}


	this.doneLoading = function() {
		if(!this.isDfa) {
			//hack to solve circular reference where client's callback is invoked before DartPlayer's constructor has finished executing
			setTimeout("dartInstreamObjects['" + this.playerIdentifier + "'].pubReadyCallback();",100);
		}
	}


	this.initWMPlayer = function() {
		if(this.isPlayerImplLoaded() && this.isEventBinLoaded()) {
			clearTimeout(this.initTimeoutId);
            if(this.isDEEventBinLoaded())
                this.enableCustomMETReporting = true;
            this.playerImpl = new WMPlayer(this, this.isDfa, this.enableCustomMETReporting);
            this.playerImpl.init();            
            this.doneLoading();
		}
		else {
			this.initTimeoutId = setTimeout("dartInstreamObjects['" + this.playerIdentifier + "'].initWMPlayer()", 100);
		}
	}

    this.isDEEventBinLoaded = function() {
        return (typeof(multipleEventDataToPost) != "undefined");
    }

	this.initDMPlayer = function() {
		if(this.isPlayerImplLoaded() && this.isEventBinLoaded()) {
			clearTimeout(this.initTimeoutId);
            this.playerImpl = new DMPlayer(this);
		}
		else {
			this.initTimeoutId = setTimeout("dartInstreamObjects['" + this.playerIdentifier + "'].initDMPlayer()", 100);
		}
	}

	this.initRMPlayer = function() {
		if(this.isPlayerImplLoaded()) {
			clearTimeout(this.initTimeoutId);
            if(this.isDEEventBinLoaded())
                this.enableCustomMETReporting = true;
            this.playerImpl = new RMPlayer(this, this.enableCustomMETReporting);
            this.playerImpl.init();            
            this.doneLoading();
		}
		else {
			this.initTimeoutId = setTimeout("dartInstreamObjects['" + this.playerIdentifier + "'].initRMPlayer()", 100);
		}
	}


	this.fsHook = function(variableName) {
		var str = "";
		str += 'function ' + variableName + '_DoFSCommand(command, args) { \n';
		str += '    dartInstreamObjects["' + this.playerIdentifier + '"].FSCommandHandler(command, args);\n';
		str += '}\n';
		window.eval(str);

		// attach FSCommand handler
		var flashObj = this.toObject(variableName);
		var pointer = eval(variableName + "_DoFSCommand");
		if(this.isInternetExplorer()) {
			flashObj.attachEvent("FSCommand", pointer);
		}
		else if(this.isFirefox()) {
			flashObj.addEventListener("FSCommand", pointer, true);
		}
	}


	this.FSCommandHandler = function(command, args) {
		var argArray = this.splitArgs(args);
		var functionCall = command + "(";
		var count = 0;
		for(var k = 0; k < argArray.length; k++) {
			if(count > 0) {
				functionCall += ", ";
			}
			functionCall += "\"" + argArray[k] + "\"";
			count++;
		}
		functionCall += ")";
		try {
			return eval("dartInstreamObjects[\"" + this.playerIdentifier + "\"]." + functionCall);
		}
		catch(e) {
			try {eval(functionCall);}
			catch(e) {}
		}
	}


	this.splitArgs = function(args) {
		var parameterArray = new Array();
		var unescapedArgs = unescape(args)
		var stringArray = unescapedArgs.split("#mtf#");
		for(var k = 0; k < stringArray.length; k++) {
			parameterArray[k] = stringArray[k];
		}
		return parameterArray;
	}


	this.getCompanionURL = function(baseURL, paramName) {
		var re = new RegExp(paramName+"=\\d*");
		var match = re.exec(baseURL);
		if (match == null) {
			if (baseURL.lastIndexOf(";") != baseURL.length-1) baseURL += ";";
			baseURL += paramName+"="+this.getAd().getDartId();
		}
		else {
			baseURL = baseURL.replace(re,paramName+"="+this.getAd().getDartId());
		}

		if (paramName == "dc_seed") {
			var tileRe = new RegExp("tile=\\d*");
			var tileMatch = tileRe.exec(baseURL);
			if (tileMatch == null) {
				if (baseURL.lastIndexOf(";") != baseURL.length-1) baseURL += ";";
				baseURL += "tile=" + ++this.tileCntr;
			}
		}
		return baseURL;
	}


	this.getRoadblockURL = function(baseURL) {
		return this.getCompanionURL(baseURL, "dc_seed");
	}


	this.writeFlashObject = function(varName) {
		var divElement = document.createElement("div");
		divElement.setAttribute("style", "visibility: hidden; position: absolute; top: 10px; left: 600px;");

		var objectElement = document.createElement("object");
		objectElement.setAttribute("id", varName);
		objectElement.setAttribute("width", "1");
		objectElement.setAttribute("height", "1");
		objectElement.setAttribute("classid", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");

		var paramElement = document.createElement("param");
		paramElement.setAttribute("name", "movie");
        paramElement.setAttribute("value", "http://m1.2mdn.net/879366/imp_" + this.playerVersion +".swf?uagent=" + navigator.userAgent);

		var embedElement = document.createElement("embed");
		embedElement.setAttribute("id", varName);
		embedElement.setAttribute("name", varName);
		embedElement.setAttribute("type", "application/x-shockwave-flash");
        embedElement.setAttribute("src", "http://m1.2mdn.net/879366/imp_" + this.playerVersion +".swf?uagent=" + navigator.userAgent);
		embedElement.setAttribute("AllowScriptAccess", "always");
		embedElement.setAttribute("play", "true");
		embedElement.setAttribute("quality", "high");
		embedElement.setAttribute("bgcolor", "#ffffff");
		embedElement.setAttribute("width", "1");
		embedElement.setAttribute("height", "1");
		embedElement.setAttribute("align", "middle");

		objectElement.appendChild(paramElement);
		objectElement.appendChild(embedElement);
		divElement.appendChild(objectElement);
		document.body.appendChild(divElement);
	}


	this.createObserver = function() {
		var variableName = "Flash_Observer_" + (new Date()).getTime();
		this.writeFlashObject(variableName);
		this.fsHook(variableName);
	}


	this.isWMPlayer = function(playerObject) {
		return playerObject.classid.toUpperCase() == 'CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6' ? true : false;
	}


	// dfa
	this.findPlayer = function(doc, loc) {
		var player = null;
		var objects = doc.getElementsByTagName('object');
		for(var i=0; i<objects.length; i++) {
			for(var z in this.pubPlayers) {
				loc+=""; //passed in as object, converting to string to get indexOf working
				if(z != "" && loc.indexOf(z) != -1) {
					if(objects[i].id == this.pubPlayers[z]) {
						player = objects[i];
						break;
					}
					else {
						this.backupPlayer = objects[i];
					}
				}
				else if(this.backupPlayer == null && this.isWMPlayer(objects[i])) {
					this.backupPlayer = objects[i];
				}
			}
			if(player != null) {
				break;
			}
		}
		return player;
	}

	this.scanPage = function(doc) {
		var player = this.findPlayer(doc, doc.location);
		if(player != null) {
			return player;
		}

		var iframes = doc.getElementsByTagName('iframe');
		for(var i = 0; i < iframes.length; i++) {
			try {
				player = this.scanPage(iframes[i].contentWindow.document);
				if(player != null) {
					return player;
				}
			}
			catch(e) {
				continue;
			}
		}
		return null;
	}

	// end dfa

	this.register = function(handle) {
		this.storePlayer();
		if(handle != null) {
			if(typeof(handle) == 'object') {
				this.playerObject = handle;
			}
			else {
				this.playerObject = this.toObject(handle);
			}
			if(!this.isDfa) {
				this.loadSupportiveJSFiles();
			}
			else {
				this.loadDFASupportiveJSFiles();
			}
		}
		else if(this.isDfa) {
			if(this.isInternetExplorer()) {
				var topAccessibleWindow = this.getTopmostWindowFromSelf();
				var playerPointer = this.scanPage(topAccessibleWindow.document);
				if(playerPointer != null) {
					(this.isWMPlayer(playerPointer)) ? this.register(playerPointer) : this.initiateDefaultPlayer();
				}
				else if(this.backupPlayer != null && this.isWMPlayer(this.backupPlayer)) {
					this.register(this.backupPlayer);
				}
				else {
					this.initiateDefaultPlayer();
				}
			}
			else {
				this.initiateDefaultPlayer();
			}
		}
	}

	this.getTopmostWindowFromSelf = function() {
		var topWindow = top;
		var currentWindow = self;
		var parentWindow = null;
		do {
			parentWindow = currentWindow.parent;
			if(!this.hasAccess(parentWindow)) {
				break;
			}
			if(parentWindow.document.getElementsByTagName("frame").length != 0) {
				break;
			}
			currentWindow = parentWindow;
		} while(currentWindow != topWindow);
		return currentWindow;
	}

	this.hasAccess = function(winRef) {
		try {
			winRef.document.getElementsByTagName("div");
			return true;
		}
		catch(e) {
			return false;
		}
	}

	this.initiateDefaultPlayer = function() {
    	if(!this.isPlayerImplLoaded()){
			var scriptTag = self.document.createElement("SCRIPT");
			scriptTag.src = this.creativeInfo.mediaServer + "/DMPlayer_" + this.creativeInfo.templateVersion + ".js";
			self.document.body.appendChild(scriptTag);
		}
		if(!this.isEventBinLoaded()){
			var scriptTagEB = self.document.createElement("SCRIPT");
			scriptTagEB.src = this.creativeInfo.mediaServer + "/EventBin_" + this.creativeInfo.templateVersion + ".js";
			self.document.body.appendChild(scriptTagEB);
    	}
		this.initDMPlayer();
	}

	this.isPlayerImplLoaded = function() {
		return (typeof(DARTInstreamImplDoneLoading) == "boolean" && DARTInstreamImplDoneLoading) ? true : false;
	}

	this.isEventBinLoaded = function() {
		return (typeof(EventBin) != "undefined");
	}

    this.isDERequested = function() {
        if(this.deScriptURL == null)
            this.deScriptURL = this.getDEScriptURL();
        return ((this.deScriptURL!=null) ? true : false);
    }

    this.getDEScriptURL = function() {
        if(!this.isScriptParsed) {
            var keyValuePair = this.getKeyValuePair("deScriptURL");
            if(keyValuePair!=null && keyValuePair[0] != null && keyValuePair[1] != null)
                return keyValuePair[1].toString();
        }
        return null;
    }
    this.getKeyValuePair = function(key) {
        var queryString = this.getQueryString();
        var keyValuePair = null;
        if(queryString != null) {
            for(var i = 0 ; i<queryString.length ; i++) {
                if(queryString[i].toString().indexOf(key)!= -1)
                    keyValuePair = queryString[i].split("=");
            }
        }
        return keyValuePair;
    }

    this.getQueryString = function() {
	    var queryString = null;
	    var dartPlayerScript = this.getDartPlayerScript();
	    if(dartPlayerScript != null){
	        var dartPlayerURL = dartPlayerScript.getAttribute("src");        
	        var queryIndex = dartPlayerURL.indexOf("?");        
	        if(queryIndex != -1) {
	            if(dartPlayerURL.indexOf("&") != -1) {
	                dartPlayerURL = dartPlayerURL.substring(dartPlayerURL.indexOf("?")+ 1);
	                queryString = dartPlayerURL.split("&");
	            }
	            else {
	                queryString = dartPlayerURL.split("?");
	            }
	        }
	    }
        return queryString;        
    }

    this.getDartPlayerScript = function() {
        var allScripts = document.getElementsByTagName("script");        
        for(i = 0; i < allScripts.length; i++) {
        	var src = allScripts[i].getAttribute("src");
            if(src && src.indexOf("DartPlayer_" + this.playerVersion) != -1) {                
                this.isScriptParsed = true;
                return allScripts[i];
            }
        }
        return null;
    };

	this.loadDFASupportiveJSFiles = function() {
		// if WMP player on IE
		if(this.playerObject.classid && this.isWMPlayer(this.playerObject)) {
			if(!this.isPlayerImplLoaded()){
				var scriptTagWmp = self.document.createElement("SCRIPT");
				scriptTagWmp.src = this.creativeInfo.mediaServer + "/WMPlayer_" + this.creativeInfo.templateVersion + ".js";
				self.document.body.appendChild(scriptTagWmp);
			}
			if(!this.isEventBinLoaded()){
				var scriptTagEB = self.document.createElement("SCRIPT");
				scriptTagEB.src = this.creativeInfo.mediaServer + "/EventBin_" + this.creativeInfo.templateVersion + ".js";
				self.document.body.appendChild(scriptTagEB);
			}
			this.initWMPlayer();
		}
	}

	this.loadSupportiveJSFiles = function() {
		if(this.isDERequested()) {
            this.insertScriptBlock(this.deScriptURL);
        }
        // if WMP player on IE
        if(this.playerObject.classid && this.isWMPlayer(this.playerObject)) {
			this.insertScriptBlock("http://m1.2mdn.net/879366/WMPlayer_" + this.playerVersion + ".js");
			this.insertScriptBlock("http://m1.2mdn.net/879366/EventBin_" + this.playerVersion + ".js");
          	this.initWMPlayer();
		}
		// if Real player
		else if ((this.playerObject.type && (this.playerObject.type.indexOf('realaudio') > -1 || this.playerObject.type.indexOf('realvideo') > -1)) || (this.playerObject.classid && this.playerObject.classid.toUpperCase() == 'CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA') ||( this.playerObject.GetLastErrorMoreInfoURL && this.playerObject.GetEntryCopyright)) {
			if (this.isInternetExplorer(7)) {
				var playerName = this.playerObject.id;
				var lineFeed = "\r\n";

				var vbSavePublisher = 'On Error Resume Next' + lineFeed +
				'Set dartPub_OnClipClosed = getRef("'+playerName+'_OnClipClosed")' + lineFeed +
				'Set dartPub_OnClipOpened = getRef("'+playerName+'_OnClipOpened")' + lineFeed +
				'Set dartPub_OnLButtonUp = getRef("'+playerName+'_OnLButtonUp")' + lineFeed +
				'Set dartPub_OnMuteChange = getRef("'+playerName+'_OnMuteChange")' + lineFeed +
				'Set dartPub_onPlayStateChange = getRef("'+playerName+'_OnPlayStateChange")';

				var vbHijack = 'Sub '+playerName+'_OnClipClosed():On Error Resume Next:onClipClosed:dartPub_OnClipClosed():End Sub' + lineFeed +
				'Sub '+playerName+'_OnClipOpened(ByVal name, ByVal url):On Error Resume Next:onClipOpened name, url:dartPub_OnClipOpened name, url:End Sub' + lineFeed +
				'Sub '+playerName+'_OnLButtonUp(ByVal nFlags, ByVal nX, ByVal nY):On Error Resume Next:onLButtonUp nFlags, nX, nY:dartPub_OnLButtonUp nFlags, nX, nY:End Sub' + lineFeed +
				'Sub '+playerName+'_OnMuteChange(ByVal bMute):On Error Resume Next:onMuteChange bMute:dartPub_OnMuteChange bMute:End Sub' + lineFeed +
				'Sub '+playerName+'_OnPlayStateChange(ByVal lNewState):On Error Resume Next:onPlayStateChange lNewState:dartPub_onPlayStateChange lNewState:End Sub';

				window.execScript(vbSavePublisher,"VBScript");
				window.execScript(vbHijack,"VBScript");
			}

			this.insertScriptBlock("http://m1.2mdn.net/879366/RMPlayer_" + this.playerVersion + ".js");
			this.insertScriptBlock("http://m1.2mdn.net/879366/EventBin_" + this.playerVersion + ".js");
			this.initRMPlayer();
		}
		// if WMP player on FF
		else if(this.playerObject.type == 'application/x-oleobject') {
			setTimeout("dartInstreamObjects['" + this.playerIdentifier + "'].doneLoading();", 100);
			if(this.isFirefox()) {
				this.createObserver();
                this.insertScriptBlock("http://m1.2mdn.net/879366/EventBin_" + this.playerVersion + ".js");
			}
		}
	}


	this.insertScriptBlock = function(scriptSrc) {
		if(scriptSrc) {
			if(this.isInternetExplorer() && document.readyState != "complete") {
				document.write('<script type="text/javascript" src="' + scriptSrc + '"></script>');
			}
			else {
				var scriptElement = document.createElement("Script");
				scriptElement.src = scriptSrc;
				document.body.appendChild(scriptElement);
			}
		}
	}

	///////////////////////////////////////////////////////////////////////////////////////
	// Player reporting/callback functions
	///////////////////////////////////////////////////////////////////////////////////////

	this.playerPause = function(eventBin) {
		eventBin.logMetEvent("Count", 15, this.ad.getDartRenderingId(), false);
		if(!this.isDfa && !this.ad.stoppedViewTimer) {
			eventBin.logMetEvent("Stop", 12, this.ad.getDartRenderingId(), false);
		}

		if (!this.ad.calledPubPause && this.isDefined(this.pauseHandler)) {
			this.pauseHandler(this.ad);
			this.ad.calledPubPause = true;
		}
	}

	this.playerFullscreen = function(eventBin) {
		eventBin.logMetEvent("Count", 19, this.ad.getDartRenderingId(), false);

		// callback
		if (!this.ad.calledPubFullscreen && this.isDefined(this.fullscreenHandler)) {
			this.fullscreenHandler(this.ad);
			this.ad.calledPubFullscreen = true;
		}
	}

	this.playerPlay = function(eventBin, playerInstance) {
		this.ad.calledPubStop = false;
		if(!this.isDfa && !this.ad.stoppedViewTimer) {
			eventBin.logMetEvent("Start", 12, this.ad.getDartRenderingId(), false);
		}

		// start
		if(!this.ad.wasStarted) {
			this.ad.wasStarted = true;
			if(!this.isDfa) {
				this.logImpression();

				if(this.autoLogThirdPartyImpression && !this.ad.wasThirdPartyImpressionLogged) {
					this.logThirdPartyImpressionURL();
					this.ad.wasThirdPartyImpressionLogged = true;
				}
			}

			if(this.isDefined(this.adStartHandler) && !this.ad.calledPubStart) {
				this.adStartHandler(this.ad);
				this.ad.calledPubStart = true;
			}

			eventBin.logMetEvent("Count", 11, this.ad.getDartRenderingId(), false);
			if(!this.isDfa && !this.ad.stoppedViewTimer) {
				eventBin.logMetEvent("Start", 12, this.ad.getDartRenderingId(), false);
			}
		}

		// reseting callback
		this.ad.calledPubPause = false;
		playerInstance.isSamePause = false;
	}

	this.playerRestart = function(eventBin) {
		if(this.ad.wasStarted && this.ad.wasStopped) {
			eventBin.logMetEvent("Count", 17, this.ad.getDartRenderingId(), false);

			// callback
			if(!this.ad.calledPubRestart && this.isDefined(this.restartHandler)) {
				this.restartHandler(this.ad);
				this.ad.calledPubRestart = true;
			}
		}
	}

	this.playerStop = function(eventBin) {
		this.ad.wasStopped = true;
		if(!this.isDfa) {
			eventBin.logMetEvent("Stop", 12, this.ad.getDartRenderingId(), false);
		}
		eventBin.logMetEvent("Count", 20, this.ad.getDartRenderingId(), false);
		eventBin.flushMetCounters(this.ad.getDartRenderingId());

		if(this.isDefined(this.adStopHandler) && !this.ad.calledPubStop) {
			this.adStopHandler(this.ad);
			this.ad.calledPubStop = true;
		}

		// reseting callback
		this.ad.calledPubMidpoint = false;
		this.ad.calledPubRestart = false;
	}

	this.playerComplete = function(eventBin) {
		eventBin.logMetEvent("Stop", 12, this.ad.getDartRenderingId(), false);
		eventBin.logMetEvent("Count", 13, this.ad.getDartRenderingId(), false);
		eventBin.flushMetCounters(this.ad.getDartRenderingId());

		if(this.isDefined(this.adCompleteHandler) && !this.ad.calledPubComplete) {
			this.adCompleteHandler(this.ad);
			this.ad.calledPubComplete = true;
		}

		// log 3rd party complete
		if(this.autoLogThirdPartyComplete && !this.ad.wasThirdPartyCompleteLogged) {
			this.logThirdPartyCompleteURL();
			this.ad.wasThirdPartyCompleteLogged = true;
		}

		// reseting callbacks
		this.ad.calledPubMidpoint = false;
		this.ad.calledPubRestart = false;
	}

	this.playerMidpoint = function(eventBin, pos) {
		if(pos > this.ad.getFirstQuarterPoint()) {
			if(!this.ad.wasOneQuarter) {
				eventBin.flushMetCounters(this.ad.getDartRenderingId());
				this.ad.wasOneQuarter = true;
			}
		}

		if(pos > this.ad.getThirdQuarterPoint()) {
			if(!this.ad.wasThreeQuarters) {
				eventBin.flushMetCounters(this.ad.getDartRenderingId());
				this.ad.wasThreeQuarters = true;
			}
		}

		if(pos > this.ad.getMidPoint() && !this.ad.wasMidpointReached) {
			this.ad.wasMidpointReached = true;
			eventBin.logMetEvent("Count", 18, this.ad.getDartRenderingId(), false);
			eventBin.flushMetCounters(this.ad.getDartRenderingId());

			if (this.autoLogThirdPartyMidpoint && !this.ad.wasThirdPartyMidpointLogged) {
				this.logThirdPartyMidpointURL();
				this.ad.wasThirdPartyMidpointLogged = true;
			}

			if(!this.ad.calledPubMidpoint && this.isDefined(this.adMidpointHandler)) {
				this.adMidpointHandler(this.ad);
				this.ad.calledPubMidpoint = true;
			}
		}

		if(pos >= 20 && (this.ad.getDuration() > 90) && !this.ad.was20secFlushed) {
			this.ad.was20secFlushed = true;
			eventBin.flushMetCounters(this.ad.getDartRenderingId());
		}
	}

	this.playerMute = function(eventBin, isMuted) {
		if(isMuted) {
			eventBin.logMetEvent("Count", 16, this.ad.getDartRenderingId(), false);

			if(!this.ad.calledPubMute && this.isDefined(this.muteHandler)) {
				this.muteHandler(this.ad);
				this.ad.calledPubMute = true;
			}
		}
		else { // unmuted
			this.ad.calledPubMute = false;
		}
	}

	this.playerRewind = function(eventBin) {
		if(this.isDefined(this.playerObject.controls)) {
			if(!this.isDfa && this.playerObject.controls.currentPosition < this.ad.currentPosition && !this.ad.stoppedViewTimer) {
				eventBin.logMetEvent("Stop", 12, this.ad.getDartRenderingId(), false);
				this.ad.stoppedViewTimer = true;
			}
			else {
				this.ad.currentPosition = this.playerObject.controls.currentPosition;
			}
		}
	}

	this.playerClick = function(eventBin) {
		if(this.ad.getClickThroughURL()) {
			eventBin.flushMetCounters(this.ad.getDartRenderingId());
		}

		if(this.autoLogThirdPartyClick && !this.ad.wasThirdPartyClickLogged) {
			this.logThirdPartyClickURL();
			this.ad.wasThirdPartyClickLogged = true;
		}

		if(this.isDefined(this.clickHandler)) {
			this.clickHandler(this.ad);
		}

		if(this.isDefined(this.ad.getClickThroughURL())) {
			var clickthroughUrl=this.ad.getClickString() + this.ad.getClickThroughURL();
			if(this.isDefined(this.clickThroughWindowFeatures)){
				var clickthroughWin=window.open(clickthroughUrl, "_blank" , this.clickThroughWindowFeatures);
				if(!clickthroughWin && this.isDefined(this.clickThroughWindowBlocked)){
					this.clickThroughWindowBlocked();
				}
			}
			else{
				document.location = clickthroughUrl;
			}
		}
	}


	this.createInStreamAd = function(mediaPlayback, creativeInfo) {
		return new function() {
			this.mediaPlayback  = (mediaPlayback) ? mediaPlayback : null;
			this.id = "Dart InStream Ad";

			this.creativeInfo = creativeInfo;
			this.isDfa = creativeInfo ? true : false;

			this.reset = function() {
				this.wasStarted = false;
				this.wasStopped = false;
				this.wasMidpointReached = false;
				this.calledPubMute = false;
				this.calledPubMidpoint = false;
				this.calledPubPause = false;
				this.calledPubRestart = false;
				this.calledPubFullscreen = false;
				this.calledPubStop = false;
				this.calledPubStart = false;
				this.calledPubComplete = false;

				this.wasOneQuarter = false;
				this.wasThreeQuarters = false;
				this.was20secFlushed = false;
				this.currentPosition = 0;
				this.stoppedViewTimer = false;

				this.wasThirdPartyImpressionLogged = false;
				this.wasThirdPartyCompleteLogged = false;
				this.wasThirdPartyMidpointLogged = false;
				this.wasThirdPartyClickLogged = false;
			}

			this.getCustomParameter = function(param) {
				return (this.mediaPlayback ? this.mediaPlayback.getItem().getItemInfo(param) : null);
			}

			this.getThirdPartyImpressionURL = function() {
				return this.isDfa ? this.creativeInfo.thirdPartyImpressionURL : this.getCustomParameter('thirdPartyImpressionURL');
			}

			this.getThirdPartyClickURL = function() {
				return this.isDfa ? this.creativeInfo.thirdPartyClickURL : this.getCustomParameter('thirdPartyClickURL');
			}

			this.getThirdPartyCompleteURL = function() {
				return this.isDfa ? this.creativeInfo.thirdPartyCompleteURL : this.getCustomParameter('thirdPartyCompleteURL');
			}

			this.getThirdPartyMidpointURL = function() {
				return  this.isDfa ? this.creativeInfo.thirdPartyMidpointURL : this.getCustomParameter('thirdPartyMidpointURL');
			}

			this.getSurveyURL = function() {
				return this.isDfa ? this.creativeInfo.surveyURL : this.getCustomParameter('surveyURL');
			}

			this.getADID = function() {
				return this.isDfa ? this.creativeInfo.ISCI : this.getCustomParameter('ISCI');
			}

			this.getISCI = function() {
				return this.getADID();
			}

			this.getDartId = function() {
				return this.isDfa ? this.creativeInfo.dartAdId : this.getCustomParameter('DartAdId');
			}

			this.getDartRenderingId = function() {
				return this.isDfa ? this.creativeInfo.renderingId : this.getCustomParameter('DartRenderingId');
			}

			this.getMetPostingURL = function() {
				return this.isDfa ? this.creativeInfo.metPostingURL : this.getCustomParameter('MetPostingURL');
			}

			this.getDuration = function() {
				return this.isDfa ? this.creativeInfo.videoDuration : (this.mediaPlayback) ? this.mediaPlayback.getLength() : -1;
			}

			this.getFirstQuarterPoint = function() {
				return this.isDfa ? this.creativeInfo.videoDuration * .25 : (this.mediaPlayback) ? this.mediaPlayback.getLength() * .25 : -1;
			}

			this.getThirdQuarterPoint = function() {
				return this.isDfa ? this.creativeInfo.videoDuration * .75 : (this.mediaPlayback) ? this.mediaPlayback.getLength() * .75 : -1;
			}

			this.getMidPoint = function() {
				return this.isDfa ? this.creativeInfo.videoDuration * .5 : (this.mediaPlayback) ? this.mediaPlayback.getLength() * .5 : -1;
			}

			this.getClickString = function() {
				return this.isDfa ? this.creativeInfo.clickString : this.getCustomParameter('clickString');
			}

			this.getClickThroughURL = function() {
				return this.isDfa ? this.creativeInfo.clickThroughURL : this.getCustomParameter('clickThroughURL');
			}

			this.getImpressionURL = function() {
				return this.isDfa ? this.creativeInfo.dartImpUrl : this.getCustomParameter('DartImpURL');
			}
		}// end of anonymous inner function
		
		function isPartOfArrayPrototype(subject) {
	        for(var prototypeItem in Array.prototype) {
	            if(prototypeItem == subject) {
	                return true;
	            }
	        }
	        return false;
	    }
	    
	    this.isPartOfArrayPrototype = isPartOfArrayPrototype;
		}
}

dartPlayerVersion = "03_24";
dartPlayerLoaded_03_24 = true;

