jQuery(document).ready(function($) {

	$("div.field").alternate();
	$("div.tabella").alternate();
	
	//url = $(this).val()+'.txt';
		url = 'http://www.tuttocasanapoli.it/dropdown.php';
		$.getJSON(url, null, function(data) {
			$("#regione").fillSelect(data);
		});	
		
	
		
	
	
	
    	$("#regione").change(function(){
		//url = $(this).val()+'.txt';
		url = 'http://www.tuttocasanapoli.it/dropdown.php?regione='+$(this).val();
		$.getJSON(url, null, function(data) {
			$("#provincia").fillSelect(data);
		});	
	
		
	});
	
	$("#provincia").change(function(){
			//url = $(this).val()+'.txt';
			url = 'http://www.tuttocasanapoli.it/dropdown.php?provincia='+$(this).val();
			$.getJSON(url, null, function(data) {
				$("#comune").fillSelect(data);
		});
	
	});
	
	$.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;
			var k;
			
			$.each(data, function(index, optionData) {
				
				var option = new Option(optionData.Text, optionData.Value);
				if ($.browser.msie) {
					dropdownList.add(option);
				}
				else {
					dropdownList.add(option, null);
				}
				
				
			});
		}
	});
}

	
	
});

function show(id){//displays an html element
	element = document.getElementById(id);
	if(element!=null){
		element.style.display = 'block';
	}
}

function hide(id){//hide an html element
	element = document.getElementById(id);
	if(element!=null){
		element.style.display = 'none';
	}
}

function openClose(id){ //hide/close an element
	element = document.getElementById(id);
	if(element!=null){
		if (element.style.display == 'block') {
			hide(id);
		}
		else{
			show(id);
			}
		}
}

jqueryslidemenu.buildmenu("top_dropdown")
droplinemenu.buildmenu("top_cats")

jQuery(document).ready(function($) {

    		$(".slider").jCarouselLite({
        		btnNext: ".next",
        		btnPrev: ".prev",
        		visible: 5,
				scroll: 5,
				auto: 4000,
				speed: 1000
    		});
});


	



