

/* Dotty  ------------------------------------------------ */
$(document).ready(function() {
    //Put a span round all-untagged text
    var textEls = $("#content p").contents().filter(function() { return this.nodeType != 1; }).wrap('<span class="textNode"/>');
    //Put a span around all characters with a dot
    $("span.textNode").each(function(i) {
        e = $(this);      
        e.html(e.html().replace(/\./g,'<span class="xc_dda">.</span>'));
    });    
});



/* External links ------------------------------------------------ */

$(document).ready(function() {

    // Tests whether 'link' begins with http://
    function linkIsToDomain(link) {
    	var re = new RegExp("^http://", "i");
    	return re.test(link);
    }
    
    //Add the openInNewWindow function, and an icon to the onclick event of external links
    
	$('a').each(function (l) {
		var $link = $(this);
        //alert($link.attr("href"));
        //alert(linkIsToDomain($link.attr("href")));
		if (linkIsToDomain($link.attr("href"))) { //tests that the link is absolute
			// Create an img element containing the new window warning text and insert it after the link text
			$link.addClass("external");
			$link.attr("title", ($link.attr("title")?$link.attr("title")+" ":"") + "(new window)");
			$link.attr("target", "_blank");
		}
	});
});



/* Misc ------------------------------------------------ */

/*
$(document).ready(function() {
	$("ul#stream p.teaser").hide();
	$("ul#stream li").hover(function() {
		$(this).find("h1 a").stop(true, true);
		$(this).find("h1 a").animate({backgroundColor: "#ff0033"}, 250);
		$(this).find("p.teaser").show(250);
	}, function() {
		$(this).find("h1 a").animate({backgroundColor: "#000066"}, 250).animate({backgroundColor: "#000000"}, 2500);
		$(this).find("p.teaser").hide(250);
	});
	
	$("ul#stream li").click(function() {
		$(this).append("<p class='content'></p>");
		$(this).find("p.content").load("/test_ajax");
	});
	
	//TODO: turn rollover interaction off for loaded items.
	
});
*/