// jQuery DropDown Fix
(function($){$.fn.dropdown=function(options){var settings=jQuery.extend({timeout:0.05},options);var closetimer=null;var ddmenuitem=null;$(this).children('li').hover(dropdown_open,dropdown_timer);document.onclick=dropdown_close;function dropdown_open(){dropdown_canceltimer();dropdown_close();ddmenuitem=$('ul',this).css('left','0')}function dropdown_close(){if(ddmenuitem){ddmenuitem.css('left','-9999em')}}function dropdown_timer(){closetimer=window.setTimeout(dropdown_close,settings.timeout*1000)}function dropdown_canceltimer(){if(closetimer){window.clearTimeout(closetimer);closetimer=null}}return this}})(jQuery);

$(document).ready(function() {
	jQuery.fn.maillink = function() {
		var at = / at /;
		var dot = / dot /g;
		this.each( function() {
			var addr = jQuery(this).text().replace(at,"@").replace(dot,".");
			var title = jQuery(this).attr('title')
			jQuery(this)
				.after('<a href="mailto:'+addr+'" title="'+title+'">'+ addr +'</a>')
				.remove();
		});
	};						   
	// Spambot Email protection
	jQuery('.maillink').maillink();
	//Open External Links in a New Window/tab
	$('a[rel*=external]').click( function() { this.target = "_blank";	});
	//jquery print function
	$('a.print').click( function() { window.print(); return false; });
	//remove noJS class
	$('body').removeClass('noJS');
	//DropDown Fix
   jQuery('ul#mainNav').dropdown();
   if ( jQuery('ul#mainNav li ul li a').length ) {
      jQuery('ul#mainNav li ul').each( function() {
         jQuery(this).children('li').children('a').width( jQuery(this).width() - 25 );
      });
   }
});
