﻿// Comscore code
if (typeof COMSCORE == "undefined") {var COMSCORE = {}; }COMSCORE.beacon = function(d) { if (!d) { return; } var a = 1.6, e = document, g = e.location, c = function(h) { if (h == null) { return ""; } return (encodeURIComponent || escape)(h); }, f = [(g.protocol == "https:" ? "https://sb" : "http://b"), ".scorecardresearch.com/b?", "c1=", c(d.c1), "&c2=", c(d.c2), "&rn=", Math.random(), "&c7=", c(g.href), "&c3=", c(d.c3), "&c4=", c(d.c4), "&c5=", c(d.c5), "&c6=", c(d.c6), "&c15=", c(d.c15), "&c16=", c(d.c16), "&c8=", c(e.title), "&c9=", c(e.referrer), "&cv=", a].join(""); f = f.length > 1500 ? f.substr(0, 1495) + "&ct=1" : f; var b = new Image(); b.onload = function() { }; b.src = f; return f; };

//<![CDATA[

// utils
//#region
// cookies
function setFiveMinCookie(c_name, value, expireMinutes) {
	var exdate = new Date();
	exdate.setMinutes(exdate.getMinutes() + parseInt(expireMinutes));
	document.cookie = c_name + "=" + escape(value) +
		((expireMinutes == null) ? "" : ";expires=" + exdate.toGMTString());
}

// Get cookies
function getFiveMinCookie(c_name) {
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1) {
			c_start = c_start + c_name.length + 1;
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start, c_end));
		}
	}
	return "";
}

// function that return params from Querystring
function getPlayerQuerystring(key, default_) {
	if (default_ == null) default_ = "";
	key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
	var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
	var qs = regex.exec(window.location.href);
	if (qs == null)
		return default_;
	else
		return qs[1];
}
//#endregion

// init the five min scripts (run only once)
//#region
if (typeof (fiveMinInit) != "string") {

	// Global variables
	var psFiveMinPlayer = new Array();
	var psFiveMincbfunc = new Array();
	var psFiveMinCounter = 0;

	var fivMin_synPlayerUrl = 'http://syn.5min.com';
	var fivemin_sharedPlayerUrl = 'http://pshared.5min.com';

	if (getPlayerQuerystring("test", "") == "localhost") {
		fivMin_synPlayerUrl = 'http://localhost/syn';
		fivemin_sharedPlayerUrl = 'http://localhost/shared';
	}
	else if (getPlayerQuerystring("test", "") == "5minlocal") {
		fivMin_synPlayerUrl = 'http://syn.5minlocal.com';
		fivemin_sharedPlayerUrl = 'http://shared.5minlocal.com';
	}

	var fiveMinAdaptvCompanionDiv = "fiveMinCB";

	// will hold all the scripts that has to be published
	aSelectedScripts = new Array();

	var fiveMinIsIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;

	// class names for the banners
	var fiveMinClassCompanionBanner = "fiveMinCompanionBanner";
	var fiveMinClassFairBalance = "fiveMinFairBalance";
	var fiveMinClassBottomBanner = "fiveMinBottomBanner";

	fiveMinInit = "completed";
}
//#endregion



// jsonp ZONE
//#region
function jsonp(url, name, query) {
    if (url.indexOf("?") > -1)
        url += "&callback=";
    else
        url += "?callback=";
	url += name + "&";
	if (query)
		url += encodeURIComponent(query) + "&";
	url += new Date().getTime().toString(); // prevent caching        

	var script = document.createElement("script");
	script.setAttribute("src", url);
	script.setAttribute("type", "text/javascript");
	document.getElementsByTagName('head')[0].appendChild(script);
}
//#endregion

// fiveMinCheckJSParams
//#region
// checks whether the parameters passed to the javascript function
function fiveMinCheckJSParams() {
	var aScripts = document.getElementsByTagName("script");
	var aCurrScript = new Array();

	// find all script elements on page that contain special loading feature
	for (var i = 0; i < aScripts.length; i++) {
		var src = aScripts[i].src.toLowerCase();
		var questionMark = src.indexOf("?");
		// if this is player seed, and there's QS and the QS is not only number
		if (src.indexOf("playerseed.js") >= 0 && questionMark > 0 && isNaN(src.substring(questionMark + 1)))
			aCurrScript.push(aScripts[i]);
	}

	// if no scripts were found
	if (aCurrScript.length == 0)
		return;

	for (var curr in aCurrScript) {
		if (fiveMinFindScript(aCurrScript[curr]))
			continue;
		var newSelectedScript = new fiveMinSelectedScript(aCurrScript[curr], aSelectedScripts.length + 1);
		aSelectedScripts.push(newSelectedScript);
	}
}

