// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function checkWindowName( windowName )
{
	var newWindowName;

	if (window.name == windowName) {
		newWindowName = windowName+'2';
	}
	else {
		newWindowName = windowName;
	}

	return newWindowName;
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function metPop( fileName )
{
	var newWinName = checkWindowName('moPop');
	
	openPop = this.open(fileName,newWinName,'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=500,height=1,left=100,top=5,screenX=100,screenY=5');

	openPop.focus();

	// close the old pop if metResized pop was blocked
	if ((window.name != newWinName) && ((window.name == 'moPop') || (window.name == 'moPop2'))) {
		window.close();
	}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function resizePop( fileName, windowWidth, windowHeight )
{

	var newWinName = checkWindowName('moResized');

	var agt = navigator.userAgent.toLowerCase();
	var is_mac = (agt.indexOf("mac")!=-1);

	var docHeight = document.height ? document.height : is_mac && document.body && document.body.scrollHeight ? document.documentElement.offsetHeight : document.body && document.body.scrollHeight ? document.body.scrollHeight: null;

	var vertScroll;
	if ((screen.height - 85) < windowHeight) {
		vertScroll = "yes";
		windowHeight = screen.height - 100;
		windowWidth +=30;
	}
	else {
		vertScroll = "no";
	}

	windowHeight +=30;
	
	newPopResized = window.open(fileName,newWinName,'toolbar=no,menubar=no,location=no,scrollbars='+vertScroll+',resizable=no,width='+windowWidth+',height='+windowHeight+',left=100,top=5,screenX=100,screenY=5');

	// if newPop fails, resize and move old pop
	if (((window.name == 'moPop') || (window.name == 'moPop2')) && (!newPopResized)) {
		windowWidth +=30;
		windowHeight +=30;
		window.resizeTo(windowWidth,windowHeight);
		window.moveTo(100,50);
		window.location.href = fileName;
	}

	newPopResized.focus();
	window.close();

}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------