//ORIGINAL: http://partner.googleadservices.com/gampad/google_service.js
(function(){var d=null,f=false,g=window,h="length",i="prototype",n="GA_jstiming",o="indexOf",p="join";function r(a){this.t={};this.tick=function(b,c,e){e=e?e:(new Date).getTime();this.t[b]=[e,c]};this.tick("start",d,a)}var s=new r;g.GA_jstiming={Timer:r,load:s};if(g[n]){g[n].c={};g[n].f=1;function t(a,b,c){var e=a.t[b];if(e){e=a.t[b][0];a=c!=undefined?c:a.t.start[0];return e-a}}g[n].report=function(a,b,c){var e="";if(a.e)e+="&"+a.e;var j=a.t,A=j.start,w=[],q=[];for(var k in j)if(k!="start")if(k[o]("_")!=0){var l=j[k][1];if(l)j[l]&&q.push(k+"."+t(a,k,j[l][0]));else A&&w.push(k+"."+t(a,k))}delete j.start;if(b)for(var m in b)e+="&"+m+"="+b[m];a=[c?c:"http://csi.gstatic.com/csi","?v=3","&s="+(g[n].sn?g[n].sn:"gam")+"&action=",a.name,q[h]?"&it="+q[p](",")+e:
e,"&rt=",w[p](",")][p]("");b=new Image;var x=g[n].f++;g[n].c[x]=b;b.onload=b.onerror=function(){delete g[n].c[x]};b.src=a;b=d;return a}};var u=this,v=function(a,b,c){a=a.split(".");c=c||u;!(a[0]in c)&&c.execScript&&c.execScript("var "+a[0]);for(var e;a[h]&&(e=a.shift());)if(!a[h]&&b!==undefined)c[e]=b;else c=c[e]?c[e]:(c[e]={})};Math.floor(Math.random()*2147483648).toString(36);var y=Date.now||function(){return+new Date},z=function(a,b,c){v(a,b,c)},B=function(a,b){function c(){}c.prototype=b[i];a.h=b[i];a.prototype=new c};function C(a,b){if(a=="true")return true;if(a=="false")return f;return b}function D(a,b){var c=/^([\w-]+\.)+[\w-]{2,}(\:[0-9]+)?$/;return c.test(a)?a:b};var E="pagead2.googlesyndication.com",F="googleads.g.doubleclick.net",G="pubads.g.doubleclick.net",H="securepubads.g.doubleclick.net",I="partner.googleadservices.com";D("googleads.g.doubleclick.net",F);D("pagead2.googlesyndication.com",E);var J=D("pubads.g.doubleclick.net",G),K=D("partner.googleadservices.com",I),L=D("securepubads.g.doubleclick.net",H);var aa=C("false",f);var M=function(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},ba=function(a,b){var c=0;a=M(String(a)).split(".");b=M(String(b)).split(".");for(var e=Math.max(a[h],b[h]),j=0;c==0&&j<e;j++){var A=a[j]||"",w=b[j]||"",q=new RegExp("(\\d*)(\\D*)","g"),k=new RegExp("(\\d*)(\\D*)","g");do{var l=q.exec(A)||["","",""],m=k.exec(w)||["","",""];if(l[0][h]==0&&m[0][h]==0)break;c=l[1][h]==0?0:parseInt(l[1],10);var x=m[1][h]==0?0:parseInt(m[1],10);c=N(c,x)||N(l[2][h]==0,m[2][h]==0)||N(l[2],m[2])}while(c==0)}return c},
N=function(a,b){if(a<b)return-1;else if(a>b)return 1;return 0};y();var O,P,Q,R,S,ca,da,ea,fa,T=function(){return u.navigator?u.navigator.userAgent:d},U=function(){return u.navigator},ga=function(){S=R=Q=P=O=f;var a;if(a=T()){var b=U();O=a[o]("Opera")==0;P=!O&&a[o]("MSIE")!=-1;R=(Q=!O&&a[o]("WebKit")!=-1)&&a[o]("Mobile")!=-1;S=!O&&!Q&&b.product=="Gecko"}};ga();var ha=O,ia=P,ja=S,V=Q,ka=function(){var a=U();return a&&a.platform||""},W=ka(),la=function(){ca=W[o]("Mac")!=-1;da=W[o]("Win")!=-1;ea=W[o]("Linux")!=-1;fa=!!U()&&(U().appVersion||"")[o]("X11")!=-1};la();
var ma=function(){var a="",b;if(ha&&u.opera){a=u.opera.version;a=typeof a=="function"?a():a}else{if(ja)b=/rv\:([^\);]+)(\)|;)/;else if(ia)b=/MSIE\s+([^\);]+)(\)|;)/;else if(V)b=/WebKit\/(\S+)/;if(b)a=(a=b.exec(T()))?a[1]:""}return a},na=ma(),X={};V&&(X["522"]||(X["522"]=ba(na,"522")>=0));function oa(a){return pa("adsense",a)}z("GS_googleAddAdSenseService",oa);function qa(){ra()}z("GS_googleEnableAllServices",qa);function sa(){g.a={}}z("GS_googleResetAllServices",sa);function ta(){var a="adsense";return ua(a)}z("GS_googleGetIdsForAdSenseService",ta);function va(a){return wa(a)}z("GS_googleFindService",va);function Y(a){this.g=a;this.b=[]}Y[i].toString=function(){for(var a="["+this.g+" ids: ",b=0;b<this.b[h];b++){if(b>0)a+=",";a+=this.b[b]}a+="]";return a};
var xa=function(a){if(a=="adsense")return new Z;return new $},pa=function(a,b){if(!(b&&typeof b=="string"&&b[h]>0))return d;if(a==d)return d;var c=g.a[a];if(c==d){c=xa(a);g.a[a]=c}ya(c,b);return c},ya=function(a,b){for(var c=0;c<a.b[h];c++)if(b==a.b[c])return;a.b[a.b[h]]=b},ra=function(){for(var a in g.a){var b=g.a[a];typeof b!="function"&&b.enable()}},wa=function(a){return a=a==d?d:g.a[a]},ua=function(a){a=a==d?d:g.a[a];return a==d?"":a.b[p]()};function $(){Y.call(this,"unknown")}B($,Y);
$[i].enable=function(){};function Z(){Y.call(this,"adsense");this.d=f}B(Z,Y);var za=function(a){if(a&&(a[o]("?google_debug")>0||a[o]("&google_debug")>0))return"google_ads_dbg.js";return"google_ads.js"},Aa=function(a){var b="http://"+K;if(aa)b="https://"+L;var c="";J==G||(c="?prodhost="+J);return b+"/gampad/"+a+c};Z[i].enable=function(){if(!this.d){var a=Aa(za(document.URL)),b="script";document.write("<"+b+' src="'+a+'"><\/script>');this.d=true;if(g[n]&&g[n].Timer){g[n].load.name="load";g[n].load.tick("start")}}};
g.a||(g.a={});})();
//ORIGINAL: site.advertising.google.js
/*** Additional Parameters for Google Use ***/
var site_google_adsize = 'nosize';
var google_channel_override = 'life123';
/*** This function is used to set the cookie. This builds the appropriate cookie string and sets the cookie  ***/
function set_cookie ( name, value, expires, path, domain, secure) {
  var today = new Date();
         today.setTime( today.getTime() );
         
         /*
         if the expires variable is set, make the correct
         expires time, the current script below will set
         it for x number of days, to make it for hours,
         delete * 24, for minutes, delete * 60 * 24
         */
         if ( expires )
         {
         expires = expires * 1000 * 60 * 60 * 24;
         }
         var expires_date = new Date( today.getTime() + (expires) );
         
         document.cookie = name + "=" +escape( value ) +
         ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
         ( ( path ) ? ";path=" + path : "" ) +
         ( ( domain ) ? ";domain=" + domain : "" ) +
         ( ( secure ) ? ";secure" : "" );
}
/* This function is used to get the cookie name and value, then returns the value portion of the match, 
*  passing it through the unescape() function to convert any escaped characters back to normal. 
*  (If it doesn't find the cookie, it returns a null value.) 
*/
function get_cookie ( cookie_name ) {
        var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
        if ( results )
            return ( unescape ( results[2] ) );
        else
            return null;
}
/* This fuction performs a check on the incoming cookie parameter value to the existing one 
* and changes it's value to the incoming one if it has got a different value to it
*/
function checkCookie(fName) {
        var fSrcOld=get_cookie('fcsource');
        var fSrcNew = fName;
        if (fSrcOld!=null && fSrcOld!="")
        {
           if(fSrcOld!=fSrcNew){
    set_cookie ( "fcsource", fSrcNew,'','/','',''); 
           } 
        }
}
/*** This function reads the Url string and gets any requested parameter values in the URL ***/
function urlParams( name ) {
       name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
       var regexS = "[\\?&]"+name+"=([^&#]*)";
       var regex = new RegExp( regexS );
       var results = regex.exec( window.location.href );
       if( results == null )
          return "";
        else
          return results[1];
}

