/**
 * Function: popupOrRedirect
 * About: Some pop-up blockers (Norton) are blocking legitimate pop-up windows on the site.
 * This function will try to open a pop-up window, and failing that redirect the user to the page
 * in the current browser window.
 *
 * - AB 17.01.06
 */

/* path to the aspx page for logging pop-up errors */
var LOGGER = "/customerror/popupError.aspx";

/**
 * Params: window to check
 * Returns: true if the window popped up successfully
 */
function isPopped(win) {
	return !((win == null) || (win == 'undefined'));
}

/**
 * Params: url of page to open
 *         name of window
 *         options for popup window
 * Returns: false
 */
function popupOrRedirect(url,name,options){
	/* fix norton's popup blocker */
	if(typeof SymRealWinOpen != 'undefined'){
        if(navigator.appVersion.indexOf("MSIE")!=-1){
			window.open = SymRealWinOpen;            
        }
    }
    
	var win = window.open(url,name,options);
	
	if(url.indexOf("redirect=1")==-1)
		url += ((url.indexOf("?")==-1)?"?":"&") + "redirect=1";

	if(!isPopped(win)) {
		/* popup failed to open correctly, log error and redirect */
		window.location.href = LOGGER+'?url='+url;
	}
	return false;
}
function pop(key,name,opts){	var h=getVal(opts,'height=');
	var w=getVal(opts,'width=');
	var opts=opts+',top='+((screen.height/2)-(h/2))+',left='+((screen.width/2)-(w/2));
	popupOrRedirect(key,name,opts);	}function getVal(str,k){
	var s=str.indexOf(k);
	var e=str.substr(s,str.length).indexOf(',');
	if(e==-1) e=str.length-s;
	return str.substr(s+k.length,e-k.length);
}