<!--

document.observe( 'dom:loaded', openYourIris );

function openYourIris( event )
{
	initGA();
}

iris_watch_domains = new Array
(
	/^https?\:\/\/([\w\-]+\.)*irisreading\.com/,
	/^https?\:\/\/([\w\-]+\.)*speedreadingblogger\.com/
);

function initGA()
{

	// Determine if document.location.href matches one of the domains above
	current_domain = -1;
	for ( var i=0; i < iris_watch_domains.length; i++ )
	{
		if ( document.location.href.match( iris_watch_domains[ i ] ) )
		{
			current_domain = i;
		}
	}

	// For each link on the page, add some GA JS if the domain is different from the current one
	$$('a').each( function( elem_iterator )
	{
		for ( var i=0; i < iris_watch_domains.length; i++ )
		{
			if ( i != current_domain && elem_iterator.href.match( iris_watch_domains[ i ] ) )
			{
				elem_iterator.observe( 'click', switchDomainGA );
			}	
		}
	} );
}

function switchDomainGA( event )
{
	element = event.element();
	a_element = null;
	if ( element.tagName == 'A' )
	{
		a_element = element;
	}
	else
	{
		element.ancestors().each( function( elem_iterator )
		{
			if ( elem_iterator.tagName == 'A' )
			{
				a_element = elem_iterator;
				throw $break; // Pretend this is a "break"
			}
		} );
	}

	if ( a_element )
	{
		__utmLinker(a_element.href);
		event.stop();
		return false;
	}
}

//-->
