jQuery(document).ready(function(){ jQuery('#regionSelect').change(function(){ var val = jQuery(this).val(); if (val) document.location.href='/?setRegion='+val; }); jQuery('.btnPopup').fancybox({ hideOnOverlayClick:true, enableEscapeButton:true, showCloseButton:true, padding:20, margin:20 }); }); function insertParam(key, value) { key = escape(key); value = escape(value); if (document.location.search.substr(1).length>0) { var kvp = document.location.search.substr(1).split('&'); var i=kvp.length; var x; while(i--) { x = kvp[i].split('='); if (x[0]==key) { x[1] = value; kvp[i] = x.join('='); break; } } if(i<0) {kvp[kvp.length] = [key,value].join('=');} //this will reload the page, it's likely better to store this until finished document.location.search = kvp.join('&'); } else document.location.search = key+'='+value; }