jQuery(document).ready(function($){
	
	// HOVER
	// $(".sf-menu li.mainNav:not(.subNav)")
	// $(".sf-menu li.mainNav > a")
	// $("#nav ul li.mainNav")
	$(".sf-menu li.mainNav > a").hover( 
		// over
		function(){
			
			//console.log(this);
			var theImg = $(this).find('img:first');
			//store the original image src
			theImg.data( "originalsrc" , theImg.attr("src") );
			
			//add -over to the image unless it is already -over
			if (!theImg.attr("src").match(/-over/) ) {
				theImg.attr( "src", theImg.attr("src").replace(/\./, "-over.") );
			}
			
		},
		
		// out
		function(){
			var theImg = $(this).find('img:first');
			
			// replace the original src
			if (theImg.data("originalsrc") != null ) {
				theImg.attr("src", theImg.data("originalsrc"));
			}
		}
		
	
	);
	
	
	$('#zebra .fullBox:odd').addClass('oddBox'); // alternate colors of boxes
	
	$('.expandButton').click(function(e){
		e.preventDefault;
		$('.expander').css({'margin-top':0});
		var $this = $(this);
		/*$this.fadeOut();*/
		$this.toggle();
		var div = $this.attr('href').substring(1);
		$('#' + div).slideDown('fast');
		
		return false;
	});
	
	
	$("a.nr_panel").live("click", function(){
		_gaq.push(['_trackEvent','Blog','Related Post']);
	});
	

});




window.onload = function() {
	// PRELOAD

	$(".sf-menu li.mainNav > a").each(
		function() {
			var theImg = $(this).find('img:first');
			if (!theImg.attr("src").match(/-over/) ) {
				$("<img>").attr( "src", theImg.attr("src").replace(/\./, "-over.") );
			}
		}
	);

}

function submitContact() {
		var $this = $("#contactForm");

		var $nameField = $this.find("input[name=first_name]");
		if (!$nameField.attr('value'))
			{
				alert('Please enter your First Name.');
				$nameField.focus();
				return false;
			}
	
		var $emailField = $this.find("input[name=email_real]");
		if (!$emailField.attr('value'))
			{
				alert('Please enter your Email.');
				$emailField.focus();
				return false;
			}						

		 var params = $this.serialize();
		$.post("/cgi-bin/contact.cgi", params,
		   	function(data){
			$this.find(".btnSubmit").fadeOut('slow', function(){
				$this.find("input[type=text], textarea").attr('value', '');
				$this.find(".btnSubmit").after(data);
				$("#response").fadeIn('slow');
			});
			
			setTimeout(function(){
					$("#response").fadeOut('slow',function(){
						$("#response").remove();
						$this.find(".btnSubmit").fadeIn('slow');
					});
					}, 5000);
	
		});
		
		return false;
		
	}

