
//Search fade

	jQuery(function($){	
		$.fn.labelFade = function(){
			var selector = $(this);
			
			$(selector).focus(_fieldFocus); // on event
			$(selector).blur(_fieldBlur); // out event
			
			var id = $(selector).attr('id');
			var label = $('label[for='+id+']'); // get label
			
			// for label on top of input
			label.click(function(){
				$(selector).focus();
			}).css('cursor','text');
			
			// hide if value on load
			if($(this).val() != '') label.hide();
		}
		
		function _fieldFocus(){
			var id = $(this).attr('id');
			$('label[for='+id+']').fadeOut();
			 $(this).addClass('active');
		}
               
		function _fieldBlur(){
			var id = $(this).attr('id');
			if($(this).val() == '') $('label[for='+id+']').fadeIn();
			$(this).removeClass('active');
		}
	});

//Brand Hover

	jQuery(function($){
		var brands = [];
		
		$.fn.brandHover = function(){
			//store brands
			$.each($(this), function(index, b){
				//preload images
				var img = new Image();
				var src = $(b).find('img').attr('src');
				brands[index] = src;
				img.src = src.replace('grey=true', 'grey=false');
			});
			
			$(this).css('opacity', 0.6);
			$(this).mouseover(_brandOver);
			$(this).mouseout(_brandOut);
		}
		
		function _brandOver(e){
			var index = $(this).index() - 1;
			var img = $(this).find('img');
			var src = brands[index].replace('grey=true', 'grey=false');
			
			$(this).css('opacity', 1);
			img.attr('src', src);
		}
               
		function _brandOut(e){
			var index = $(this).index() - 1;
			var img = $(this).find('img');
			var src = brands[index];
			
			$(this).css('opacity', 0.6);
			img.attr('src', src);
		}
		
		$('.brand').brandHover();
	});