/*** checks for Valid Channel ID's***/
function isValid(sName){
  if(sName=="300x600browse") return true;
  if(sName=="468x60browse") return true;
  if(sName=="adblade") return true;
  if(sName=="adon") return true;
  if(sName=="dell") return true;
  if(sName=="exciteexplore") return true;
  if(sName=="fbook") return true;
  if(sName=="findquick") return true;
  if(sName=="gadbanners") return true;
  if(sName=="gadwords") return true;
  if(sName=="gradlinks") return true;
  if(sName=="miva") return true;
  if(sName=="miva1") return true;
  if(sName=="mktgask") return true;
  if(sName=="mktglsmart") return true;
  if(sName=="mktgmiva3") return true;
  if(sName=="mktgmiva4") return true;
  if(sName=="mktgpulse") return true;
  if(sName=="mktgsfeed") return true;
  if(sName=="mktgyahoo") return true;
  if(sName=="msnad") return true;
  if(sName=="mstoolbar1") return true;
  if(sName=="myweb1") return true;
  if(sName=="myweb2") return true;
  if(sName=="nonus") return true;
  if(sName=="opensearch") return true;
  if(sName=="su") return true;
  if(sName=="toolbar") return true;
  if(sName=="vclick") return true;
  if(sName=="ysearch") return true;
}
var fSource = urlParams('fcsource').toLowerCase();
  if(fSource!=null && fSource.length>0 && isValid(fSource)){

  if (!get_cookie ("fcsource") ) {
     set_cookie ( "fcsource", fSource,'','/','',''); 
     google_channel_override = get_cookie("fcsource");
  } else {
     checkCookie(fSource);
     google_channel_override = get_cookie("fcsource");
    }
  } else {
       if(get_cookie("fcsource")!=null) {
          google_channel_override = get_cookie("fcsource");
       }
   }
