/* sni-core - Wed, 07 Jan 2009 15:58:38 -0500 */

/*! SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
/*
	NOTE: 2008-09-17 - This version is modified for Scripps to show a noPlayerMessage so please don't replace it.
*/

/*! SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/

var swfobject = function() {

	var UNDEF = "undefined",
		OBJECT = "object",
		SHOCKWAVE_FLASH = "Shockwave Flash",
		SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
		FLASH_MIME_TYPE = "application/x-shockwave-flash",
		EXPRESS_INSTALL_ID = "SWFObjectExprInst",

		win = window,
		doc = document,
		nav = navigator,

		domLoadFnArr = [],
		regObjArr = [],
		objIdArr = [],
		listenersArr = [],
		script,
		timer = null,
		storedAltContent = null,
		storedAltContentId = null,
		isDomLoaded = false,
		isExpressInstallActive = false,
		noPlayerMessage = 'For the best website experience please <a href="http://www.adobe.com/go/getflashplayer">install Adobe Flash Player</a> version 9 or higher.';

	/* Centralized function for browser feature detection
		- Proprietary feature detection (conditional compiling) is used to detect Internet Explorer's features
		- User agent string detection is only used when no alternative is possible
		- Is executed directly for optimal performance
	*/
	var ua = function() {
		var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
			playerVersion = [0,0,0],
			d = null;
		if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
			d = nav.plugins[SHOCKWAVE_FLASH].description;
			if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
				d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
				playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
				playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
				playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
			}
		}
		else if (typeof win.ActiveXObject != UNDEF) {
			var a = null, fp6Crash = false;
			try {
				a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7");
			}
			catch(e) {
				try {
					a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".6");
					playerVersion = [6,0,21];
					a.AllowScriptAccess = "always";	 // Introduced in fp6.0.47
				}
				catch(e) {
					if (playerVersion[0] == 6) {
						fp6Crash = true;
					}
				}
				if (!fp6Crash) {
					try {
						a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
					}
					catch(e) {}
				}
			}
			if (!fp6Crash && a) { // a will return null when ActiveX is disabled
				try {
					d = a.GetVariable("$version");	// Will crash fp6.0.21/23/29
					if (d) {
						d = d.split(" ")[1].split(",");
						playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
				}
				catch(e) {}
			}
		}
		var u = nav.userAgent.toLowerCase(),
			p = nav.platform.toLowerCase(),
			webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
			ie = /msie/.test(u) && !/opera/.test(u),
			windows = p ? /win/.test(p) : /win/.test(u),
			mac = p ? /mac/.test(p) : /mac/.test(u);
		return { w3cdom:w3cdom, pv:playerVersion, webkit:webkit, ie:ie, win:windows, mac:mac };
	}();

	/* Cross-browser onDomLoad
		- Based on Dean Edwards' solution: http://dean.edwards.name/weblog/2006/06/again/
		- Will fire an event as soon as the DOM of a page is loaded (supported by Gecko based browsers - like Firefox -, IE, Opera9+, Safari)
	*/
	var onDomLoad = function() {
		if (!ua.w3cdom) {
			return;
		}
		addDomLoadEvent(main);
		if (ua.ie && ua.win) {
			try {	 // Avoid a possible Operation Aborted error
				doc.write("<scr" + "ipt id=__ie_ondomload defer=true src=//:></scr" + "ipt>"); // String is split into pieces to avoid Norton AV to add code that can cause errors
				script = getElementById("__ie_ondomload");
				if (script) {
					addListener(script, "onreadystatechange", checkReadyState);
				}
			}
			catch(e) {}
		}
		if (ua.webkit && typeof doc.readyState != UNDEF) {
			timer = setInterval(function() { if (/loaded|complete/.test(doc.readyState)) { callDomLoadFunctions(); }}, 10);
		}
		if (typeof doc.addEventListener != UNDEF) {
			doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, null);
		}
		addLoadEvent(callDomLoadFunctions);
	}();

	function checkReadyState() {
		if (script.readyState == "complete") {
			script.parentNode.removeChild(script);
			callDomLoadFunctions();
		}
	}

	function callDomLoadFunctions() {
		if (isDomLoaded) {
			return;
		}
		if (ua.ie && ua.win) { // Test if we can really add elements to the DOM; we don't want to fire it too early
			var s = createElement("span");
			try { // Avoid a possible Operation Aborted error
				var t = doc.getElementsByTagName("body")[0].appendChild(s);
				t.parentNode.removeChild(t);
			}
			catch (e) {
				return;
			}
		}
		isDomLoaded = true;
		if (timer) {
			clearInterval(timer);
			timer = null;
		}
		var dl = domLoadFnArr.length;
		for (var i = 0; i < dl; i++) {
			domLoadFnArr[i]();
		}
	}

	function addDomLoadEvent(fn) {
		if (isDomLoaded) {
			fn();
		}
		else {
			domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
		}
	}

	/* Cross-browser onload
		- Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
		- Will fire an event as soon as a web page including all of its assets are loaded
	 */
	function addLoadEvent(fn) {
		if (typeof win.addEventListener != UNDEF) {
			win.addEventListener("load", fn, false);
		}
		else if (typeof doc.addEventListener != UNDEF) {
			doc.addEventListener("load", fn, false);
		}
		else if (typeof win.attachEvent != UNDEF) {
			addListener(win, "onload", fn);
		}
		else if (typeof win.onload == "function") {
			var fnOld = win.onload;
			win.onload = function() {
				fnOld();
				fn();
			};
		}
		else {
			win.onload = fn;
		}
	}

	/* Main function
		- Will preferably execute onDomLoad, otherwise onload (as a fallback)
	*/
	function main() { // Static publishing only
		var rl = regObjArr.length;
		for (var i = 0; i < rl; i++) { // For each registered object element
			var id = regObjArr[i].id;
			if (ua.pv[0] > 0) {
				var obj = getElementById(id);
				if (obj) {
					regObjArr[i].width = obj.getAttribute("width") ? obj.getAttribute("width") : "0";
					regObjArr[i].height = obj.getAttribute("height") ? obj.getAttribute("height") : "0";
					if (hasPlayerVersion(regObjArr[i].swfVersion)) { // Flash plug-in version >= Flash content version: Houston, we have a match!
						if (ua.webkit && ua.webkit < 312) { // Older webkit engines ignore the object element's nested param elements
							fixParams(obj);
						}
						setVisibility(id, true);
					}
					else if (regObjArr[i].expressInstall && !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac)) { // Show the Adobe Express Install dialog if set by the web page author and if supported (fp6.0.65+ on Win/Mac OS only)
						showExpressInstall(regObjArr[i]);
					}
					else { // Flash plug-in and Flash content version mismatch: display alternative content instead of Flash content
						displayAltContent(obj);
					}
				}
			}
			else {	// If no fp is installed, we let the object element do its job (show alternative content)
				setVisibility(id, true);
			}
		}
	}

	/* Fix nested param elements, which are ignored by older webkit engines
		- This includes Safari up to and including version 1.2.2 on Mac OS 10.3
		- Fall back to the proprietary embed element
	*/
	function fixParams(obj) {
		var nestedObj = obj.getElementsByTagName(OBJECT)[0];
		if (nestedObj) {
			var e = createElement("embed"), a = nestedObj.attributes;
			if (a) {
				var al = a.length;
				for (var i = 0; i < al; i++) {
					if (a[i].nodeName == "DATA") {
						e.setAttribute("src", a[i].nodeValue);
					}
					else {
						e.setAttribute(a[i].nodeName, a[i].nodeValue);
					}
				}
			}
			var c = nestedObj.childNodes;
			if (c) {
				var cl = c.length;
				for (var j = 0; j < cl; j++) {
					if (c[j].nodeType == 1 && c[j].nodeName == "PARAM") {
						e.setAttribute(c[j].getAttribute("name"), c[j].getAttribute("value"));
					}
				}
			}
			obj.parentNode.replaceChild(e, obj);
		}
	}

	/* Show the Adobe Express Install dialog
		- Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
	*/
	function showExpressInstall(regObj) {
		isExpressInstallActive = true;
		var obj = getElementById(regObj.id);
		if (obj) {
			if (regObj.altContentId) {
				var ac = getElementById(regObj.altContentId);
				if (ac) {
					storedAltContent = ac;
					storedAltContentId = regObj.altContentId;
				}
			}
			else {
				storedAltContent = abstractAltContent(obj);
			}
			if (!(/%$/.test(regObj.width)) && parseInt(regObj.width, 10) < 310) {
				regObj.width = "310";
			}
			if (!(/%$/.test(regObj.height)) && parseInt(regObj.height, 10) < 137) {
				regObj.height = "137";
			}
			doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
			var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
				dt = doc.title,
				fv = "MMredirectURL=" + win.location + "&MMplayerType=" + pt + "&MMdoctitle=" + dt,
				replaceId = regObj.id;
			// For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
			// In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
			if (ua.ie && ua.win && obj.readyState != 4) {
				var newObj = createElement("div");
				replaceId += "SWFObjectNew";
				newObj.setAttribute("id", replaceId);
				obj.parentNode.insertBefore(newObj, obj); // Insert placeholder div that will be replaced by the object element that loads expressinstall.swf
				obj.style.display = "none";
				var fn = function() {
					obj.parentNode.removeChild(obj);
				};
				addListener(win, "onload", fn);
			}
			createSWF({ data:regObj.expressInstall, id:EXPRESS_INSTALL_ID, width:regObj.width, height:regObj.height }, { flashvars:fv }, replaceId);
		}
	}

	/* Show no player message with link to install player */
	function showNoPlayerMessage(regObj) {
		var obj = getElementById(regObj.id);
		if (obj) {
			obj.style.width = regObj.width + "px";
			obj.style.height = regObj.height + "px";

			var newObj = createElement("div");
			newObj.className = "no-player-installed";
			newObj.innerHTML = noPlayerMessage;
			obj.appendChild(newObj);
		}
	}

	/* Functions to abstract and display alternative content
	*/
	function displayAltContent(obj) {
		if (ua.ie && ua.win && obj.readyState != 4) {
			// For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
			// In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
			var el = createElement("div");
			obj.parentNode.insertBefore(el, obj); // Insert placeholder div that will be replaced by the alternative content
			el.parentNode.replaceChild(abstractAltContent(obj), el);
			obj.style.display = "none";
			var fn = function() {
				obj.parentNode.removeChild(obj);
			};
			addListener(win, "onload", fn);
		}
		else {
			obj.parentNode.replaceChild(abstractAltContent(obj), obj);
		}
	}

	function abstractAltContent(obj) {
		var ac = createElement("div");
		if (ua.win && ua.ie) {
			ac.innerHTML = obj.innerHTML;
		}
		else {
			var nestedObj = obj.getElementsByTagName(OBJECT)[0];
			if (nestedObj) {
				var c = nestedObj.childNodes;
				if (c) {
					var cl = c.length;
					for (var i = 0; i < cl; i++) {
						if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
							ac.appendChild(c[i].cloneNode(true));
						}
					}
				}
			}
		}
		return ac;
	}

	/* Cross-browser dynamic SWF creation
	*/
	function createSWF(attObj, parObj, id) {
		var r, el = getElementById(id);
		if (el) {
			if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
				attObj.id = id;
			}
			if (ua.ie && ua.win) { // IE, the object element and W3C DOM methods do not combine: fall back to outerHTML
				var att = "";
				for (var i in attObj) {
					if (attObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries, like Object.prototype.toJSONString = function() {}
						if (i.toLowerCase() == "data") {
							parObj.movie = attObj[i];
						}
						else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
							att += ' class="' + attObj[i] + '"';
						}
						else if (i.toLowerCase() != "classid") {
							att += ' ' + i + '="' + attObj[i] + '"';
						}
					}
				}
				var par = "";
				for (var j in parObj) {
					if (parObj[j] != Object.prototype[j]) { // Filter out prototype additions from other potential libraries
						par += '<param name="' + j + '" value="' + parObj[j] + '" />';
					}
				}
				el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
				objIdArr[objIdArr.length] = attObj.id; // Stored to fix object 'leaks' on unload (dynamic publishing only)
				r = getElementById(attObj.id);
			}
			else if (ua.webkit && ua.webkit < 312) { // Older webkit engines ignore the object element's nested param elements: fall back to the proprietary embed element
				var e = createElement("embed");
				e.setAttribute("type", FLASH_MIME_TYPE);
				for (var k in attObj) {
					if (attObj[k] != Object.prototype[k]) { // Filter out prototype additions from other potential libraries
						if (k.toLowerCase() == "data") {
							e.setAttribute("src", attObj[k]);
						}
						else if (k.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
							e.setAttribute("class", attObj[k]);
						}
						else if (k.toLowerCase() != "classid") { // Filter out IE specific attribute
							e.setAttribute(k, attObj[k]);
						}
					}
				}
				for (var l in parObj) {
					if (parObj[l] != Object.prototype[l]) { // Filter out prototype additions from other potential libraries
						if (l.toLowerCase() != "movie") { // Filter out IE specific param element
							e.setAttribute(l, parObj[l]);
						}
					}
				}
				el.parentNode.replaceChild(e, el);
				r = e;
			}
			else { // Well-behaving browsers
				var o = createElement(OBJECT);
				o.setAttribute("type", FLASH_MIME_TYPE);
				for (var m in attObj) {
					if (attObj[m] != Object.prototype[m]) { // Filter out prototype additions from other potential libraries
						if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
							o.setAttribute("class", attObj[m]);
						}
						else if (m.toLowerCase() != "classid") { // Filter out IE specific attribute
							o.setAttribute(m, attObj[m]);
						}
					}
				}
				for (var n in parObj) {
					if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // Filter out prototype additions from other potential libraries and IE specific param element
						createObjParam(o, n, parObj[n]);
					}
				}
				el.parentNode.replaceChild(o, el);
				r = o;
			}
		}
		return r;
	}

	function createObjParam(el, pName, pValue) {
		var p = createElement("param");
		p.setAttribute("name", pName);
		p.setAttribute("value", pValue);
		el.appendChild(p);
	}

	/* Cross-browser SWF removal
		- Especially needed to safely and completely remove a SWF in Internet Explorer
	*/
	function removeSWF(id) {
		var obj = getElementById(id);
		if (obj && (obj.nodeName == "OBJECT" || obj.nodeName == "EMBED")) {
			if (ua.ie && ua.win) {
				if (obj.readyState == 4) {
					removeObjectInIE(id);
				}
				else {
					win.attachEvent("onload", function() {
						removeObjectInIE(id);
					});
				}
			}
			else {
				obj.parentNode.removeChild(obj);
			}
		}
	}

	function removeObjectInIE(id) {
		var obj = getElementById(id);
		if (obj) {
			for (var i in obj) {
				if (typeof obj[i] == "function") {
					obj[i] = null;
				}
			}
			obj.parentNode.removeChild(obj);
		}
	}

	/* Functions to optimize JavaScript compression
	*/
	function getElementById(id) {
		var el = null;
		try {
			el = doc.getElementById(id);
		}
		catch (e) {}
		return el;
	}

	function createElement(el) {
		return doc.createElement(el);
	}

	/* Updated attachEvent function for Internet Explorer
		- Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
	*/
	function addListener(target, eventType, fn) {
		target.attachEvent(eventType, fn);
		listenersArr[listenersArr.length] = [target, eventType, fn];
	}

	/* Flash Player and SWF content version matching
	*/
	function hasPlayerVersion(rv) {
		var pv = ua.pv, v = rv.split(".");
		v[0] = parseInt(v[0], 10);
		v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
		v[2] = parseInt(v[2], 10) || 0;
		return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
	}

	/* Cross-browser dynamic CSS creation
		- Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
	*/
	function createCSS(sel, decl) {
		if (ua.ie && ua.mac) {
			return;
		}
		var h = doc.getElementsByTagName("head")[0], s = createElement("style");
		s.setAttribute("type", "text/css");
		s.setAttribute("media", "screen");
		if (!(ua.ie && ua.win) && typeof doc.createTextNode != UNDEF) {
			s.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
		}
		h.appendChild(s);
		if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
			var ls = doc.styleSheets[doc.styleSheets.length - 1];
			if (typeof ls.addRule == OBJECT) {
				ls.addRule(sel, decl);
			}
		}
	}

	function setVisibility(id, isVisible) {
		var v = isVisible ? "visible" : "hidden";
		if (isDomLoaded && getElementById(id)) {
			getElementById(id).style.visibility = v;
		}
		else {
			createCSS("#" + id, "visibility:" + v);
		}
	}

	/* Filter to avoid XSS attacks
	*/
	function urlEncodeIfNecessary(s) {
		var regex = /[\\\"<>\.;]/;
		var hasBadChars = regex.exec(s) != null;
		return hasBadChars ? encodeURIComponent(s) : s;
	}

	/* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
	*/
	var cleanup = function() {
		if (ua.ie && ua.win) {
			window.attachEvent("onunload", function() {
				// remove listeners to avoid memory leaks
				var ll = listenersArr.length;
				for (var i = 0; i < ll; i++) {
					listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
				}
				// cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
				var il = objIdArr.length;
				for (var j = 0; j < il; j++) {
					removeSWF(objIdArr[j]);
				}
				// cleanup library's main closures to avoid memory leaks
				for (var k in ua) {
					ua[k] = null;
				}
				ua = null;
				for (var l in swfobject) {
					swfobject[l] = null;
				}
				swfobject = null;
			});
		}
	}();


	return {
		/* Public API
			- Reference: http://code.google.com/p/swfobject/wiki/SWFObject_2_0_documentation
		*/
		registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr) {
			if (!ua.w3cdom || !objectIdStr || !swfVersionStr) {
				return;
			}
			var regObj = {};
			regObj.id = objectIdStr;
			regObj.swfVersion = swfVersionStr;
			regObj.expressInstall = xiSwfUrlStr ? xiSwfUrlStr : false;
			regObjArr[regObjArr.length] = regObj;
			setVisibility(objectIdStr, false);
		},

		getObjectById: function(objectIdStr) {
			var r = null;
			if (ua.w3cdom) {
				var o = getElementById(objectIdStr);
				if (o) {
					var n = o.getElementsByTagName(OBJECT)[0];
					if (!n || (n && typeof o.SetVariable != UNDEF)) {
							r = o;
					}
					else if (typeof n.SetVariable != UNDEF) {
						r = n;
					}
				}
			}
			return r;
		},

		embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj) {
			if (!ua.w3cdom || !swfUrlStr || !replaceElemIdStr || !widthStr || !heightStr || !swfVersionStr) {
				return;
			}
			widthStr += ""; // Auto-convert to string
			heightStr += "";
			if (hasPlayerVersion(swfVersionStr)) {
				setVisibility(replaceElemIdStr, false);
				var att = {};
				if (attObj && typeof attObj === OBJECT) {
					for (var i in attObj) {
						if (attObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries
							att[i] = attObj[i];
						}
					}
				}
				att.data = swfUrlStr;
				att.width = widthStr;
				att.height = heightStr;
				var par = {};
				if (parObj && typeof parObj === OBJECT) {
					for (var j in parObj) {
						if (parObj[j] != Object.prototype[j]) { // Filter out prototype additions from other potential libraries
							par[j] = parObj[j];
						}
					}
				}
				if (flashvarsObj && typeof flashvarsObj === OBJECT) {
					for (var k in flashvarsObj) {
						if (flashvarsObj[k] != Object.prototype[k]) { // Filter out prototype additions from other potential libraries
							if (typeof par.flashvars != UNDEF) {
								par.flashvars += "&" + k + "=" + flashvarsObj[k];
							}
							else {
								par.flashvars = k + "=" + flashvarsObj[k];
							}
						}
					}
				}
				addDomLoadEvent(function() {
					createSWF(att, par, replaceElemIdStr);
					if (att.id == replaceElemIdStr) {
						setVisibility(replaceElemIdStr, true);
					}
				});
			}
			else if (xiSwfUrlStr && !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac)) {
				isExpressInstallActive = true; // deferred execution
				setVisibility(replaceElemIdStr, false);
				addDomLoadEvent(function() {
					var regObj = {};
					regObj.id = regObj.altContentId = replaceElemIdStr;
					regObj.width = widthStr;
					regObj.height = heightStr;
					regObj.expressInstall = xiSwfUrlStr;
					showExpressInstall(regObj);
				});
			} else {
				addDomLoadEvent(function() {
					var regObj = {};
					regObj.id = regObj.altContentId = replaceElemIdStr;
					regObj.width = widthStr;
					regObj.height = heightStr;
					showNoPlayerMessage(regObj);
				});
			}
		},

		getFlashPlayerVersion: function() {
			return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
		},

		hasFlashPlayerVersion: hasPlayerVersion,

		createSWF: function(attObj, parObj, replaceElemIdStr) {
			if (ua.w3cdom) {
				return createSWF(attObj, parObj, replaceElemIdStr);
			}
			else {
				return undefined;
			}
		},

		removeSWF: function(objElemIdStr) {
			if (ua.w3cdom) {
				removeSWF(objElemIdStr);
			}
		},

		createCSS: function(sel, decl) {
			if (ua.w3cdom) {
				createCSS(sel, decl);
			}
		},

		addDomLoadEvent: addDomLoadEvent,

		addLoadEvent: addLoadEvent,

		getQueryParamValue: function(param) {
			var q = doc.location.search || doc.location.hash;
			if (param == null) {
				return urlEncodeIfNecessary(q);
			}
			if (q) {
				var pairs = q.substring(1).split("&");
				for (var i = 0; i < pairs.length; i++) {
					if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
						return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)));
					}
				}
			}
			return "";
		},

		// For internal usage only
		expressInstallCallback: function() {
			if (isExpressInstallActive && storedAltContent) {
				var obj = getElementById(EXPRESS_INSTALL_ID);
				if (obj) {
					obj.parentNode.replaceChild(storedAltContent, obj);
					if (storedAltContentId) {
						setVisibility(storedAltContentId, true);
						if (ua.ie && ua.win) {
							storedAltContent.style.display = "block";
						}
					}
					storedAltContent = null;
					storedAltContentId = null;
					isExpressInstallActive = false;
				}
			}
		}
	};
}();





