function TrackEvent( oArgument )
{
	if ( typeof oArgument == "undefined" )
		oArgument = new Object;

	window[ ( this._self = "TrackEventObject" ) ] = this;

	this._domain = this._getDomain( document.location.href );
	this._folder = typeof oArgument.folder != "undefined" ? oArgument.folder : "/clickout/";
	this._collect();
};

TrackEvent.prototype._collect = function()
{
	if ( !document && typeof document.getElementsByTagName == "undefined" )
		this._postpone();

	var aLink = document.getElementsByTagName( "a" );
	for ( var i = 0; i < aLink.length; ++i )
		if ( aLink[ i ].href )
			this._hijack( aLink[ i ] );
};

TrackEvent.prototype._getDomain = function( mLink )
{
	if ( typeof mLink == "string" )
	{
		var oLink  = document.createElement( "a" );
		oLink.href = mLink;
		mLink      = oLink;
	}

	return mLink.hostname;
};

TrackEvent.prototype._postpone = function()
{
	clearTimeout( this._timer );
	this._timer = setTimeout( this._self + "._collect();", 100 );
};

TrackEvent.prototype._hijack = function( oLink )
{
	oLink._control   = this;
	oLink.__oldclick = oLink.onclick;
	oLink.onclick    = this.__onclick;
};

TrackEvent.prototype.__onclick = function( e )
{
	return this._control._click( this );
};

TrackEvent.prototype._click = function( oLink )
{
	bReturn = false; //  false to prevent the link from being triggered
	if ( oLink.href )
	{
		if ( this._getDomain( oLink ) == this._domain ) //  internal links
		{
			bReturn = true;
		}
		else if ( oLink.href.substr( 0, 10 ) == "javascript" ) // scripted links
		{
			bReturn = true;
		}
		else //  offsite link
		{
			var nTarget = oLink.href.indexOf( "target=" );
			if ( pageTracker )
			{
				var sName = "";
				if ( nTarget >= 0 )
					sName = oLink.href.substr( nTarget + 7 );
				else
					sName = escape( oLink.href );

				if ( sName != "" )
				{
					pageTracker._trackEvent( this._folder, sName );
					bReturn = true;
				}

				var oWindow = window.open( oLink.href ); oWindow.focus(); oWindow=null;
				return false;
			}
		}
	}

	if ( oLink.__oldclick )
	{
		var mReturn = oLink.__oldclick();
		if ( typeof mReturn != "undefined" )
			return mReturn;
	}

	return bReturn;
};
