function getquerystring(itemname) {		var hu = window.location.search.substring(1);		var gy = hu.split("&");		if((typeof itemname == "undefined") || (itemname.length == 0)){			var r = new Object			for (i=0;i<gy.length;i++){				var a = gy[i].split("=")				r[a[0]] = a[1]			}			return r		} else {			for (i=0;i<gy.length;i++) {				ft = gy[i].split("=");				if (ft[0] == itemname) {					return ft[1];				}			}		}	}

$(function() {
	var nosubmit = false;
	$("#ricerca").keypress(function (e) {
	
		var k = e.which
		nosubmit = true;
		if (k == 13) {	
			$("#btncerca").trigger('click');
		}
	});
	$("form").submit(function(){
		if (nosubmit) return false;
	});

	$("#btncerca").click(function() {
		//#edc 30lug08 - ricerca per aree	
		var t = "" //template
		if  (($("#t").length>0) && ($("#t").val().length>0)){
		    t = "t=" + $("#t").val()  + "&"
		} 
		var a = "" //id area
		if  (($("#a").length>0) && ($("#a").val().length>0)){
		    a= "a=" + $("#a").val() + "&"
		}	
		var g = "" // id gruppo di lavoro
		if  (($("#g").length>0) && ($("#g").val().length>0)){
		    g = "g=" + $("#g").val()  + "&"
		} 
		//#edc 30lug08 - ricerca per aree	
		nosubmit = true;
		newlocation = "/servizi/ricerca.aspx?" + a + t + g + "str=" + escape($("#ricerca").val());
		window.location.href = newlocation;
		return false;
	});
	
	$("#pagenavigator a.page").click(function(){
	    var qs = getquerystring()
	    
	    var str = ""
	    for(name in qs){
	        if((name != "page") && (qs[name]  != "undefined")){
	            str += "&" + name + "=" + qs[name] 
	        }
	    }
	    str += "&page=" + $(this).attr("href").slice(1)
	    var newlocation = "?" + str.slice(1)
	    window.location.href = newlocation;
		return false;
	
	});
});