﻿/**
 *  Functionality related to persisting the current postal code in the query string
 */
function persistPostal(target, postalID) {
    var query = window.location.search.replace(/[?&]pc=[^&]*/, '', 'g');
    var txtPostal = document.getElementById(postalID);
    if (query.length > 0 && query.charAt(0) != '?') {
        query = '?' + query;
    } else if (query.length > 0) {
        query += '&';
    }
    query += 'pc=' + escape(txtPostal.value);
    target.href = target.href.replace(/(?:\?.*)?$/, query);
    return true;
}
