var BLIP_SITE_URL = "http://blip.tv"; 
var OUTPUT_METHOD = "document_write";

var posts = [{ "Post" : {
	"title":"Adventure Men - Promo 2 - Ultimate Adventures",
	"adminTitle":"Adventure Men - Promo 2 - Ultimate Adventures",
	"description":"<p>What would the Adventure Men\'s ultimate advetures be? Let\'s find out in this promo for the new comedy web series, Adventure Men.</p><p> http://twitter.com/AdventureMen</p><p>http://adventuremen.wordpress.com/ </p>",
	"tags":["adventure","fail","survival","bear","grylls","mears","irwin","beach","crocodile","hunter","ultimate"],
	"datestamp":"08-04-09 03:09pm",
	"datestampUnixtime":"1249412995",
	"datestampDate":"2009-08-04",
	"datestampText":"Aug  4, 2009",
		
	"postsId":2458394,
	"postsGuid":"657588F2-812A-11DE-B2B2-85ACBE4F91B6",
	"itemType":"file",
	"itemId":2438366,
	"url":"http://blip.tv/file/2438366",
	"mediaUrl":"http://blip.tv/file/get/AdventureMen-AdventureMenPromo2UltimateAdventures681.mov?source=2",
	"thumbnailUrl":"http://a.images.blip.tv/AdventureMen-AdventureMenPromo2UltimateAdventures681-789.jpg",
	"thumbnail120Url":"http://a.images.blip.tv/AdventureMen-AdventureMenPromo2UltimateAdventures681-789-153.jpg",
	"login":"AdventureMen",
	"userId":420219,
	"showName":"Adventure Men",
	"blogUrl":"http://adventuremen.wordpress.com/",
	"media":{
		"url":"http://blip.tv/file/get/AdventureMen-AdventureMenPromo2UltimateAdventures681.mov?source=2",
		"mimeType":"video/quicktime",
		"duration":97,
		"width":1280,
		"height":720
	},
	"contentRating":"TV-G",
	"advertising":"",

	/* Version 1 implementation, please supply version=2 in the future */
	"Title":"Adventure Men - Promo 2 - Ultimate Adventures",
	"posts_id":"2458394",
	"item_type":"file",
	"item_id":"2438366",
	"posts_url":"http://blip.tv/file/2438366",
	
	"media_src":"blip.tv/file/get/AdventureMen-AdventureMenPromo2UltimateAdventures681.mov?source=2",
	
	
	"Thumbnail":{
		"Url":"http://a.images.blip.tv/AdventureMen-AdventureMenPromo2UltimateAdventures681-789.jpg"
	},
	
	"User":"AdventureMen"
}},{ "Post" : {
	"title":"Adventure Men - Promo 1 - What does it take?",
	"adminTitle":"Adventure Men - Promo 1 - What does it take?",
	"description":"What does it take to be Adventure Men? Let\'s get a slight insight...",
	"tags":["adventure","survival","comedy","humor","humour","funny","beach","seaside"],
	"datestamp":"07-31-09 03:52am",
	"datestampUnixtime":"1249026729",
	"datestampDate":"2009-07-31",
	"datestampText":"Jul 31, 2009",
		
	"postsId":2443222,
	"postsGuid":"0CC22354-7DA7-11DE-8CF8-FA77FB2F6978",
	"itemType":"file",
	"itemId":2423186,
	"url":"http://blip.tv/file/2423186",
	"mediaUrl":"http://blip.tv/file/get/AdventureMen-AdventureMenPromo1WhatDoesItTake950.mov?source=2",
	"thumbnailUrl":"http://a.images.blip.tv/AdventureMen-AdventureMenPromo1WhatDoesItTake326.jpg",
	"thumbnail120Url":"http://a.images.blip.tv/AdventureMen-AdventureMenPromo1WhatDoesItTake326-572.jpg",
	"login":"AdventureMen",
	"userId":420219,
	"showName":"Adventure Men",
	"blogUrl":"http://adventuremen.wordpress.com/",
	"media":{
		"url":"http://blip.tv/file/get/AdventureMen-AdventureMenPromo1WhatDoesItTake950.mov?source=2",
		"mimeType":"video/quicktime",
		"duration":72,
		"width":1280,
		"height":720
	},
	"contentRating":"TV-G",
	"advertising":"",

	/* Version 1 implementation, please supply version=2 in the future */
	"Title":"Adventure Men - Promo 1 - What does it take?",
	"posts_id":"2443222",
	"item_type":"file",
	"item_id":"2423186",
	"posts_url":"http://blip.tv/file/2423186",
	
	"media_src":"blip.tv/file/get/AdventureMen-AdventureMenPromo1WhatDoesItTake950.mov?source=2",
	
	
	"Thumbnail":{
		"Url":"http://a.images.blip.tv/AdventureMen-AdventureMenPromo1WhatDoesItTake326.jpg"
	},
	
	"User":"AdventureMen"
}}
];



	
		var html; 
