// JavaScript Document

// find a business - food type switcher
$(function() {
	function foodTypeShowHide() {
		var theli =  $(this).parent().next("li");
		var theselect = $(this).parent().next("li").children('select');
		
		if($(this).val() == 1) {
			theli.slideDown(); // show the food types
		} else {
			theli.slideUp(); // hide the food types
			theselect.val($('option:first', theselect).val()); // reset the food types
		}
	}
	$(".searchbox #businessTypeID").change(foodTypeShowHide); // safari doesn't do click() on a select element. must use change()
});

// results table striping
$(function() {
	$("#resultstable tr:nth-child(even)").addClass("odd");
});

// email obscure
function eadisplay(eavar, edvar) {
	return document.write("mailto:"+eavar+"@"+edvar);
}

// email obscure for profiles. replaces '123' with @
$(function() {
	$(".emob a").each(function() {
		$(this).attr("href", $(this).attr("href").replace("1337","@"));
		$(this).text($(this).text().replace("1337","@"));
	});
});

$(function() {
	var content = $("#secondary #content");
	var sidebar = $("#secondary #sidebar");
	if(content.height() > sidebar.height()) {
		content.css("border-right", "1px dotted #e14b0c");
	} else {
		sidebar.css("border-left", "1px dotted #e14b0c");
	}
});