$(function()
{
	if($('#slider').length)	{
		/*$('#slider').nivoSlider({effect: 'fade', directionNavHide: false, afterChange:function(){
			$("input[swap_value], textarea[swap_value]").swap_value();
			$('form').checkForm();
		}});*/
		$('#slider').nivoSlider({effect: 'fade', directionNavHide: false});
	}

	if($('.easySlider .slider').length)
	{
		$('.easySlider .slider').easySlider();
	}

	if($('.accordion').length)
	{
		$(".accordion").accordion({ active: 99999 });
	}

	$('.top-menu ul li a, #top .top-menu .notifica a').click(function()
	{
		$('.top-menu ul li a').removeClass('selected');
		$(this).addClass('selected');

		var panel	= $(this).parent().find('.panel');
		if(panel.length)
		{
			if(panel.hasClass('opened'))
			{
				/*panel.fadeOut().removeClass('opened');*/
				panel.fadeOut( function(){
				
					$(this).find('input').val('').removeClass('error');
					$(this).find('.inFieldLabel').removeClass('error').css({'display':'block','opacity':1});
					
				}).removeClass('opened');
				$('.top-menu ul li a').removeClass('selected');
			}else{
				$('.top-menu ul li .panel.opened').fadeOut().removeClass('opened');
				panel.fadeIn().addClass('opened');
			}
			return false;
		}else{
			return true;
		}
	});
	
	if($('.inFieldLabel').length > 0){
		$("label.inFieldLabel").inFieldLabels();
		$("label.inFieldLabel").each(function(){
			if($(this).parent().find("input").val() != ""){
				$(this).css({'opacity':0});
			}
		});
	}
	
	$("input[swap_value], textarea[swap_value]").swap_value();
	$('form').checkForm();
	Custom.init();
	
	
	
	//* CORSO */
		
	$('.corso-lista .scheda').click(function(){
		$(this).parent().parent().find('.item-panel').fadeIn();
		return false;
	});
	
	$('.corso-lista .scheda').click(function(){
		$(this).parent().parent().find('.item-panel-lezioni').fadeIn();
		return false;
	});
	
	$('.corso-lista .iscritti').click(function(){
		$(this).parent().parent().find('.item-panel-iscritti').fadeIn();
		return false;
	});
	
	$('.corso-lista .item-panel .close a').click(function(){
		$(this).parent().parent().parent().fadeOut();
		return false;
	});
	
	$('.corso-lista .item-panel-lezioni .close a').click(function(){
		$(this).parent().parent().parent().fadeOut();
		return false;
	});
	
	$('.corso-lista .item-panel-iscritti .close a').click(function(){
		$(this).parent().parent().parent().fadeOut();
		return false;
	});
		
	//MATTEO
	$('.anagrafica .info4 .orari-corso').click(function(){
		$(this).parent().parent().find('.item-panel').fadeIn();
		return false;
	});
	
	$('.anagrafica .item-panel .close a').click(function(){
		$(this).parent().parent().parent().fadeOut();
		return false;
	});
	
	//END MATTEO
		
	var count = 1;
	$('#add-address').click(function() {
		if (count_inviti > count){
			$('#address-to-add').append('<p><label>Nome</label><input id="name' + count + '" type="text" name="nome' + count + '" swap_value="Nome*" value="" /></p><p><label>E-mail</label><input id="email' + count + '" type="text" name="email' + count + '" swap_value="E-mail*" value="" /></p><div class="clear"></div>');
			$("input[swap_value], textarea[swap_value]").swap_value();
			count++;
		}
		return false;
	});
	
});




