function fiveMinFindScript(oScript) {
	for (var curr in aSelectedScripts) {
		if (aSelectedScripts[curr].valueOf() == oScript.src)
			return true;
	}
	return false;
}


function ReportComscore(key) {
	// Report to comscore
	
		COMSCORE.beacon({
			c1: 7,
			c2: "6473742",
			c3: key,
			c4: "",
			c5: "",
			c6: "",
			c15: ""
		});
	
	

}

//#endregion

// ***************************************************************************************************
// Class SelectedScript
// ***************************************************************************************************
//#region
if (typeof (fiveMinSelectedScript) != "function") {
	function fiveMinSelectedScript(oScript, counter) {
		this.Script = oScript;          // hold the script DOM object to load the player according to it
		this.IsPlayerCreated = false;   // whether the player created
		this.Counter = counter;         // counter of this player in the page
		this.SmartPlayerDiv = null;     // the div DOM object that will hold the player
		this.PlayerSeed = null;         // the player seed object that loads the player

		// creates and returns the div for the player
		this.createDiv = function() {
			var oNewDiv = document.createElement("div");
			oNewDiv.setAttribute("id", "SmartPlayer_" + this.Counter);
			if (this.Script.parentNode)
				fiveMinAppendAfter(this.Script, oNewDiv);
			this.SmartPlayerDiv = oNewDiv;
			return oNewDiv;
		};

		// createPlayerSeed()
		//#region
		this.createPlayerSeed = function(isToLoad) {
			// get the object params for the server request
			var aParams = this.getParams();
			// create DIV if not yet created,
			if (this.SmartPlayerDiv == null)
				this.createDiv();
			// create temp object to store the data with eval
			window.tempPlayerSeed = null;
			window.tempPlayerSeed = new PlayerSeed(this.SmartPlayerDiv.id);
			// loop on params and store in temp object
			for (var propertyName in aParams) {
				if (typeof (propertyName) == "string" && propertyName.length > 0)
					eval("window.tempPlayerSeed." + propertyName + " = fiveMinGetParamValue(aParams['" + propertyName + "']);");
			}
			// set the new player object and delete the temp object
			this.PlayerSeed = window.tempPlayerSeed;
			window.tempPlayerSeed = null;
			// set the counter of the player object
			this.PlayerSeed.counter = this.Counter;
			// set the cbCustomID
			this.PlayerSeed.cbCustomID = fiveMinAdaptvCompanionDiv + "_" + this.PlayerSeed.counter;
			// load the player
			if (isToLoad)
				this.PlayerSeed.Load();
			this.IsPlayerCreated = true;
		};
		//#endregion

		// getParams()
		//#region
		// gets the parameters from the qs of the javascript
		this.getParams = function() {
		    var url = this.Script.src === undefined ? "" : this.Script.src;
		    var qs = url.substring(url.indexOf("?") + 1).replace(/\+/g, ' ');
		    var args = qs.split("&");
		    var aParams = new Array();
		    // loop on the arguments in the QS to split them
		    for (var i in args) {
		        if (typeof (args[i]) != "string")
		            continue;
		        var pair = args[i].split("=");
		        var name = decodeURIComponent(pair[0]);
		        var value = (pair.length == 2) ? decodeURIComponent(pair[1]) : name;
		        aParams[name] = value;
		    }

		    return aParams;
		};
		//#endregion

		// checks whether the current object equals to specified one
		this.isEqualTo = function(oFiveMinSelectedScript) {
		    return this.valueOf() === oFiveMinSelectedScript.valueOf();
		};

		// override the toString and valueOf methods
		this.toString = this.valueOf = function() {
		    return this.Script.src;
		};

		// load the video and the flash object
		this.createPlayerSeed(true);
	}
}
//#endregion

