$(document).ready(function(){  
	$('#footer p a:not(.info), .accetto a').colorbox({width:"600px", height:"500px", iframe:true });
	$('a.sfoglia').colorbox({width:"990px", height:"600px", iframe:true });
	$('.info').colorbox({width:"500px", height:"350px", iframe:true });	
	$('a.lb').colorbox();
	$("a.blank").click( function() { $(this).attr("target", "_blank") });
	
	if( $('#slideshow div').length > 1 ) {
		setInterval( "slideSwitch()", 11000 );	
	}
	if( $('.altMenu').length != 0 ) {
		$(".altMenu li").live("click", function() {
			var url = $(this).find("a").attr("href");
			window.location=url;
		});
		$(".altMenu li").live("mouseover", function() { $(this).addClass("over") });
		$(".altMenu li").live("mouseout", function() { $(this).removeClass("over") });
	}
	
	
//	/* newsletter */
//	$("#newsletter>p>a").click( function() {
//		$("#newsletter").toggleClass("open");
//		return false;
//	});
//	$("#newsletterForm .invia a").click( function() { 
//		$("#newsletterForm").submit();
//		return false;
//	});
//	$("#newsletterForm").validate({
//		rules: {
//			nome: { required: true },
//			cognome: { required: true },
//			mail: { email: true, required: true },	
//			accetto: { required: true }
//		},
//		messages: {
//			nome: "",
//			cognome: "",
//			mail: "",
//			accetto: ""
//		},
//		submitHandler: function (form) {
//			
//			PostNewsletterRequest();
//		}
//	});
//	/* !newsletter */
//	
//	
//	
//	
});

function slideSwitch() {
    var $active = $('#slideshow div.active');

    if ( $active.length == 0 ) $active = $('#slideshow div:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow div:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


//function PostNewsletterRequest() {
//    var url = "/AjaxSaveNewsletterRequest.aspx?tick=<%= System.DateTime.Now.Ticks.ToString() %>&l=it";
//	var theData = "&contact=true&nome=" + $("#nome").val() + "&cognome=" + $("#cognome").val() + "&mail=" + $("#mail").val() + "&id=" + $("#id").val();
//	$.ajax(
//	{
//		type: "POST",
//		url: url,
//		data: theData,
//		success: function (msg) {
//			var response = msg.toLocaleString().split("|");
//			var ok = response[0].toLocaleString().split(":");
//			var retVal = ok[1];
//			if (ok[0] == 0) {
//				alert(retVal);
//				location.reload();
//			}
//			else {
//				//$('#f_contatti').hide();
//				var htmlOk = '<p class=\"ok\">' + retVal + '</p>';
//				$('#newsletter .scroll').html(htmlOk);
//				$('#newsletter .scroll').css("height", "auto");
//			}
//		},
//		error: function () {
//			alert("E stato ricevuta un errore di comunicazione!");
//		}
//	});
//};
