$(document).ready(function() {
	
	
	// Clear & Refill fields
	//autoFill($("#realname"), "Name");

	function autoFill(id, v){
		$(id).css({ color: "#b2adad" }).attr({ value: v }).focus(function(){
			if($(this).val()==v){
				$(this).val("").css({ color: "#333" });
			}
		}).blur(function(){
			if($(this).val()==""){
				$(this).css({ color: "#b2adad" }).val(v);
			}
		});
	}
	
	
	// Open external links in new windows
	$(function() { 
		$('a[href^=http]').click( function() {
			window.open(this.href);
			return false;
		});
	});
	
	
	
	
	

	

	
	$("#nav-primary-home li").mouseover(function(){
		
		// put the index # of the li that was just moused over into a variable
		var indexnum = $("#nav-primary-home li").index(this);
		
		//turn the value into the position we want to put the background into
		indexnum = (indexnum + 1);
		indexnum = (indexnum * 150)
		
		// move the background image
		$("#container").css("background-position","265px -" + indexnum + "px");
	}).mouseout(function(){
		$("#container").css("background-position","265px 0");
	});
	
	
	
	
	// Change the background color of the div containing the audio files because flash makes a 1px border at the top 
	var BGcolor = $(".audio-player-container *").css("background-color");
	$(".audio-player-container *").mouseover(function(){		
		$(this).css("background-color","#534741");
	}).mouseout(function(){		
		$(".audio-player-container *").css("background-color", BGcolor);
	});
	
	
	
	
	
	

	// VALIDATE CONTACT FORM //////////////////////////
	
	
	 
 $("form#contactFORM").submit(function() {
		
		
	// reset previous alerts
	
	
	
	$(".alert").hide();
	$(".success").hide();
	var $returnvalue;
	$returnvalue = true;
	

											
	
	
	if ($("#realname").val() == "") {
		$(".alert").show();
		$returnvalue = false;
		$("input#realname").addClass("not-filled-out");
		$("input#realname").next().show();
	}
	
	if ($("#comments").val() == "") {
		$(".alert").show();
		$returnvalue = false;
		$("textarea#comments").addClass("not-filled-out");
		$("textarea#comments").next().show();
	}

		
		return $returnvalue;
});
 
 
 
	$("#realname").keyup(function () {	
		$(this).removeClass("not-filled-out");
		$(this).next().hide();
		
		if ($("#comments").val() != "") {
			$(".alert").hide();
		}

	});
	
	$("#comments").keyup(function () {	
		$(this).removeClass("not-filled-out");
		$(this).next().hide();
		
		if ($("#realname").val() != "") {
			$(".alert").hide();
		}

	});





	// VALIDATE Newsletter FORM //////////////////////////
	
	
	 
 $("form#newsletterFORM").submit(function() {
										  
	// reset previous alerts	
	$(".alert").hide();
	$(".success").hide();
	var $returnvalue;
	$returnvalue = true;
	$("#Email-Address").val($("#email").val());

		
	
	// Check if blank
	if ($("#email").val() == "") {
		$(".alert").show();
		$returnvalue = false;
		$("input#email").addClass("not-filled-out");
	}

	// Submit form (or not)
	
	return $returnvalue;
});
 
 
	// Clear alerts
	$("#email").keyup(function () {	
		$(this).removeClass("not-filled-out");
		$(".alert").hide();

	});

	
	$("ul.audio-main-list li:nth-child(even)").addClass("odd");

	
	$("ul.audio-main-list li li").removeClass("odd");
	
	//$("ul.audio-main-list li ul:eq(0)").parent().addClass("first");
	
	//$("ul.audio-main-list li ul:eq(1)").parent().addClass("first");


	
	

	
	
	
	
	
	

});




