// JavaScript Document
$(document).ready(function(){
	var end = new Date();
	$('#from_cat').change(function(){
		var cat = '';
		$('#from_cat option:selected').each(function () {
			cat += $(this).val();
		});
		
		
		
		var post_url = 'ajax_getList.php?ts='+end.getTime();;
		var data_set = { todo_detail: cat}
		$.post(
			post_url ,
			data_set,
			function(resp){
				var txt = '';
				//alert(resp);
				//txt += "<ul>";
				
				//$('#business_name').val(resp);
				p = resp.split(",");
				$('#list_bus').remove();
				for(var i = 0; i<p.length; i++)
				{
					if(p[i]){
						q = p[i].split("|");
						txt += "<li><a href='javascript:void(0)' name='todo_id[]'>"+q[1]+"</a></li>";
					}
				}
				//txt += "</ul>";
				$('#result_bus').prepend("<ul id='list_bus'>"+txt+"</ul>").slideToggle("slow");
			}
					 
		);
		
		// Test
		$('#result_bus').hide();	
		
		if($('#hiden_drink').val() == "on"){
			$('#hiden_drink').val("off");
			$('#drink').hide("slow");
		}
		if($('#hiden_eat').val() == "on"){
			$('#hiden_eat').val("off");
			$('#eat').hide("slow");
		}
		if($('#hiden_go').val() == "on"){
			$('#hiden_go').val("off");
			$('#go').hide("slow");
		}
		if($('#hiden_shopping').val() == "on"){
			$('#hiden_shopping').val("off");
			$('#shopping').hide("slow");
		}
		if($('#hiden_play').val() == "on"){
			$('#hiden_play').val("off");
			$('#play').hide("slow");
		}
		
		$('#logo_side').empty();
		
	});
	
	
	 
	$('[name^=todo_id]').live( 'click' , function(){
		//alert($(this).text());
		$('#business_name').val($(this).text());
		$('#result_bus').hide();
	});
	
	// On Button Click
	$('#btn_list').click(function(){
		//alert("444");
		var str = $('#business_name').val();
		readMap("?bus_name="+str,null);
	});
	
	//$(".cat_listing").hover(
	//	function(){
	//		$(this).fadeOut(500);
	//		$(this).fadeIn(500);
	//	}
	//);
	
	// Result Effect
	//$(".event li").hover(
	//	function(){
	//		$(this).fadeOut(500);
	//		$(this).css({'background-color' : '#f1f1f1'});
	//		$(this).fadeIn(500);
	//	},
	//	function(){
	//		$(this).css({'background-color' : '#ffffff'});
	//	}
//	);
	
});
