// JavaScript Document

// Creating custom :external selector
$.expr[':'].external = function(obj){
    return !obj.href.match(/^mailto\:/)
            && (obj.hostname != location.hostname)
			&& (!obj.href.match(/^javascript/));
};



$(document).ready(function() {
	
	$(".staffLink").click(function(){
		displayPopup('staff', null, null, 'id=' + $(this).attr('id'));
	});
	

	// All external links open in new window, rel=nofollow
	$('a:external').click(function() {
		$(this).attr("target", "_blank");
		
		//add nofollow if 5 or more are external...
		if($('a:external').length > 4){
			$(this).attr("rel", "nofollow");
		}
		
		if($(this).attr("onclick")==undefined){
			var linkHostname = get_hostname_from_url($(this).attr('href'));
			pageTracker._trackEvent('link', 'click', linkHostname);
		}
	});


	//all PDF links in new window
	$("a[href*=.pdf]").click(function(){
		$(this).attr("target", "_blank");
	});
	//all DOC links in new window
	$("a[href*=.doc]").click(function(){
		$(this).attr("target", "_blank");
	});
	//all DOCX links in new window
	$("a[href*=.docx]").click(function(){
		$(this).attr("target", "_blank");
	});
	//all JPG links in new window
	$("a[href*=.jpg]").click(function(){
		$(this).attr("target", "_blank");
	});

	
	
});

