$(function() {
    // clear search terms if search box is selected
	$("#search_query").bind("click", function(e){
		$(this).addClass('active_search');
		
		if ($(this).val() == 'type search terms here') {
			$(this).val(''); // clear box
		}
	});
	
	// make header clickable
	$("#header").bind("click", function(e){
		window.location = baseURL + '/mobile/browse/';
	});
	
	$("#category_filter").change(function() {
		$(this).parent().submit();
	});
	
	$("#pid, #pc").change(function() {
		$('#form_portion_control').submit();
	});
	
	// detect viewport width, hide "carbculator" logo if less than minimum width
	if ($(window).width() < 280) $('#app_name').hide();
	
	// activate back button on detail page
	$("#back_button").bind("click", function(e){
		history.go(-1);
		return false;
	});
	
	// make intro bubble clickable (submit form)
	$("#intro, #intro_button a").bind("click", function(e){
		$("#intro_form").submit();
		return false;
	});
	
	/* add loading effect for phones that support it
	$("#listing ul li a").bind("click", function(e){
		// preload the spinner
		imageObj = new Image();
		imageObj.src = '../images/mobile/loading.gif'; 
		
		$(this).addClass('loading');
		return false;
	}); */
});
