how can I clean up this javascript jquery
<p>I have these two functions.</p>

<p>The first is well written because someone who knows how to write js did it.</p>

<p>The second I did.</p>

<pre><code>var GetURLParameter = function($param){
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&amp;');
    for(var i = 0; i &lt; sURLVariables.length; i++) {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == $param) {
            return sParameterName[1];
        }
    }
}


if(GetURLParameter('filter')!= "undefined"){
     $('#'+GetURLParameter('filter')).parent().parent().children('li.active').removeClass('active')
     $('#'+GetURLParameter('filter')).parent().addClass('active');
}
</code></pre>

<p>I would like to simplify the calls as I'm repeating the line <code>GetURLParameter('filter')</code> but I don't know how I can make it work like the key word <code>this</code></p>
