// custom JavaScript for map popups
$(document).ready(function() { 
	$("a.map").fancybox({
		'zoomOpacity'	: true,
		'overlayShow'	: false,
		'zoomSpeedIn'	: 500,
		'zoomSpeedOut'	: 500
	});
// custom JavaScript for image popups
	$("a.pop").fancybox({
		'zoomOpacity'	: true,
		'overlayShow'	: false,
		'zoomSpeedIn'	: 500,
		'zoomSpeedOut'	: 500
	});
// custom JavaScript for zebra lists
$(function(){
$('.zebra li:odd').addClass('stripe');
// determine link type
 	$("a[href$='.jpg']").addClass("img");
	$("a[href$='.pdf']").addClass("pdf").attr("target", "_blank");
 	$("a[href$='.doc'], a[href$='.txt'], a[href$='.rft']").addClass("txt");
 	$("a[href$='.zip'], a[href$='.rar']").addClass("zip"); 
 	$("a[href^='mailto:']").addClass("email");
 	$('a').filter(function() {
	    return this.hostname && this.hostname !== location.hostname;
	  }).addClass("external");
	$('a').filter(function() {
	    return this.hostname && this.hostname !== location.hostname;
	  }).addClass("external").attr("target", "_blank");
	});
});
// display blog feed
jQuery(function() {
    jQuery.getFeed({
        url: 'http://aux.uncc.edu/news/index.php/feed/rss2/',
        success: function(feed) {
            jQuery('#result')
            var html = '';
            for(var i = 0; i < feed.items.length && i < 2; i++) {
                var item = feed.items[i];
                html += '<h5>'
                + '<a href="'
                + item.link
                + '">'
                + item.title
                + '&nbsp;&raquo;</a>'
                + '</h5>';
                html += '<div class="updated">'
                + item.updated
                + '</div>';
            }
            jQuery('#result').append(html);
        }    
    });
});
// outbound links in google analytics
if(typeof jQuery == 'function') { /* use jQuery if it exists because it is a more elegant solution */
	jQuery(function () {
		jQuery('a:not([href*="' + document.domain + '"])').click(function () {
			pageTracker._trackPageview('/outgoing/' + jQuery(this).attr('href'));
		});
	});
}
else { /* use regular Javascript if jQuery does not exist */
	window.onload = function () {
		var links = document.getElementsByTagName('a');
		for (var x=0; x < links.length; x++) {
			links[x].onclick = function () {
				var mydomain = new RegExp(document.domain, 'i');
				if(!mydomain.test(this.getAttribute('href'))) {
					pageTracker._trackPageview('/outgoing/' + this.getAttribute('href'));
				}
			};
		}
	};
}