jQuery(function(){
	var select = jQuery('.sort select');
	var options = jQuery('option', select);
	for (var i = 0; i < options.length; i++) {
		var opt = options.eq(i);
		if (typeof opt.attr('name') == 'string') {
			opt.attr('name', opt.attr('name').replace(/\?[^p].*\?/img, "?"));
		}
    }
    
    var name, name2;
    var regex = /(.*)1/;
    for (var i = 3; i < 7; i++) {
       name = jQuery('option', select).eq(i).attr('name');
       if (name && name.length != 0) {
           name2 = regex.exec(name);
           jQuery('option', select).eq(i).attr('name', name2[1] + '0');
       }
    }    

    jQuery(select).change(function () {
		var loc = document.location.pathname;
		var to = jQuery('option:selected', this).attr('name');
		window.location.href = (to.substr(0,1) == "?") ? loc + to : to;
	})
});
