var AutoPopUpWindow = null;

var img = new Image();

function AutoPopUp( src )
{
	img.src = src || "/PopUps/Auto/Auto.gif";	// It's always this image unless supplied as src !!!
	window.setTimeout( "AutoPopUp_Check()", 100 );
}

function AutoPopUp_Check()
{
	if( img.w < 1 || img.h < 1 )
	{
		window.setTimeout( "AutoPopUp_Check()", 100 );
		return;
	}

	var x = 100, y = 100;

	var w = img.width, h = img.height;
	var t = 68, r = 10;		// This was fine tuned with Win XP, chrome theme, may vary on others
	if( h + t > window.screen.height ) h = window.screen.height - t;
	if( w + r > window.screen.width )  w = window.screen.width  - r;
	if( AutoPopUpWindow ) AutoPopUpWindow.close();
	AutoPopUpWindow = window.open( "http://www.heartlandapp.com/PopUps/Auto/?"+(new Date()).getTime(), "AutoPopUp",
			"left="+x+",top="+y+",width="+w+",height="+h+",scrollbars=0,resizable=0,titlebar=no" );
}