$(document).ready(function(){
	// newsletter signup input
	$("#header input").attr("value", "enter email address");
	
    $("#header input").one("click", function(){
        $("#header input").attr("value", "");
    });
    
    $("input#newsletterEmail").attr("value", "Enter your e-mail address");
	
	$("input#newsletterEmail").one("click", function(){
        $("input#newsletterEmail").attr("value", "");
    });
    
	// Nav Fixes for IE6 and slide animation for subnav
	$("#nav ul").hide(); 
	$("#nav li").hover(
			  function () {
			    $(this).addClass("over");
				$("ul", this).slideDown(200);
			  },
			  function () {
				$("ul", this).slideUp(300);
			    $(this).removeClass("over");
			  }
			);
	$('a[rel=external]').click(function(){window.open(this.href); return false});
	
	//IE6 PNG transparency fix
	$(document).pngFix();
	// Height Adjustment for 'Container' Divs (#main, #divider, #right)
	var mainHeight = $("#main").height();
	var rightHeight = $("#right").height();
	var heightChange;
	if (mainHeight>rightHeight) {
		heightChange = mainHeight;
	}
	else {   
		heightChange = rightHeight;
	}
	$("#divider").height(heightChange-130);
	
	// Cycle pic for homepage
		$('#homeTop1').cycle({ 
		    fx:    'fade', 
		    timeout:  5000,
		speed: 1000,
		random:  1
		});
		$('#homeTop3').cycle({ 
		    fx:    'fade', 
		    timeout:  8000,
		speed: 1000,
		random:  1
		});
		/*$('#ads').cycle({ 
		    fx:    'fade', 
		    timeout:  5000,
			speed: 1000,
			random:  1,
			containerResize: 1,
			height: heightChange,
			sync: true  
		});*/
		
});

$(function() {
	var rowIndex = 0;
	// Table Row Striping
	$('table.zebra tr').each(function(index) {
		if($('th', this).length) {
			rowIndex = -1;
		}
		else {
			if(rowIndex%2<1) {
				$(this+':odd').removeClass('even');
			}
			else {
				$(this).addClass('even');
			}
		};
		rowIndex++;
	});
	// Highlighting Row with Joey Logano
	$('table.zebra td.driverCol').filter(':contains("Joey Logano")').parent().removeClass('even').addClass('selected');
	
	// Removing Extra Borders on the First and Last TH/TD
	$('table.zebra tr').each(function() {
		$('th:first-child', this).css({'border-left':'none'});
		$('th:last-child', this).css({'border-right':'none'});
		$('td:last-child', this).css({'border-right':'none'});
	});
});

$(function() {
	$("a.team20Photo").click(function() { $("#teamPhotoOverlay").fadeIn(500); return false; });
	
	$("#teamPhotoOverlay a.closeOverlayBtn").click(function() { $(this).parent().fadeOut(300); return false; }); 
});

$(function() {
	$('.journalEntry:last').css({'background':'none'});
	$('.answerEntry:last').css({'background':'none'});
	$('.raceNews:last').css({'background':'none', 'padding':'0'});
});

$(function () {
	$('#login_error').hide();
	
	$('a.loginBtn').click(assocEnter);
	$('input#associateId').keypress(function(e) {
		if (e.which == 13) {
			assocEnter();
		}
	});
	
	function assocEnter() {
		var associateId = $('input#associateId').val();
		if (associateId.length != 9) {
			$("#login_error").show();
	  		$("input#associateId").focus();
			return false;
		}
		else if (/^\d+$/.test(associateId) != true) {
			$("#login_error").show();
	  		$("input#associateId").focus();
			return false;
		}
		else {
			location.href="associates.aspx";
			return false;
		}
	}
});