/**
 * define root SNI namespace
 */

if( typeof(SNI) == "undefined" ) {
	var SNI = {};
}



/**
 * MetaData Manager
 */

SNI.MetaData = {};

SNI.MetaData.Parameter = function(){
	var parameters = {};		// object to store parameters

	this.addParameter = function(key, value){
		key = key.toUpperCase();		// always force key to uppercase before insert (case-insensitive insert and lookup)
		if(!parameters[key]) {
			parameters[key] = [];
		}
		parameters[key].push(value);
	};

	this.getParameter = function(key, separator){
		key = key.toUpperCase();		// always force key to uppercase before retrieval (case-insensitive insert and lookup)
		if(!parameters[key]) {
			return;
		}
		return parameters[key].join(separator);
	};

	this.getKeys = function(){
		return parameters;
	};
};



/* -------------------------------------------
			MetaDataManager
------------------------------------------- */
SNI.MetaData.Manager = function(){
	var m = new SNI.MetaData.Parameter();
	this.addParameter = m.addParameter;
	this.getParameter = m.getParameter;
	this.getKeys = m.getKeys;

	// gets the value of the parameter, but returns empty string if parameter doesn't exist
	this.getParameterString = function(key) {
		var s =  this.getParameter(key," ");
		if ( s == null ) {
			s = "";
		}
		return s;
	};

	// these getters are for backwards compatibility; should use getParameterString() now

	// generic getters
	this.getPageType = 		function() { return this.getParameterString("Type"); };
	this.getPageTitle = 	function() { return this.getParameterString("Title"); };
	this.getSite = 			function() { return this.getParameterString("Site"); };
	this.getSctnId = 		function() { return this.getParameterString("SctnId"); };
	this.getSctnName = 		function() { return this.getParameterString("SctnName"); };
	this.getSponsorship = 	function() { return this.getParameterString("Sponsorship"); };
	this.getAbstract = 		function() { return this.getParameterString("Abstract"); };
	this.getKeywords = 		function() { return this.getParameterString("Keywords"); };
	this.getClassification =function() { return this.getParameterString("Classification"); };
	this.getSctnDspName = 	function() { return this.getParameterString("SctnDspName"); };
	this.getCategoryDspName=function() { return this.getParameterString("CategoryDspName"); };
	this.getShowAbbr = 		function() { return this.getParameterString("Show_Abbr"); };
	this.getRole = 			function() { return this.getParameterString("Role"); };
	this.getDetailId = 		function() { return this.getParameterString("DetailId"); };
	this.getPageNumber = 	function() { return this.getParameterString("PageNumber"); };
	this.getUniqueId = 		function() { return this.getParameterString("UniqueId"); };
	this.getUserId = 		function() { return this.getParameterString("UserId"); };
	this.getUserIdEmail = 	function() { return this.getParameterString("UserIdEmail"); };
	this.getUserIdCreateDt =function() { return this.getParameterString("UserIdCreateDt"); };
	this.getUserIdVersion = function() { return this.getParameterString("UserIdVersion"); };
	this.getFilters = 		function() { return this.getParameterString("Filters"); };

	// food specific getters
	this.getMultimediaFlag =function() { return this.getParameterString("MultimediaFlag"); };
	this.getChefName = 		function() { return this.getParameterString("ChefName"); };
	this.getMealPart = 		function() { return this.getParameterString("MealPart"); };
	this.getCuisine = 		function() { return this.getParameterString("Cuisine"); };
	this.getOccasion = 		function() { return this.getParameterString("Occasion", " "); };
	this.getMainIngredient =function() { return this.getParameterString("MainIngredient"); };
	this.getTechnique = 	function() { return this.getParameterString("Technique", " "); };
	this.getDish = 			function() { return this.getParameterString("Dish", " "); };
	this.getMealType = 		function() { return this.getParameterString("MealType", " "); };
	this.getNutrition = 	function() { return this.getParameterString("Nutrition", " "); };
	this.getDifficulty = 	function() { return this.getParameterString("Difficulty", " "); };

	// other methods

	this.getSearchTerm = function() {
		var args = parseQueryString ();
		for (var arg in args) {
			var s = arg.toUpperCase();
			if ( s == 'SEARCHSTRING' ){
				return args[arg];
			}
		}
		return "";
	};

	this.setMultimediaFlag = function(flag) {
		if ( flag != null ) {
			this.addParameter("MultimediaFlag",flag);
		} else {
			this.addParameter("MultimediaFlag","");
		}
	};

	this.parseQueryString = function(str) {
	  str = str ? str : document.location.search;
	  var query = str.charAt(0) == '?' ? str.substring(1) : str;
	  var args = {};
	  if (query) {
	    var fields = query.split('&');
	    for (var f = 0; f < fields.length; f++) {
	      var field = fields[f].split('=');
	      args[unescape(field[0].replace(/\+/g, ' '))] =
			unescape(field[1].replace(/\+/g, ' '));
	    }
	  }
	  return args;
	};

};