/*** Additional Google Setup for AdServer ***/
GS_googleAddAdSenseService('ca-pub-2731187216061657');
GS_googleEnableAllServices();
/*
* This function is required and is used to display the ads that are returned from the JavaScript
* request. You should modify the document.write commands so that the HTML they write out fits
* with your desired ad layout.
*/
function google_ad_request_done(google_ads) {
  var s = '';
  var i;
  /* optional clickable backgrounds. If this is set, the second and third lines of text ads are
  * linked to the advertiser's URL. This increases click-through but decreases click-through accuracy.
  */
  var clickable_background = 0;
  /*
  *Attribution for Google ads
  */
  var google_attribution = 'Sponsored Links';
  var title_span = '<span class="google_title_span">';
  var description_span = '<span class="google_description_span">';
  var url_style = 'class="google_url_style">';
  /*
  * Verify that there are actually ads to display.
  */
  if (google_ads.length == 0)
  return;

  /*
  * If an image or Flash ad is returned, display that ad. If a rich media ad is returned, display that as "as is."
  * Otherwise, build a string containing all of the ads and then use a document.write() command to print that string.
  */

  if (google_ads[0].type == "image") {
    s += '<a target="_blank" style="cursor: pointer; cursor: hand" href="'
    + google_ads[0].url + '" '
    + 'onclick="return fc_click(\'google_image\',\'ad\');" '
    + 'onmouseout="window.status=\'\'" '
    + 'onmouseover="window.status=\'go to '
    + google_ads[0].visible_url + '\';return true;'
    + '"> <img border="0" src="' + google_ads[0].image_url
    + '"width="' + google_ads[0].image_width
    + '"height="' + google_ads[0].image_height
    + '"></a>';
  } else if (google_ads[0].type == "flash") {
    s += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
    'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"'+
    ' WIDTH="' + google_ad.image_width +
    '" HEIGHT="' + google_ad.image_height + '">' +
    '<PARAM NAME="movie" VALUE="' + google_ad.image_url + '">' +
    '<PARAM NAME="quality" VALUE="high">' +
    '<PARAM NAME="AllowScriptAccess" VALUE="never">' +
    '<EMBED src="' + google_ad.image_url +
    '" WIDTH="' + google_ad.image_width +
    '" HEIGHT="' + google_ad.image_height +
    '" TYPE="application/x-shockwave-flash"' +
    ' AllowScriptAccess="never" ' +
    ' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
  } else if (google_ads[0].type == "html") {
    s += google_ads[0].snippet;
  }
  /*attributes ad to Google*/
  if (google_ads[0].type == "image"){
  } else if (google_ads[0].type == "text") {
    s += '<div class="clearer"></div><div class="google_attribution">'+
    google_attribution +'</div><ul>';
    /*
    * Larger text for single ad.
    */
    if (google_ads.length == 1) {
      title_span = '<span style="text-decoration:none;font-size:20pt">';
      description_span = '<span style="color:#000000;font-size:16pt">';
      //url_style =' style="color:#008000;font-size:14pt;text-decoration:none">' ;
      url_style =' style="font-size:14pt;text-decoration:none">' ;
    }
    /*
    * For text ads, append each ad to the string.
    */
    for(i=0; i < google_ads.length; ++i) {
      s += '<li><a target="_blank" href="' + google_ads[i].url + '" ' +
      'onclick="return fc_click(\'google_' + site_google_adsize + '\',\'ad\');"' +
      'onmouseout="window.status=\'\'" ' +
      'onmouseover="window.status=\'go to ' +
      google_ads[i].visible_url + '\';return true;" ' +
      'style="text-decoration:none" >' +
      title_span +
      google_ads[i].line1 + '</span> ';
      if (clickable_background == 0){
        s += '</a><br/>';
      }
      s += '<a target="_blank" href="' + google_ads[i].url + '" ' +
      'onclick="return fc_click(\'google_' + site_google_adsize + '\',\'ad\');"' +
      'onmouseout="window.status=\'\'" ' +
      'onmouseover="window.status=\'go to ' +
      google_ads[i].visible_url + '\';return true;" ' +
      'style="text-decoration:none">' +
      description_span +
      google_ads[i].line2 + ' ' +
      google_ads[i].line3 + '<br/></span>';
      if (clickable_background == 1){
        s += '</a>';
      }
      s += '<a target="_blank" href="' + google_ads[i].url + '" ' +
      'onclick="return fc_click(\'google_' + site_google_adsize + '\',\'ad\');"' +
      'onmouseout="window.status=\'\'" ' +
      'onmouseover="window.status=\'go to ' +
      google_ads[i].visible_url + '\';return true;" ' +
      url_style +
      google_ads[i].visible_url + '</span></a></li>';
    }
  s+= '</ul>';
  }
  document.write(s);
  return;
}
function google_radlink_request_done(radlinks) {
  /*
  * This function is required and is used to display
  * the ads that are returned from the JavaScript
  * request. You should modify the document.write
  * commands so that the HTML they write out fits
  * with your desired Link Unit layout.
  */
  if (radlinks.length < 1)
     return;
  document.write("<div class=\"link_list\">\n<ul>\n");
  for(i=0; i < radlinks.length; ++i) {
     document.write("<li><a target=\"_top\" onclick=\"return fc_click('google_radlink','ad');\" href=\"/site-pages/related-search/related-link-results.shtml?google_kw=" + radlinks[i].url_escaped_term + "&google_rt=" + radlinks[i].radlink_token + "&google_page_url=" + window.location + "\">" + radlinks[i].term + "</a></li> \n");
  }
  document.write("</ul>\n</div>");
}
//ORIGINAL: http://shared.5min.com/scripts/ThumbSeed.js
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();
          }
        }, 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.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;
      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, "");
      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,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;