function videoLink() {
	var a, href, type, ftype;
	a = document.getElementsByTagName("a");
//	a = document.getElementById("body").getElementsByTagName("a");
	if (a) {
		for (i=0;i<a.length;i++) {
			if (a[i].getAttribute("rel") == "enclosure") {
				href = a[i].getAttribute("href");
				type = a[i].getAttribute("type");
				if (type.substring(0, type.lastIndexOf('/')) == "video") {
					ftype = href.substring(href.lastIndexOf('.'), href.length);
					switch (ftype) {
						case ".mov":
							type = "video";
						break
						case ".mp4":
							ftype = ".mov";
							type = "video";
						break
						case ".avi":
							ftype = ".mov";
							type = "video";
						break
						case ".wmv":
							type = "video";
						break
						case ".wma":
							ftype = ".wmv";
							type = "video";
						break
						default:
							type = false;
						break
					}
					if (type == "video") {
							a[i].onclick=function(){return(replaceVideoLink(this, ftype, type));};
					}
				}
			}
		}
	}
}
function replaceVideoLink (o, ftype, type) {
	var href, p, text, div, a, object, embed;
	var videoHeight = "253";
	var videoWidth = "320";
//	href = o.firstChild.nodeName
	href = o.getAttribute("href");
	// Check if link has an image as the first child. Only replace if so.
	if (o.firstChild.nodeName.toLowerCase() == "img") {
		// Create replacement.
		div = document.createElement("div");
		div.setAttribute("class", "video-window");
		// Create <object> and <embed> elements to show video.
		object = document.createElement("object");
		if (ftype == ".mov") {
			object.setAttribute("classid", "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B");
			object.setAttribute("codebase", "http://www.apple.com/qtactivex/qtplugin.cab");
			object.setAttribute("width", "320");
			object.setAttribute("height", "252");
			var param1 = document.createElement("param");
			param1.setAttribute("name", "src");
			param1.setAttribute("value", href);
			var param2 = document.createElement("param");
			param2.setAttribute("name", "autoplay");
			param2.setAttribute("value", "true");
			var param3 = document.createElement("param");
			param3.setAttribute("name", "controller");
			param3.setAttribute("value", "true");
			object.appendChild(param1);
			object.appendChild(param2);
			object.appendChild(param3);
			embed = document.createElement("embed");
			embed.setAttribute("src", href);
			embed.setAttribute("autoplay", "true");
			embed.setAttribute("controller", "true");
			embed.setAttribute("pluginspage", "http://www.apple.com/quicktime/download/");
			embed.setAttribute("width", videoWidth);
			embed.setAttribute("height", videoHeight);
			object.appendChild(embed);
		} else if (ftype == ".wmv")	{
			object.setAttribute("classid", "CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95");
			object.setAttribute("codebase", "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701");
			object.setAttribute("standby", "Loading Microsoft Windows Media Player components...");
			object.setAttribute("type", "application/x-oleobject");
			object.setAttribute("width", "320");
			object.setAttribute("height", "285");
			var param1 = document.createElement("param");
			param1.setAttribute("name", "fileName");
			param1.setAttribute("value", href);
			var param2 = document.createElement("param");
			param2.setAttribute("name", "animationatStart");
			param2.setAttribute("value", "true");
			var param3 = document.createElement("param");
			param3.setAttribute("name", "transparentatStart");
			param3.setAttribute("value", "true");
			var param4 = document.createElement("param");
			param4.setAttribute("name", "autoStart");
			param4.setAttribute("value", "true");
			var param5 = document.createElement("param");
			param5.setAttribute("name", "showControls");
			param5.setAttribute("value", "true");
			var param6 = document.createElement("param");
			param6.setAttribute("name", "loop");
			param6.setAttribute("value", "false");
			object.appendChild(param1);
			object.appendChild(param2);
			object.appendChild(param3);
			object.appendChild(param4);
			object.appendChild(param5);
			object.appendChild(param6);
			embed = document.createElement("embed");
			embed.setAttribute("src", href);
			embed.setAttribute("type", "application/x-mplayer2");
			embed.setAttribute("loop", "false");
			embed.setAttribute("pluginspage", "http://microsoft.com/windows/mediaplayer/en/download/");
			embed.setAttribute("autostart", "true");
			embed.setAttribute("showcontrols", "true");
			embed.setAttribute("width", "320");
			embed.setAttribute("height", "285");
			object.appendChild(embed);
		}
		p = document.createElement("p");
		a = document.createElement("a");
		a.setAttribute("href", href);
		text = document.createTextNode("Download video");
		a.appendChild(text);
		p.appendChild(a);

		div.appendChild(object);
		div.appendChild(p);
		// Replace
		o.parentNode.replaceChild(div, o);
		return false;
	}
}
function addEvent(obj, evType, fn){
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}
addEvent(window, 'load', videoLink);