// extending browser detect of IE6 b/c of IE7 bug...
// credit: http://jamazon.co.uk/web/2008/03/14/jquerybrowserversion-doesnt-recognise-ie7/
$.browser.msie6 = $.browser.msie && /MSIE 6\.0/i.test(window.navigator.userAgent) && !/MSIE 7\.0/i.test(window.navigator.userAgent);

$(document).ready(function(){
// set body.has-js to cue CSS changes and prep for JS use
	$("body").addClass("has-js");
	$("a[rel='external']").click( function() {
		window.open($(this).attr("href"));
		return false;
	});
	$("input[type='text']").val("");
// table reservation w max 2
	$("#tablenum").change(function() {
		if ( $(this).val() == ('' || 0) ) {
			$("#table1, #table2").slideUp();
		}
		if ( $(this).val() == 1) {
			$("#table1").slideDown();
			$("#table2").slideUp();
		}
		if ( $(this).val() >= 2) {
			$("#table1").slideDown();
			$("#table2").slideDown();
		}
	});
// guest reservation w max 7
	$("#numadults").change(function() {
		if ( $(this).val() == ('' || 0) ) {
			$("#ind-guests").slideUp();
		}
		if ( $(this).val() >= 1) {
			$("#ind-guests").slideDown();
		}
	});

// Site-wide .more-detail popup window fix
// Will always use structure a span.more-detail
	$("a:has(.more-detail)").hover(function(e) {
		if ( $("div:not(#case-details) a") && ( e.pageX >= (($("#content").width()) - ($(this).children(".more-detail").width())) )) {
		// if not in #case-details and cursor is as close to the right edge as the popup is wide...
			$(this).children(".more-detail").css({'right' : '0','left' : 'auto'});
			// then set an alternate display, so it won't run over
		}
	});

//News item bubble fix for IE
//credit: http://www.vancelucas.com/article/fixing-ie7-z-index-issues-with-jquery/
	if ($.browser.msie) {
		if (parseInt($.browser.version) <= 7) {
			$(function() {
				var zIndexNumber = 5000;
				$("#griev-type ul li").each(function() {
					$(this).css('zIndex', zIndexNumber);
					zIndexNumber -= 10;
				});
			});
		}
	}
});