if (typeof (FIVEMIN) == "undefined") var FIVEMIN = {};
if (typeof (FIVEMIN.LIB) == "undefined") FIVEMIN.LIB = (function() {
	/* DEVIGN js fw */
	FIVEMIN.LIB = function() {
		function $() { return $.getById.apply(this, arguments); }

		$.extend = function(destination, source) {
			for (var key in (source || {})) {
				destination[key] = source[key];
			}
			return destination;
		};

		var _docForRestore;

		$.extend($, {
			// elements
			document: document,
			// elements
			getById: function(id, doc) {
				return id ? id.nodeName ? id : (doc || document).getElementById(id) : null;
			},
			create: function(tag, props, doc) {
				var el = (doc || $.document || document).createElement(tag);
				if (props) $.alter(el, props);
				return el;
			},
			setDocument: function(doc) { $.log("set document = ", doc); _docForRestore = $.document || document; $.document = doc; },
			restoreDocument: function() { $.document = _docForRestore; _docForRestore = null; },
			alter: function(el, props) {
				if (!props) return;
				if (props.styles) {
					$.css(el, props.styles);
					delete props.styles;
				}
				if (props.events) {
					$.each(props.events, function(handler, name) { $.addEvent(el, name, handler); });
					delete props.events;
				}
				if (props.children) {
					$.each(props.children, function(child) { el.appendChild(child); });
					delete props.children;
				}
				var parent = props.parent;
				delete props.parent;

				$.extend(el, props);

				if (parent) parent.appendChild(el);

				return el;
			},

			removeNode: function(el) {
				if (el.parentNode) el.parentNode.removeChild(el);
			},

			getElement: function(selector, ctx) {
				return $.getElements(selector, ctx)[0];
			},
			getElements: function(selector, ctx) {
				if (!ctx) ctx = $.document;
				
				var result = [];

				if (selector.indexOf(".") > -1) {
					for (
						var split = selector.split("."),
							re = new RegExp("\\b" + split[1] + "\\b"),
							list = ctx.getElementsByTagName(split[0] || "*"),
							length = list.length,
							i = 0,
							j = 0,
							node;
						i < length;
						++i
					) {
						node = list[i];
						if (re.test(node.className))
							result[j++] = node;
					};
				}
				else result = $.toArray(ctx.getElementsByTagName(selector));

				return result;
			},

			hasChild: function(parent, el) {
				if ($.browser.engine == "webkit" && $.browser.version < 420) return $.indexOf($.toArray(parent.getElementsByTagName(el.tagName)), el) > -1;
				return parent.contains ? parent != el && parent.contains(el) : !!(parent.compareDocumentPosition(el) & 16);
			},


			// events
			addEvent: document.attachEvent ?
				function(el, name, fn) { el.attachEvent("on" + name, fn); }
				:
				function(el, name, fn) { el.addEventListener(name, fn, false); },
			removeEvent: document.detachEvent ?
				function(el, name, fn) { el.detachEvent("on" + name, fn); }
				:
				function(el, name, fn) { el.removeEventListener(name, fn, false); },

			stopEvent: function(e, preventDefault, stopPropagation) {
				if (preventDefault !== false) {
					if (e.preventDefault) e.preventDefault();
					else e.returnValue = false;
				}
				if (stopPropagation !== false) {
					if (e.stopPropagation) e.stopPropagation();
					else e.cancelBubble = true;
				}
			},
			eventElement: function(e) { return e.target ? e.target : e.srcElement; },

			// arrays/objects
			toArray: function(data) {
				if (data instanceof Array) return data;
				if (data.item) {
					var array = [];
					for (var i = 0, l = data.length; i < l; i++) array[i] = data[i];
					return array;
				}
				return Array.prototype.slice.call(data);
			},
			indexOf: function(data, item, from) {
				var len = data.length;
				for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++) {
					if (data[i] === item) return i;
				}
				return -1;
			},
			removeItem: function(arr, item) {
				for (var i = arr.length; i--; ) {
					if (arr[i] === item) arr.splice(i, 1);
				}
			},
			each: function(data, fn, bind) {
				if (data instanceof Array) {
					for (var i = 0; i < data.length; i++) fn.call(bind || null, data[i], i);
				}
				else {
					for (var key in data) fn.call(bind || null, data[key], key);
				}
				return data;
			},

			trim: function(s) { return s.replace(/^\s+|\s+$/g, ""); },

			time: function() { return new Date().getTime(); },

			map: function(data, fn, bind) {
				var a = data instanceof Array ? [] : {};
				$.each(data, function(value, key) {
					a[key] = fn.call(bind || null, value, key);
				});
				return a;
			},
			css: function(el, style) {
				if (typeof (style) == "string") el.style.cssText = style;
				else {
					if (style.opacity !== undefined) {
						$.opacity(el, style.opacity);
						delete style.opacity;
					}

					style = $.map(style, function(value, key) {
						if ($.indexOf(CSS_NUMERIC_VALUE, key) != -1) return parseFloat(value);
						if ($.indexOf(CSS_PIXEL_VALUE, key) != -1 && typeof (value) == "number") return value + "px";
						return value;
					});
					$.extend(el.style, style);
				}
				return el;
			},

			addCls: function(el, cls) {
				if (!$.hasCls(el,cls)) el.className += " " + cls;
			},
			removeCls: function(el, cls) {
				el.className = el.className.replace(new RegExp("(^|\\s+)" + cls + "(\\s+|$)","g"), " ");
			},
			hasCls: function(el, cls) {
				return new RegExp("(^|\\s)" + cls + "(\\s|$)").test(el.className);
			},

			currCss: function(el, key, toNumber) {
				if (key == "float") key = "cssFloat";

				if (key == "opacity" && $.browser.engine == "ie") return $.opacity(el);

				var result = null;

				if (el.currentStyle) result = el.currentStyle[key.replace(/-\D/g, function(match) {
					return match.charAt(1).toUpperCase();
				})];
				else {
					var computed = el.ownerDocument.defaultView.getComputedStyle(el, null);
					result = computed ? computed.getPropertyValue(key) : null;
				}

				if (result == "auto" && (key == "width" || key == "height")) {
					result = el["offset" + key.charAt(0).toUpperCase() + key.substr(1)];
					var removePadding = key == "width" ? ["left", "right"] : ["top", "bottom"];
					result -= $.currCss(el, removePadding[0]) + $.currCss(el, removePadding[1]);
					if (result < 0) result = 0;
				}

				if (
					result !== null &&
					(
						$.indexOf(CSS_PIXEL_VALUE, key) != -1 ||
						$.indexOf(CSS_NUMERIC_VALUE, key) != -1 ||
						toNumber ||
						result.indexOf("px") == result.length - 2
					)
				) result = parseFloat(result);

				return result;
			},

			opacity: function(el, value) {
				if (value === undefined) { // get
					if ($.browser.engine != "ie") return $.currCss(el, "opacity");
					var filter = el.style.filter;
					return filter && filter.indexOf("opacity=") >= 0 ? (parseFloat(filter.match(/opacity=([^)]*)/)[1]) / 100) : 1;
				}
				else { // set
					if (value == 0) {
						if (el.style.visibility != 'hidden') el.style.visibility = 'hidden';
					} else {
						if (el.style.visibility != 'visible') el.style.visibility = 'visible';
					}
					if (!el.currentStyle || !el.currentStyle.hasLayout) el.style.zoom = 1;
					if ($.browser.engine == "ie") el.style.filter = value == 1 ? '' : 'alpha(opacity=' + value * 100 + ')';
					el.style.opacity = value;
				}
			},

			bind: function(fn, bind) {
				return function() {
					fn.apply(bind, arguments);
				};
			},

			htmlenc: function encode(s) {
				return s ? s.replace(/&/g, "&amp;")
						.replace(/</g, "&lt;")
						.replace(/>/g, "&gt;")
						.replace(/'/g, "&apos;")
						.replace(/"/g, "&quot;") : "";
			},


			log: function() {
				if (typeof (console) == "undefined") return;
				try { console.log.apply(console, arguments); }
				catch (ex) { console.log($.toArray(arguments)); }
			}
		});

		$.browser = {};

		(function() {
			if (window.ActiveXObject) {
				$.browser.engine = "ie";
				$.browser.version = window.XMLHttpRequest ? 7 : 6;
			}
			else if (document.getBoxObjectFor == undefined) {
				$.browser.engine = "gecko";
				$.browser.version = window.getElementsByClassName ? 19 : 18;
			}
			else if (navigator.userAgent.indexOf('AppleWebKit/') > -1) {
				$.browser.engine = "webkit";
				$.browser.version = !!document.evaluate ? (!!document.querySelector ? 525 : 420) : 419;
			}
		})();

		(function() {
			var _loaded,
				_observers = [];

			$.extend($, {
				addDomReady: function(fn) {
					if (_loaded) return fn();

					_observers[_observers.length] = fn;

					if (!_domReadyInitialized) {
						_domReadyInitialized = true;
						initDomReady();
					}
				}
			});

			var _domReadyInitialized;
			function initDomReady() {

				if ($.browser.engine == "ie") {
					var temp = $.create('div');
					(function() {
						var success;
						try {
							temp.doScroll('left');
							$.document.body.appendChild(temp);
							temp.innerHTML = "temp";
							$.removeNode(temp);
							success = true;
						} catch (ex) {
							setTimeout(arguments.callee, 500);
						}

						if (success) domready();
					})();
				} else if ($.browser.engine = "webkit" && $.browser.version < 525) {
					(function() {
						if ($.document.readyState == "loaded" || $.document.readyState == "complete") domready();
						else setTimeout(arguments.callee, 500);
					})();
				} else {
					$.addEvent(window, 'load', domready);
					$.addEvent(document, 'DOMContentLoaded', domready);
				}

				function domready() {
					if (_loaded) return;
					_loaded = true;
					$.each(_observers, function(fn) {
						fn();
					});
				}
			}
		})();

		var MAX_DUMP_DEPTH = 5;
		var CSS_PIXEL_VALUE = "left,top,bottom,right,width,height,maxWidth,maxHeight,minWidth,minHeight,fontSize,letterSpacing,lineHeight,margin,marginLeft,marginRight,marginTop,marginBottom,padding,paddingLeft,paddingRight,paddingTop,paddingBottom,borderWidthLeft,borderWidthRight,borderWidthTop,borderWidthBottom".split(",");
		var CSS_NUMERIC_VALUE = "z-index,font-weight,opacity,zoom,line-height".split(",");

		return $;
	} ();
	var $ = FIVEMIN.LIB;
	FIVEMIN.LIB.Fx = function() {
		var _defaultOptions = {
			duration: 500,
			fps: 50
		};
		function Fx(element, options) {
			this.element = element;
			this.options = $.extend($.extend({}, _defaultOptions), options);
		}
		Fx.prototype = {
			transition: function(p) {
				return -(Math.cos(Math.PI * p) - 1) / 2;
			},
			start: function(to) {
				if (this.timer) return false;
				this.to = to;
				this.from = this.getFrom();
				this.startTime = $.time();
				this.endTime = this.startTime + this.options.duration;
				this.timer = setInterval($.bind(this.step, this), Math.round(1000 / this.options.fps));
				return this;
			},
			stop: function() {
				if (!this.timer) return false;
				clearInterval(this.timer);
				this.timer = null;
			},
			cancel: function() {
				this.stop();
				if (this.options.onCancel) this.options.onCancel.call(this);
			},
			complete: function() {
				this.set(1);
				this.stop();
				if (this.options.onComplete) this.options.onComplete.call(this);
			},
			step: function() {
				var time = $.time();
				if (time < this.endTime) {
					var percentage = this.transition((time - this.startTime) / this.options.duration);
					this.set(percentage);
				}
				else this.complete();
			},
			getFrom: function(p) {
				var from = {};
				$.each(this.to, function(value, key) {
					from[key] = $.currCss(this.element, key);
				}, this);
				return from;
			},
			set: function(p) {
				var style = {};
				$.each(this.to, function(value, key) {
					style[key] = (value - this.from[key]) * p + this.from[key];
					if (key !== "opacity") style[key] = Math.floor(style[key]);
				}, this);
				$.css(this.element, style);
			}
		};

		return Fx;
	} ();

	return FIVEMIN.LIB;
})();

