/*
 * Name: local.js
 * Btime: 2009-11-18
 * Description: tempurpedic.com gift guide
 * Last Modified: 2009-11-19
 * $Revision: 4 $
 */

$(document).ready(function() {

// 2009-11-19 - Starting off set all tiles to be active & opaque
		$("div#portfolio .fx_slidedown").addClass("active");

// 2009-11-17 - menu click event handler
	$('ul#filter a').click(function() {
		$(this).css('outline', 'none');
		$('ul#filter .current').removeClass('current');
		$(this).parent().addClass('current');

		var filterVal = $(this).text().toLowerCase().replace(' ','-').replace('$', '');
			
		$('div#portfolio').fadeIn('normal', function(){
			$('div#portfolio .fx_slidedown').each(function() {
				if (filterVal == 'all') {
					$(this).addClass("active");
					if (jQuery.support.opacity == false) {
						if (jQuery.browser.version == "8.0") {
							$("img", this).fadeTo('normal', 1);
						}
						$("div", this).css("visibility", "hidden");
					}
					$(this).css("border", "1px solid #D1D5D4");
					$(this).fadeTo('normal', 1);
				}
				else if (!$(this).hasClass(filterVal)) {
					$(this).removeClass("active");
					if (jQuery.support.opacity == false) {
						if (jQuery.browser.version == "8.0") {
							$("img", this).fadeTo('normal', 0.15);
						}
						$("div", this).css("visibility", "hidden");
					}
					$(this).css("border", "1px solid #D1D5D4");
					$(this).fadeTo('normal', 0.15);
				}
				else {
					$(this).addClass("active");
					if (jQuery.support.opacity == false) {
						if (jQuery.browser.version == "8.0") {
							$("img", this).fadeTo('normal', 1);
						}
					}
					$(this).css("border", "1px solid #A72624");
					$(this).fadeTo('normal', 1);
				}
			});
		});
	
		return false;
	});


// 2009-11-19 - fx_slidedown hover event handler / only for active tiles
	$("div#portfolio .fx_slidedown").hover(
		function(){
			if ($(this).hasClass("active") ) {
				if (jQuery.support.opacity == false) {
					$("div", this).css("visibility", "visible");
				}
				$(this).children("img").stop().animate({top: '155px'}, {queue: false, duration: 300});
				}
			},
			function(){
				if ($(this).hasClass("active") ) {
					$(this).children("img").stop().animate({top: '0px'}, {queue: false, duration: 300});
				}
			}
	);

});