


var isIE6 = /MSIE ((5\.5)|[6])/.test(navigator.userAgent) && navigator.platform == "Win32";
var isIE = /MSIE \d+/.test(navigator.userAgent) && navigator.platform == "Win32";
var realSrc;
var blankSrc = "http://assetscdn.vodpod.com/images/blank.gif";
if (typeof(vp_videos) == 'undefined')
  var vp_videos = {};
var page6275969659 = 1;
var origOpacity = null;
var hosted_url = null;
var custom_url = null;

var widget6275969659 = document.getElementById('vodpod_recent_videos');
var vp_widget_id = 'vodpod_recent_videos';


widget6275969659.innerHTML = '';
// Hide the widget, until it has been created
widget6275969659.style.display = 'none';
widget6275969659.className = "vodpod_videos_widget";

if (typeof(String.prototype.trim) == 'undefined') {
  String.prototype.trim = function() {
  	return this.replace(/^\s+|\s+$/g,"");
  }
}

// Load style
var cssNode = null;


  // Kill any existing vodpod css
  cssNode = document.getElementById('vodpod_widget_css');
  
  if (cssNode) {
    cssNode.parentNode.removeChild(cssNode);
  }
  
  cssText = ".vodpod_videos_widget { position:relative !important; font-size:11px !important; font-family:arial,verdana,sans-serif !important; margin:0px !important; padding:0px !important; } .vodpod_videos_widget * { padding-top:0px !important; padding-right:0px !important; padding-bottom:0px !important; padding-left:0px !important; margin-top:0px !important; margin-right:0px !important; margin-bottom:0px !important; margin-left:0px !important; background:none !important; border:none !important; text-align:left !important; text-decoration:none !important; } .vodpod_videos_widget .vodpod_footer a div { width:auto !important; color:#fff !important; }.vodpod_videos_widget { width:165px !important; color:#666 !important; position:relative !important; border:2px solid #777 !important; font-family:arial,verdana,sans-serif !important; margin:0px !important; padding:0px !important; } .vodpod_videos_widget * { font-size:11px !important; } .vodpod_videos_widget a { color:#666 !important; text-decoration:none !important; } .vodpod_videos_widget a:hover { text-decoration:underline !important; } .vodpod_videos_widget .vodpod_header { display:block !important; height:24px !important; line-height:22px !important; overflow:hidden !important; color:#fff !important; background:#777 !important; width:100% !important; } .vodpod_videos_widget .vodpod_header img { vertical-align:middle !important; margin-left:2px !important; } .vodpod_videos_widget .vodpod_header a { color:#fff !important; } .vodpod_videos_widget .vodpod_video { position:relative !important; width:157px !important; height:75px !important; padding:4px !important; margin:0px !important; border-bottom:1px solid #ccc !important; background:#fff !important; } .vodpod_videos_widget .vodpod_video .vodpod_video_thumbnail { display:block !important; width:100px !important; height:75px !important; } .vodpod_videos_widget .vodpod_video .vodpod_video_thumbnail img { width:100px !important; height:75px !important; border:none !important; } .vodpod_videos_widget .vodpod_video .vodpod_video_thumbnail img:hover { border-color:#00adef !important; } .vodpod_videos_widget .vodpod_video .vodpod_video_placeholder1 { position:absolute !important; background:#666 !important; width:98px !important; padding-left:2px !important; opacity:0.5 !important; filter:alpha(opacity=50) !important; -moz-opacity:0.50 !important; height:24px !important; top:55px !important; } .vodpod_videos_widget .vodpod_video .vodpod_video_play_image { display:none !important; } .vodpod_videos_widget .vodpod_video .vodpod_video_title { position:absolute !important; display:block !important; top:56px !important; left:5px !important; font-weight:bold !important; height:22px !important; width:100px !important; line-height:11px !important; overflow:hidden !important; text-align:left !important; color:#fff !important; } .vodpod_videos_widget .vodpod_video .vodpod_video_views { display:block !important; position:absolute !important; width:50px !important; line-height:12px !important; right:3px !important; top:5px !important; text-align:right !important; } .vodpod_videos_widget .vodpod_video .vodpod_video_views .vodpod_video_views_num { font-weight:bold !important; font-size:1.1em !important; } .vodpod_videos_widget .vodpod_video .vodpod_video_views .vodpod_video_views_label { font-size:0.9em !important; } .vodpod_videos_widget .vodpod_video .vodpod_video_created_at { line-height:12px !important; display:block !important; position:absolute !important; width:55px !important; line-height:12px !important; right:3px !important; top:68px !important; text-align:right !important; font-size:11px !important; } .vodpod_videos_widget .vodpod_video .vodpod_video_clear { } .vodpod_videos_widget .vodpod_video_container .vodpod_video_container_clear { } .vodpod_videos_widget .vodpod_footer_separator { height:1px !important; line-height:1px !important; } .vodpod_videos_widget .vodpod_footer { background:#777 !important; text-align:right !important; padding:3px !important; height:30px !important; width:160px !important; } .vodpod_videos_widget .vodpod_footer a { color:#fff !important; line-height:14px !important; } .vodpod_videos_widget .vodpod_footer .vodpod_see_all { } .vodpod_videos_widget .vodpod_powered_by { float:right !important; margin-top:2px !important; } .vodpod_videos_widget .vodpod_footer .vodpod_footer_clear { } #vodpod_player_container { margin:0px !important; padding:0px !important; font-size:11px !important; font-family:arial,verdana,sans-serif; } #vodpod_player_container * { margin:0px !important; padding:0px !important; border:none !important; text-align:left !important; } .vodpod_videos_widget #vodpod_paging { display:none !important; }";
  
  if (/MSIE (6|7|8)/.test(navigator.userAgent)) {
    var styleSheetObj = document.createStyleSheet();

    var styleObj = styleSheetObj.owningElement || styleSheetObj.ownerNode;
    styleObj.setAttribute("type", "text/css");
    styleObj.id = 'vodpod_widget_css';
    
    ruleArray = cssText.split("}");

    for (var i = 0; i < ruleArray.length - 1; i++) {
      var currentRule = ruleArray[i].trim();
      var nameValueArray = currentRule.split("{");
      var name = nameValueArray[0].trim();
      var value = nameValueArray[1].trim();
      
      if (value != "") {
        styleSheetObj.addRule(name,value);
      }
    }
  } else {
    cssNode = document.createElement('style');
    cssNode.type = 'text/css';
    cssNode.id = 'vodpod_widget_css';
    cssNode.appendChild(document.createTextNode(cssText));
    document.getElementsByTagName("head")[0].appendChild(cssNode);
  }

