function autoresize(newWidth, newHeight)
{
    if(shouldresize())
    {
	window.resizeTo(newWidth,newHeight);
	return true;
    }
    else return false;
}

// Decide whether to resize based on whether we think the new window
// is in a tab.  In this case, resizing the tab would change
// the size of the original window, which is undesirable.
// The detection of this situation is not 100% accurate.
function shouldresize()
{
    // Firefox is different from other browsers in that it can open
    // new windows in the same place as the old one (if maximised)
    // Firefox 1.x doesn't use tabs by default, so we will always resize it
    if (navigator.userAgent.indexOf('Firefox/1') != -1) return true;
    if (navigator.userAgent.indexOf("MSIE 5")!=-1) return true;
    if (!opener){return true;} 		//some safari builds have an issue with opener

    // Check if the new window is in the same place as the old one
    var leftpos;
    var parentleftpos;
    if (window.screenLeft)
    {
	leftpos = window.screenLeft;
	parentleftpos = opener.window.screenLeft;
    }
    else
    {
	leftpos = window.screenX;
	parentleftpos = opener.window.screenX;
    }
    if (leftpos != parentleftpos) return true; // The window has moved - no tabs

    // So we are not in FF1.x and the window is in the same place as the old one
    // It is likely to be in a tab, so we shouldn't resize it
    return false;
}

