$( window ).load( function()
{
	// only pick up link elements that do not yet have a click event
	$( "a:not(:click)" ).each( function()
	{
		$this = $( this );
		/*
			We want a elements that have
			either the popup class or a different domain than the root domain
			and are not empty
			and are not undefined
			and do not have the "mailto:" string anywhere
		*/
		if( ( $this.hasClass( "popup" ) || this.href.indexOf( document.domain ) == -1 ) && this.href != "" && this.href != "undefined" && this.href.indexOf( "mailto:" ) == -1 )
			$this.click( function( e )
			{
				e.preventDefault();
				e.stopPropagation();
				window.open( this.href );
				return false;
			} );
	} );
} );

/**
 *  Create a hasEvent method that allows for the detection of any bound event
 *  Original function
 * (function( A ){A.fn.hasEvent = function(C){var B=this.data("events");return( B && B[C] );}})(jQuery)
 */

$.fn.hasEvent = function ( sEvent ) {
	var oEvents = this.data("events");
	return ( typeof oEvents != "undefined" && typeof oEvents[ sEvent ] != "undefined" );
};

/**
 *  Bind the :click selector to $( n ).hasEvent( 'click' );
 *  Can be extended to include any and all events and (custom) triggers
 */
$.extend( $.expr[':'], {
	click: function ( o )
	{
		return $( o ).hasEvent( 'click' );
	}
} );