// ***************************************************************************************************
// Class CompanionBanner
// ***************************************************************************************************
//#region
if (typeof (fiveMinCompanionBanner) != "function") {
	function fiveMinCompanionBanner(htmlID, width, height, isFairBalance, className) {
		this.HtmlID = htmlID;
		this.Width = width;
		this.Height = height;
		this.IsFairBalance = isFairBalance;
		this.ClassName = className;

		this.toString = function(counter, withAmpersand) {
		    var prefix = withAmpersand ? "&" : "";
		    var suffix = counter == 0 ? "" : "" + counter;
		    return "" +
				prefix + "cbHtmlID" + suffix + "=" + this.HtmlID +
				prefix + "cbWidth" + suffix + "=" + this.Width +
				prefix + "cbHeight" + suffix + "=" + this.Height +
				(this.IsFairBalance ? prefix + "cbIsFairBalance" + suffix + "=" + this.IsFairBalance : "");
		};
	}
}
//#endregion

// ***************************************************************************************************
// Class Player - to load the smartplayer density
// ***************************************************************************************************
//#region
var PlayerSeed = function(divLayer) {

    this.divLayer = divLayer;
    this.url = escape(document.location);
    this.cbCustomID = fiveMinAdaptvCompanionDiv;
    this.obj = new Object();
    this.counter = -1;
    this.filterString = "";
    this.libraryID = 0;
    this.wmode = "window";
    this.innerMargin = 1;
    this.companionCenter = true;
    this.cbCheckTime = 200;
    this.cbCount = -1;
    this.CompanionBanners = new Array();

    psFiveMinCounter++;

    // GetParams()
    //#region
    this.GetParams = function() {
        var str = '&isPlayerSeed=true';

        if (this.categories && (this.categories.length > 0 || this.categories > 0)) str += '&categories=' + this.categories;
        if (this.contentQuality && this.contentQuality > 0) str += '&ContentQuality=' + this.contentQuality;
        if (this.featured != undefined) str += '&featured=' + this.featured;
        if (this.fallbackType != undefined) str += "&fallbackType=" + this.fallbackType;
        if (this.playList && (this.playList.length > 0 || this.playList > 0)) str += '&playlist=' + this.getRandomList(this.playList);
        if (this.fallback && (this.fallback.length > 0 || this.fallback > 0)) str += '&fallback=' + this.getRandomList(this.fallback);
        if (this.overlay != undefined) str += '&overlay=' + this.overlay;
        if (this.autoStart != undefined) str += '&autoStart=' + this.autoStart;
        if (this.cbCustomID) str += '&cbCustomID=' + this.cbCustomID;
        if (this.cbFailOverURL) str += '&cbFailOverUrl=' + this.cbFailOverURL;
        if (this.cbFailOverOnStart) str += '&cbFailOverOnStart=' + this.cbFailOverOnStart;
        if (this.skinType != undefined) str += '&skinType=' + this.skinType;
        if (this.testData) str += '&testData=' + this.testData;
        if (this.volume && this.volume >= 0 && this.volume <= 100) str += '&volume=' + this.volume;
        if (this.mute != undefined) str += '&mute=' + this.mute;
        if (this.topHeader) str += '&topHeader=' + this.topHeader;
        if (this.videoControlDisplayColor != undefined && this.videoControlDisplayColor != 'default') str += '&videoControlDisplayColor=' + encodeURIComponent(this.videoControlDisplayColor);
        str += '&ExposureType=PlayerSeed';

        if (this.hasCompanion != undefined) {
            this.obj.hasCompanion = this.hasCompanion;
            str += '&hasCompanion=' + this.hasCompanion;
        }

        if (this.isPreviewMode != undefined) str += '&isPreviewMode=' + this.isPreviewMode;
        if (getPlayerQuerystring("playernewversion3", "") == "true") str += '&playernewversion3=true';
        if (getPlayerQuerystring("playerdebug5min", "") != "") str += '&playerdebug5min=' + getPlayerQuerystring("playerdebug5min", "");
        if (getPlayerQuerystring("isTestDensity", "") == "true") str += '&isTestDensity=true';
        if (document.getElementsByTagName('title')[0]) str += '&shortAnalysisText=' + escape(document.getElementsByTagName('title')[0].innerHTML);
        str += '&url=' + encodeURIComponent(this.url);
        str += "&filterString=" + encodeURIComponent(this.filterString);
        if (this.libraryID > 0) str += "&libraryID=" + this.libraryID;

        str += this.CreateCBQS();

        var test = document.getElementById("__yukitest");
        if (test) {
            test.innerHTML += "PlayerSeed : " + this.counter + "<br />" + str + "<br /><br />";
        }

        return str;
    };
    //#endregion

    // getRandomList()
    //#region
    this.getRandomList = function(videoList) {
        var videoListArr;
        var newVideoListArr = new Array();

        if (!isNaN(videoList)) {
            return "" + videoList;
        }
        if (videoList.length > 0) {
            videoListArr = videoList.split(',');
            var counter = 0;
            for (var j = 0; j < videoListArr.length; j++) {
                var no = Math.round(Math.random() * (videoListArr.length - 1));
                var isInArray = false;
                // Check that value not will be more than one
                for (var i = 0; i < newVideoListArr.length; i++) {
                    if (newVideoListArr[i].toString() == videoListArr[no].toString()) {
                        isInArray = true;
                        break;
                    }
                }

                if (!isInArray)
                    newVideoListArr.push(videoListArr[no]);
            }
        }
        return newVideoListArr.toString();
    };
    //#endregion

    // checkPlayerSeedCookie()
    //#region
    this.checkPlayerSeedCookie = function() {
        var useFrequency = getFiveMinCookie('asPlayerSeed');
        if (useFrequency != null && useFrequency != "")
            return true;
        else
            setFiveMinCookie('asPlayerSeed', '1', this.frequency);

        return false;
    };
    //#endregion

    // Load()
    //#region
    this.Load = function() {

        if (this.doNotDisplay())
            return;

        if (this.counter == -1) {
            this.counter = psFiveMinCounter;
            if (this.cbCustomID == fiveMinAdaptvCompanionDiv)
                this.cbCustomID = fiveMinAdaptvCompanionDiv + "_" + this.counter;
        }
        psFiveMinPlayer[this.counter] = this;

        if (this.cbCount == 3 || this.CompanionBanners == null || typeof (this.CompanionBanners) == "object" && this.CompanionBanners.length == 0) {
            // cbCount == 3 ==> need to override any other defintion and make the 3 banners as should be
            // and if no banners defined, create 2 banners as default
            this.CompanionBanners = new Array();
            this.CompanionBanners.push(new fiveMinCompanionBanner(this.cbCustomID + "_cb", 300, 250, false, fiveMinClassCompanionBanner));
            this.CompanionBanners.push(new fiveMinCompanionBanner(this.cbCustomID + "_fb", 300, Math.max(60, this.height - 250), true, fiveMinClassFairBalance));
            // always create the 3rd banner // if (this.cbCount == 3 || this.cbCount == 2)
            this.CompanionBanners.push(new fiveMinCompanionBanner(this.cbCustomID + "_bt", 728, 90, false, fiveMinClassBottomBanner));
        }

        jsonp
		(fivMin_synPlayerUrl + '/handlers/SenseHandler.ashx?videoCount=1&func=GetResults&counter=' + this.counter + '&sid=' + this.sid + this.GetParams(), 'onSuccessURLPlayer', "");
    };
    //#endregion

    // CreateCBQS()
    //#region
    this.CreateCBQS = function() {
        var cbString = "";
        // always pass this to the player // if (this.cbCount == 2 || this.cbCount == 3)
        cbString = "&cbCount=3";
        if (this.cbCustomID && this.cbCustomID.indexOf(fiveMinAdaptvCompanionDiv) < 0) {
        } else {
            if (typeof (this.CompanionBanners) == "object" && this.CompanionBanners.length > 0) {
                for (var i = 0; i < this.CompanionBanners.length; i++) {
                    cbString += this.CompanionBanners[i].toString(i, true);
                }
            }
        }
        return cbString;
    };
    //#endregion

    // doNotDisplay()
    //#region
    this.doNotDisplay = function() {
        if (this.frequency) {
            if (this.checkPlayerSeedCookie())
                return true;
        }

        return false;
    };
    //#endregion

    // onSuccessURLPlayer()
    //#region
    onSuccessURLPlayer = function(reqJSONtext) {
        //Evaluate Json string to Videos object
        var fiveminVideo = reqJSONtext;

        if (!fiveminVideo) {
            ReportComscore("9");
            return;
        }

        this.height = (fiveminVideo.UsePlayer3 ? 255 : 401);
        this.width = (fiveminVideo.UsePlayer3 ? 400 : 480);

        // Check if no videos then display none
        if (fiveminVideo == undefined || fiveminVideo.ID == 0 || !fiveminVideo.success) {
            ReportComscore("9");
            return;
        }

        var currPlayerSeed = psFiveMinPlayer[reqJSONtext.counter];

        // Display External title if have
        if (psFiveMinPlayer[1].displayIfResults) {
            this.displayIfResults = psFiveMinPlayer[1].toRemoveIfNR;
            document.getElementById(this.displayIfResults).style.display = '';
        }

        // Create wrapper Div include companion if have
        this.divWrapper = document.createElement("div");
        this.divWrapper.setAttribute('id', 'playerWrapper' + reqJSONtext.counter);
        this.divWrapper.setAttribute('style', 'float:left;');
        document.getElementById(currPlayerSeed.divLayer).appendChild(this.divWrapper);

        if (currPlayerSeed.obj.hasCompanion == undefined)
            currPlayerSeed.obj.hasCompanion = reqJSONtext.HasCompanion;

        if (currPlayerSeed.companionPos == undefined)
            currPlayerSeed.companionPos = reqJSONtext.CompanionPos;

        currPlayerSeed.strPlayer = "";
        currPlayerSeed.strPlayer = "<div id='adaptvDiv" + reqJSONtext.counter + "'>";

        if (currPlayerSeed.width)
            this.width = currPlayerSeed.width;

        if (currPlayerSeed.height)
            this.height = currPlayerSeed.height;

        // Check if has logoUrl when isPreviewMode = ture
        if (currPlayerSeed.isPreviewMode && currPlayerSeed.logoUrl)
            this.logoUrl = '&logoUrl=' + currPlayerSeed.logoUrl;
        else
            this.logoUrl = '';

        // check is has companion banner
        var cbString = currPlayerSeed.CreateCBQS();
        if (currPlayerSeed.cbCheckTime > 0)
            cbString += "&cbCheckTime=" + currPlayerSeed.cbCheckTime;
        currPlayerSeed.strPlayer += "<object id='FiveminPlayer" + ((reqJSONtext.counter == 1) ? '' : reqJSONtext.counter) + "' width='" + this.width + "' height='" + this.height + "' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'>" +
            "<param name='allowfullscreen' value='true' />" +
            "<param name='allowScriptAccess' value='always' />" +
            "<param name='movie' value='" + fiveminVideo.EmbededURL + cbString + "' />" +
            "<param name='wmode' value='" + currPlayerSeed.wmode + "' />" +
            "<embed src='" + fiveminVideo.EmbededURL + this.logoUrl + cbString + "' type='application/x-shockwave-flash' width='" + this.width + "' height='" + this.height + "' allowfullscreen='true' " +
            "allowScriptAccess='always' wmode='" + currPlayerSeed.wmode + "'></embed></object>";

        currPlayerSeed.strPlayer += "</div>";

        document.getElementById(currPlayerSeed.divLayer).innerHTML = currPlayerSeed.strPlayer;
        BuildCompanionBanner(currPlayerSeed, fiveminVideo, reqJSONtext);
    };
    //#endregion
};
//#endregion