// MetaDataManager for backwards compatibility
var MetaDataManager = SNI.MetaData.Manager;











/**
 * ads core
 */

// requires SNI.MetaData


// instantiate Ads object/namespace
if( typeof(SNI.Ads)=='undefined' ) {
	SNI.Ads = {
		// should be adsremote.scrippsnetworks.com for production and devadsremote.scrippsnetworks.com for development/staging
		_adServerHostname: "adsremote.scrippsnetworks.com"
	};
}
// for any jitterbug previews, force to devadsremote
//if( window.location.hostname.indexOf("jitterbug") != (-1) ) {
//	SNI.Ads._adServerHostname = "devadsremote.scrippsnetworks.com";
//}


// Url obj
SNI.Ads.Url = function() {
	var p = new SNI.MetaData.Parameter();

	// functions
	this.addParameter = p.addParameter;
	this.getParameter = p.getParameter;
	this.getKeys = p.getKeys;
	this.url = '';
	this.buildUrl = buildUrl;
	this.buildExpandedUrl = buildExpandedUrl;
	this.setUrl = setUrl;
	this.getUrl = getUrl;
	this.buildQueryStringValuePairs = buildQueryStringValuePairs;
	this.buildExpandedQueryStringValuePairs = buildExpandedQueryStringValuePairs;

 	// setUrl
	function setUrl(u) { this.url = u; }

	// getUrl
	function getUrl() { return this.url; }

	// buildQueryStringValuePairs
	function buildQueryStringValuePairs() {
			var queryString = "";
			for ( key in this.getKeys() ) {
				if (queryString !== "") {
					queryString += '&';
				}
				queryString += key +'='+ this.getParameter(key, ',');
	    	}
	    	return queryString;
	}

	// buildUrl
	function buildUrl() {
		return this.getUrl() + this.buildQueryStringValuePairs();
	}


	// buildExpandedQueryStringValuePairs
	function buildExpandedQueryStringValuePairs() {
			var queryString = "";

			for ( key in this.getKeys() ) {

					var item = this.getParameter(key, ",");
					var iArray = item.split(",");

					for(i = 0; i < iArray.length; i++) {
						if (queryString !== "" && iArray[i] !== "" && iArray[i] !== undefined) {
							queryString += '&';
						}
						if (iArray[i] !== "" && iArray[i] !== undefined) {
							queryString += key +'='+ iArray[i];
						}

					}
	    	}
	    	return queryString;
	}

	// buildUrl
	function buildExpandedUrl() {
		// for any jitterbug previews, append string to adserver call
		var sJitterbug = "";
		if( window.location.hostname.indexOf("jitterbug") != (-1) ) {
			sJitterbug = "&domain=jitterbug";
		}

		return this.getUrl() + this.buildExpandedQueryStringValuePairs() + sJitterbug;
	}

};


