// Code for when the DOM is ready to be manipulated
$(document).ready(function() {
	 
	 //	Unobstructive method for new window popup
	 //	Just give a <a> tag the class 'new-window' and jquery will do the rest
	 // Should work for any elements dynamically added
	 //	Example: <a href="http://www.google.com" rel="new-window">
/*
	$('a[rel*="new-window"]').live('click', function() {
		window.open(this.href,'_blank');
		return false;
	});
	
	$('div.restaurant').delegate('a.restaurant', 'click', function(target) {
		var parent = $(target).attr('div');
		alert($(parent).attr('class'));
		$.get(this, function(data) {
			//alert($(parent).attr('class'));
			//$(parent).after(data);
		}, 'html');
		return false;
	});
	*/
	/*
	$('div.restaurant').children('a.restaurant').each(function(){
		alert(this);
	});*/

	$('#steps select[name=state]').each(function() {
		$(this).change(function() {
			var arg = $('#steps form').serialize();
			$.get('filter.php?' + arg, function(data) {
				$('#steps select[name=city]').replaceWith($(data).filter('select[name=city]'));
			}, 'html');
			
		});
	});
	
	if($('#steps select[name=state]').val() !== '') {
		var arg = $('#steps form').serialize();
		$.get('filter.php?' + arg, function(data) {
			$('#steps select[name=city]').replaceWith($(data).filter('select[name=city]'));
		}, 'html');
	}
});
