$().ready(function() {
	$("#header #navigation li a").hoverIntent(function() {
		 var bodyClass = $(this).parent().parent().parent().parent().parent().attr('class');
		 var liItem = $(this).parent().attr('class');
		 if (bodyClass != liItem) {
			$(this).find('span em').fadeIn(200);
		}
	}, function() {
		 var bodyClass = $(this).parent().parent().parent().parent().parent().attr('class');
		 var liItem = $(this).parent().attr('class');
		 if (bodyClass != liItem) {
			$(this).find('span em').fadeOut(200);
		}
	});
	$.preload([ 'h3Blog', 'h3Press', 'h3Hungry', 'buttonbg' ], {
	    base:'/images/',
	    ext:'.gif'
	});
});



var cellWidth = {
    "wine-list": [395, 80, 110, 100]
};



function applyCellWidths(tableName) {
    if (tableName == null || tableName == "") {
        //tbody
        $.each(cellWidth, function(key, val) {
            applyWidth(key, val);
        });
        //thead
        $.each(cellWidth, function(key, val) {
            for (var i = 0, cl = val.length; i < cl; i++) {
                $('.' + key + ' thead th:nth-child(' + (i + 1) + ')').width(val[i]);
            };
        });
    }
    else {
        applyWidth(tableName, cellWidth[tableName]);
    }
}

function applyWidth(key, value) {
    for (var i = 0, cl = value.length; i < cl; i++) {
        $('.' + key + ' thead th:nth-child(' + (i + 1) + ')').width(value[i]);
        $('.' + key + ' tbody td:nth-child(' + (i + 1) + ')').width(value[i])
            .children().not("td:last-child").css({ overflow: 'hidden' }).width(value[i] - 9);
    };
    $("td:last-child").children().css({ overflow: 'visible' }).width("auto");
}