Ad.prototype = new SNI.Ads.Url();
function Ad()
{
	var url = new SNI.Ads.Url();
	this.addParameter = url.addParameter;
	this.getParameter = url.getParameter;
	this.getKeys = url.getKeys;
	this.buildUrl = url.buildUrl;
	this.buildExpandedUrl = url.buildExpandedUrl;

	var feature = new SNI.MetaData.Parameter();
	this.useFeature = useFeature;
	this.getFeature = getFeature;
	this.debug = debug;
	this.write = write;
    this.deferrable = 1;

	// add the parameter
	function useFeature(key) {feature.addParameter(key, "T");}

	// add the parameter
	function getFeature(key) {return feature.getParameter(key, ",");}

 	// this should be overloaded
	function debug() {document.write('<div style="background:red;color:white;">'+ this.buildExpandedUrl() +'</div>');}

	// this should be overloaded
	function write() {}
}


/* -------------------------------------------
Ad Object inherits paramter
------------------------------------------- */

DartAd.prototype = new Ad();
function DartAd()
{
	DartAd.prototype = new Ad();
	this.write = write;
	this.useFeature("site");
	this.useFeature("category");
	this.useFeature("vgncontent");
	this.useFeature("ord");
	this.useFeature("topic");
	this.useFeature("tile");
	this.useFeature("pagetype");
	this.useFeature("SECTION_ID");
	this.useFeature("SUBSECTION");
	this.useFeature("page");
	this.useFeature("uniqueid");
	this.useFeature("hubId");
	this.useFeature("hubType");
	this.useFeature("adkey1");
	this.useFeature("adkey2");
	this.useFeature("chef");
	this.useFeature("show");
	this.useFeature("delvfrmt");
	this.useFeature("source");
	this.useFeature("filter");
	this.useFeature("difficulty");
	this.useFeature("cuisine");
	this.useFeature("ingredient");
	this.useFeature("occasion");
	this.useFeature("mealpart");
	this.useFeature("technique");

	this.adClass = "AD_CLASS";

	function write() {
		if (navigator.userAgent.indexOf("#sni-loadtest#") !== -1) {
			// if this is a load-test (token detected in user agent string), don't make dart call
			return;
		}

		document.write('<script type="text/javascript" src="'+ this.buildExpandedUrl() +'"></script>');
	}
}