// Build companion banner if have
// BuildCompanionBanner()
//#region
function BuildCompanionBanner(currPlayerSeed, fiveminVideo, reqJSONtext) {
	if (!currPlayerSeed.obj.hasCompanion)
		return;

	var divCompanion;

	if (currPlayerSeed.cbCustomID && currPlayerSeed.cbCustomID.indexOf(fiveMinAdaptvCompanionDiv) < 0)
		return;

	divCompanion = document.createElement('div');
	divCompanion.setAttribute('id', currPlayerSeed.cbCustomID);

	if (currPlayerSeed.innerMargin > 10 || currPlayerSeed.innerMargin <= 0)
		currPlayerSeed.innerMargin = 1;

	var comPos = currPlayerSeed.cbCount == 3 ? "right" : currPlayerSeed.companionPos;
	var sCenter = currPlayerSeed.companionCenter ? " text-align:center; " : "";
	// Add companion position
	switch (comPos) {
		case "top":
			document.getElementById('adaptvDiv' + reqJSONtext.counter).parentNode.insertBefore(divCompanion, document.getElementById('adaptvDiv' + reqJSONtext.counter));
			if (!fiveMinIsIE)
				divCompanion.setAttribute('style', 'margin-bottom:' + currPlayerSeed.innerMargin + 'px;' + sCenter);
			else
				divCompanion.style.setAttribute('style', 'margin-bottom:' + currPlayerSeed.innerMargin + 'px;' + sCenter);
			break;

		case "left":
			document.getElementById('adaptvDiv' + reqJSONtext.counter).parentNode.insertBefore(divCompanion, document.getElementById('adaptvDiv' + reqJSONtext.counter));
			if (!fiveMinIsIE) {
				divCompanion.setAttribute('style', 'margin-right:' + currPlayerSeed.innerMargin + 'px;float:left;');
				document.getElementById('adaptvDiv' + reqJSONtext.counter).setAttribute('style', 'float:left;');
			} else {
				divCompanion.style.setAttribute('cssText', 'margin-right:' + currPlayerSeed.innerMargin + 'px;float:left;');
				document.getElementById('adaptvDiv' + reqJSONtext.counter).style.setAttribute('cssText', 'float:left;');
			}
			break;

		case "right":
			if (!fiveMinIsIE) {
				document.getElementById('adaptvDiv' + reqJSONtext.counter).setAttribute('style', 'float:left;');
				divCompanion.setAttribute('style', 'float:left;margin-left:' + currPlayerSeed.innerMargin + 'px;');
			} else {
				document.getElementById('adaptvDiv' + reqJSONtext.counter).style.setAttribute('cssText', 'float:left;');
				divCompanion.style.setAttribute('cssText', 'float:left;margin-left:' + currPlayerSeed.innerMargin + 'px;');
			}
			document.getElementById('adaptvDiv' + reqJSONtext.counter).parentNode.appendChild(divCompanion);
			break;

		case "bottom":
		default:
			document.getElementById('adaptvDiv' + reqJSONtext.counter).appendChild(divCompanion);
			if (!fiveMinIsIE)
				divCompanion.setAttribute('style', 'margin-top:' + currPlayerSeed.innerMargin + 'px;' + sCenter);
			else
				divCompanion.style.setAttribute('cssText', 'margin-top:' + currPlayerSeed.innerMargin + 'px;' + sCenter);
			break;
	}

	var numOfBanners = currPlayerSeed.CompanionBanners.length;
	for (var i = 0; i < numOfBanners; i++) {
		// create the 3rd banner only if cbCount is 3
		if (currPlayerSeed.cbCount != 3 && i == numOfBanners - 1)
			continue;
		// create the banner
		fiveMinCreateBannerDiv(divCompanion, currPlayerSeed.CompanionBanners[i], i != 2);
	}
}
//#endregion

