// BASIC FUNCTIONS
jQuery(function() {
	// ADD FILETYPE ICONS AND BEHAVIOUR TO DOCUMENT HYPERLINKS	
	var x
	var fileTypes = ['pdf', 'doc', 'zip'];
	jQuery('a[href]').filter(function(index) {
		return jQuery("img", this).length == 0;
	}).each(function(i) {
		for (x in fileTypes) {
			// Create regular expression: 'link ends in file extension'
			var re = "/." + fileTypes[x] + "$/i";
			re = eval(re);
			if (this.toString().match(re)) {
				jQuery(this).addClass("new-window").addClass('filetype-' + fileTypes[x]).attr('target', '_blank');
			}
		}
	});

	// APPLY 'EXTERNAL SITE' CLASS TO LINKS TO EXTERNAL WEBSITES, and OPEN IN NEW WINDOW
	// 'External Sites' are defined as those not on the exception list below
		jQuery("a[href*=:\/\/]")
		.not("[href*=javascript:]")
		.not("[href*=mailto:]")
		.not("[href*=vikingsailingclub]")
		.not("[href*=localhost]")
		.not("[href*=ultrawebsites]")
		.addClass("external-site")
		.attr('target', '_blank');
});
