function isDNDEventSupported(eventName) {
	var el = document.createElement('div');
	eventName = 'on' + eventName;
	var isSupported = (eventName in el);
	if (!isSupported) {
		el.setAttribute(eventName, 'return;');
		isSupported = typeof el[eventName] == 'function';
	}
	el = null;
	return isSupported;
}

window.onload = function () {
	var links = document.getElementById("content").getElementsByTagName("a"),
		len = links.length,
		domain = new RegExp(document.location.hostname),
		zipMime = "application/zip",
		lhost,
		dndSource,
		lhref,
		source;
		
	while(len--) {
		lhref = links[len].href;
		lhost = lhref.split("/")[2];
		
		if(!domain.test(lhost)) {
			links[len].setAttribute("target","_blank");
		}
		
		if(links[len].className.indexOf("source") !== -1 && isDNDEventSupported("dragstart")) {
			source = links[len].href.split("/").reverse()[0];
			dndSource = zipMime+":"+source+":"+lhref;
			
			links[len].ondragstart = function(e) {
				e.dataTransfer.setData("DownloadURL",dndSource);
			}
		}
	}
}