$(document).ready(function() {
	$('.tabs').tabs();
	
	$('area').hover(function() {
		$(".overlay_map").attr("src", 'images/'+$(this).attr("alt"));
	},
		function() {
			$(".overlay_map").attr("src", 'images/map.gif');
		}
	).click(function(){
		$('#province').val($(this).attr("title"));
		return false;
	});
	
	$("#cat").change(function(){
		//url = $(this).val()+'.txt';
		url = 'http://www.quattromura.it/view_menu_new.asp?command=dropdown&dropdown=9&value='+$(this).val();
		$.getJSON(url, null, function(data) {
			$("#tip").fillSelect(data);
		});	
	
		
	});
	
	$("#provincia").change(function(){
			//url = $(this).val()+'.txt';
			url = 'http://www.quattromura.it/view_menu_new.asp?command=dropdown&dropdown=3&value='+$(this).val();
			$.getJSON(url, null, function(data) {
				$("#citta").fillSelect(data);
		});
	
	});
	
	
	$("#citta").change(function(){
				//url = $(this).val()+'.txt';
				url = 'http://www.quattromura.it/view_menu_new.asp?command=dropdown&dropdown=4&value='+$(this).val();
				$.getJSON(url, null, function(data) {
					$("#zone").fillSelect(data);
			});
		
	});
	
	$("#ordina").change(function(){
					window.location = $(this).val();
					
			
	});
	
	$("#slider_1 .jCarouselLite").jCarouselLite({
    btnNext: "#slider_1 .next",
    btnPrev: "#slider_1 .prev",
    visible: 7,
    auto: 2000,
    speed: 1000

	});
	
	$("#slider_2 .jCarouselLite").jCarouselLite({
    btnNext: "#slider_2 .next",
    btnPrev: "#slider_2 .prev",
    visible: 7,
    auto: 2000,
    speed: 1000

	});

	$(".jCarouselLite_3").jCarouselLite({
    btnNext: "#slider_3 .next",
    btnPrev: "#slider_3 .prev",
	auto: 4000,
    speed: 800,
	visible: 4,
	vertical: true

	});
	
	$(".jCarouselLite_3 img").click(function() {
		$("#slider_3 .mid img").attr("src", $(this).attr("src"));
		$("#slider_3 .mid img").attr("alt", $(this).attr("alt"));
		$("#slider_3 .mid a").attr("href", $(this).attr("src"));
		$("#slider_3 .mid a").attr("rel", "prettyPhoto[gallery]");
		//$("#slider_3 .mid strong.desc").text($(this).attr("alt"));
		$("#slider_3 .mid .number em").text($(this).attr("title"));
		return false;
	})


});

$.fn.clearSelect = function() {
	return this.each(function() {
		if (this.tagName == 'SELECT')
			this.options.length = 0;
	});
} 

 

$.fn.fillSelect = function(data) {
	return this.clearSelect().each(function() {
		if (this.tagName == 'SELECT') {
			var dropdownList = this;
			$.each(data, function(index, optionData) {
				var option = new Option(optionData.Text, optionData.Value);
				if ($.browser.msie) {
					dropdownList.add(option);
				}
				else {
					dropdownList.add(option, null);
				}
			});
		}
	});
}