if (typeof (FIVEMIN.ThumbSeed) == "undefined") FIVEMIN.ThumbSeed = function() {
    var $ = FIVEMIN.LIB;
    $.fx = FIVEMIN.LIB.Fx;

    var CURRENT_SCRIPT_SRC_RX = /http:\/\/pshared\.5min\.com\/scripts\/ThumbSeed\.js\?/i;

    var CSS_PREFIX = "fmts-";

    var DEFAULT_LAYOUT = _getQueryString("fmts-layout", "300x250"),
		DEFAULT_HEADER_COLOR = _getQueryString("fmts-headercolor", "black"),
		DEFAULT_BG_COLOR = _getQueryString("fmts-bgcolor", "white");

    var CSS_RESETTER_CLASS = "fmtsw";
    var CSS_RESETTER_ID = "fmtsw";

    function getRnd(s) { var a = s.split(","); return a[Math.floor(Math.random() * a.length)]; }

    var URL_WEBSITE = "http://www.5min.com/",
		URL_SYN = "http://syn.5min.com/",
		URL_SHARED = "http://pshared.5min.com/",
		URL_GRAPHICS = URL_SHARED + "Graphics/VideoSeed/";

    var DEBUG = false;

    switch (_getQueryString("fmts-test")) {
        case "localhost":
            URL_WEBSITE = "http://localhost/5min/";
            URL_SYN = "http://localhost/syn/";
            URL_SHARED = "http://localhost/shared/";
            CURRENT_SCRIPT_SRC_RX = /\/scripts\/ThumbSeed?\.js\?/i;
            DEBUG = true;
            break;
        case "5minlocal":
            URL_WEBSITE = "http://www.5min.com/";
            URL_SYN = "http://syn.5minlocal.com/";
            URL_SHARED = "http://shared.5minlocal.com/";
            CURRENT_SCRIPT_SRC_RX = /\/scripts\/ThumbSeed?\.js\?/i;
            DEBUG = true;
            break;
    }

    function getHead() {
        return $.getElement("head") || $.document.body || $.document.documentElement;
    }

    var THUMBSEED_CSS = "";

    function ThumbSeed(wrapperId) {
        this.wrapperId = wrapperId;
        this.instanceNumber = ThumbSeed._instances.length;
        ThumbSeed._instances.push(this);
    }

    var _cssAdded = false,
		_cssRequested = false,
		_cssAddedCallbacks = [];
    // static
    $.extend(ThumbSeed, {
        _instances: [],
        getTopMostWindow: function n() {
            var p = window;
            while (p) {
                try {
                    p = p.parent;
                    // try to reach the document, if didn't succeed - goes to catch {}
                    var doc = p.document;
                    if (p == p.parent) break;
                } catch (ex) {
                    break;
                }
            }
            // overwrite the function to return the found window next time, without the loop
            ThumbSeed.getTopMostWindow = function() { return p; };
            return p;
        },
        addCssFile: function(callback) {
            if (_cssAdded) { // css already added - free to call the callback
                callback();
                return;
            }

            _cssAddedCallbacks.push(callback);

            if (!_cssRequested) {
                _cssRequested = true;
                jsonp(URL_SHARED + "Scripts/ThumbSeed.Style.js", null, { xpreventCache: false }); // TODO
            }

            return;

            $.create("link", {
                parent: getHead(),
                rel: "Stylesheet",
                type: "text/css",
                href: URL_SHARED + "CSS/ThumbSeed2.css?r=" + $.time() // TODO
            });

            setTimeout(callback, 1000);
        },
        putThumbSeedCss: function(resetCss, thumbSeedCss) {
            var css = [resetCss];
            if (!this.customCss) css.push(thumbSeedCss);
            this.putCss(css.join(" "));
        },
        putCss: function(css) {
            this.putCssOnDocument($.document, css);
            var win = ThumbSeed.getTopMostWindow();
            if (win != window) {
                this.putCssOnDocument(ThumbSeed.getTopMostWindow().document, css);
            }

            _cssAdded = true;

            setTimeout(function() {
                $.each(_cssAddedCallbacks, function(fn) {
                    fn();
                });
            }, 50);
        },
        putCssOnDocument: function(doc, css) {
            $.setDocument(doc);
            $.log("putCssOnDocument", doc, $.getElement("head").ownerDocument);
            if ($.browser.engine == "ie") {
                var styleTag = '<span>DumbIE</span><style type="text/css">' + css + '</style>';
                var div = $.create("div", { innerHTML: styleTag });

                var styleContainer = getHead(doc);
                styleContainer.appendChild(div.lastChild);
            }
            else {
                var style = $.create("style", {
                    type: "text/css",
                    parent: getHead(),
                    textContent: css
                });
            }
            $.restoreDocument();
        }
    });

    // instance
    $.extend(ThumbSeed.prototype, {
        // defaults
        displayHeader: true,
        displayFooter: true,
        displayBorder: true,

        load: function() {
            $.log("ThumbSeed#load", this);
            $.addDomReady($.bind(function() {
                this.setStyleProperties();
                ThumbSeed.addCssFile($.bind(function() {
                    this.requestData();
                }, this));
            }, this));
        },

        requestData: function() {
            if (!this.url) {
                this.url = location.href;

                var win = ThumbSeed.getTopMostWindow();

                this.url = win.location.href;
            }

            if (this.drawBeforeData) this.draw(); // will put "loading"

            jsonp(
				URL_SYN + "handlers/SenseHandler.ashx?func=GetResults&thumbSeedCounter=" + this.instanceNumber + "&sid=" + this.sid + this.getParamsForHandler() + '&url=' + encodeURIComponent(this.url),
				$.bind(function(data) {
				    $.log("[jsonp data]", data, "drawBeforeData=", this.drawBeforeData);
				    if (data && data.binding) {
				        this.videos = data.binding;
				        if (this.drawBeforeData) this.drawVideos(); // ui already drawn, draw just videos
				        else this.draw();
				        var ss = document.getElementById(this.wrapperToShow);
				        if (this.wrapperToShow) $.css(ss, { display: "block" });
				    }
				}, this)
			);
        },

        setStyleProperties: function() {
            this.layout = this.layout ? this.layout.toLowerCase() : DEFAULT_LAYOUT;
            this.headerColor = this.headerColor ? this.headerColor.toLowerCase() : DEFAULT_HEADER_COLOR;
            this.backgroundColor = this.backgroundColor ? this.backgroundColor.toLowerCase() : DEFAULT_BG_COLOR;
        },

        getParamsForHandler: function() {
            var params = {};

            params.videoCount = this.forceVideoCount || this._getVideoCount();

            if (this.categories && this.categories.length > 0) params.categories = this.categories;

            if (this.playList && this.playList.length > 0) params.playlist = this._getRandomList(this.playList);

            if (this.fallback) params.fallback = this._getRandomList(this.fallback);

            if (this.fallbackType) params.fallbackType = this._getRandomList(this.fallbackType);

            if (this.featured && this.featured == true) params.featured = true;

            if (this.contentQuality && this.contentQuality > 0) params.ContentQuality = this.contentQuality;

            if (this.layout) params.rectSize = this.layout;

            if (this.testData) params.testData = this.testData;

            if (this.explicitTags) params.explicitTags = this.explicitTags;

            if (this.relatedMode) params.relatedMode = this.relatedMode;

            params.autoStart = (this.autoStart !== undefined ? this.autoStart : true);

            $.extend(params, { cbCustomID: "fiveMinAdaptvCompanionDiv", ExposureType: "ThumbSeed" });

            if (_getQueryString("playernewversion3") == "true") params.playernewversion3 = true;

            if (_getQueryString("isTestDensity") == "true") params.isTestDensity = true;

            if (_getQueryString("playerdebug5min") != "") params.playerdebug5min = _getQueryString("playerdebug5min");

            if ($.getElement("title")) params.shortAnalysisText = $.getElement("title").innerHTML;

            if (this.libraryID > 0) params.libraryID = this.libraryID;

            var paramsString = "&" + toQueryString(params);

            return paramsString;
        },

        _getVideoCount: function() {
            //if (this.forceVideoCount) return this.forceVideoCount;

            var max = this._getMaximumVideoCountForLayout();

            if (this.videos) {
                if (this.videoCount && this.videoCount > 0) return Math.min(this.videoCount, this.videos.length, max);
                return Math.min(this.videos.length, max);
            }

            var count = !this.videoCount || this.videoCount > max ? max : this.videoCount;
            var possible = this._getPossibleVideoCountsForLayout();
            if (possible && $.indexOf(possible, count) == -1) count = max;

            return count;
        },

        _getMaximumVideoCountForLayout: function() {
            // maximum videos
            var videoCount;
            switch (this.layout) {
                case "160x600":
                case "700x180":
                    videoCount = 5;
                    break;
                case "728x90":
                case "205x335":
                case "500x175":
                    videoCount = 4;
                    break;
                case "590x96":
                case "575x100":
                    videoCount = 3;
                    break;
                case "468x60":
                case "250x250":
                case "300x250":
                    videoCount = 2;
                    break;
                case "120x120":
                    videoCount = 1;
                    break;
                case "425x400":
                    videoCount = 9;
                    break;
                default:
                    videoCount = 5;
                    break;
            }
            return videoCount;
        },
        _getPossibleVideoCountsForLayout: function() {
            function range(from, to) {
                var arr = [];
                for (var i = from; i <= to; i++) arr.push(i);
                return arr;
            }

            // maximum videos
            var videoCount;
            switch (this.layout) {
                case "300x250":
                case "250x250":
                    videoCount = range(1, 2);
                    break;
                case "160x600":
                    videoCount = range(1, 5);
                    break;
                case "728x90":
                    videoCount = range(1, 4);
                    break;
                case "700x180":
                    videoCount = range(2, 5);
                    break;
                case "590x96":
                    videoCount = range(1, 3);
                    break;
                case "500x175":
                    videoCount = range(1, 4);
                    break;
                case "575x100":
                    videoCount = range(1, 3);
                    break;
                case "468x60":
                    videoCount = range(1, 2);
                    break;
                case "425x400":
                    videoCount = [3, 6, 9];
                    break;
                case "205x335":
                    videoCount = range(1, 4);
                    break;
                case "120x120":
                    videoCount = [1];
                    break;
            }
            return videoCount;
        },
        _getRandomList: function(videoList) {
            var videoListArr;
            var newVideoListArr = [];

            if (videoList.length > 0) {
                videoListArr = videoList.split(',');
                var videoCount = Math.min(this.forceVideoCount || this._getMaximumVideoCountForLayout(), videoListArr.length);

                var counter = 0;
                while (counter < videoCount) {
                    var no = Math.round(Math.random() * (videoListArr.length - 1));

                    // TODO $.indexOf()

                    var isInArray = false;
                    // Check if no in Array if yes we have to 
                    for (var i = 0; i < newVideoListArr.length; i++) {
                        if (newVideoListArr[i].toString() == videoListArr[no].toString()) {
                            isInArray = true;
                            break;
                        }
                    }
                    if (!isInArray) {
                        newVideoListArr.push(videoListArr[no]);
                        counter++;
                    }
                }
            }
            return newVideoListArr.toString();
        },

        /* draw */
        draw: function() {
            if (!this.drawBeforeData && !this.videos) return;

            if (this._drew) return;
            this._drew = true;

            this.wrapper = $(this.wrapperId);

            $.log("this.wrapper=", this.wrapper, " - ", "this._drew=", this._drew);

            if (this.layout) this.layout = this.layout.toLowerCase();
            if (this.headerColor) this.headerColor = this.headerColor.toLowerCase();
            if (this.backgroundColor) this.backgroundColor = this.backgroundColor.toLowerCase();

            if (!this.wrapper) {
                $.log("No wrapper with ID=", this.wrapperId);
                return;
            }

            this.container = $.create("div", { id: CSS_RESETTER_ID, className: CSS_RESETTER_CLASS + " " + CSS_PREFIX + "c" });

            if (this.displayHeader) this.drawHeader();
            else this.headerColor = "noheader";

            this.videosContainer = $.create("ul", {
                parent: this.container,
                className: CSS_PREFIX + "vl"
            });

            this.setStyle(this.layout, this.headerColor, this.backgroundColor);

            this.wrapper.appendChild(this.container);

            $.addCls(this.container, CSS_PREFIX + "bg-" + this.backgroundColor + "-loading");

            // adjust height for preloader
            if (!$.currCss(this.videosContainer, "height")) {
                var containerHeight = $.currCss(this.container, "height");
                $.css(this.videosContainer, { height: containerHeight || "100%" || 50 });
            }

            this.setLayout(this.layout);
            this.setHeaderColor(this.headerColor);
            this.setBackgroundColor(this.backgroundColor);
            this.setBorder(this.displayBorder);

            this.drawVideos();

            if (this._shouldDisplayFooter()) {
                $.removeCls(this.container, CSS_PREFIX + "no-footer");
                this.drawFooter();
            }
            else $.addCls(this.container, CSS_PREFIX + "no-footer");

            if ($.indexOf("300x250,250x250,160x600,700x180,205x335,500x175,425x400".split(","), this.layout) > -1) {
                $.removeCls(this.container, CSS_PREFIX + "footer-on-side");
                $.addCls(this.container, CSS_PREFIX + "footer-on-bottom");
            }
            else {
                $.removeCls(this.container, CSS_PREFIX + "footer-on-bottom");
                $.addCls(this.container, CSS_PREFIX + "footer-on-side");
            }

            this._drew = true;
        },

        redraw: function() {
            if (this.header) $.css(this.header, { backgroundImage: "url('" + URL_GRAPHICS + this.backgroundColor + this.headerColor + "Strip_700X180.png')" });
            if (this.titleElement) {
                $.css(this.titleElement, { backgroundImage: "url('" + URL_GRAPHICS + this.backgroundColor + this.headerColor + "Trig_700X180.png')" });
                this.titleElement.innerHTML = this.title || this._getDefaultTitle();
            }
            if (this._shouldDisplayFooter()) {
                $.removeCls(this.container, CSS_PREFIX + "no-footer");
                this.drawFooter();
            }
            else $.addCls(this.container, CSS_PREFIX + "no-footer");

            if ($.indexOf("300x250,250x250,160x600,700x180,205x335,500x175,425x400".split(","), this.layout) > -1) {
                $.removeCls(this.container, CSS_PREFIX + "footer-on-side");
                $.addCls(this.container, CSS_PREFIX + "footer-on-bottom");
            }
            else {
                $.removeCls(this.container, CSS_PREFIX + "footer-on-bottom");
                $.addCls(this.container, CSS_PREFIX + "footer-on-side");
            }

            this.drawVideos();
        },

        _resizeByItemCount: function() {
            var maximumVideoCount = this._getMaximumVideoCountForLayout(), // current width/height from css determined according to the max items
				videoCount = this._getVideoCount(); // current width/height from css determined according to the max items

            //$.log("_resizeByItemCount",this._resizeByItemCount.caller.toSource());
            size = this._getItemRelevantSize();
            $.log("_getItemRelevantSize = ", size);
            if (size) {
                var style = {};

                $.css(this.container, { width: "", height: "" }); // reset w/h so it's read from the css

                var currentSize = $.currCss(this.container, size.property);

                // special treatment for multiline
                if (this.layout == "425x400") {
                    maximumVideoCount = 3; // maximum number of lines
                    videoCount = Math.ceil(videoCount / 3); // actual number of lines
                }

                style[size.property] = currentSize - (size[size.property] * (maximumVideoCount - videoCount)); // substract width/height by number of current items missing from default size

                if (!this._shouldDisplayFooter()) {
                    //if (size.property=="width") style[size.property]-=12;
                    //else style[size.property]-=12;
                }

                $.log(this.container, style);

                $.css(this.container, style);

                $.log(this.container, style);

                style[size.property] = size[size.property] * videoCount; // substract width/height by number of current items missing from default size
                if (size.property == "height") style.width = size.width;
                else style.height = size.height;

                if (this.layout == "425x400") {
                    videoCount = this._getVideoCount();
                    style.width *= videoCount >= 3 ? 3 : videoCount % 3;
                    $.css(this.container, { width: style.width });
                }

                $.css(this.videosContainer, style);
            }
        },

        // returns item width/height depends on the container orientation
        _getItemRelevantSize: function() {
            var size = { property: "width" /* default */ };
            switch (this.layout) {
                case "300x250":
                    size.property = "height";
                    size.height = 96;
                    size.width = 298;
                    break;
                case "250x250":
                    size.property = "height";
                    size.height = 96;
                    size.width = 248;
                    break;
                case "160x600":
                    size.property = "height";
                    size.height = 110;
                    size.width = 160;
                    break;
                case "728x90":
                    size.width = 165;
                    size.height = 62;
                    break;
                case "700x180":
                    size.width = 140;
                    size.height = 125;
                    break;
                case "205x335":
                    size.property = "height";
                    size.height = 77;
                    size.width = 198;
                    break;
                case "590x96":
                    size.width = 175;
                    size.height = 66;
                    break;
                case "500x175":
                    size.width = 126;
                    size.height = 119;
                    break;
                case "575x100":
                    size.width = 164;
                    size.height = 69;
                    break;
                case "468x60":
                    size.width = 204;
                    size.height = 44;
                    break;
                case "425x400":
                    size.property = "height";
                    size.height = 126;
                    size.width = 143;
                    break;
            }

            return size;
        },

        drawHeader: function() {
            this.header = $.create("div", { className: CSS_PREFIX + "header", parent: this.container });

            $.css(this.header, { backgroundImage: "url('" + URL_GRAPHICS + this.backgroundColor + this.headerColor + "Strip_700X180.png')" });

            this.titleElement = $.create("h2", { parent: this.header });
            this.titleElement.innerHTML = this.title || this._getDefaultTitle();

            $.css(this.titleElement, { backgroundImage: "url('" + URL_GRAPHICS + this.backgroundColor + this.headerColor + "Trig_700X180.png')" });
        },

        drawVideos: function() {
            //$.log("drawVideos "+this.videos);

            if (!this.videos) return;
            $.css(this.videosContainer, { width: "", height: "" });

            //var ellipsisizeElements=[];

            var maxVideos = this._getVideoCount();

            this.videosContainer.innerHTML = "";

            $.each(this.videos.slice(0, Math.min(this.videos.length, maxVideos)), function(data, i) {
                //alert(this.videos.length+"\n"+i+"\n"+maxVideos+"\n"+(i>=maxVideos));
                var video = this.getVideoElement(data);
                this.videosContainer.appendChild(video);

                // text overflows
                if (video.__name.offsetHeight < video.__name.scrollHeight) {
                    //ellipsisizeElements.push(video);
                    this._ellipsisizeText(video);
                }
                else video.__nameLink = video.__name = null;
            }, this);
            if (!this._shouldDisplayFooter()) {
                if (this.videosContainer.lastChild) $.css(this.videosContainer.lastChild, { backgroundImage: "none" }); // remove last seperator
            }
            $.removeCls(this.container, CSS_PREFIX + "bg-" + this.backgroundColor + "-loading");

            this._resizeByItemCount();
        },

        _ellipsisizeText: function(video) {
            var offsetHeight = video.__name.offsetHeight;

            var prop;
            var title = video.__nameLink.textContent;
            if (title !== undefined) prop = "textContent";
            else {
                title = video.__nameLink.innerText;
                if (title !== undefined) prop = "innerText";
                else {
                    title = video.__nameLink.innerHTML;
                    prop = "innerHTML";
                }
            }

            var tilteParts = title.split(/\s+/g);

            var lastGoodIndex = tilteParts.length;

            var currentParts = [];

            while (video.__name.scrollHeight > offsetHeight && lastGoodIndex > 0) {
                currentParts = tilteParts.slice(0, --lastGoodIndex);
                video.__nameLink[prop] = currentParts.join(" ") + "...";
            }

            video.__nameLink = video.__name = null;
        },

        drawFooter: function() {
            var logoSize = this.layout == "575x100" ? "590x96" : this.layout;

            if (!this.footer) {
                this.footer = $.create("div", { className: CSS_PREFIX + "footer", parent: this.container });
                this.footerContent = $.create("div", { className: CSS_PREFIX + "footer-content", parent: this.footer });
            }

            this.footerContent.innerHTML = '\
					<a href="' + URL_WEBSITE + '" target="_blank">\
						' + (this._shouldRenderImageInFooter() ?
							'<img src="' + URL_GRAPHICS + this.backgroundColor + 'logo_' + logoSize + '.png" alt="5min"/>' :
							'<span class="fmts-footer-text">By 5min <strong>Life Videopedia</strong></span>'
						) + '\
					</a>\
				';

            this._applySeparatorOnFooter();
        },

        getVideoElement: function(data) {
            var htTarget = this.ht ? this.ht : "_blank";
            var startLink = '<a href="', endLink = '</a>';

            if (this.directUrl)
                startLink += this.directUrl.replace(/\[VIDEOID\]/ig, data.ID);
            else
                startLink += data.PageURL;

            startLink += '" target="' + htTarget;

            startLink += '" title="' + $.htmlenc(data.Title) + '">';

            var name = $.create("div", { className: "name", innerHTML: startLink + data.Title + endLink });

            var video = $.create("li", {
                className: CSS_PREFIX + "vi",
                children: [
						$.create("div", { className: "img", innerHTML: startLink + '<img src="' + data.ThumbURL + '" title="' + $.htmlenc(data.Title) + '" alt="' + $.htmlenc(data.Title) + '"/>' + endLink }),
						$.create("div", { className: "play", innerHTML: startLink + endLink }),
						$.create("div", { className: "duration", innerHTML: data.Duration }),
						name
					],
                events: this.directUrl ? {} : { click: $.bind(function(e) {
                    $.stopEvent(e);
                    this.showVideo(data);
                }, this)
                }
            });

            video.__name = name;
            video.__nameLink = name.firstChild;

            this._applySeperator(video);

            return video;
        },

        showVideo: function(videoData) {
            var lb = new VideoLightbox(this, videoData);
            lb.show();
        },


        /* set */
        setStyle: function(layout, headerColor, backgroundColor) {
            this.setLayout(layout);
            this.setHeaderColor(headerColor);
            this.setBackgroundColor(backgroundColor);

            // combination of classes for ie6 which can't handle .class1.class2.class3
            $.addCls(this.container, CSS_PREFIX + "l-" + layout + "-bg-" + backgroundColor);
        },

        setLayout: function(name) {
            if (!name) return;
            this.layout = name.toLowerCase();
            this._removeClassOfCategory("l");
            $.addCls(this.container, CSS_PREFIX + "l-" + this.layout);

            $.log("setHeaderColor(" + this.layout + ") = ", this.container.className);

            this.setTitle();
        },
        setHeaderColor: function(name) {
            if (!name) return;
            this.headerColor = name.toLowerCase();
            this._removeClassOfCategory("hc");
            $.addCls(this.container, CSS_PREFIX + "hc-" + this.headerColor);

            $.log("setHeaderColor(" + this.headerColor + ") = ", this.container.className);
        },
        setBackgroundColor: function(name) {
            if (!name) return;
            this.backgroundColor = name.toLowerCase();
            this._removeClassOfCategory("bg");
            $.addCls(this.container, CSS_PREFIX + "bg-" + this.backgroundColor);
            this.setBorder(this.displayBorder);

            $.log("setBackgroundColor(" + this.backgroundColor + ") = ", this.container.className);
        },
        setBorder: function(visible) {
            this.displayBorder = visible;

            var rx = new RegExp("(^|\\s*)" + CSS_PREFIX + "([^ ]+)?bordered(?:\\s*|$)", "gi");
            $.log(rx, rx.test(this.container.className));
            this.container.className = this.container.className.replace(rx, " ");

            if (visible) {
                $.addCls(this.container, CSS_PREFIX + "bordered");
                $.addCls(this.container, CSS_PREFIX + "bg-" + this.backgroundColor + "-bordered");
            }

            $.log("setBorder(" + this.displayBorder + ") = ", this.container.className);
        },
        setTitle: function(title) {
            if (title !== undefined) this.title = title;
            if (this.titleElement) this.titleElement.innerHTML = this.title || this._getDefaultTitle();
        },

        _getDefaultTitle: function() {
            return this.layout == "120x120" ? "Featured" : "Featured Videos";
        },

        _removeClassOfCategory: function(category) {
            var rx = new RegExp("(^|\\s+)" + CSS_PREFIX + category + "-[\\w\\-]+?(?:\\s+|$)", "gi");
            this.container.className = this.container.className.replace(rx, " ");
        },

        /* private */
        _shouldDisplayFooter: function() {
            return this.displayFooter && this.layout != "120x120";
        },
        _shouldRenderImageInFooter: function() {
            switch (this.layout) {
                case "728x90":
                case "590x96":
                case "575x100":
                case "468x60":
                    return true;
            }
            return false;
        },
        _applySeperator: function(videoElement) {
            if (!this._separatorImageForLayout) this._separatorImageForLayout = {};

            if (!this._separatorImageForLayout[this.layout]) {
                switch (this.layout) {
                    case "300x250":
                    case "250x250":
                    case "160x600":
                    case "205x335":
                        this._separatorImageForLayout[this.layout] = "160x600";
                        this._separatorImageForLayout[this.layout + "Side"] = "";
                        break;
                    case "728x90":
                    case "700x180":
                    case "590x96":
                    case "500x175":
                    case "575x100":
                    case "468x60":
                    case "425x400":
                        this._separatorImageForLayout[this.layout] = "700x180";
                        this._separatorImageForLayout[this.layout + "Side"] = "Left";
                        break;
                }
            }
            if (this._separatorImageForLayout[this.layout]) {
                $.css(videoElement, { backgroundImage: "url('" + URL_GRAPHICS + this.backgroundColor + this._separatorImageForLayout[this.layout + "Side"] + "Seperator_" + this._separatorImageForLayout[this.layout] + ".png')" });
            }
        },
        _applySeparatorOnFooter: function(videoElement) {
            switch (this.layout) {
                case "700x180":
                case "500x175":
                    $.css(this.footer, { backgroundImage: "url('" + URL_GRAPHICS + this.backgroundColor + "Seperator_700x180.gif')" });
                    break;
                default:
                    $.css(this.footer, { backgroundImage: "none" });
            }
        }
    });

    ThumbSeed.prototype.Load = ThumbSeed.prototype.load; // backward compatability

    var LIGHTBOX_CSS_PREFIX = CSS_PREFIX + "lb-";
    var LIGHTBOX_CONTENT_CSS_PREFIX = CSS_PREFIX + "lb-cn-";

    var PLAYER_WIDTH = 480, PLAYER_HEIGHT = 401;

    function VideoLightbox(host, data) {
        this.host = host;
        this.data = data;
        this.instanceIndex = VideoLightbox.instanceCount++;
    }
    VideoLightbox.instanceCount = 0;
    $.extend(VideoLightbox.prototype, {
        _create: function() {
            this.element = $.create("div", {
                id: CSS_RESETTER_ID,
                className: CSS_RESETTER_CLASS + " " + LIGHTBOX_CONTENT_CSS_PREFIX + "wrapper",
                innerHTML: '<table class="' + LIGHTBOX_CONTENT_CSS_PREFIX + 'centerizer"><tbody><tr><td class="' + LIGHTBOX_CONTENT_CSS_PREFIX + 'centerizer"></td></tr></tbody></table>',
                parent: $.document.body,
                styles: { display: "none" }
            });
            var contentContainer = $.getElement("td", this.element);

            this.content = $.create("div", { className: LIGHTBOX_CSS_PREFIX + "cn", parent: contentContainer });

            this.overlay = $.create("div", { id: CSS_RESETTER_ID, className: CSS_RESETTER_CLASS + " " + LIGHTBOX_CSS_PREFIX + "overlay" });

            // CHANGE ONLINE - ELAD 091125-0027
            if ($.browser.engine == "ie") {
                this._adjustOnResize = $.bind(function(e) {
                    var offsetHeight = $.document.documentElement.offsetHeight,
						scrollHeight = $.document.documentElement.scrollHeight;
                    $.log("[TS] [LB] resizing lightbox");
                    if (offsetHeight > 0 && scrollHeight > 0) {
                        $.css(this.element, {
                            height: offsetHeight,
                            width: $.document.documentElement.scrollWidth
                        });
                        $.css(this.overlay, {
                            height: scrollHeight,
                            width: $.document.documentElement.scrollWidth
                        });
                    }

                    if ($.browser.version > 6) {
                        $.css(this.element, { position: "fixed" });
                        $.css(this.overlay, { position: "fixed" });
                    }
                }, this);

                if ($.browser.version == 6) {
                    this._adjustOnScroll = $.bind(function(e) {
                        $.css(this.element, {
                            top: $.document.documentElement.scrollTop
                        });
                    }, this);
                    this._adjustOnScroll();
                    $.addEvent(window, "scroll", this._adjustOnScroll);
                }

                this._adjustOnResize();
                $.addEvent(window, "resize", this._adjustOnResize);
            }
            // END CHANGE

            var hideOnEscFunction = $.bind(function(e) {
                if (e.keyCode == 27) {
                    this.hide();
                    $.removeEvent(document, "keydown", hideOnEscFunction);
                    $.removeEvent($.document, "keydown", hideOnEscFunction);
                }
            }, this);

            $.addEvent(document, "keydown", hideOnEscFunction);
            $.addEvent($.document, "keydown", hideOnEscFunction);

            $.addEvent(contentContainer, "click", $.bind(function(e) {
                var target = $.eventElement(e);
                if (target != this.content && !$.hasChild(this.content, $.eventElement(e))) this.hide();
            }, this));

            $.create("div", { className: LIGHTBOX_CONTENT_CSS_PREFIX + "title", innerHTML: this.data.Title, parent: this.content });
            $.create("div", { className: LIGHTBOX_CONTENT_CSS_PREFIX + "close", innerHTML: "Close", parent: this.content, events: {
                click: $.bind(function() {
                    this.hide();
                }, this)
            }
            });

            var playerHtml = this.getPlayerHtml();

            var playerContainer = $.create("div", { className: LIGHTBOX_CONTENT_CSS_PREFIX + "player-container", parent: this.content });
            this._drawAds();
            playerContainer.innerHTML = playerHtml;
        },
        show: function() {
            if (VideoLightbox._current) {
                VideoLightbox._current.immediateHide();
            }
            VideoLightbox._current = this;

            $.setDocument(ThumbSeed.getTopMostWindow().document);

            if (!this.element) this._create();

            $.opacity(this.overlay, 0);

            $.document.body.appendChild(this.overlay);
            new $.fx(this.overlay, { onComplete: $.bind(function() {
                $.css(this.element, { display: "block" });
                $.restoreDocument();
            }, this), duration: 300
            }).start({ opacity: .7 });
        },
        hide: function() {
            // CHANGE - ELAD 091125
            if ($.browser.engine == "ie") {
                if ($.browser.version == 6) $.removeEvent(window, "scroll", this._adjustOnScroll);
                $.removeEvent(window, "resize", this._adjustOnResize);
            }
            // END CHANGE

            VideoLightbox._current = null;

            this.element.innerHTML = "";

            new $.fx(this.overlay, { onComplete: $.bind(function() {
                this.immediateHide();
            }, this), duration: 200
            }).start({ opacity: 0 });
        },
        immediateHide: function() {
            if (this.element.parentNode) {
                this.element.innerHTML = "";
                $.removeNode(this.element);
            }
            $.removeNode(this.overlay);
            VideoLightbox._current = null;
        },

        getPlayerHtml: function() {
            var embedUrl = this.data.EmbededURL;

            // server gives other cbHtmlID, but i want mine.
            embedUrl = embedUrl.replace(/cbHtmlID=.*?(?:&|$)/i, "");

            // adding relatedMode bottom to all thumbSeed players.
            embedUrl += "&relatedMode=2";

            var adsDataForPlayer = toQueryString(this._getFlashAdParams());

            embedUrl += "&" + adsDataForPlayer;

            var playerHtml = '<object \
				id="FiveMinEmbed_' + this.host.instanceNumber + '" width="' + PLAYER_WIDTH + '" height="' + PLAYER_HEIGHT + ' "classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">\
					<param name="allowfullscreen" value="true">\
					<param name="allowScriptAccess" value="always">\
					<param name="movie" value="' + embedUrl + '">\
					<param name="wmode" value="window">\
					<embed src="' + embedUrl + '" name="FiveMinEmbed_' + this.host.instanceNumber + '" type="application/x-shockwave-flash" width="' + PLAYER_WIDTH + '" height="' + PLAYER_HEIGHT + '" allowfullscreen="true" allowScriptAccess="always" wmode="window"></embed>\
				</object>';

            return playerHtml;
        },


        _getAdElementId: function(id) {
            return LIGHTBOX_CONTENT_CSS_PREFIX + "cb-ad-" + this.instanceIndex + "-" + id;
        },

        _drawAds: function() {
            this.adsContainer = $.create("div", { parent: this.content, className: LIGHTBOX_CONTENT_CSS_PREFIX + "side-ad-container" });
            $.create("div", { parent: this.content, styles: { clear: "both"} });

            var adBaseClassName = LIGHTBOX_CONTENT_CSS_PREFIX + "ad";

            $.create("div", {
                parent: this.adsContainer,
                id: this._getAdElementId("side-top"),
                className: adBaseClassName + " " + LIGHTBOX_CONTENT_CSS_PREFIX + "side-top"
            });
            $.create("div", {
                parent: this.adsContainer,
                id: this._getAdElementId("side-bottom"),
                className: adBaseClassName + " " + LIGHTBOX_CONTENT_CSS_PREFIX + "side-bottom"
            });
            if (this.host.cbCount == 3) {
                $.create("div", {
                    parent: this.content,
                    id: this._getAdElementId("bottom"),
                    className: adBaseClassName + " " + LIGHTBOX_CONTENT_CSS_PREFIX + "bottom"
                });
                $.addCls(this.content, LIGHTBOX_CONTENT_CSS_PREFIX + "with-bottom-ad");
            }
        },

        //cbHtmlID=fiveMinCB_1_cb&cbWidth=300&cbHeight=250&cbHtmlID1=fiveMinCB_1_fb&cbWidth1=300&cbHeight1=[60]&cbIsFairBalance1=true

        _getFlashAdParams: function() {
            var flashAdParams = {
                cbHtmlID: this._getAdElementId("side-top"), cbWidth: 300, cbHeight: 250,
                cbHtmlID1: this._getAdElementId("side-bottom"), cbWidth1: 300, cbHeight1: 250, cbFailoverUrl1: URL_SHARED + "Banners/G_180x150_TS_T_I.htm",
                cbHtmlID2: this._getAdElementId("bottom"), cbWidth2: 728, cbHeight2: 90
            };

            if (this.host.cbCount == 3) {
                $.extend(flashAdParams, {
                    cbIsFairBalance1: true,
                    cbFailoverUrl2: URL_SHARED + "Banners/G_728x90_TS_T_I.htm"
                });
            }

            return flashAdParams;
        }
    });

    function _getQueryString() {
        if (!_getQueryString._overwritten) {
            _getQueryString._overwritten = true;

            var queryString = _parseQueryString(location.search.substr(1));
            _getQueryString = function(key, def) {
                key = key.toLowerCase();
                return (queryString[key] === undefined ? def : queryString[key]) || "";
            };
            return _getQueryString.apply(null, arguments);
        }
    }

    function _parseQueryString(query) {
        var params = {};
        query.replace(/(.*?)=(.*?)(?:&|$)/g, function(match, key, value) {
            params[key/*.toLowerCase()*/] = decodeURIComponent(value);
        });
        return params;
    }


    function jsonp(url, callback, options) {
        options = $.extend({ preventCache: true }, options || {});
        ThumbSeed.jsonpCallbacks.push(callback); // save the callback (a function) in the array,and set the callback to this function reference

        url += (url.indexOf("?") > -1 ? "&" : "?") + "callback=FIVEMIN.ThumbSeed.jsonpCallbacks[" + (ThumbSeed.jsonpCallbacks.length - 1) + "]";
        if (options.preventCache) url += "&rnd=" + $.time(); // prevent caching

        $.log("[json:] ", url);

        var script = $.create("script", {
            src: url,
            type: "text/javascript",
            parent: getHead()
        });
    }

    function toQueryString(params) {
        var arr = [];
        $.each(params, function(value, key) { arr.push(key + "=" + encodeURIComponent(value)); });
        var paramsString = arr.join("&");
        return paramsString;
    }

    ThumbSeed.jsonpCallbacks = [];

    var _parametersWithTypes = {
        sid: Number,
        url: String,
        categories: String,
        layout: String,
        headerColor: String,
        backgroundColor: String,
        displayHeader: Boolean,
        displayBorder: Boolean,
        displayFooter: Boolean,
        playList: String,
        fallback: String,
        fallbackType: String,
        featured: Boolean,
        contentQuality: Number,
        videoCount: Number,
        layout: String,
        testData: String,
        autoStart: Boolean,
        libraryID: Number,
        drawBeforeData: Boolean
    };

    ThumbSeed.loadParameterizedScripts = function() {
        var allScripts = $.getElements("script"),
			widgetScripts = [];
        $.each(allScripts, function(script) {
            if (CURRENT_SCRIPT_SRC_RX.test(script.src)) {
                if (DEBUG) $.log("ThumbSeed Creation");
                var widgetContainer = $.create("div");
                script.parentNode.insertBefore(widgetContainer, script);

                var widgetParams = script.src.split("?")[1];

                if (widgetParams.indexOf("sid=") == -1) return;

                var instance = new ThumbSeed(widgetContainer);

                if (widgetParams) {
                    widgetParams = _parseQueryString(widgetParams);

                    widgetParams = $.map(widgetParams, function(v, k) {
                        var type = _parametersWithTypes[k];
                        if (type == Boolean) return v == "true";
                        return type ? type(v) : v;
                    });
                    $.extend(instance, widgetParams);
                }

                if (DEBUG) $.log(widgetParams);

                instance.load();
            }
        });
    };

    $.addDomReady(ThumbSeed.loadParameterizedScripts);

    return ThumbSeed;
} ();

var ThumbSeed = FIVEMIN.ThumbSeed;

