var $j=jQuery.noConflict();

$j(document).ready(function(){
	textReplace();
	var spinSpeed = 300;
	var qlOpen = false;

    /*var inAction = false;
    $j('#featuredProducts li:first').mouseenter( function(){
        if(!inAction){
            inAction = true;
            var theWidth = $j(this).children('img').width();
            $j(this).children('img').animate( {'paddingLeft':theWidth/2,'width':0}, spinSpeed, function(){
                $j(this).animate( {'paddingLeft':0,'width':'93px'}, spinSpeed, function(){
                    inAction = false;
                });
            });
        }
	});
	var inAction2 = false;
    $j('#featuredProducts li:eq(1)').mouseenter( function(){
        if(!inAction2){
            inAction2 = true;
            var theWidth = $j(this).children('img').width();
            $j(this).children('img').animate( {'paddingLeft':theWidth/2,'width':0}, spinSpeed, function(){
                $j(this).animate( {'paddingLeft':0,'width':'93px'}, spinSpeed, function(){
                    inAction2 = false;
                });
            });
        }
	});
	var inAction3 = false;
    $j('#featuredProducts li:last').mouseenter( function(){
        if(!inAction3){
            inAction3 = true;
            var theWidth = $j(this).children('img').width();
            $j(this).children('img').animate( {'paddingLeft':theWidth/2,'width':0}, spinSpeed, function(){
                $j(this).animate( {'paddingLeft':0,'width':'93px'}, spinSpeed, function(){
                    inAction3 = false;
                });
            });
        }
	});
	
	$j("#featuredProducts li").hover( function(){
			$j(this).children('span').children('a').animate( {paddingRight: "1.6em"}, { queue:false, duration:350 } );
		},function(){
			$j(this).children('span').children('a').animate( {paddingRight: "0.8em"}, { queue:false, duration:750 } );
		}
    );
	
	$j("#featuredProducts a").bigTarget({
    	clickZone : 'li:eq(0)'
	});*/
	
	$j('.productContent h3').mouseenter( function(){
		$j(this).wrap('<a href="' + $j(this).next().children().attr('href') + '"></a>');
	});
	
	$j('.seeDetails').click( function(){
		if( !$j(this).hasClass('hideDetails') ){
			$j('.productDetails').slideUp();
			$j('.seeDetails').removeClass('hideDetails');
			$j('.seeDetails a').text('Show Details');
			$j(this).parent().next().slideDown();
			$j(this).parent().next().children('h3').removeClass('currentTab');
			$j(this).parent().next().children('h3:first').addClass('currentTab');
			$j(this).parent().next().children('div').hide();
			$j(this).parent().next().children('div:first').show();
			
			$j(this).addClass('hideDetails');
			$j(this).children().text('Hide Details');
		}
		else{
			$j('.productDetails').slideUp();
			$j(this).parent().next().children('h3').removeClass('currentTab');
			$j(this).removeClass('hideDetails');
			$j(this).children().text('Show Details');
		}
		return false;
	});
	
	$j('.productDetails div').hide();
	customTabSwap();
	
	var ibValue = $j('#infoBlurb').html();
	if (ibValue.indexOf('span') !=-1){
		$j('#quickLinks4 a.lastChild').css('font-weight', 'bold');
		$j('#quickLinks4 a.lastChild').css('color', '#002544');
		$j('#quickLinks4 a.lastChild').click( function(){
		
			if( !qlOpen ){
				$j('#infoBlurb').slideDown();
				qlOpen = true
			}
			else{
				$j('#infoBlurb').slideUp();
				qlOpen = false;
			}
			return false;
		});
	}
	
	$j('#locList li:first').css("border-bottom", "1px solid #ccc");
}); 

function textReplace(){
	$j('#searchForm input').click(function (){
		if( $j('#searchForm input').val() == "Search" ){
			$j('#searchForm input').val("");
		}
	});
	$j('#searchForm input').blur(function (){
		if( $j('#searchForm input').val() == "" ){
			$j('#searchForm input').val("Search");
		}
	});
}

function customTabSwap(){
	$j('.productDetails h3:eq(0)').click( function(){
		$j('.productDetails h3').removeClass('currentTab');
		$j(this).addClass('currentTab');
		$j('.productDetails div').slideUp();
		$j('.productDetails div:eq(0)').slideDown();
	});
	$j('.productDetails h3:eq(1)').click( function(){
		$j('.productDetails h3').removeClass('currentTab');
		$j(this).addClass('currentTab');
		$j('.productDetails div').slideUp();
		$j('.productDetails div:eq(1)').slideDown();
	});
	$j('.productDetails h3:eq(2)').click( function(){
		$j('.productDetails h3').removeClass('currentTab');
		$j(this).addClass('currentTab');
		$j('.productDetails div').slideUp();
		$j('.productDetails div:eq(2)').slideDown();
	});
	$j('.productDetails h3:eq(3)').click( function(){
		$j('.productDetails h3').removeClass('currentTab');
		$j(this).addClass('currentTab');
		$j('.productDetails div').slideUp();
		$j('.productDetails div:eq(3)').slideDown();
	});
	$j('.productDetails h3:eq(4)').click( function(){
		$j('.productDetails h3').removeClass('currentTab');
		$j(this).addClass('currentTab');
		$j('.productDetails div').slideUp();
		$j('.productDetails div:eq(4)').slideDown();
	});
}