vp_createWidget6275969659();

function vpAddTracking(pod_id, gv_id) {
  var img = document.createElement('img');
  img.src = 'http://stats.vodpod.com/stats/external_view/' + gv_id + '/' + pod_id + '/' + Math.floor(Math.random() * 10000) + '/pod.gif';
  img.style.position = 'absolute';
  img.style.right = '0';
  img.style.bottom = '0';
  document.body.appendChild(img);
}

var vp_EmbedSwapper = {
  find_top: function(obj) {
  	var curtop = 0;
  	if (obj.offsetParent) {
  	  do {
  			curtop += obj.offsetTop;
  		} while (obj = obj.offsetParent);
		}
		return curtop;
	},
  replace_embed: function(embd) {
    var rplc;
    if(isIE) {
      var html = embd.outerHTML;
      
      if (html.match(/wmode\s*=\s*('|")opaque('|")/i) || html.match(/wmode\s*=\s*('|")transparent('|")/i)) {
        return;
      }
      
      if(html.match(/wmode\s*=\s*('|")[a-zA-Z]+('|")/i)) {
        rplc = html.replace(/wmode\s*=\s*('|")window('|")/i,"wmode='opaque'");
      } else {
        rplc = html.replace(/<embed\s/i,"<embed wmode='opaque' ");
      }
      
      embd.insertAdjacentHTML('beforeBegin',rplc);
      embd.parentNode.removeChild(embd);
    } else {
      rplc = embd.cloneNode(true);
      if(!rplc.getAttribute('wmode') || rplc.getAttribute('wmode').toLowerCase() == 'window') {
        rplc.setAttribute('wmode','opaque');
        embd.parentNode.replaceChild(rplc,embd);
      }
    }
  },
  replace_object: function(object) {
    if(isIE) {
      var html = object.outerHTML;

      if (object.innerHTML == "") {
        var innerHTML = "";
        for (var i = 0; i < object.childNodes.length; i++) {
	        var node = object.childNodes[i];

      	  if (node.name.toLowerCase() == 'wmode' && node.value.toLowerCase() == 'opaque')
      	    return;

	        if (node.name.toLowerCase() != 'wmode')
	          innerHTML += node.outerHTML;
        }

        html = html.replace(/<\/object>/i, innerHTML + "</object>");
      }

      html = html.replace(/<(.*?)param(.*?)wmode(.*?)>/i, '');
      html = html.replace(/<\/object>/i, "<param name=\"wmode\" value=\"opaque\"></object>");

      object.insertAdjacentHTML('beforeBegin', html);
      object.parentNode.removeChild(object);
    } else {
      var html = object.innerHTML;

      if (html.match(/wmode\s*=\s*('|")[a-zA-Z]+('|")/i)) {
        html = html.replace(/wmode\s*=\s*('|")window('|")/i,"wmode='opaque'");
      } else {
        html = "<param name=\"wmode\" value=\"opaque\">" + html;
      }

      rplc = object.cloneNode(true);
      rplc.innerHTML = html;
      object.parentNode.replaceChild(rplc,object);
    }
  },
  run: function(top, bottom) {
    if (navigator.platform != "Win32") return;

    var replaceEmbeds = function(embds, is_object) {
      for(i = 0; i < embds.length; i++)  {
        embd = embds[i];

        embd_top = vp_EmbedSwapper.find_top(embd);
        embd_bottom = embd_top + (embd.offsetHeight ? embd.offsetHeight : embd.height);

        if ((embd_top > top && embd_top < bottom) || (embd_bottom > top && embd_bottom < bottom) || embd_top == 0) {
          if (is_object)
            vp_EmbedSwapper.replace_object(embd);
          else
            vp_EmbedSwapper.replace_embed(embd);
        }
      }
    }

    replaceEmbeds(document.getElementsByTagName('object'), true);
    replaceEmbeds(document.getElementsByTagName('embed'), false);
  }
}

function vp_createWidget6275969659() {
  
  widget_header = '    <div class=\"vodpod_placeholder_top\"><\/div>\n    <div class=\"vodpod_header\" title=\"Classy Videos\">\n    <img src=\"http://assetscdn.vodpod.com/images/widget/logo_14px.png\" class=\"vodpod_header_logo vodpod_png\" style=\"width:14px;height:14px;\" />\n    <a href=\"http://classycomedy.vodpod.com\" target=\"_new\">Classy Videos<\/a><\/div>\n';
  
  widget6275969659.innerHTML += widget_header;
  
  
  video_html = '<div class="vodpod_video_container" id="vodpod_video_container_vodpod_recent_videos_266522">';
  
  widget6275969659.innerHTML += video_html;
    
  footer_html = '<div class="vodpod_footer_separator">&nbsp;</div>\
  <div class="vodpod_footer">\
    <a href="http://classycomedy.vodpod.com" target="_new" class="vodpod_see_all" style="">see all 3 videos &gt;</a>';

  footer_html += '';
  
  
    footer_html += '<a href="http://vodpod.com/widgets?r=widget" target="_new" class="vodpod_powered_by"> \
    <div style="float:left">I collect with</div>\
    <img src="http://assetscdn.vodpod.com/images/widget/logo_10px.png" class="vodpod_png" style="float:left;width:10px;height:10px;display:inline;margin-top:2px !important;margin-left:2px !important;margin-right:2px !important;border:none;"/>\
    <div style="float:left;display:inline;">vodpod</div>\
    </a>'
  
  
  footer_html += '<div id="vodpod_footer_clear"></div></div>';

  widget6275969659.innerHTML += footer_html

  
    
    paging_html = '<div id="vodpod_paging" style="display:none;">';
    paging_html += '<div id="vodpod_paging_prev" class="inactive" onclick="vp_loadNextSet6275969659(-1);return false;"><a href="#">Previous 5</a></div>';
    paging_html += '<div id="vodpod_paging_next" class="active" onclick="vp_loadNextSet6275969659(1);return false;"><a href="#">Next 5</a></div>';
    paging_html += '</div><div id="vodpod_paging_clear"></div>'
    widget6275969659.innerHTML += paging_html;
       

  // Load the videos
  vp_loadJsonVideos6275969659({"videos":{"items":[{"video":{"thumbnails":{"large":"http://img.vpimg.net/777180.large.jpg","assigned":false,"small":"http://img.vpimg.net/777180.jpg","medium":"http://img.vpimg.net/777180.medium160.jpg"},"video_id":1263864,"created_at":"Mon, 02 Jun 2008 13:56:59 -0500","embed_tag":"<embed src=\"http://www.youtube.com/v/-OChOQNq0Q8&autoplay=&fs=1&showinfo=0&showsearch=0&rel=0&autoplay=&border=0&rel=0\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" width=\"100%\" height=\"100%\" id=\"myytplayer\"></embed>","original_url":"","description":"Classy (www.classycomedy.com) has put together this film in the hopes that you will come see their new sketch comedy show at 11pm on June 14th, 21st, or 28th at The Peoples Improv Theater in New York City.\r\nClassy is Aaron Kheifets, James Rich, Sam Forman and Dave Warth.  They're directed by Kevin Scott and Kevin Allison from MTV's The State.  Kevin Gottlieb filmed this.  He's awesome.\r\nMany awesome Kevins are involved.\r\nSo, please check them out.\r\nThe music is by Regina Spektor.  You should probably check ","link":"http://vodpod.com/watch/777180-a-promotional-film-from-classy","autoplay_embed_tag":"<embed src=\"http://www.youtube.com/v/-OChOQNq0Q8&autoplay=1&fs=1&showinfo=0&showsearch=0&rel=0&autoplay=&border=0&rel=0\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" width=\"100%\" height=\"100%\" id=\"myytplayer\"></embed>","pod_id":266522,"stats":{"total_widget_views":52,"total_views":65,"weekly_pod_views":1,"weekly_widget_views":0,"weekly_views":1,"total_pod_views":13},"uid":"de6577164908f7b72105938b2a0c3ddfd0fe9ffc","updated_at":"Mon, 02 Jun 2008 13:56:59 -0500","vodpod_id":777180,"user":{"link":"/classycomedy","username":"classycomedy","_value":"ClassyComedy","user_id":258695},"num_collectors":1,"embed_host":"youtube.com","title":"A Promotional Film From Classy"}},{"video":{"thumbnails":{"large":"http://img.vpimg.net/777210.large.jpg","assigned":false,"small":"http://img.vpimg.net/777210.jpg","medium":"http://img.vpimg.net/777210.medium160.jpg"},"video_id":1263881,"created_at":"Mon, 02 Jun 2008 14:00:05 -0500","embed_tag":"<embed src=\"http://www.youtube.com/v/iza-2yG26Tk&autoplay=&fs=1&showinfo=0&showsearch=0&rel=0&autoplay=&border=0&rel=0\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" width=\"100%\" height=\"100%\" id=\"myytplayer\"></embed>","original_url":"","description":"If you're going to hold certain views, it's in for a penny, in for a pound.\r\n\r\nYou've got to hand it to him for consistency (though not for anything else)\r\n\r\nwith Livia Scott!\r\n\r\na Classy sketch ( http://www.ClassyComedy.com )","link":"http://vodpod.com/watch/777210-a-man-of-principle","autoplay_embed_tag":"<embed src=\"http://www.youtube.com/v/iza-2yG26Tk&autoplay=1&fs=1&showinfo=0&showsearch=0&rel=0&autoplay=&border=0&rel=0\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" width=\"100%\" height=\"100%\" id=\"myytplayer\"></embed>","pod_id":266522,"stats":{"total_widget_views":54,"total_views":62,"weekly_pod_views":0,"weekly_widget_views":1,"weekly_views":1,"total_pod_views":8},"uid":"88e261979895ce61159b38e80a750572e7f42514","updated_at":"Mon, 02 Jun 2008 14:00:05 -0500","vodpod_id":777210,"user":{"link":"/classycomedy","username":"classycomedy","_value":"ClassyComedy","user_id":258695},"num_collectors":1,"embed_host":"youtube.com","title":"A Man of Principle","orig_description":"If you're going to hold certain views, it's in for a penny, in for a pound.\r\n\r\nYou've got to hand it to him for consistency (though not for anything else)\r\n\r\nwith Livia Scott!\r\n\r\na Classy sketch ( http://www.ClassyComedy.com ) "}},{"video":{"thumbnails":{"large":"http://img.vpimg.net/592476.large.jpg","assigned":false,"small":"http://img.vpimg.net/592476.jpg","medium":"http://img.vpimg.net/592476.medium160.jpg"},"video_id":1263892,"created_at":"Mon, 02 Jun 2008 14:05:06 -0500","embed_tag":"<embed src=\"http://www.youtube.com/v/LNNeEAmI2Nw&autoplay=&fs=1&showinfo=0&showsearch=0&rel=0&hl=en\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" width=\"100%\" height=\"100%\" id=\"myytplayer\"></embed>","original_url":"http://www.youtube.com/v/LNNeEAmI2Nw&hl=en","description":"One can only guess what happened to make Barry so concerned with this topic.\r\n\r\na Classy sketch ( http://www.ClassyComedy.com )","link":"http://vodpod.com/watch/592476-welcome-to-communotech","autoplay_embed_tag":"<embed src=\"http://www.youtube.com/v/LNNeEAmI2Nw&autoplay=1&fs=1&showinfo=0&showsearch=0&rel=0&hl=en\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" width=\"100%\" height=\"100%\" id=\"myytplayer\"></embed>","pod_id":266522,"stats":{"total_widget_views":46,"total_views":53,"weekly_pod_views":0,"weekly_widget_views":1,"weekly_views":1,"total_pod_views":7},"uid":"4005dec193c0a19a292878818292790d4fd97c98","updated_at":"Mon, 02 Jun 2008 14:05:06 -0500","vodpod_id":592476,"user":{"link":"/classycomedy","username":"classycomedy","_value":"ClassyComedy","user_id":258695},"num_collectors":1,"embed_host":"youtube.com","title":"Welcome to Communotech"}}],"total":3}});
  
  widget6275969659.innerHTML += '<div class="vodpod_placeholder_bottom"></div>';
  widget6275969659.innerHTML += '<img src="http://stats.vodpod.com/stats/widget/266522/blank.gif?' + parseInt(Math.random()*9999999) +
    '&page=' + encodeURIComponent(document.location) +
    '" style="width:0px;height:0px;padding:0px;margin:0px;"/>';
  
  // Set custom widget color
  widget_header = ''
  
      els = vp_getElementsByClassName(widget6275969659.parentNode, 'vodpod_footer');
      for (i = 0; i<els.length; i++)
      {
        els[i].style.background = '#606060';
      }
  
      els = vp_getElementsByClassName(widget6275969659.parentNode, 'vodpod_header');
      for (i = 0; i<els.length; i++)
      {
        els[i].style.background = '#606060';
      }
  
      els = vp_getElementsByClassName(widget6275969659.parentNode, 'vodpod_videos_widget');
      for (i = 0; i<els.length; i++)
      {
        els[i].style.border = '2px solid #606060';
      }
  
      els = vp_getElementsByClassName(widget6275969659.parentNode, 'vodpod_video_placeholder1');
      for (i = 0; i<els.length; i++)
      {
        els[i].style.background = '#606060';
      }
  
  
  widget6275969659.style.display = 'block';
}

function createInfoBox6275969659() {
  var img = document.createElement('img');
  img.id = 'popup_image_6275969659';
  img.style.position = 'absolute';
  img.style.bottom = '10px';
  img.style.left = '7px';
  img.style.zIndex = '1000';
  
  var container = document.createElement('div');
  container.id = 'popup_container_6275969659';
  container.className = 'vodpod_popup_container';
  container.style.position = 'absolute';
  container.style.bottom = '20px';
  container.style.left = '20px';
  container.style.width = '136px';
  container.style.height = '230px'; //250
  container.style.zIndex = '1001';
  
  var html = "<p>This widget powered by <a href='http://vodpod.com'>Vodpod.com</a>.</p>";
  html += "<div style=\"text-align:center !important\"><a href=\"#\" onclick=\"vp_getCode(); return false\"><img src=\"http://assetscdn.vodpod.com/images/widget/get_this_code.gif\" /></div>";
  html += "<br /><br /><p><a href='http://vodpod.com/site/register?r=widgetinfo'>Sign up</a> to Build your own video collection and put a ";
  html += "Vodpod on your blog, website, Facebook, Myspace.</p>";

  html += "<div style='text-align:center !important;position:absolute;bottom:10px;left:0;width:100%;'>";
  html +=   "<img src='http://assetscdn.vodpod.com/images/widget/close_button_white.png' style='cursor:pointer' onclick='closeInfoBox6275969659()'>";
  html += "</div>"
  
  container.innerHTML = html;
  
  var header = document.createElement('div');
  header.id = 'popup_header_6275969659';
  header.style.position = 'absolute';
  header.style.bottom = '265px';
  header.style.left = '48px';
  header.style.width = '110px';
  header.style.height = '23px';
  header.style.lineHeight = '23px';
  header.style.fontSize = '12px';
  header.style.zIndex = '1001';
  
  header.innerHTML = "Widget Info"

  img.onload = function() {
    document.getElementById(vp_widget_id).appendChild(header);
    document.getElementById(vp_widget_id).appendChild(container);
  }
  img.src = "http://assetscdn.vodpod.com/images/widget/info_popup.png";

  
  document.getElementById(vp_widget_id).appendChild(img);
  
  // We actually only need Prototype for viewport dimension functions for the code lightbox. We could copy those inline.
  var proto_scr = document.createElement("script");
  proto_scr.src = 'http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js';
  document.body.appendChild(proto_scr);
}

function closeInfoBox6275969659() {
  var image = document.getElementById('popup_image_6275969659');
  var container = document.getElementById('popup_container_6275969659');
  var header = document.getElementById('popup_header_6275969659');
  
  image.parentNode.removeChild(image);
  container.parentNode.removeChild(container);
  header.parentNode.removeChild(header);
}

// function vp_createVideo(id, embed, title, descrp, thumbnail, views, date, hostname, url, num_collectors) {
  // html = vp_createVideo(video.video_id, video.autoplay_embed_tag, video.title, video.description, thumbnail, video.stats.total_views, video.created_at, video.embed_host, video.original_url, video.num_collectors);
  
function vp_createVideo(video) {
  vp_videos[video.video_id] = video;
  date_match = video.created_at.match(/(\d{1,2} \w{3,4}) \d*?(\d{2})\b/);
  video.date = date_match[1] + " " + date_match[2];
  var views_label = video.stats.total_views == '0' ? '' :  '<span class="vodpod_video_views_num">' + video.stats.total_views + '</span> <span class="vodpod_video_views_label">views</span>';
  // vp_videos[id]['num_collectors'] = num_collectors;
  video.thumbnail = video.thumbnails.medium;
  video.thumbnail_html = '<div class="vodpod_video" id="vodpod_video_' + video.video_id + '" onmouseover="vp_videoMouseOver(this);" onmouseout="vp_videoMouseOut(this);" onclick="vp_loadVideo(' + video.video_id + ', ' + video.vodpod_id + ');return false;">\
    <a href="#" class="vodpod_video_thumbnail">\
      <img src="' + video.thumbnail + '" title="' + video.description.replace(/"/g,'') + '" />\
    </a>\
    <div class="vodpod_video_placeholder1"></div>\
    <img src="http://assetscdn.vodpod.com/images/widget/play_icon.png" class="vodpod_video_play_image vodpod_png" style="display:none;"/>\
    <img src="http://assetscdn.vodpod.com/images/black_trans_1px.png" class="vodpod_video_title_shading vodpod_png" style="display:none;"/>\
    <a href="#" class="vodpod_video_title" title="' + video.title.replace(/"/g,'') + '">\
      ' + video.title + ' \
    </a>\
    <div class="vodpod_video_views">' + views_label + '</div>\
    <div class="vodpod_video_created_at">' + video.date + '</div>\
    <div class="vodpod_video_placeholder2"></div>\
    <div class="vodpod_video_index" style="display:none;">' + (video.index < 10 ? '0' : '') + video.index + '</div>\
    <div id="vodpod_video_clear">\
    </div>\
  </div>';

  return video.thumbnail_html;
}

function vp_loadNextSet6275969659(direction) {
  page6275969659 += direction;
  url = 'http://api.vodpod.com/api/pod/videos.js?pod_id=266522&api_key=js_widget&callback=vp_loadJsonVideos6275969659&per_page=5&page=' + page6275969659 + '&category_id=';

  var json_script = document.createElement('script');
  json_script.src = url;
  document.body.appendChild(json_script);
}

function vp_loadJsonVideos6275969659(json) {
  video_container = vp_getElementsByClassName(widget6275969659, 'vodpod_video_container')[0]; //document.getElementById('vodpod_video_container_classycomedy');
  video_container.innerHTML = '';
  per_page = 5;
  var next_node = document.getElementById('vodpod_paging_next');
  var prev_node = document.getElementById('vodpod_paging_prev');
  
  if (next_node != null) {
    if (json.videos.total > page6275969659*per_page) {
      next_node.className = 'active';
    } else {
      next_node.className = 'inactive';
    }
  }
  
  if (prev_node != null) {
    if (page6275969659 > 1) {
      prev_node.className = 'active';
    } else {
      prev_node.className = 'inactive';
    }
  }
  
  if (json.videos.items) {
    for(var i = 0; i < json.videos.items.length; i++) {
      var video = json.videos.items[i].video;
      video.index = i + 1 + (page6275969659 - 1) * per_page;
      html = vp_createVideo(video);
      
      video_container.innerHTML += html;
    }
  }
  
  vp_fixIePngs(widget6275969659);
}

function vp_loadVideo1(id) {
  // Clear the previous embed holder
  vp_closeVideo();

  var vid_html = vp_videos[id].autoplay_embed_tag
  var descrp = vp_videos[id].description;
  var date = vp_videos[id].date;
  var vodpod_video = document.getElementById('vodpod_video_' + id);
  var video_div = document.createElement('div');
  video_div.id = "vodpod_player_container";
  video_div.style.position = 'absolute';
  video_div.style.border = 'none';
  video_div.style.width = '402px';
  video_div.style.zIndex = '10000';
  var top = vp_offsetTop(vodpod_video);
  video_div.style.top = top + 'px';

  var els = vp_getElementsByClassName(widget6275969659, 'vodpod_video_placeholder1')
  for (i=0; i < els.length; i++) {
    els[i].style.opacity = 1;
  }
  
  //video_div.style.left = vp_offsetLeft(vodpod_video) + 'px';
  video_div.innerHTML = '<div style="background:url(http://assetscdn.vodpod.com/images/widget/player_top_402px.gif) no-repeat !important;height:3px;padding:0px !important;margin:0px !important;overflow:hidden;"></div>\
  <div style="cursor:move !important;height:28px;color:#fff;overflow:hidden;background:#606060 !important;width:402px;">\
      <img src="http://assetscdn.vodpod.com/images/widget/logo_16px.png" class="vodpod_png" style="float:left;margin-top:6px !important;margin-left:6px !important;margin-right:6px !important;"/>\
      <div style="float:left;width:260px;height:18px;overflow:hidden;padding-top:6px !important;margin:0px;font-size:13px;text-align:left;">\
        <a href="http://vodpod.com/pod/video/' + id + '" style="color:#fff;" title="View this video at Vodpod">' + vp_videos[id].title + '</a>\
      </div>\
      <a href="#" id="vp_close_img" onclick="vp_closeVideo();return false;" style="display:block;float:right;color:#fff;margin-top:6px !important;margin-left:0px !important;margin-right:4px !important;padding:0px !important;border:none !important">\
        <img src="http://assetscdn.vodpod.com/images/widget/close_large.png" style="border:none !important;margin:0px !important;padding:0px !important;"/>\
      </a>\
      <a href="#" title="Popout video to a new window (video will start over)" onclick="vp_popoutVideo(' + id + ');return false;" style="display:block;float:right;color:#fff;margin-top:6px !important;margin-left:2px !important;margin-right:2px !important;padding:0px !important;border:none !important">\
        <img src="http://assetscdn.vodpod.com/images/widget/popout_large2.gif"  style="border:none !important;margin:0px !important;padding:0px !important;"/>\
      </a>\
      <div style="clear:both;"></div>\
    </div>';
  
  // Determine if widget is on right or left side of the page
  var widget_left = vp_offsetLeft(widget6275969659);
  var widget_width = widget6275969659.offsetWidth;
  var widget_right = widget_left + widget_width;
  var video_thumb_left = vp_offsetLeft(vodpod_video);
  
  // If widget is horizontally positioned (width > 400)
  // then display the videos from left to right
  if (widget_width > 400)
  {
    // Don't let video extend beyond widget
    if ((video_thumb_left + 400) > widget_right)
    {
      video_left = widget_right - 400;
    } else {
      video_left = video_thumb_left;
    }
  }
  else 
  {
    // Otherwise, if the widget is vertical, figure out what side of the page it's on,
    // and display the videos accordingly
    if (widget_left < document.body.clientWidth/2)
    {
      // left
      video_left = widget_left + widget6275969659.offsetWidth;
    } else {
      // right
      video_left = widget_left - 400 - 2;
    }
    
  }
  
  video_div.style.left = video_left + "px";
 
  var vid_html = '<div class="ed_holder" style="background:#606060 !important;position:relative !important;width:400px;height:320px;border-style:solid !important;border-width:0px 1px !important;border-color:#606060 !important;">' + vid_html + '</div>\
    <div style="width:384px;background:#f1f1f1 !important;overflow:hidden;border-style:solid !important;border-width:0px 1px !important;border-color:#606060 !important;padding:8px !important;margin:0px !important;">\
      <div class="vodpod_description" style="color:#666;padding-top:5px !important;padding-bottom:5px !important;max-height:36px;overflow:hidden;line-height:18px;">' + descrp + '</div>\
      <div style="color:#aaa;text-transform:uppercase;font-size:9px;font-weight:bold;height:14px;overflow:hidden;padding-top:5px !important">\
        <div style="float:left;text-align:left;width:255px;overflow:hidden;white-space:nowrap;">' + 
          vp_videos[id].stats.total_views + ' views\
          &nbsp;&nbsp;&nbsp;Video from <a href="' + vp_videos[id].original_url + '" target="_new" style="color:#aaa;">' + vp_videos[id].embed_host + '</a>\
        </div>\
        <div style=\"float:right;\">\
          Added ' + date + '\
        </div>\
        <div style="clear:both"></div>\
      </div style="text-align:left;">';
  
  if (vp_videos[id].num_collectors > 1) {
    vid_html += '<a href="http://vodpod.com/pod/video/' + id + '" style="font-size:11px;font-weight:bold;color:#00adef" target="_new">Collected by ' + vp_videos[id].num_collectors + ' people</a>';
  }
  
  vid_html += '</div>\
    <div style="width:402px;background:#606060 !important;">\
      <a href="http://vodpod.com/widgets?r=widget" target="_new" style="float:right;color:#fff;margin-right:8px !important;line-height:16px !important;text-decoration:none;">\
        <div style="float:left">I collect with</div>\
        <img src="http://assetscdn.vodpod.com/images/widget/logo_10px.png" class="vodpod_png" style="float:left; width:10px; height:10px; display:inline; margin-top:3px !important; margin-left:4px !important; margin-right:4px !important;"/>\
        <div style="float:left;display:inline;">vodpod</div>\
      </a>\
      <div style="clear:both;"></div>\
    </div>\
    <div style="background:url(http://assetscdn.vodpod.com/images/widget/player_bottom_402px.gif) no-repeat !important;height:3px;padding:0px !important;margin:0px !important;overflow:hidden;"></div>';
  
  video_div.innerHTML += vid_html;
  
  vp_EmbedSwapper.run(top, top + 447);
  
  document.body.appendChild(video_div);

	vp_DragHandler.attach(video_div, video_div.getElementsByTagName("div")[1]);
	  
  vp_fixIePngs(document.body);
  vpAddTracking(vp_videos[id].pod_id, id);
  
}

function vp_scrollTop() {
  if (document.body.scrollTop) {
    // Some browsers (WebKit) do this the web-standards way.
    return (document.body.scrollTop);
  } else {
    // And some just mimic IE 6 (everyone else).
    return (document.documentElement.scrollTop);
  }
}

function vp_loadVideo2(id) {
  vp_closeVideo();
  
  var container = document.createElement('div');
  var iframe = document.createElement('iframe');
  var close_img = document.createElement('img');
  
  if (Math.random() < 0.5) {
    iframe.src = 'http://widgets.vodpod.com' + '/javascripts/video_popup/' + id;
  } else {
    iframe.src = 'http://widgets.vodpod.com' + '/javascripts/video_popup/' + id + '?ad=user';
  }

  var scrollTop = vp_scrollTop();
  
  var top = Math.max(((document.documentElement.clientHeight / 2) + (scrollTop)), 292);
  
  iframe.style.border = '0';
  iframe.frameBorder = 0;
  iframe.allowTransparency = true;
  iframe.style.width = '100%';
  iframe.style.height = '100%';
  iframe.style.overflow = 'hidden';
  iframe.scrolling = 'no';
  
  container.id = 'vodpod_widget_popup';
  container.style.width = '818px';
  container.style.height = '584px';
  container.style.marginTop = '-292px';
  container.style.marginLeft = '-409px';
  container.style.position = 'absolute';
  container.style.left = '50%';
  container.style.zIndex = '1000';
  container.style.top = top + 'px';
  
  close_img.src = 'http://assetscdn.vodpod.com/images/widget/close_large.png'
  close_img.style.position = 'absolute';
  close_img.style.top = '32px';
  close_img.style.right = '32px';
  close_img.style.border = '0';
  close_img.style.cursor = 'pointer';
  
  vp_EmbedSwapper.run(top - 292, top + 292);
  
  close_img.onclick = function() {
    vp_closeVideo();
  }
  
  // if (/MSIE (6|7)/.test(navigator.userAgent)) {
  //   // We can't attach to the iframe.
  //   setTimeout(function() {
  //     container.appendChild(close_img);
  //   }, 1000);
  // } else  {
  //   iframe.onload = function() {
  //     container.appendChild(close_img);
  //   }
  // }
  
  setTimeout(function() {
    container.appendChild(close_img);
  }, 1000);
  
  container.appendChild(iframe);
  
  document.body.appendChild(container);
}

function vp_loadVideo(id, video_id) {
  if (hosted_url) {
    // this is for legacy ERb vodspots
    document.location = "http://" + hosted_url + "/?id=" + id;
    return false;
  } else if(custom_url) {
    // this is for laminate vodspots
    var url = 'http://' + custom_url.replace('%id%', video_id);
    document.location = url;
    return false;    
  }
  
  if (/Camino/.test(navigator.userAgent))
    vp_loadVideo1(id);
  else
    vp_loadVideo1(id);
  
  
}

function vp_closeVideo() {
  el = document.getElementById('vodpod_widget_popup');
  if (el) {
    el.parentNode.removeChild(el);
  } else {
    embed_holder = document.getElementById('vodpod_player_container');
    if (embed_holder != null)
      embed_holder.parentNode.removeChild(embed_holder);

    els = vp_getElementsByClassName(widget6275969659, 'vodpod_video_placeholder1')
    for (i=0; i < els.length; i++) {
      els[i].style.opacity = 0.8;
    }
  }
}

var thechild = null;

function vp_popoutVideo(id) {
  vid_html = vp_videos[id].autoplay_embed_tag;
  var child = window.open('', 'vp_popout', 'resizable=yes,status=no,toolbar=no,width=402,height=323');
  var el = child.document.createElement("div");
  el.innerHTML = vid_html;
  child.document.body.innerHTML = '';
  child.document.body.appendChild(el);
  
  vp_closeVideo();
  child.focus();
}

function vp_offsetTop(obj) {
    curtop = 0;
    if (obj.offsetParent) {
    curtop = obj.offsetTop
    while (obj = obj.offsetParent) {
      curtop += obj.offsetTop
    }
  }
  return curtop;
}

function vp_offsetLeft(obj) {
  curtop = 0;
  if (obj.offsetParent) {
    curtop = obj.offsetLeft;
    while (obj = obj.offsetParent) {
      curtop += obj.offsetLeft;
    }
  }
  return curtop;
}

function vp_fixIePngs(node)
{
  if (isIE6)
  {
    els = vp_getElementsByClassName(node, 'vodpod_png');
    var blankSrc = "http://assetscdn.vodpod.com/images/blank.gif";
  
    for (i=0; i < els.length; i++) {
      var img = els[i];
      var origSrc = img.src;
      img.src = blankSrc;
    
      filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + origSrc + "',sizingMethod='image')";
      img.style.filter = filter;
    }
  }  
}

function vp_getElementsByClassName(node, classname)
{
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function vp_videoMouseOver(container) {
  
}

function vp_videoMouseOut(container) {
  
}

function vp_getCode() {
  var tag_src = 'http://widgets.vodpod.com/javascripts/get_widget_code?div_id=vodpod_recent_videos_266522&opts=id%3Dclassycomedy%26tag_id%3Drandom%26title%3DClassy%2BVideos%26options%5Btheme%5D%3Dsidebar1%26';
  var sc_tag = document.createElement("script");
  sc_tag.src = tag_src;
  document.body.appendChild(sc_tag);
}

function vp_showWidgetCode(content) {
  var docHeight = document.viewport.getHeight();

	var elt = document.createElement("div");
	elt.style.zIndex = 999999;
	var width = 400;
	var height = 300;
	elt.id = 'vp_code_lb';
	elt.style.width = width + 'px';
	elt.style.height = height + 'px';
	elt.style.position = 'absolute';
	elt.style.left = ((document.body.clientWidth/2) - (width/2)) + 'px'
	elt.style.top = ((docHeight / 2) + (vp_scrollTop()) - (height/2)) + 'px';
	elt.style.padding = '10px';
	elt.style.border = '4px solid black';
	elt.style.backgroundColor = 'white';
	elt.innerHTML = content;
	document.body.appendChild(elt);
	
  vp_EmbedSwapper.run(0, docHeight);
}

/**
*
*  Crossbrowser Drag Handler
*  http://www.webtoolkit.info/
*
**/

var vp_DragHandler = {

    // private property.
    _oElem : null,


    // public method. Attach drag handler to an element. I modified this function so you can provide a click_target which
    // will be the only element which can receive the mouse down, but its actual parent will be the element moved.
    attach : function(oElem, clickTarget) {
        clickTarget.onmousedown = vp_DragHandler._dragBegin;
        //oElem.onmousedown = vp_DragHandler._dragBegin;

        // callbacks
        oElem.dragBegin = new Function();
        oElem.drag = new Function();
        oElem.dragEnd = new Function();

        return oElem;
    },


    // private method. Begin drag process.
    _dragBegin : function(e) {
        var oElem = vp_DragHandler._oElem = this.parentNode;

        if (isNaN(parseInt(oElem.style.left))) { oElem.style.left = '0px'; }
        if (isNaN(parseInt(oElem.style.top))) { oElem.style.top = '0px'; }

        var x = parseInt(oElem.style.left);
        var y = parseInt(oElem.style.top);

        e = e ? e : window.event;
        oElem.mouseX = e.clientX;
        oElem.mouseY = e.clientY;

        oElem.dragBegin(oElem, x, y);

        document.onmousemove = vp_DragHandler._drag;
        document.onmouseup = vp_DragHandler._dragEnd;
        return false;
    },


    // private method. Drag (move) element.
    _drag : function(e) {
        var oElem = vp_DragHandler._oElem;

        var x = parseInt(oElem.style.left);
        var y = parseInt(oElem.style.top);

        e = e ? e : window.event;
        oElem.style.left = x + (e.clientX - oElem.mouseX) + 'px';
        oElem.style.top = y + (e.clientY - oElem.mouseY) + 'px';

        oElem.mouseX = e.clientX;
        oElem.mouseY = e.clientY;

        oElem.drag(oElem, x, y);

        return false;
    },


    // private method. Stop drag process.
    _dragEnd : function() {
        var oElem = vp_DragHandler._oElem;

        var x = parseInt(oElem.style.left);
        var y = parseInt(oElem.style.top);

        oElem.dragEnd(oElem, x, y);

        document.onmousemove = null;
        document.onmouseup = null;
        vp_DragHandler._oElem = null;
    }

}


