/***********************************************
***  PRELOAD IMAGES     ************************
************************************************/

$("<img>").attr("src", "/images/icons/ico-nav-bullet-hover.gif");

/***********************************************
***  ACTIVATE LAVALAMP  ************************
************************************************/

$(function() { $("#menu").lavaLamp({ fx: "backout", speed: 700 })});

/***********************************************
***  OPACITY HOVER  ****************************
************************************************/

$(document).ready(function(){
	$('.brands img').hover(function(){
		$(this).fadeTo(0, .80);

	}, function(){
		$(this).fadeTo(0, 1);
	});
});

/***********************************************
***  CONFORMANCE HOVER  ************************
************************************************/

$(document).ready(function(){
	$('#conformanceList a').hover(function(){
		var ele = $(this);
		while(ele && !ele.is('li'))
			ele = ele.parent();
		if(ele)
			ele.addClass('conformLiHover');
	}, function(){
		var ele = $(this);
		while(ele && !ele.is('li'))
			ele = ele.parent();
		if(ele){
			ele.removeAttr('class');
		}
	});
});

/***********************************************
***  FIREFOX 2.0 FIX  **************************
************************************************/

$(document).ready(function() {
	if (/Firefox[\/\s]2\./.test(navigator.userAgent)) { // ff2 hack
		$('.btn').css('display','-moz-inline-box');
	}
});


/***********************************************
***  COMPACT FORM (LABEL OVER INPUT)  **********
************************************************/

$(function(){
	$('form.compact input, form.compact select, form.compact textarea').focus(function(){
			$('label[for=' + $(this).attr('id') + ']').hide();
		});
	$('form.compact input, form.compact select, form.compact textarea').each(function(ele){
			if($(this).val().length > 0)
				$('label[for=' + $(this).attr('id') + ']').css({ display: "none" });
		});
	$('form.compact input, form.compact select, form.compact textarea').blur(function(){
			if($(this).val().length == 0)
				$('label[for=' + $(this).attr('id') + ']').show();
		});
	$('form.compact').removeClass('compact');
});


/***********************************************
***  NAV SLIDING  ******************************
************************************************/

$(function(){
	$('#nav li').hover(function(){
			$(this).stop().animate({
					paddingLeft: 15
				}, 200);
		},
		function(){
				$(this).stop().animate({
						paddingLeft: 0
					}, 200);
			});
});


/***********************************************
***  TEXTAREA RESIZE  **************************
************************************************/

$(function(){
	$('#qeMessage').autoResize({
		    // After resize:
		    animateCallback : function() {
		        $(this).css({opacity:1});
		    },
		    // Quite slow animation:
		    animateDuration : 300,
		    // More extra space:
		    extraSpace : 40,
		    limit: 300
		});
});


/***********************************************
***  EXTERNAL LINKS  ***************************
************************************************/

$(document).ready(function() {
	$("a[rel=external]").each(function() {
		$(this).addClass('external');
		$(this).attr({
			title: "Open this page in a new window",
			target: "_blank"
		});
	})
});