AdUrl.prototype = new Ad();
function AdUrl()
{
	AdUrl.prototype = new Ad();
	this.write = write;
	this.useFeature("site");
	this.useFeature("category");
	this.useFeature("vgncontent");
	this.useFeature("ord");
	this.useFeature("topic");
	this.useFeature("tile");
	this.useFeature("pagetype");
	this.useFeature("SECTION_ID");
	this.useFeature("SUBSECTION");
	this.useFeature("page");
	this.useFeature("uniqueid");
	this.useFeature("SearchKeywords");
	this.useFeature("SearchFilters");
	this.useFeature("hubId");
	this.useFeature("hubType");
	this.useFeature("adkey1");
	this.useFeature("adkey2");
	this.useFeature("chef");
	this.useFeature("show");
	this.useFeature("delvfrmt");
	this.useFeature("source");
	this.useFeature("filter");
	this.useFeature("difficulty");
	this.useFeature("cuisine");
	this.useFeature("ingredient");
	this.useFeature("occasion");
	this.useFeature("mealpart");
	this.useFeature("technique");

	function write() {}
}


DartAdvanceAd.prototype = new DartAd();
function DartAdvanceAd()
{
	DartAdvanceAd.prototype = new DartAd();
	this.write = write;
	this.align='';
	this.frameborder = 0;
	this.height='';
	this.longdesc='';
	this.marginheight=0;
	this.marginwidth=0;
	this.name='';
	this.scrolling = 'no';
	this.width = '100%';
	this.useIframe = false;

	function write() {
		if (navigator.userAgent.indexOf("#sni-loadtest#") !== -1) {
			// if this is a load-test (token detected in user agent string), don't make dart call
			return;
		}

		if(this.useIframe == false) {
			this.setUrl("http://"+SNI.Ads._adServerHostname+"/js.ng/");
			document.write('<script type="text/javascript" src="'+ this.buildExpandedUrl() +'"></script>');
		} else {
			this.setUrl("http://"+SNI.Ads._adServerHostname+"/html.ng/");
			document.write('<iframe src ="'+this.buildExpandedUrl()+'" align ="'+this.align+'" frameborder ="'+this.frameborder+'" height ="'+this.height+'" longdesc ="'+this.longdesc+'" marginheight ="'+this.marginheight+'" marginwidth ="'+this.marginwidth+'" name ="'+this.name+'" scrolling ="'+this.scrolling+'" width ="'+this.width+'"></iframe>');
		}
	}
}