function fiveMinCreateBannerDiv(divCompanion, companionBanner, isChild) {
	var divBanner = document.createElement("div");
	divBanner.setAttribute("id", companionBanner.HtmlID);
	divBanner.setAttribute("IsFairBalance", companionBanner.IsFairBalance);
	if (companionBanner.ClassName)
		divBanner.setAttribute("class", companionBanner.ClassName);

	if (isChild)
		divCompanion.appendChild(divBanner);
	else {
		if (!fiveMinIsIE)
			divBanner.setAttribute("style", "clear: both; width: " + companionBanner.Width + "px;");
		else
			divBanner.style.setAttribute("cssText", "clear: both; width: " + companionBanner.Width + "px;");
		fiveMinAppendAfter(divCompanion, divBanner);
	}
}

function fiveMinAppendAfter(appendAfter, newNode) {
	if (appendAfter.nextSibling)
		appendAfter.parentNode.insertBefore(newNode, appendAfter.nextSibling);
	else
		appendAfter.parentNode.appendChild(newNode);
}

function fiveMinGetParamValue(valueString) {
	if (valueString == "true")
		return true;
	if (valueString == "false")
		return false;
	if (isNaN(valueString))
		return valueString;
	else
		return new Number(valueString);
}

fiveMinCheckJSParams();

//]]>