/*
    Skip to the MP3 download on IT Conversation show detail pages.
    (c) 2005 Carsten Clasohm
    http://www.clasohm.com/

    Copy, use, modify, spread as you see fit.
*/

// ==UserScript==
// @name            ITConversations Automatic MP3 Download
// @namespace       http://www.clasohm.com
// @description     Skips to the MP3 download when the Download link on the details page is clicked. (2005-07-02)
// @include         http://www.itconversations.com/*
// ==/UserScript==

(function() {

    if (document.URL.indexOf('/shows/detail') != -1) {
	var downloadLink = getObj(document, "//a[@class='menu'][1]");
	downloadLink.href = downloadLink.href.replace(/download/, 'download-link');
	downloadLink.firstChild.data = 'Download MP3';
    } else if (document.URL.indexOf('/download-link.php') != -1) {
	var downloadLink = getObj(document, "//a[@class='featurelink'][1]");
	window.open(downloadLink.href, '_self');
    }

    function getObj(obj, xpath) {
	try { 
	    return document.evaluate( xpath, obj, null, 
		XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; 
	} catch(e) { 
	    return null; 
	}
    }

 })();

