jQuery(document).ready(function($){
	var t = 'spot', v = $('a[rel^="video"]'), w = 320, h = 180,
			sv = function(){try{this.pause();this.currentTime = 0;}catch(err){};},
			av = function(){
				var a = $(this), s = !a.attr('class').length, vf = a.attr('href');
				if (vf.match(/^#/)) { return a.parent('li').remove() }
				var d = a.next('.'+t+'-description'), de = $('<div class="'+t+'-description" />').html('<h5>'+a.html()+'</h5>'+(d.html()||'')),
							fav = function(){$(this).parent('li').addClass('active').siblings().removeClass('active').find('video').each(sv);return false;};
				if ($.browser.msie) {
					var fo = '';
							fo += '<object width="'+w+'" height="'+(h+15)+'" type="application/x-shockwave-flash" data="player.swf">';
							fo += '<param name="movie" value="player.swf" />';
							fo += '<param name="flashvars" value="autostart=false&image='+vf+'.jpg&file=http://another.bakeryfilms.com/'+vf+'.mp4" />';
							if (a.hasClass('has-image')) { fo += '<img src="' + vf + '.jpg" alt="' + (a.attr('title') || '') + '" width="' + w + '" height="' + h + '" />'; }
							fo += '</object>';
					var vo = $(fo),
							ve = $('<div class="video" />').append(vo).append(de);
				}
				else {
					var vo = $('<video controls="" preload="none"'+(a.hasClass('has-image')?' poster="'+vf+'.jpg"':'')+' width="'+w+'" height="'+h+'" />'),
							ve = $('<div class="video" />').append(vo).append(de);
					if (s || a.hasClass('mp4')) { vo.append($('<source src="'+vf+'.mp4" type="video/mp4"></source>'));a.removeClass('mp4'); }
					if (s || a.hasClass('ogv')) { vo.append($('<source src="'+vf+'.ogv" type="video/ogg"/>'));a.removeClass('ogv'); }
					if (a.hasClass('has-image')) { vo.append('<img src="'+vf+'.jpg" alt="'+(a.attr('title')||'')+'" width="'+w+'" height="'+h+'" />');a.removeClass('has-image'); }
				}
				a.unbind('click').click(fav).after(ve).parent('li').addClass('active').siblings().removeClass('active').find('video').each(sv);d.remove();
				return false;
			};
	if(v.length){v.click(av);$('li:first-child a[rel^="video"]').click();/*$('li:first-child a[rel^="video"]').click();*/}
});
