/***********************************************
***  COMPACT FORM (LABEL OVER INPUT)  **********
************************************************/

$(function(){
	$('form.compact input, form.compact select').focus(function(){
			$('label[for=' + $(this).attr('id') + ']').hide();
		});
	$('form.compact input, form.compact select').each(function(ele){
			if($(this).val().length > 0)
				$('label[for=' + $(this).attr('id') + ']').css({ display: "none" });
		});
	$('form.compact input, form.compact select').blur(function(){
			if($(this).val().length == 0)
				$('label[for=' + $(this).attr('id') + ']').show();
		});
	$('form.compact').removeClass('compact');
});

/***********************************************
***  COMMON FUNCTIONS  *************************
************************************************/

$(function(){
	// nav functionality
	$("#custService span").click(function(){
			if($(this).parent().hasClass('expanded')) {
				$(this).parent().removeClass('expanded');
				$(this).parent().addClass('collapsed');
				$("#custService > ul").fadeOut("fast");
			}
			else if($(this).parent().hasClass('collapsed')) {
				$(this).parent().addClass('expanded');
				$(this).parent().removeClass('collapsed');
				$("#custService > ul").fadeIn("fast");
			}
		});
});

$(function(){
	// 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'));
		});
	// button rollover 
	$('#regSubmit, .submitButton').hover(function(){
			$(this).attr("src", $(this).attr("src").replace(/(.*)(\..*?)/,'$1-hover$2'));
		},
		function(){
				$(this).attr("src", $(this).attr("src").replace(/(.*)-hover(\..*?)/i, '$1$2'));
		});
	// progressive enhancement
	$(".orderTable tr:nth-child(odd)").addClass("dark");
	$('.orderTable tr').hover(function(){
			$(this).addClass('hover');
		},
		function(){
				$(this).removeClass('hover');
				if($(this).attr("class").length == 0)
					$(this).removeAttr("class");
			});
});

