/*$(function() {
    var nosubmit = false;
    $("#ricerca").keypress(function (e) {
        nosubmit = true;
        if (e.which == 13) {	
            $("#btncerca").trigger('click');
        }
    });
    $("form").submit(function(){
        if (nosubmit) return false;
    });

    $("#btncerca").click(function() {
        nosubmit = true;
        ricerca = $("#ricerca").val();
        ricerca = ricerca.replace("&", "%26");
        newlocation = "/servizi/ricerca.aspx?str=" + ricerca;
        window.location.href = newlocation;
    });
});*/


$(function() {
	var nosubmit = false;
	$("div.ricerca input[type='text'].txcerca").keypress(function (e) {
	
		var k = e.which
		nosubmit = true;
		if (k == 13) {	
			$("#btncerca").trigger('click');
		}
	});
	$("form").submit(function(){
		if (nosubmit) return false;
	});

	$("div.ricerca input[type='button'].btncerca").click(function() {
		$root = $(this).parent()
		//#edc 30lug08 - ricerca per aree	
		var t = "" //template
		if  (($root.find(".t").length>0) && ($root.find(".t").val().length>0)){
		    t = "t=" + $root.find(".t").val()  + "&"
		} 
		var a = "" //id area
		if  (($root.find(".a").length>0) && ($root.find(".a").val().length>0)){
		    a= "a=" + $root.find(".a").val() + "&"
		}	
		var g = "" // id gruppo di lavoro
		if  (($root.find(".g").length>0) && ($root.find(".g").val().length>0)){
		    g = "g=" + $root.find(".g").val()  + "&"
		} 
		//#edc 30lug08 - ricerca per aree	
		nosubmit = true;
		newlocation = "/servizi/ricerca.aspx?" + a + t + g + "str=" + $root.find("input[type='text'].txcerca").val();
		window.location.href = newlocation;
		return false;
	});
	
	
	
	
});