$(function(){
	
	// button rollover 
	$('.btn input').hover(function(){
			$(this).attr("src", $(this).attr("src").replace(/(.*)(\..*?)/,'$1-hover$2'));
		},
		function(){
				$(this).attr("src", $(this).attr("src").replace(/(.*)-hover(\..*?)/i, '$1$2'));
			});
	
	// 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'));
		});
		
	// submenu hover
	$('#header ul ul').hover(function(){
			$(this).parent().addClass('hover');
		},
		function(){
				$(this).parent().removeClass('hover');
				if($(this).parent().attr("class").length == 0)
					$(this).parent().removeAttr("class");
			});
});

/***********************************************
***  COMPACT FORM (LABEL OVER INPUT)  **********
************************************************/

$(function()
{
  var eles = $('form.compact input, form.compact select, form.compact textarea');

	eles.focus(function()
	{
		$('label[for=' + $(this).attr('id') + ']').hide();
	});

	eles.each(function(ele)
  {
		if($(this).val().length > 0) $('label[for=' + $(this).attr('id') + ']').css({ display: "none" });
	});

	eles.blur(function()
  {
		if($(this).val().length == 0) $('label[for=' + $(this).attr('id') + ']').show();
	});

	$('form.compact').removeClass('compact');
});

/***********************************************
***  PRODUCT DETAIL GALLEY IMAGES **********
************************************************/

$(function(){
	$('.galleyThumb').click(function(){
			var thb =  $(this);
			if ($('#galleyHolder').attr('src') !=thb.next().attr('src')){
				$('#galleyHolder').fadeOut("fast", function(){
						$(this).attr('src', thb.next().attr('src')).fadeIn("slow");
				});
			}
		});
	
});
/***********************************************
***  OUR RANGE PRODUCT SEARCH  **********
************************************************/
$(function(){
	$("#searchJewellery a.expanding").click(function(){
		$(this).next().toggle();
		return false;
	})
})