/* -------------------------------------------
AdManager
------------------------------------------- */
function AdManager()
{
	var p = new SNI.MetaData.Parameter();
	this.addParameter = p.addParameter;
	this.getParameter = p.getParameter;
	this.getKeys = p.getKeys;
	this.createAd = createAd;
	this.createDeferredAd = createDeferredAd;
	this.moveAds = moveAds;
	this.ads = [];
	this.defer = false;

	if(document.deferAds !== null &&
	 	   document.deferAds == 1 &&
	   	   document.deferEnabled !== null &&
	   	   document.deferEnabled == 1) {
	   	   this.defer = true;
	 }

	// add the parameter
	function createAd(ad) {
		// add the site params
		for ( key in this.getKeys()) {
			if ( ad.getFeature(key) !== undefined) {
				ad.addParameter(key, this.getParameter(key, ','));
			}
 		}

		if(document.debug == 1) {
 			ad.debug();
		}
		ad.write();
	}

	// Create Deferred Ad
	function createDeferredAd(i) {
	}

	// Move Ads
	function moveAds() {
	}
}


// Url obj
function AdRestriction()
{
	var p = new SNI.MetaData.Parameter();
	// functions
	this.addParameter = p.addParameter;
	this.getParameter = p.getParameter;
	this.getKeys = p.getKeys;
	this.isActive = true;
	this.isIframe = false;

}

function AdDefault()
{
	var p = new SNI.MetaData.Parameter();
	// functions
	this.addParameter = p.addParameter;
	this.getParameter = p.getParameter;
	this.getKeys = p.getKeys;
	this.display = false;
}

function AdRestrictionManager() {
	this.restriction = [];
	this.adDefaults = [];
	this.isActive = isActive;
	this.isIframe = isIframe;
	this.isMatch = isMatch;
	this.startMatch = startMatch;
	// is active
	function isActive(ad, mdm) {
		var value = false;
		var adDefaultMatch = false;
		var defaultReturnValue = true;

		for (var i = 0; i < this.adDefaults.length; i++){
			adDefaultMatch = this.startMatch(ad, mdm, this.adDefaults[i]);
			if (adDefaultMatch == true) {
				defaultReturnValue = this.adDefaults[i].display;
				break;
			}
		}

		for (var i = 0; i < this.restriction.length; i++){
			adRestriction = this.restriction[i];
			if(!adRestriction.isActive) {
				value = this.startMatch(ad, mdm, adRestriction);
			}
			if(value == true) {
				return !defaultReturnValue;
			}
		}

		return defaultReturnValue;
	}

	// is Iframe
	function isIframe(ad, mdm) {
		var value = false;
		for (var i = 0; i < this.restriction.length; i++){
			adRestriction = this.restriction[i];
			if(adRestriction.isIframe) {
				value = this.startMatch(ad, mdm, adRestriction);
			}

		}
		return value;

	}

	function startMatch(ad, mdm, adRestriction) {
		var match = true;
		for ( var key in adRestriction.getKeys() ) {
					var restrictions = adRestriction.getParameter(key, ',');

					// get it from the mdm
					var value = mdm.getParameter(key, '----');
					match = this.isMatch(value, restrictions);

					// ad
					if(!match) {
						value = ad.getParameter(key, '----');
						match = this.isMatch(value, restrictions);
					}
					if(!match) {return false;}

		}
		return match;
	}

	function isMatch(value, restrictions) {
		var match = false;
		if(value) {
			splitValue = value.split('----');
			for(var x = 0; x < splitValue.length; x++) {
				if(restrictions == splitValue[x]) {match = true;}
				for(var a; a < restrictions.length; a++) {
					if(splitValue[x] == restrictions[a]) {
						return true;
					}
				}
			}
		}
		return match;
	}

}




