﻿// JScript File
function JoinPopup(strPageToOpen, intScreenWidth, MyWin)
{		
	var w = 1024;
	var h = 685;
	var winl = 100;
	//A bug in the way IE preloads js files causes this to fail when the page first loads
	//The try catch enables it to get through the initial load while still working correctly
	//when called.
	try{winl = (intScreenWidth - w)/2;}catch(e){winl=100;}
	var wint = 2;
	MyWin.open(strPageToOpen,'JoinAARP', 'width='+ w +',height='+ h +',left='+ winl +',top='+ wint +',scrollbars=yes,resizable,toolbar=no,status,menubar=no,location=no');
}

// make new popup window
// oAnchor is the 'this' object from the referring page. This is the only mandatory argument.
//sProps is the parameters for the window.open event. i.e. 'height=250,width=300,top=50,left=50,scrollbars=yes,titlebar=true'
//sWindow is the title for the page if the html does not have a title tag in it.
function PopNewWin(oAnchor,sProps,sWindow){
	var sUrl = '';
	
	// get URL from calling link oAnchor
	if(oAnchor.getAttribute) sUrl = oAnchor.getAttribute('href');
	if(sUrl=='' && isIE) sUrl = window.event.srcElement.getAttribute('href');
	if(sUrl=='') sUrl = oAnchor.href;
	
	// if still no URL, return true and let the regular link take over
	if(sUrl=='') return true;

	// set window name ('_blank' for new window each time)
	var sWindowName = sWindow?sWindow:'_blank';
	
	// if no window properties are defined in the function call's optional parameter 'sProps'
	if(!sProps) sProps = 'width=640,height=480,scrollbars,resizable,toolbar,status,menubar,location';
	
	// assign the popup to this variable so we can verify it exists
	if(sUrl) var oPopup = window.open(sUrl,sWindowName,sProps);
	
	// An Opera bug returns too early if you focus the window, so we don't focus it in that browser.
	// Only a noticeable defect if a window is already open and hidden.
    var isOpera = (navigator.userAgent.toLowerCase().indexOf('opera') != -1) ? true : false;
	if(oPopup && !isOpera) oPopup.focus();
	
	// If popup was created successfully, cancel link in calling window.
	// Acts as regular link in browser that blocks requested popups or has JavaScript turned off.
	return (oPopup)?false:true;

}


