/**
 * 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;
}