var container;
if(OUTPUT_METHOD == "dom") {
	container = document.createElement('div');
	container.className = 'bliptv_sidebar';
	container.style.width = '110px';
	container.style.border = '1px solid black';
	container.style.padding = '5px';
	
	var c = document.createElement('center');
	container.appendChild(c);

	var title = document.createElement('span');
	title.style.fontFamily = 'arial';
	title.style.fontSize = '7.5pt';
	title.style.fontWeight = 'bold';
	title.innerHTML = 'Adventure Men';
	c.appendChild(title);
	c.appendChild(document.createElement('br'));
	c.appendChild(document.createElement('br'));
} else {
	html = '<div class="bliptv_sidebar" style="width: 110px; border: 1px solid black; padding: 5px;"><center>';
	html += '<span style="font-family: arial; font-size: 7.5pt; font-weight: bold;">Adventure Men</span><br /><br />'; 
}

for(var i = 0; i < posts.length; i++) {
	if(posts[i]['Post']['Thumbnail']) {
		if(OUTPUT_METHOD == "dom") {
			var anchor = document.createElement('a');
			anchor.href = BLIP_SITE_URL + '/' + posts[i]['Post']['item_type'] + '/'+ posts[i]['Post']['item_id'];

			var img = document.createElement('img');
			img.src = posts[i]['Post']['Thumbnail']['Url'];
			img.width = '90';
			img.height = '75';
			img.border = '0';
			img.title = posts[i]['Post']['Title'];

			anchor.appendChild(img);
			c.appendChild(anchor);
			c.appendChild(document.createElement('br'));
			c.appendChild(document.createElement('br'));
		} else {
			html += '<a href="' + BLIP_SITE_URL + '/' + posts[i]['Post']['item_type'] + '/'+ posts[i]['Post']['item_id'] + '"><img src="' + posts[i]['Post']['Thumbnail']['Url'] + '" width="90" height="75" style="border: 0px;" title="' + posts[i]['Post']['Title'] + '"/></a><br /><br />';
		}
	}
}

if(OUTPUT_METHOD == "dom") {
	c.appendChild(document.createElement('br'));
	var anchor = document.createElement('a');
	anchor.href = BLIP_SITE_URL;
	
	var img = document.createElement('img');
	img.src = BLIP_SITE_URL  + '/skin/blipcast/blip.tv.share.button.gif';
	img.border = 0;

	anchor.appendChild(img);
	c.appendChild(anchor);

	document.getElementById('blip_sidebar_container').appendChild(container);
	
} else {
	html += '<br /><a href="' + BLIP_SITE_URL + '"><img src="' + BLIP_SITE_URL  + '/skin/blipcast/blip.tv.share.button.gif" border="0" /></a>'; 
	html += '</center></div>';
	document.write(html);
}

	

