function indirizzoEmailValido(indirizzo) {
	if (window.RegExp) { 
		var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
		var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
		var regnv = new RegExp(nonvalido);
		var regv = new RegExp(valido);
			
			if (!regnv.test(indirizzo) && regv.test(indirizzo)) return true;

		return false;

	} else {

		if(indirizzo.indexOf("@") >= 0) return true;

		return false;

	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

		$(document).ready(function() {
//			$("#sidebarmenu_sfondo").pngfix();
			$("#panel_sfondo").pngfix();
			$("#eth1").pngfix();
			$("#mytigota_sfondo").pngfix();
			$("#box .sfondo").pngfix();
			$("#box .sfondo_tigota").pngfix();
			$("#box .sfondo_tigota_maxi").pngfix();
			$("#box .etichetta").pngfix();
			$(".panes .foto img").pngfix();
			$(".panes p img").pngfix();
			$(".fr_left img").pngfix();
			$(".fr_right img").pngfix();
			$("#mytigota input").pngfix();
			$(".single").colorbox();
			
			$("#testata img").pngfix();
			$("#sidebarmenu_sfondo").css("z-index","0");
			$("#panel_sfondo").css("z-index","1");
			$("#eth1").css("z-index","2");
			$("#sidebarmenu").css("z-index","3");
			
			$(".panes p img").css({"vertical-align":"middle","margin-bottom":"3px"});
			
			$('#sidebar_spv .scelti_per_voi').cycle({ 
				before: function() {
					$(this).css("background","none");
				},
				fx:     'fade', 
				speed:  'fast', 
				timeout: 0, 
				next:   '#next2', 
				prev:   '#prev2' 
			});
			
			$("#rss").html($("#nav li:last-child").html());
			$("#nav li:last-child").remove();
			
			$("#nav li.tigota a").css("padding-left","4px").prepend("<img src=\"../images/tigota_promo.gif\" />");
			$("#nav li.tigota_maxi a").css("padding-left","4px").prepend("<img src=\"../images/tigota_maxi_promo.gif\" />");
			
			$("#nav ul li").css("float","none");
		
			i = 0;	
			$("#nav ul li").each(function() {
				i++;
				if(i%4==0) $(this).after("closeit");
			});	
			nav_html = $("#nav").html().replace(/closeit/g,"</ul><ul>");
			$("#nav").html(nav_html);
			$("#contenuto").corner("15px bottom");
			
//			if ($("#contenuto").height()>$("#sidebar").height()) $("#sidebar").height($("#contenuto").height());

		});
		
        $(window).load(function() {

			$(".sidebar_box h3").click(function() {
				location.href = $(this).parent().find("a").attr("href");
			});
			
			$("#boxfooter li").click(function() {
				location.href = $(this).find("a").attr("href");
			});
			
			var i = 0;

			$("#provincia").change(function() {
				if ($("#provincia").val()=="") {
				$("#comune").html('<option value="">Seleziona il comune</option>');
				} else {
				getComuni();
				}
			});
			
			$("#provincia_maxi").change(function() {
				if ($("#provincia_maxi").val()=="") {
				$("#comune").html('<option value="">Seleziona il comune</option>');
				} else {
				getComuniMaxi();
				}
			});

			$("#contenuto").height("");
			$("#sidebar").height("");
			if ($("#contenuto").height()>$("#sidebar").height()) $("#sidebar").height($("#contenuto").height());

		});
		
		function redesign_table() {
			$("th:even").css({"background":"url(../images/td.gif) right top repeat-y","background-color":"#f1f8fc"});			
			$("tr.pv > td:even").css({"padding":"15px 20px 10px 20px","background":"url(../images/td.gif) right top repeat-y"});
			$("tr.pv > td:odd").css("padding","0 18px 0 0");
			$("tr.col").after("<tr><td colspan=\"2\" style=\"height: 15px;\"></td></tr>");
			$("tr.pv:not(:last-child)").after("<tr><td colspan=\"2\" style=\"height: 11px; background: url(../images/ptu.gif) center 6px no-repeat; font-size: 0;\">&nbsp;</td></tr>");
			$("tr.pv:last").after("<tr><td colspan=\"2\" style=\"height: 15px;\"></td></tr>");
			$("tr.vl:not(:last-child)").after("<tr><td colspan=\"2\" style=\"height: 7px; background: url(../images/pt.gif) left 2px repeat-x; font-size: 0; line-height: 0;\">&nbsp;</td></tr>");			

			$("#contenuto").height("");
			if ($("#contenuto").height()>$("#sidebar").height()) $("#sidebar").height($("#contenuto").height());

		}
		
		function getComuni() {
			if ($("#provincia").val()!="") {
				$.ajax({
					type: "POST",
					url: "ajax_comuni.jsp",
					data: "prov="+$("#provincia").val()+"&com=",
					success: function(sel) {
						$("#comune").html(sel);
					}
				});
			}
		}

		function getComuniMaxi() {
			if ($("#provincia_maxi").val()!="") {
				$.ajax({
					type: "POST",
					url: "ajax_comuni_maxi.jsp",
					data: "prov="+$("#provincia_maxi").val()+"&com=",
					success: function(sel) {
						$("#comune").html(sel);
					}
				});
			}
		}

