﻿        var qs = window.location.search.substring(1);
        
        function replaceQSParm(searchkey, newvalue)
        {
            var newqs = "";
            var parms = qs.split('&');
            var found = false;
            
            for (var i=0; i<parms.length; i++) 
            {
                var pos = parms[i].indexOf('=');
                if (pos > 0) 
                {
                    var key = parms[i].substring(0,pos);
                    var val = parms[i].substring(pos+1);
                    if(key == searchkey)
                    {
                        val = newvalue;
                        found = true;
                    }
                    newqs += key + "=" + val + "&";
                }
            }
            if(newqs.length > 0)
            {
                qs = newqs.substring(0, newqs.length - 1);
            }
            if(found == false)
            {
                qs += (parms.length > 0 ? "&" : "?") + searchkey + "=" + newvalue;
            }
        }
        
        function showCource(ctrl)
        {
            u = document.location.href;
            i = u.indexOf('?');
            if(i > 0)
            {
                u = u.substring(0, i);
            }
            replaceQSParm("xslCource", ctrl.options[ctrl.selectedIndex].value);
            u += "?" + qs;
            
            document.location.href = u;
        }
        function showTeam(ctrl)
        {
            u = document.location.href;
            i = u.indexOf('?');
            if(i > 0)
            {
                u = u.substring(0, i);
            }
            replaceQSParm("xslTeam", ctrl.options[ctrl.selectedIndex].value);
            u += "?" + qs;
            
            document.location.href = u;
        }
        function showClass(ctrl)
        {
            u = document.location.href;
            i = u.indexOf('?');
            if(i > 0)
            {
                u = u.substring(0, i);
            }
            replaceQSParm("xslClass", ctrl.options[ctrl.selectedIndex].value);
            u += "?" + qs;
            
            document.location.href = u;
        }
