$(function(){
	
	// button rollover 
	$('.imgBtn, input#searchSubmit, input#priceSliderUpdate, input#reviewSubmit').hover(function(){
			$(this).attr("src", $(this).attr("src").replace(/(.*)(\..*?)/,'$1-hover$2'));
		},
		function(){
				$(this).attr("src", $(this).attr("src").replace(/(.*)-hover(\..*?)/i, '$1$2'));
			});
	// ie6 hover functionality
	$('#header li, .tabs li, .navBox li span, .popupLink').hover(function(){
			$(this).addClass('hover');
		},
		function(){
				$(this).removeClass('hover');
				if($(this).attr("class").length == 0)
					$(this).removeAttr("class");
			});
	// font manipulation
	$('.fontSizing #textSizeUp').click(function(){
			ts('content',1);
		});
	$('.fontSizing #textSizeDown').click(function(){
			ts('content',-1);
		});
	// search field js
	$('#searchTerm').focus(function(){
			if($(this).val() == 'Type your search here')
				$(this).val('');
		});
	$('input#searchTerm').blur(function(){
			if($(this).val() == '')
				$(this).val('Type your search here');
		});

	// preload image rollovers
	$("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']").each(function(){
			$("<img>").attr("src", $(this).attr("src").replace(/(btn-.*)(\..*?)/i, '$1-hover$2'));
		});

	// progressive enhancement
	$(".featured td:first-child").addClass("featuredLeft");
	$(".featured td:last-child").addClass("featuredRight");
	$(".quickpeekWrapper tr:first-child td").addClass("first");
	$(".buyingGuide li:last-child").addClass("last");
	$(".searchGrid").append("<li class='clearFloat'></li>");

	// tooltip
	$("#whatsthis").tooltip({
		track: true,
		delay: 0,
		showURL: false,
		fixPNG: true,
		showBody: " - ",
		extraClass: "pretty",
		top: -211,
		left: -210
	});
	
	// tooltip
	$(".whatsthis1").tooltip({
		track: true,
		delay: 0,
		showURL: false,
		fixPNG: true,
		showBody: " - ",
		extraClass: "pretty",
		top: -211,
		left: -205
	});


	// JQuery Select Box
	$('#searchCat').selectbox({debug: true});

	// quickpeek
	$('.quickpeekContainer').bgiframe();

	$('.quickPeek span.popupLink').click(function(){
			$('.quickPeek.open').each(function(){
					$(this).removeClass('open');
				});
			$(this).parent('.quickPeek').addClass('open');
		});
	$('.quickPeek .close').click(function(){
			$('.quickPeek.open').each(function(){
					$(this).removeClass('open');
				});
		});
});