//Listings Sort by select (form name will be sortFormtop or sortFormbottom)
function srpSort(type,sortForm) {
    sortForm.sort_type.value = type;
    sortForm.submit();
}

//Listings per page select (form name will be listings_changetop or listings_changebottom)
function atcLCSubmit(num,listings_change) {
    listings_change.rdpage.value = num;
    listings_change.submit();
}

/**
 * Opens a link in a new window.
 * @param {string} url the url to open in a new window
 */
function openInNewWindow(url)
{
    if (url == null)
    {
        return false;
    }
    // Window handle.
    var win = null;
    // Window name.
    var name = "NCME";
    // Set height and width.
    var w = 828;
    var h = 836;
    var screenH = screen.height;
    var screenW = screen.width;
    if (screenW < w){
        w = screenW - 30;
    }
    if (screenH < h){
        h = screenH - 30;
    }
    // Center the window.
    var t = (screenH - h) / 2;
    var l = (screenW - w) / 2;
    // Set parameters for popup.
    var features = "";
    features += "width=" + w;
    features += ",height=" + h;
    features += ",top=" + t;
    features += ",left=" + l;
    features += ",menubar=no,toolbar=no,location=no,directories=no,status=yes,resizable=yes,scrollbars=yes,channelmode=no";
    // Open the window.
    win = window.open(url, name, features);
    if (win == null)
    {
        return false;
    }
    // Attempt to reset window size and location
    // if we are reusing a window that is already open.
    try
    {
        win.resizeTo(w, h);
    }
    catch(e)
    {
    }
    try
    {
        win.moveTo(l, t);
    }
    catch(e)
    {
    }
    // Bring the popup window to the foreground.
    try
    {
        win.focus();
    }
    catch(e)
    {
    }
    return false;
}