function initAdManager(adm, mdm) {
	// adm = ad manager
	// mdm = metadata manager

	function admAppendParam(key, val) {
		// appends the parameter to the ad manager if val is not empty string
		if( val != "" ) {
			val = val.replace(/-/g, "_");		// replace all dashes with underscores
			val = val.replace(/ /g, "_");		// replace all spaces with underscores

			s = val.split(',', 1);				// just grab the first val of any multi-value string separated by commas
			adm.addParameter(key, s);

			//alert("key = " + key + ", val = " + s);			// debug
		}
	}


	var ranNum = String(Math.round(Math.random()*10000000000));
	var now = new Date();
	var ad_ord = now.getTime()%10000000000;

	var amPageType = mdm.getPageType() ;
	var amSponsorship = mdm.getSponsorship();
	var amKeywords = mdm.getKeywords();
	amPageType = amPageType.replace(/-/g , "_");

	var amUniqueId = mdm.getUniqueId();
	amUniqueId = amUniqueId.replace(/-/g , "_");

	if (amSponsorship !== "" && amSponsorship !== undefined) {
		amSponsorship = amSponsorship.replace(/-/g , "_");
		amSponsorship = amSponsorship.replace(/ /g , "_");
	}

	if (amKeywords !=="" && amKeywords !== undefined) {
		amKeywords = amKeywords.replace(/,/g , "_");
	}

	amSctns = mdm.getClassification();
	amSctns = amSctns.split(",");

	if (amSctns.length > 1) {
		for (var i=0; i < amSctns.length; i++) {
			if (i == (amSctns.length-1)) {
				adm.addParameter("sitesection", amSctns[i]);
			} else if (i == (amSctns.length-2)) {
				adm.addParameter("category", amSctns[i]);
			} else if (i == (amSctns.length-3)) {
				adm.addParameter("vgncontent", amSctns[i]);
			} else {
				adm.addParameter("SUBSECTION", amSctns[i]);
			}
		}
	} else {
		var c = mdm.getClassification();
		adm.addParameter("category", c );
	}

	if (amPageType == 'SECTION') {
		if (!adm.getParameter("vgncontent", " ")) {
			adm.addParameter("page", "MAIN");
		}
	}
	var s = mdm.getSite();
	adm.addParameter("site",s );
	var gsId = mdm.getSctnId();
	adm.addParameter("tile", ranNum +  gsId );
	adm.addParameter("ord", ad_ord);
	adm.addParameter("topic", amSponsorship);
	adm.addParameter("keywords", amKeywords);
	adm.addParameter("pagetype", amPageType);
	adm.addParameter("uniqueid", amUniqueId);
	var sId = mdm.getSctnId();
	adm.addParameter("SECTION_ID", sId);

	// these first column keys need to match with this.useFeature(key) from the DartAd() and AdUrl() objects
	admAppendParam("hubId", mdm.getParameterString("HubId"));
	admAppendParam("hubType", mdm.getParameterString("HubType"));
	admAppendParam("adkey1", mdm.getParameterString("AdKey1").toUpperCase());
	admAppendParam("adkey2", mdm.getParameterString("AdKey2").toUpperCase());
	admAppendParam("delvfrmt", mdm.getParameterString("DelvFrmt"));
	admAppendParam("source", mdm.getParameterString("Source"));
	admAppendParam("filter", mdm.getParameterString("filter"));
	admAppendParam("chef", mdm.getParameterString("ChefName"));
	admAppendParam("show", mdm.getParameterString("Show_Abbr"));
	admAppendParam("difficulty", mdm.getParameterString("Difficulty"));
	admAppendParam("cuisine", mdm.getParameterString("Cuisine"));
	admAppendParam("ingredient", mdm.getParameterString("MainIngredient"));
	admAppendParam("occasion", mdm.getParameterString("Occasion"));
	admAppendParam("mealpart", mdm.getParameterString("MealPart"));
	admAppendParam("technique", mdm.getParameterString("Technique"));
}








/* sni-food.js - Wed, 07 Jan 2009 15:57:57 -0500 */

if( typeof(SNI.Food) == "undefined" ) {
	SNI.Food = {};
}





/**
 * food-ads.js
 *
 * requires core ads functionality from sni-global.js
 * requires mdManager (uses mdManager within functions, but not during load)
 */


function FoodAd(adtype, adsize, pos, keywords) {
	if(pos < 0 || pos == undefined) {pos = 1;}
	if(keywords == undefined) { keywords = ""; }

	var ad = new DartAd();
	ad.setUrl("http://"+SNI.Ads._adServerHostname+"/js.ng/");

	if (adtype== 'BIGBOX' && pos == 5) {
		ad.addParameter("adtype", 'BIGBOX');
	} else {
		ad.addParameter("adtype", adtype );
	}

	ad.addParameter("adsize", adsize);
	ad.addParameter("PagePos", pos);
	ad.addParameter("Params.styles", "SNI_LEADERBOARD");

	if( keywords != "" ) {
		var words = keywords.split(" ");
		for(i=0; i < words.length; i++) {
			ad.addParameter("keyword", words[i]);
		}
	}

	writeAd(ad);
}


function writeAd(ad){
	if (typeof adRestrictionManager != 'undefined') {
		ad.useIframe = adRestrictionManager.isIframe(ad, mdManager);
		if( adRestrictionManager.isActive(ad, mdManager) != false) {
			adManager.createAd(ad);
		}
	} else {
		adManager.createAd(ad);
	}
}


//Recipe Ad
function RecipeAd (pos, adtype, pnames, pvals) {
	if(pos < 0 || pos == undefined) {pos = 1;}

	var ad = new DartAd();

	if (pos == 1 && adtype == 'GOOGLE') {pos = 2;}

	ad.setUrl("http://"+SNI.Ads._adServerHostname+"/js.ng/");
	ad.addParameter("PagePos", pos);
	// ad.addParameter("Params.styles", "trace");

	if (adtype != "" &&  adtype != undefined)
	 {
       ad.addParameter("adtype", adtype);
	 } else {
	  	if(pos == 5) {
  			ad.addParameter("adtype", 'BIGBOX');
		}
	 }

	var paramNames = pnames.split(" ");
	var paramVals = pvals.split(" ");

	for(i = 0; i < paramNames.length; i++) {
		ad.addParameter(paramNames[i], paramVals[i]);
	}

	writeAd(ad);
}


