
	$(function() {	
		
		var min = 1950;
		
		var max = 2010;
		
		$("#slider-range").slider({
			range: true,
			min: 1950,
			max: 2010,
			values: [1950, 2010],
			slide: function(event, ui) {				
				$("#amount").val(ui.values[0] + ' - ' + ui.values[1]);
				min = ui.values[0];
				max = ui.values[1];			
			}, 
			
			stop: function(event, ui) {
				$("div#result").remove();	
				var type = "";
			  	var area = "";
				var key = "";
		 		$("ul#type a.alt").map(function(){
					type += $(this).text() +"#";
		    	});
				$("ul#area a.alt").map(function(){
					area += $(this).text() +"#";
		    	});
				
				key = $("input#keywords").val();
				
				$.ajax({
		   			type: "POST",
		   			url: "result.php",
		   			data: ({type_a : type, area_a : area, min_a : min, max_a : max, key_a : key}),
		   			success: function(msg){
						$("#port").after("" + msg + "");
						$("div#result").hide();
						$("div#result").fadeIn("slow");
		   			}
		 		});	
			}
			
		});
		$("#amount").val($("#slider-range").slider("values", 0) + ' - ' + $("#slider-range").slider("values", 1));
	
		$("#cat").hide();
		$("#year").hide();
		$("#place").hide();
	
	
	$("ul#type a").click(function () {
		$("div#result").remove();		
			
      $(this).toggleClass("alt");
	  	var type = "";
	  	var area = "";
		var key = "";
 		$("ul#type a.alt").map(function(){
			type += $(this).text() +"#";
    	});
		$("ul#area a.alt").map(function(){
			area += $(this).text() +"#";
    	});
		
		key = $("input#keywords").val();
		
		$.ajax({
   			type: "POST",
   			url: "result.php",
   			data: ({type_a : type, area_a : area, min_a : min, max_a : max, key_a : key}),
   			success: function(msg){
				$("#port").after("" + msg + "");
				$("div#result").hide();
				$("div#result").fadeIn("slow");
   			}
 		});	
    });

	$("ul#area a").click(function () {
		$("div#result").remove();		
			
      $(this).toggleClass("alt");
	  	var type = "";
	  	var area = "";
		var key = "";
 		$("ul#type a.alt").map(function(){
			type += $(this).text() +"#";
    	});
		$("ul#area a.alt").map(function(){
			area += $(this).text() +"#";
    	});
		
		key = $("input#keywords").val();
		
		$.ajax({
   			type: "POST",
   			url: "result.php",
   			data: ({type_a : type, area_a : area, min_a : min, max_a : max, key_a : key}),
   			success: function(msg){
				$("#port").after("" + msg + "");
				$("div#result").hide();
				$("div#result").fadeIn("slow");
   			}
 		});	
    });
	
	});