$(document).ready(function() {
	/* homepage slider parameters */						   
	$('.home-slider').after('<div id="nav">').cycle({ 
	fx:     'fade', 
	speed:  1000, 
	timeout: 5000, 
	pager:  '#nav' 
	});

	$("a#mappa").fancybox();


	/* entire block clickable for latest news */						   
	$(".ln-list li").click(function(){
    	window.location=$(this).find("a").attr("href");
		return false;
	});

	$(".ln-list li").mouseover(function(){
		$(this).addClass('ln-active');
		$(this).find("a").attr("class", "ln-link");
	 
    }).mouseout(function(){
	    $(this).removeClass('ln-active');
		$(this).find("a").attr("class", "");
    });
	
	
	/* entire block clickable for header contact box(present in all interior pages) */	
	$(".header-contact").click(function(){
    	window.location=$(this).find("a").attr("href");
		return false;
	});	

	jQuery('#mycarousel').jcarousel({
        auto: 4,
        wrap: 'circular',
		scroll: 1,
        easing: 'BounceEaseOut'
    });

	// Credits: Robert Penners easing equations (http://www.robertpenner.com/easing/).
	jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	};

	var frmContact = $("#contactform");
	if (frmContact.length) {


		$('#contactform').validate({
			errorPlacement: function(error, element) {
				error.appendTo( element.parent().parent() );
			},
			rules: {
				contactcompany: { required: true },
				contactname: { required: true },
				email: { required: true },
				tel: { required: true },
				message: { required: true }
			},
			messages: {
				contactcompany: '&uarr; campo obbligatorio',
				contactname: '&uarr; campo obbligatorio',
				email: '&uarr; campo obbligatorio',
				tel: '&uarr; campo obbligatorio',
				message: '&uarr; campo obbligatorio'
			}
		});

	}
	
});