function LeaderboardAd(pos) {
	if(pos < 0 || pos == undefined || pos=='') {pos = 1;}
	FoodAd('LEADERBOARD', '468x60',  pos);
}


function PushdownAd(pos) {
	if(pos < 0 || pos == undefined) {pos = 1;}
	FoodAd('PUSHDOWN', '', pos);
}


function GoogleBixboxAd(pos) {
	// Food GOOGLE BIG BOX 300x250 adtag
	if(pos < 0 || pos == undefined) {pos = 1;}
	FoodAd('GOOGLE_BIGBOX', '', pos);
}


function GoogleLeaderboardAd(pos) {
	// Food GOOGLE HORIZONTAL RECTANGLE 630x132 adtag
	if(pos < 0 || pos == undefined) {pos = 1;}
	FoodAd('GOOGLE_LEADERBOARD', '', pos);
}


function BigboxAd(pos, keywords) {
	if(pos < 0 || pos == undefined) {pos = 1;}
	FoodAd('BIGBOX', '', pos, keywords);
}


function SuperstitialAd(pos) {
	if(pos < 0 || pos == undefined) {pos = 1;}
	FoodAd('SUPERSTITIAL', '', pos);
}


/*
function WDSearchAd(adtype, pos, keywords) {
	if(pos < 0 || pos == undefined) {pos = 1;}

	var ad = new DartAd();

	ad.setUrl("http://"+SNI.Ads._adServerHostname+"/js.ng/");
	ad.addParameter("adtype", adtype);
	ad.addParameter("adsize", "");
	ad.addParameter("PagePos", pos);
	// ad.addParameter("Params.styles", "trace");

	var words = keywords.split(" ");
	for(i = 0; i < words.length; i++) {
		ad.addParameter("keyword", words[i]);
	}
	writeAd(ad);
}

*/


//Video PreRoll & Overlay Ad functions for Maven, Pickle
function VideoPlayerAd(adtype, adsize, pos) {
	var ad = new AdUrl();

	ad.setUrl("http://"+SNI.Ads._adServerHostname+"/html.ng/");
	if (adtype != '') {	ad.addParameter("adtype", adtype); }
	if (adsize != '') { ad.addParameter("adsize", adsize); }
	if (!pos || pos=='') { pos = 1; }
	ad.addParameter("PagePos", pos);
	ad.useFeature("tile");
	writeAd(ad);

   return ad.buildExpandedUrl();
}


// Video Player Ad Integration
// The video player will make calls to the following javascript functions to
//    1. Get a Dart ad tag url for PRE_ROLL and OVERLAY ads.
//--Wrapper function which the video player calls to get a preroll ad tag url -->
function getDartEnterpriseUrl(adtype,pos){
   		adtype = adtype.toUpperCase();
   		var strUrl = VideoPlayerAd(adtype,'', pos);
   		return strUrl;
}

function setDartEnterpriseBanner(adType, sync_banner) {
	if (adType == 'LEADERBOARD') {
	  if($("#leaderboard").length > 0) {
			boxW = 728;
			boxH = 90;
			$("#leaderboard").html("<iframe src='" + sync_banner + "\' width=\'" + boxW + "\' height=\'" + boxH + "\'" + "frameborder='0' scrolling='no' marginheight='0' marginwidth='0'></iframe>");
		}
	} else { // assumes adType == 'BIGBOX' or should
		if($("#bigbox").length > 0) {
			boxW = 300;
			boxH = 250;
			if (sync_banner.indexOf("336x850") > -1) {
				boxW = 336;
				boxH = 850;
			} else if (sync_banner.indexOf("300x600") > -1)	{
				boxW = 300;
				boxH = 600;
			}
			$("#bigbox").html("<iframe src='" + sync_banner + "\' width=\'" + boxW + "\' height=\'" + boxH + "\'" + "frameborder='0' scrolling='no' marginheight='0' marginwidth='0'></iframe>");
		}
	}
	return;
}

// multiple sponsor logo tag
function MultiLogoAd(adtype,logoNum) {
	var ad = new DartAd();
	if (logoNum == undefined || logoNum == '' || logoNum > 4 || logoNum < 1) { logoNum = 4; }
	if (adtype == undefined || adtype == '') { adtype = 'LOGO';	}
	ad.setUrl("http://"+SNI.Ads._adServerHostname+"/snDigitalLogo"+logoNum+".html?");
	ad.addParameter("adtype", adtype );
	ad.addParameter("PagePos", 1 );
	if (logoNum > 0) {
		writeAd(ad);
		$(document).ready( function() {
			if ($(".sponsor-multi-logo a img").length > 0) {
				$(".sponsor-multi-logo").prepend("<em>Sponsored by:</em>");
			}
		});
	}
}


//==ENDECA Functions Begin ===============================================================
//functions added at the request of Amy Thomason for the Endeca recipe search

function WDGuidedNavSearchAds(adtype, pos, keywords, filters, pageNo) {
	var ad = new DartAd();
	if(pos < 0 || pos == undefined) {
		pos = 1;
	}
	if(pageNo > 0 && pageNo != undefined) {
	   ad.addParameter("Page", pageNo);
	}
	ad.setUrl("http://"+SNI.Ads._adServerHostname+"/js.ng/");
	ad.addParameter("adtype", adtype);
	ad.addParameter("adsize", "");
	ad.addParameter("PagePos", pos);
	// ad.addParameter("Params.styles", "trace");
	var words = keywords.split(" ");
	for(i = 0; i < words.length; i++) {
		ad.addParameter("keyword", words[i]);
	}
	var words = filters.split(" ");
	for(i = 0; i < words.length; i++) {
		ad.addParameter("filter", words[i]);
	}
	writeAd(ad);
}


function WDGuidedNavSiteAdAds(adtype, keywords, filters, pageNo) {
	WDGuidedNavSearchAds(adtype, 1, keywords, filters, pageNo);
	//WDGuidedNavSearchAds(adtype, 2, keywords, filters, pageNo)
}

//==ENDECA Functions End ===============================================================

