
// Generic routine for opening popup windows.
function popUp(url, type)
{
    var win;
    if (type == null) type = 0;
    switch (parseInt(type))
    {
        case 0:
        case 1:
            win = openWindow(url, "Medium", 520, 420, true, true, false, false, "");
            break;            
        case 2:
            win = openWindow(url, "HelpCenter", 574, 520, true, true, false, false, "");
            break;
        case 3:
            win = openWindow(url, "MediaPlayer", 359, 384, false, false, false, false, "");
            break;
        case 4:
            win = openWindow(url, "DigSigAgreement", 820, 550, true, true, true, true, "");
            break;
        case 5:
            win = openWindow(url, "Chat", 580, 450, true, true, true, true, "");
            break;
        case 6:
            win = openWindow(url, "Tall", 520, 620, true, true, false, false, "");
            break;   
        case 7:
            win = openWindow(url, "PaymentDate", 874, 580, true, true, false, false, "");
            break;
        case 8:
            win = openWindow(url, "Short", 520, 310, true, true, false, false, "");
            break; 
        case 9:
            win = openWindow(url, "MediaPlayer", 359, 440, false, false, false, false, "");
            break;  
        case 10:
            win = openWindow(url, "ExitSurvey", 750, 580, true, true, false, false, "");
            break;
        case 11:
            win = openWindow(url, "Privacy", 574, 480, true, true, false, false, "");
            break;
    }
    
    return win;
}

// Opens a new modal window.  window.showModalDialog doesn't work in FireFox.  Call the openWindow
// function below with "modal=yes" in the "options" parameter.  Keep in mind this won't be a true
// modal window (it keeps the new window on top of the opener) and thus you'll have to handle return
// values differently.
function openModalWindow(url, arguments, width, height, status)
{
	var features = "edge:sunken;center:yes;help:no;unadorned:yes";
	features += ";dialogHeight:" + height + "px";
	features += ";dialogWidth:" + width + "px";
	features += ";status:" + ((status) ? "yes" : "no");
	
	return window.showModalDialog(url, arguments, features);
}

// Opens a new modaless window (good for a "Help" window).
function openModalessWindow(url, arguments, width, height, resize, status)
{
	var features = "border:thick;center:yes;help:no;";	
	features += ";dialogHeight:" + height + "px";
	features += ";dialogWidth:" + width + "px";
	features += ";resizable:" + ((resize) ? "yes" : "no");
	features += ";status:" + ((status) ? "yes" : "no");
	
	return window.showModelessDialog(url, arguments, features);
}

// Opens a new window.
function openWindow(url, name, width, height, resize, scroll, menu, status, options)
{   
    var top = 0, left = 0;
    
	if (screen.availWidth)
	{
		top = (parseInt(screen.availHeight) - height) / 2;
		left = (parseInt(screen.availWidth) - width) / 2;
	}
	else
	{
		top = (parseInt(screen.height) - height) / 2;
		left = (parseInt(screen.width) - width) / 2;
	}
    
	var features = "directories=0";	
	features += ",top=" + top;
	features += ",left=" + left;
	features += ",height=" + height;
	features += ",width=" + width;
	features += ",menubar=" + ((menu) ? "yes" : "no");
	features += ",toolbar=" + ((menu) ? "yes" : "no");
	features += ",location=" + ((menu) ? "yes" : "no");
	features += ",status=" + ((status) ? "yes" : "no");
	features += ",scrollbars=" + ((scroll) ? "yes" : "no");
	features += ",resizable=" + ((resize) ? "yes" : "no");
	features += "," + options.toString();
	
	if (name.toLowerCase().indexOf("popup") == -1)
	{
		name += "PopUp";
	}
	
	window[name] = window.open(url, name, features, true);
	window.setTimeout("window." + name + ".focus()", 100);
	
	return window[name];
}

/* Called by popup windows when they need to navigate the parent window - JMH */
function navigateOpener(url) {
	window.opener.location.href = url;
	window.close();	
}
