$(document).ready(function() {
      jQuery.validator.addMethod("decimalTwo", function(value, element) {
    	return this.optional(element) || /^(\d{1,3})(\,\d{2})$/.test(value);
		}, "Must be in US currency format 0.99");  
	jQuery.extend(jQuery.validator.messages, {
		required: "Questo campo e obbligatorio.",
		remote: "Riempire questo campo per continuare.",
		email: "Inserire un indirizzo email valido.",
		url: "Inserire un indirizzo URL valido.",
		date: "Inserire una data in formato mm-gg-aaaa.",
		dateDE: "Inserire una data in formato gg-mm-aaaa.",
		dateISO: "Inserire una data in formato aaaa-mm-gg.",
		number: "Inserire un numero valido.",
		digits: "Inserire (solo) un numero.",
		creditcard: "Inserire un numero di carta di credito valido.",
		equalTo: "Inserire lo stesso valore usato sopra.",
		decimalTwo: "Deve essere un numero con due cifre decimali (es. 200,99)",
		accept: "Usare un'estensione valida.",
		maxlength: jQuery.format("Inserire al massimo {0} caratteri."),
		minlength: jQuery.format("Inserire almeno {0} caratteri."),
		rangelength: jQuery.format("Inserire da {0} a {1} caratteri."),
		range: jQuery.format("Inserire un numero compreso tra {0} e {1}."),
		max: jQuery.format("Inserire un numero minore o uguale a {0}."),
		min: jQuery.format("Inserire un numero maggiore o uguale a {0}.")
	});
	Cufon.replace(
		'#menu ul.primo-livello > li > a,' +
		'#magazine h2,' +
		'#presentation h2 a,' +
		'#eventi h2,' +
		'#europa h2,' +
		'#formazione h2,' +
		'#newsletter h2,' +
		'#social-network h2,'+
		'#contenuti h2,'+
		'#presentation h3,'+
		'#footer #widget-facebook h3,'+
		'#contenuti-dinamici .occhiello-interno,'
	);

	
	$("#slider ul").cycle({
		fx: 'fade',
		timeout: 6000,
		speed: 2000
	});

	if ( $('#map').length > 0 ) {
		showmaps();
	}
	
	$('a[rel=external]').click(function() {
		window.open($(this).attr('href'));
		return false;
	});
	
			
	$("a[rel='gallery']").colorbox();
	$("a[rel^='gals']").colorbox({maxWidth:'95%', maxHeight:'95%'});
	$("a[rel='video']").colorbox({iframe:true, innerWidth:425, innerHeight:344,current: ' '});

	$(".form-generico").each(function(i) { 
		$(this).validate();
	});
	
	
	$('#news-nome').defaultValue('nome');
	$('#news-email').defaultValue('email');
	$('#ricerca').defaultValue('cerca');
	
	if($('#ajax-rss').length != 0){
		$.ajax({
			url: 'components/rss.php',
			success: function(data) {
				$('#ajax-rss').html(data);
			}
		});
	}
	
	if($('#bassolino').length != 0){
		$.ajax({
			url: 'components/blog.php',
			success: function(data) {
				$('#bassolino').html(data);
			}
		});
	}
});
