
window.addEvent( 'domready', function() {

	new Element('div', {
		'id': 'trailimageid',
		'styles': {
			'position': 'absolute',
			'top': '0',
			'left': '0',
			'display': 'none'
		}
	}).inject( document.body );

	document.addEvent( 'mousemove', function( event ) {
		var event = new Event( event );
		popup_position( event );
	});

});

function popup_position ( event )
{

	var win = {
		'x': window.getWidth(),
		'y': window.getHeight()
		};

	var scroll = {
		'x': window.getScrollLeft(),
		'y': window.getScrollTop()
		};

	/**
	 * Ensure that the box doesn't fall off the screen (providing it isnt taller than 250 px).
	 */
	if ( ( win.y + scroll.y ) - event.page.y < 255 ) {

		event.page.y = event.page.y - Math.max( 0, ( ( 255 + event.page.y ) - ( win.y + scroll.y ) ) );

	}

	$( 'trailimageid' ).setStyles( {
		'left': event.page.x + 5,
		'top': event.page.y + 5
	} );

}

function showtrail ( image, title )
{

	image = 'http://www.classynetworks.com.au/id_img/' + image;

	$( 'trailimageid' ).setHTML( '<p>' + title + '</p><img src="' + image + '">' );
	$( 'trailimageid' ).setStyle( 'display', 'inline' );

};

function showtext(txt)
{
	$( 'trailimageid' ).setHTML( txt );
	$( 'trailimageid' ).setStyle( 'display', 'inline' );
};

function hidetrail ()
{

	$( 'trailimageid' ).setStyle( 'display', 'none' );
	
};

