
  //video switcher
  /*
  $(".youtube-button").click(function(){
    $(".video").children().hide();
    $("#youtube-video").show();
    $(".buttons").children().css({"font-weight":"normal","cursor":"pointer"});
    $(this).css({"font-weight":"bold","cursor":"auto"});
  });
  
  $(".vimeo-button").click(function(){
    $(".video").children().hide();
    $("#vimeo-video").show();
    $(".buttons").children().css({"font-weight":"normal","cursor":"pointer"});
    $(this).css({"font-weight":"bold","cursor":"auto"});
  });
  
  $(".blip-button").click(function() {
    $(".video").children().hide();
    $("#blip-video").show();
    $(".buttons").children().css({"font-weight":"normal","cursor":"pointer"});
    $(this).css({"font-weight":"bold","cursor":"auto"});	
  });
  
  $(".other-button").click(function() {
    $(".video").children().hide();
    $("#other-video").show();
    $(".buttons").children().css({"font-weight":"normal","cursor":"pointer"});
    $(this).css({"font-weight":"bold","cursor":"auto"});
  });
  */
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}



//view counts

var totalViews = 0;
function getViews(service, id)
{
	if (service == 'youtube') {
		var url = "http://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&q=" + id;
		$.getJSON(url,
			function(a){
				totalViews = totalViews + parseInt(a.data.items[0].viewCount);
				$("#viewcount").html(addCommas(totalViews));
				var account = a.data.items[0].uploader;
				account = '<iframe src="http://www.youtube.com/subscribe_widget?p=' + account + '" style="overflow: hidden; height: 97px; width: 300px; border: 0; background-color:white;" scrolling="no" frameBorder="0"></iframe>';
				$(".subscribebox").html(account);
			}
		);	
	}
	
	else if (service == 'vimeo') {
		var url = "http://vimeo.com/api/v2/video/" + id + ".json?callback=?";
		$.getJSON(url,
			function(a){
				totalViews = totalViews + parseInt(a[0].stats_number_of_plays);
				$("#viewcount").html(addCommas(totalViews));
			}
		);
	}
	
	else if (service == 'blip') { 
		var url = "http://blip.tv/players/episode/" + id + "?skin=json&callback=?&version=2";
		$.getJSON(url,
			function(a){
				totalViews = totalViews + parseInt(a[0].Post.views);
				$("#viewcount").html(addCommas(totalViews));
			}
		);		
	}
}




















